Class: LoyaltyApIs::BalanceAmountDetail
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- LoyaltyApIs::BalanceAmountDetail
- Defined in:
- lib/loyalty_ap_is/models/balance_amount_detail.rb
Overview
BalanceAmountDetail Model.
Instance Attribute Summary collapse
-
#amount ⇒ Float
Current value of specified balance.
-
#cash_amount ⇒ Float
Point to cash exchange amnount.
-
#date_time ⇒ DateTime
Expiration Date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ” Nullable.
-
#date_timestamp ⇒ Integer
Date as Unix epoch (UTC).
-
#period ⇒ Integer
Period of expiration, minimum value is 1.
-
#position ⇒ Array[Integer]
The list of numbers describes an index of boost’s position in qualifying visit, Seralized only when it’s not null and not empty.
-
#state ⇒ BalanceState
State of the points balance amount.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(amount:, state:, date_time:, date_timestamp:, cash_amount: SKIP, period: SKIP, position: SKIP, additional_properties: nil) ⇒ BalanceAmountDetail
constructor
A new instance of BalanceAmountDetail.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_date_time ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(amount:, state:, date_time:, date_timestamp:, cash_amount: SKIP, period: SKIP, position: SKIP, additional_properties: nil) ⇒ BalanceAmountDetail
Returns a new instance of BalanceAmountDetail.
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 71 def initialize(amount:, state:, date_time:, date_timestamp:, cash_amount: SKIP, period: SKIP, position: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @amount = amount @state = state @date_time = date_time @date_timestamp = @cash_amount = cash_amount unless cash_amount == SKIP @period = period unless period == SKIP @position = position unless position == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#amount ⇒ Float
Current value of specified balance.
15 16 17 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 15 def amount @amount end |
#cash_amount ⇒ Float
Point to cash exchange amnount.
32 33 34 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 32 def cash_amount @cash_amount end |
#date_time ⇒ DateTime
Expiration Date in JSON recommended format: “yyyy-MM-ddTHH:mm:ssZ” Nullable.
24 25 26 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 24 def date_time @date_time end |
#date_timestamp ⇒ Integer
Date as Unix epoch (UTC).
28 29 30 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 28 def @date_timestamp end |
#period ⇒ Integer
Period of expiration, minimum value is 1. Seralized only when it’s not null.
37 38 39 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 37 def period @period end |
#position ⇒ Array[Integer]
The list of numbers describes an index of boost’s position in qualifying visit, Seralized only when it’s not null and not empty.
42 43 44 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 42 def position @position end |
#state ⇒ BalanceState
State of the points balance amount.
19 20 21 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 19 def state @state end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
88 89 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 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 88 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. amount = hash.key?('amount') ? hash['amount'] : nil state = hash.key?('state') ? hash['state'] : nil date_time = if hash.key?('dateTime') (DateTimeHelper.from_rfc3339(hash['dateTime']) if hash['dateTime']) end = hash.key?('dateTimestamp') ? hash['dateTimestamp'] : nil cash_amount = hash.key?('cashAmount') ? hash['cashAmount'] : SKIP period = hash.key?('period') ? hash['period'] : SKIP position = hash.key?('position') ? hash['position'] : 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. BalanceAmountDetail.new(amount: amount, state: state, date_time: date_time, date_timestamp: , cash_amount: cash_amount, period: period, position: position, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['amount'] = 'amount' @_hash['state'] = 'state' @_hash['date_time'] = 'dateTime' @_hash['date_timestamp'] = 'dateTimestamp' @_hash['cash_amount'] = 'cashAmount' @_hash['period'] = 'period' @_hash['position'] = 'position' @_hash end |
.nullables ⇒ Object
An array for nullable fields
67 68 69 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 67 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
58 59 60 61 62 63 64 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 58 def self.optionals %w[ cash_amount period position ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
133 134 135 136 137 138 139 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 133 def inspect class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount.inspect}, state: #{@state.inspect}, date_time:"\ " #{@date_time.inspect}, date_timestamp: #{@date_timestamp.inspect}, cash_amount:"\ " #{@cash_amount.inspect}, period: #{@period.inspect}, position: #{@position.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_custom_date_time ⇒ Object
120 121 122 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 120 def to_custom_date_time DateTimeHelper.to_rfc3339(date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
125 126 127 128 129 130 |
# File 'lib/loyalty_ap_is/models/balance_amount_detail.rb', line 125 def to_s class_name = self.class.name.split('::').last "<#{class_name} amount: #{@amount}, state: #{@state}, date_time: #{@date_time},"\ " date_timestamp: #{@date_timestamp}, cash_amount: #{@cash_amount}, period: #{@period},"\ " position: #{@position}, additional_properties: #{@additional_properties}>" end |