Class: Verizon::BillUsageRequest

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

Overview

Bill usage request.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(account_name:, start_date:, end_date:, usage_for_all_accounts: SKIP, additional_properties: nil) ⇒ BillUsageRequest

Returns a new instance of BillUsageRequest.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/verizon/models/bill_usage_request.rb', line 50

def initialize(account_name:, start_date:, end_date:,
               usage_for_all_accounts: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_name = 
  @start_date = start_date
  @end_date = end_date
  @usage_for_all_accounts = usage_for_all_accounts unless usage_for_all_accounts == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_nameString

Account identifier.

Returns:

  • (String)


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

def 
  @account_name
end

#end_dateString

End date to search for billable usage, mm-dd-yyyy.

Returns:

  • (String)


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

def end_date
  @end_date
end

#start_dateString

Start date to search for billable usage, mm-dd-yyyy.

Returns:

  • (String)


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

def start_date
  @start_date
end

#usage_for_all_accountsTrueClass | FalseClass

Request usage for single or multiple accounts.

Returns:

  • (TrueClass | FalseClass)


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

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.



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/verizon/models/bill_usage_request.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('accountName') ? hash['accountName'] : nil
  start_date = hash.key?('startDate') ? hash['startDate'] : nil
  end_date = hash.key?('endDate') ? hash['endDate'] : nil
  usage_for_all_accounts =
    hash.key?('usageForAllAccounts') ? hash['usageForAllAccounts'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  BillUsageRequest.new(account_name: ,
                       start_date: start_date,
                       end_date: end_date,
                       usage_for_all_accounts: usage_for_all_accounts,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/verizon/models/bill_usage_request.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_name'] = 'accountName'
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['usage_for_all_accounts'] = 'usageForAllAccounts'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/verizon/models/bill_usage_request.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
# File 'lib/verizon/models/bill_usage_request.rb', line 39

def self.optionals
  %w[
    usage_for_all_accounts
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



97
98
99
100
101
102
# File 'lib/verizon/models/bill_usage_request.rb', line 97

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name.inspect}, start_date: #{@start_date.inspect},"\
  " end_date: #{@end_date.inspect}, usage_for_all_accounts:"\
  " #{@usage_for_all_accounts.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
94
# File 'lib/verizon/models/bill_usage_request.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_name: #{@account_name}, start_date: #{@start_date}, end_date:"\
  " #{@end_date}, usage_for_all_accounts: #{@usage_for_all_accounts}, additional_properties:"\
  " #{@additional_properties}>"
end