Class: SplititWebApiV4::AuthorizeRequest

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

Overview

AuthorizeRequest 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(offer_id:, auto_capture:, shopper_accepted_terms:, merchant_order_reference: SKIP, three_ds: SKIP, processing_data: SKIP, additional_properties: nil) ⇒ AuthorizeRequest

Returns a new instance of AuthorizeRequest.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/splitit_web_api_v4/models/authorize_request.rb', line 62

def initialize(offer_id:, auto_capture:, shopper_accepted_terms:,
               merchant_order_reference: SKIP, three_ds: SKIP,
               processing_data: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @offer_id = offer_id
  @auto_capture = auto_capture
  @shopper_accepted_terms = shopper_accepted_terms
  @merchant_order_reference = merchant_order_reference unless merchant_order_reference == SKIP
  @three_ds = three_ds unless three_ds == SKIP
  @processing_data = processing_data unless processing_data == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#auto_captureTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def auto_capture
  @auto_capture
end

#merchant_order_referenceString

TODO: Write general description for this method

Returns:

  • (String)


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

def merchant_order_reference
  @merchant_order_reference
end

#offer_idString

TODO: Write general description for this method

Returns:

  • (String)


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

def offer_id
  @offer_id
end

#processing_dataProcessingData

TODO: Write general description for this method

Returns:



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

def processing_data
  @processing_data
end

#shopper_accepted_termsTrueClass | FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass | FalseClass)


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

def shopper_accepted_terms
  @shopper_accepted_terms
end

#three_dsThreeDsRequestData

TODO: Write general description for this method

Returns:



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

def three_ds
  @three_ds
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/splitit_web_api_v4/models/authorize_request.rb', line 78

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  offer_id = hash.key?('OfferId') ? hash['OfferId'] : nil
  auto_capture = hash.key?('AutoCapture') ? hash['AutoCapture'] : nil
  shopper_accepted_terms =
    hash.key?('ShopperAcceptedTerms') ? hash['ShopperAcceptedTerms'] : nil
  merchant_order_reference =
    hash.key?('MerchantOrderReference') ? hash['MerchantOrderReference'] : SKIP
  three_ds = ThreeDsRequestData.from_hash(hash['ThreeDS']) if hash['ThreeDS']
  processing_data = ProcessingData.from_hash(hash['ProcessingData']) if hash['ProcessingData']

  # 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.
  AuthorizeRequest.new(offer_id: offer_id,
                       auto_capture: auto_capture,
                       shopper_accepted_terms: shopper_accepted_terms,
                       merchant_order_reference: merchant_order_reference,
                       three_ds: three_ds,
                       processing_data: processing_data,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['offer_id'] = 'OfferId'
  @_hash['auto_capture'] = 'AutoCapture'
  @_hash['shopper_accepted_terms'] = 'ShopperAcceptedTerms'
  @_hash['merchant_order_reference'] = 'MerchantOrderReference'
  @_hash['three_ds'] = 'ThreeDS'
  @_hash['processing_data'] = 'ProcessingData'
  @_hash
end

.nullablesObject

An array for nullable fields



58
59
60
# File 'lib/splitit_web_api_v4/models/authorize_request.rb', line 58

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
54
55
# File 'lib/splitit_web_api_v4/models/authorize_request.rb', line 49

def self.optionals
  %w[
    merchant_order_reference
    three_ds
    processing_data
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



118
119
120
121
122
123
124
# File 'lib/splitit_web_api_v4/models/authorize_request.rb', line 118

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} offer_id: #{@offer_id.inspect}, auto_capture: #{@auto_capture.inspect},"\
  " shopper_accepted_terms: #{@shopper_accepted_terms.inspect}, merchant_order_reference:"\
  " #{@merchant_order_reference.inspect}, three_ds: #{@three_ds.inspect}, processing_data:"\
  " #{@processing_data.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



109
110
111
112
113
114
115
# File 'lib/splitit_web_api_v4/models/authorize_request.rb', line 109

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} offer_id: #{@offer_id}, auto_capture: #{@auto_capture},"\
  " shopper_accepted_terms: #{@shopper_accepted_terms}, merchant_order_reference:"\
  " #{@merchant_order_reference}, three_ds: #{@three_ds}, processing_data:"\
  " #{@processing_data}, additional_properties: #{@additional_properties}>"
end