Class: LoyaltyApIs::RedemptionResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/loyalty_ap_is/models/redemption_response.rb

Overview

RedemptionResponse Model.

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(reference_id:, transaction_date_time:, updated_point_balance:, redemption_req_array:, additional_properties: nil) ⇒ RedemptionResponse

Returns a new instance of RedemptionResponse.



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 51

def initialize(reference_id:, transaction_date_time:,
               updated_point_balance:, redemption_req_array:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @reference_id = reference_id
  @transaction_date_time = transaction_date_time
  @updated_point_balance = updated_point_balance
  @redemption_req_array = redemption_req_array
  @additional_properties = additional_properties
end

Instance Attribute Details

#redemption_req_arrayArray[RedemptionResponseItem]

This array requests the points to be redeemed from the users point balance for the items requested. The same information will be shown to the user. Multiple items can be redeemed in a single API request.

Returns:



29
30
31
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 29

def redemption_req_array
  @redemption_req_array
end

#reference_idString

A unique Reference ID for the transaction, generated by the partner.

Returns:

  • (String)


14
15
16
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 14

def reference_id
  @reference_id
end

#transaction_date_timeString

The time and date of the redemption transaction.

Returns:

  • (String)


18
19
20
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 18

def transaction_date_time
  @transaction_date_time
end

#updated_point_balanceString

The user's current loyalty point balance after the requested items have been redeemed.

Returns:

  • (String)


23
24
25
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 23

def updated_point_balance
  @updated_point_balance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 65

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  reference_id = hash.key?('referenceId') ? hash['referenceId'] : nil
  transaction_date_time =
    hash.key?('transactionDateTime') ? hash['transactionDateTime'] : nil
  updated_point_balance =
    hash.key?('updatedPointBalance') ? hash['updatedPointBalance'] : nil
  # Parameter is an array, so we need to iterate through it
  redemption_req_array = nil
  unless hash['redemptionReqArray'].nil?
    redemption_req_array = []
    hash['redemptionReqArray'].each do |structure|
      redemption_req_array << (RedemptionResponseItem.from_hash(structure) if structure)
    end
  end

  redemption_req_array = nil unless hash.key?('redemptionReqArray')

  # 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.
  RedemptionResponse.new(reference_id: reference_id,
                         transaction_date_time: transaction_date_time,
                         updated_point_balance: updated_point_balance,
                         redemption_req_array: redemption_req_array,
                         additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['reference_id'] = 'referenceId'
  @_hash['transaction_date_time'] = 'transactionDateTime'
  @_hash['updated_point_balance'] = 'updatedPointBalance'
  @_hash['redemption_req_array'] = 'redemptionReqArray'
  @_hash
end

.nullablesObject

An array for nullable fields



47
48
49
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 47

def self.nullables
  []
end

.optionalsObject

An array for optional fields



42
43
44
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 42

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



110
111
112
113
114
115
116
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 110

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} reference_id: #{@reference_id.inspect}, transaction_date_time:"\
  " #{@transaction_date_time.inspect}, updated_point_balance:"\
  " #{@updated_point_balance.inspect}, redemption_req_array: #{@redemption_req_array.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
106
107
# File 'lib/loyalty_ap_is/models/redemption_response.rb', line 101

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} reference_id: #{@reference_id}, transaction_date_time:"\
  " #{@transaction_date_time}, updated_point_balance: #{@updated_point_balance},"\
  " redemption_req_array: #{@redemption_req_array}, additional_properties:"\
  " #{@additional_properties}>"
end