Class: LoyaltyApIs::RedemptionRequest

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

Overview

RedemptionRequest 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(uuid:, reference_id:, redemption_req_array:, additional_properties: nil) ⇒ RedemptionRequest

Returns a new instance of RedemptionRequest.



49
50
51
52
53
54
55
56
57
58
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 49

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

  @uuid = uuid
  @reference_id = reference_id
  @redemption_req_array = redemption_req_array
  @additional_properties = additional_properties
end

Instance Attribute Details

#redemption_req_arrayArray[RedemptionItem]

Specifies the number of points to be redeemed from the user's point balance and the reason for redemption, which will also be shown to the user. Mutiple redemption items can be submitted in a single API request.

Returns:



28
29
30
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 28

def redemption_req_array
  @redemption_req_array
end

#reference_idString

A unique ID for the transaction from the partner. Used to identify duplicate requests.

Returns:

  • (String)


22
23
24
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 22

def reference_id
  @reference_id
end

#uuidUUID | String

The SSO uuid of the user signed in with Shell credentials. Format: 32 hexadecimal digits grouped the following way: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx See: https://www.wikiwand.com/en/Universally_unique_identifier#/Format

Returns:

  • (UUID | String)


17
18
19
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 17

def uuid
  @uuid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



61
62
63
64
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
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 61

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  uuid = hash.key?('uuid') ? hash['uuid'] : nil
  reference_id = hash.key?('referenceId') ? hash['referenceId'] : 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 << (RedemptionItem.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.
  RedemptionRequest.new(uuid: uuid,
                        reference_id: reference_id,
                        redemption_req_array: redemption_req_array,
                        additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 31

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

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



40
41
42
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 40

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



100
101
102
103
104
105
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 100

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

#to_sObject

Provides a human-readable string representation of the object.



93
94
95
96
97
# File 'lib/loyalty_ap_is/models/redemption_request.rb', line 93

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