Class: SplititWebApiV4::OffersRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/splitit_web_api_v4/models/offers_request.rb

Overview

OffersRequest 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(purchase_method:, purchase_amount:, currency:, shopper_details:, payment_method:, merchant_order_reference: SKIP, merchant_details: SKIP, metadata: SKIP, additional_properties: nil) ⇒ OffersRequest

Returns a new instance of OffersRequest.



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

def initialize(purchase_method:, purchase_amount:, currency:,
               shopper_details:, payment_method:,
               merchant_order_reference: SKIP, merchant_details: SKIP,
               metadata: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @merchant_order_reference = merchant_order_reference unless merchant_order_reference == SKIP
  @purchase_method = purchase_method
  @purchase_amount = purchase_amount
  @currency = currency
  @shopper_details = shopper_details
  @payment_method = payment_method
  @merchant_details = merchant_details unless merchant_details == SKIP
  @metadata =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#currencyString

TODO: Write general description for this method

Returns:

  • (String)


26
27
28
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 26

def currency
  @currency
end

#merchant_detailsOffersMerchantDetails

TODO: Write general description for this method



38
39
40
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 38

def merchant_details
  @merchant_details
end

#merchant_order_referenceString

TODO: Write general description for this method

Returns:

  • (String)


14
15
16
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 14

def merchant_order_reference
  @merchant_order_reference
end

#metadataArray[MetadataItem]

TODO: Write general description for this method

Returns:



42
43
44
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 42

def 
  @metadata
end

#payment_methodOffersPaymentMethod

TODO: Write general description for this method

Returns:



34
35
36
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 34

def payment_method
  @payment_method
end

#purchase_amountString

TODO: Write general description for this method

Returns:

  • (String)


22
23
24
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 22

def purchase_amount
  @purchase_amount
end

#purchase_methodPurchaseMethod

TODO: Write general description for this method

Returns:



18
19
20
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 18

def purchase_method
  @purchase_method
end

#shopper_detailsOffersShopperDetails

TODO: Write general description for this method



30
31
32
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 30

def shopper_details
  @shopper_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 91

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  purchase_method =
    hash.key?('PurchaseMethod') ? hash['PurchaseMethod'] : nil
  purchase_amount =
    hash.key?('PurchaseAmount') ? hash['PurchaseAmount'] : nil
  currency = hash.key?('Currency') ? hash['Currency'] : nil
  shopper_details = OffersShopperDetails.from_hash(hash['ShopperDetails']) if
    hash['ShopperDetails']
  payment_method = OffersPaymentMethod.from_hash(hash['PaymentMethod']) if
    hash['PaymentMethod']
  merchant_order_reference =
    hash.key?('MerchantOrderReference') ? hash['MerchantOrderReference'] : SKIP
  merchant_details = OffersMerchantDetails.from_hash(hash['MerchantDetails']) if
    hash['MerchantDetails']
  # Parameter is an array, so we need to iterate through it
   = nil
  unless hash['Metadata'].nil?
     = []
    hash['Metadata'].each do |structure|
       << (MetadataItem.from_hash(structure) if structure)
    end
  end

   = SKIP unless hash.key?('Metadata')

  # 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.
  OffersRequest.new(purchase_method: purchase_method,
                    purchase_amount: purchase_amount,
                    currency: currency,
                    shopper_details: shopper_details,
                    payment_method: payment_method,
                    merchant_order_reference: merchant_order_reference,
                    merchant_details: merchant_details,
                    metadata: ,
                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['merchant_order_reference'] = 'MerchantOrderReference'
  @_hash['purchase_method'] = 'PurchaseMethod'
  @_hash['purchase_amount'] = 'PurchaseAmount'
  @_hash['currency'] = 'Currency'
  @_hash['shopper_details'] = 'ShopperDetails'
  @_hash['payment_method'] = 'PaymentMethod'
  @_hash['merchant_details'] = 'MerchantDetails'
  @_hash['metadata'] = 'Metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



68
69
70
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 68

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 59

def self.optionals
  %w[
    merchant_order_reference
    merchant_details
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



149
150
151
152
153
154
155
156
157
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 149

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} merchant_order_reference: #{@merchant_order_reference.inspect},"\
  " purchase_method: #{@purchase_method.inspect}, purchase_amount:"\
  " #{@purchase_amount.inspect}, currency: #{@currency.inspect}, shopper_details:"\
  " #{@shopper_details.inspect}, payment_method: #{@payment_method.inspect}, merchant_details:"\
  " #{@merchant_details.inspect}, metadata: #{@metadata.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



139
140
141
142
143
144
145
146
# File 'lib/splitit_web_api_v4/models/offers_request.rb', line 139

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} merchant_order_reference: #{@merchant_order_reference}, purchase_method:"\
  " #{@purchase_method}, purchase_amount: #{@purchase_amount}, currency: #{@currency},"\
  " shopper_details: #{@shopper_details}, payment_method: #{@payment_method},"\
  " merchant_details: #{@merchant_details}, metadata: #{@metadata}, additional_properties:"\
  " #{@additional_properties}>"
end