Class: SplititWebApiV4::UpdateOffersRequest

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

Overview

UpdateOffersRequest 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(merchant_order_reference: SKIP, shopper_details: SKIP, payment_method: SKIP, metadata: SKIP, additional_properties: nil) ⇒ UpdateOffersRequest

Returns a new instance of UpdateOffersRequest.



53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/splitit_web_api_v4/models/update_offers_request.rb', line 53

def initialize(merchant_order_reference: SKIP, shopper_details: SKIP,
               payment_method: 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
  @shopper_details = shopper_details unless shopper_details == SKIP
  @payment_method = payment_method unless payment_method == SKIP
  @metadata =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#merchant_order_referenceString

TODO: Write general description for this method

Returns:

  • (String)


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

def merchant_order_reference
  @merchant_order_reference
end

#metadataArray[MetadataItem]

TODO: Write general description for this method

Returns:



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

def 
  @metadata
end

#payment_methodUpdateOffersPaymentMethod

TODO: Write general description for this method



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

def payment_method
  @payment_method
end

#shopper_detailsOffersShopperDetails

TODO: Write general description for this method



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

def shopper_details
  @shopper_details
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
99
100
101
# File 'lib/splitit_web_api_v4/models/update_offers_request.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  merchant_order_reference =
    hash.key?('MerchantOrderReference') ? hash['MerchantOrderReference'] : SKIP
  shopper_details = OffersShopperDetails.from_hash(hash['ShopperDetails']) if
    hash['ShopperDetails']
  payment_method = UpdateOffersPaymentMethod.from_hash(hash['PaymentMethod']) if
    hash['PaymentMethod']
  # 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.
  UpdateOffersRequest.new(merchant_order_reference: merchant_order_reference,
                          shopper_details: shopper_details,
                          payment_method: payment_method,
                          metadata: ,
                          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/splitit_web_api_v4/models/update_offers_request.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['merchant_order_reference'] = 'MerchantOrderReference'
  @_hash['shopper_details'] = 'ShopperDetails'
  @_hash['payment_method'] = 'PaymentMethod'
  @_hash['metadata'] = 'Metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
# File 'lib/splitit_web_api_v4/models/update_offers_request.rb', line 49

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
44
45
46
# File 'lib/splitit_web_api_v4/models/update_offers_request.rb', line 39

def self.optionals
  %w[
    merchant_order_reference
    shopper_details
    payment_method
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



112
113
114
115
116
117
# File 'lib/splitit_web_api_v4/models/update_offers_request.rb', line 112

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

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
109
# File 'lib/splitit_web_api_v4/models/update_offers_request.rb', line 104

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