Class: TXTextControl::ReportingCloud::AccountSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/txtextcontrol/reportingcloud/account_settings.rb

Overview

Represents ReportingCloud account settings.

Author:

  • Thorsten Kummerow (@thomerow)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(serial_number, created_documents, uploaded_templates, max_documents, max_templates, valid_until = nil) ⇒ AccountSettings

Returns a new instance of AccountSettings

Parameters:

  • serial_number (String, Symbol)

    The serial number that is attached to the account. Possible values are :free, :trial and a 13 character long serial number.

  • created_documents (Integer)

    The number of created documents in the current month.

  • uploaded_templates (Integer)

    The number of uploaded templates to the template storage.

  • max_documents (Integer)

    The maximum number of documents that can be created per month.

  • max_templates (Integer)

    The maximum number of templates that can be uploaded to the template storage.

  • valid_until (DateTime) (defaults to: nil)

    The date until the current subscription is valid. Can be nil.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 51

def initialize(serial_number, created_documents, uploaded_templates, max_documents, max_templates, valid_until = nil)
  case serial_number.downcase
    when "trial"
      @serial_number = :trial
    when "free"
      @serial_number = :free
    else 
      @serial_number = serial_number
  end                
  @created_documents = Integer(created_documents)
  @uploaded_templates = Integer(uploaded_templates)
  @max_documents = Integer(max_documents)
  @max_templates = Integer(max_templates)
  case valid_until
    when DateTime
      @valid_until = valid_until
    when String
      @valid_until = DateTime.iso8601(valid_until)
    else
      @valid_until = nil      
  end
end

Instance Attribute Details

#created_documentsInteger (readonly)

The number of created documents in the current month.

Returns:

  • (Integer)

    the current value of created_documents



31
32
33
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 31

def created_documents
  @created_documents
end

#max_documentsInteger (readonly)

The maximum number of documents that can be created per month.

Returns:

  • (Integer)

    the current value of max_documents



31
32
33
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 31

def max_documents
  @max_documents
end

#max_templatesInteger (readonly)

The maximum number of templates that can be uploaded to the template storage.

Returns:

  • (Integer)

    the current value of max_templates



31
32
33
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 31

def max_templates
  @max_templates
end

#serial_numberString, Symbol (readonly)

The serial number that is attached to the account. Possible values are :free, :trial and a 13 character long serial number.

Returns:

  • (String, Symbol)

    the current value of serial_number



31
32
33
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 31

def serial_number
  @serial_number
end

#uploaded_templatesInteger (readonly)

The number of uploaded templates to the template storage.

Returns:

  • (Integer)

    the current value of uploaded_templates



31
32
33
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 31

def uploaded_templates
  @uploaded_templates
end

#valid_untilDateTime (readonly)

The date until the current subscription is valid. Can be nil.

Returns:

  • (DateTime)

    the current value of valid_until



31
32
33
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 31

def valid_until
  @valid_until
end

Class Method Details

.from_camelized_hash(hash) ⇒ AccountSettings

Creates an AccountSettings instance from a hash.

Parameters:

  • hash (Hash)

    The hash to try and create an AccountSettings instance from.

Returns:



77
78
79
80
81
82
83
84
85
# File 'lib/txtextcontrol/reportingcloud/account_settings.rb', line 77

def self.from_camelized_hash(hash)
  sn = hash["serialNumber"]
  cd = hash["createdDocuments"]
  ut = hash["uploadedTemplates"]
  md = hash["maxDocuments"]
  mt = hash["maxTemplates"]
  vu = hash["validUntil"]
  return AccountSettings.new(sn, cd, ut, md, mt, vu)
end