Class: Verizon::BillableUsageReport

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/billable_usage_report.rb

Overview

Bill usage report.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(account_name = SKIP, usage_for_all_accounts = SKIP, sku_name = SKIP, transactions_allowed = SKIP, total_transaction_count = SKIP, primary_account = SKIP, managed_accounts = SKIP) ⇒ BillableUsageReport

Returns a new instance of BillableUsageReport.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/verizon/models/billable_usage_report.rb', line 73

def initialize( = SKIP,
               usage_for_all_accounts = SKIP,
               sku_name = SKIP,
               transactions_allowed = SKIP,
               total_transaction_count = SKIP,
                = SKIP,
               managed_accounts = SKIP)
  @account_name =  unless  == SKIP
  @usage_for_all_accounts = usage_for_all_accounts unless usage_for_all_accounts == SKIP
  @sku_name = sku_name unless sku_name == SKIP
  @transactions_allowed = transactions_allowed unless transactions_allowed == SKIP
  @total_transaction_count = total_transaction_count unless total_transaction_count == SKIP
  @primary_account =  unless  == SKIP
  @managed_accounts = managed_accounts unless managed_accounts == SKIP
end

Instance Attribute Details

#account_nameString

Account identifier.

Returns:

  • (String)


14
15
16
# File 'lib/verizon/models/billable_usage_report.rb', line 14

def 
  @account_name
end

#managed_accountsArray[ServiceUsage]

Zero or more managed accounts.

Returns:



40
41
42
# File 'lib/verizon/models/billable_usage_report.rb', line 40

def managed_accounts
  @managed_accounts
end

#primary_accountServiceUsage

The total number of billable device location requests during the reporting period from all included accounts.

Returns:



36
37
38
# File 'lib/verizon/models/billable_usage_report.rb', line 36

def 
  @primary_account
end

#sku_nameString

SKU Name of the service subscription.

Returns:

  • (String)


22
23
24
# File 'lib/verizon/models/billable_usage_report.rb', line 22

def sku_name
  @sku_name
end

#total_transaction_countString

The total number of billable device location requests during the reporting period from all included accounts.

Returns:

  • (String)


31
32
33
# File 'lib/verizon/models/billable_usage_report.rb', line 31

def total_transaction_count
  @total_transaction_count
end

#transactions_allowedString

The number of location requests included with the subscription type.

Returns:

  • (String)


26
27
28
# File 'lib/verizon/models/billable_usage_report.rb', line 26

def transactions_allowed
  @transactions_allowed
end

#usage_for_all_accountsTrueClass | FalseClass

The usage is for a single or multiple accounts.

Returns:

  • (TrueClass | FalseClass)


18
19
20
# File 'lib/verizon/models/billable_usage_report.rb', line 18

def usage_for_all_accounts
  @usage_for_all_accounts
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/verizon/models/billable_usage_report.rb', line 90

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountName') ? hash['accountName'] : SKIP
  usage_for_all_accounts =
    hash.key?('usageForAllAccounts') ? hash['usageForAllAccounts'] : SKIP
  sku_name = hash.key?('skuName') ? hash['skuName'] : SKIP
  transactions_allowed =
    hash.key?('transactionsAllowed') ? hash['transactionsAllowed'] : SKIP
  total_transaction_count =
    hash.key?('totalTransactionCount') ? hash['totalTransactionCount'] : SKIP
   = ServiceUsage.from_hash(hash['PrimaryAccount']) if hash['PrimaryAccount']
  # Parameter is an array, so we need to iterate through it
  managed_accounts = nil
  unless hash['ManagedAccounts'].nil?
    managed_accounts = []
    hash['ManagedAccounts'].each do |structure|
      managed_accounts << (ServiceUsage.from_hash(structure) if structure)
    end
  end

  managed_accounts = SKIP unless hash.key?('ManagedAccounts')

  # Create object from extracted values.
  BillableUsageReport.new(,
                          usage_for_all_accounts,
                          sku_name,
                          transactions_allowed,
                          total_transaction_count,
                          ,
                          managed_accounts)
end

.namesObject

A mapping from model property names to API property names.



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/verizon/models/billable_usage_report.rb', line 43

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_name'] = 'accountName'
  @_hash['usage_for_all_accounts'] = 'usageForAllAccounts'
  @_hash['sku_name'] = 'skuName'
  @_hash['transactions_allowed'] = 'transactionsAllowed'
  @_hash['total_transaction_count'] = 'totalTransactionCount'
  @_hash['primary_account'] = 'PrimaryAccount'
  @_hash['managed_accounts'] = 'ManagedAccounts'
  @_hash
end

.nullablesObject

An array for nullable fields



69
70
71
# File 'lib/verizon/models/billable_usage_report.rb', line 69

def self.nullables
  []
end

.optionalsObject

An array for optional fields



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/verizon/models/billable_usage_report.rb', line 56

def self.optionals
  %w[
    account_name
    usage_for_all_accounts
    sku_name
    transactions_allowed
    total_transaction_count
    primary_account
    managed_accounts
  ]
end