splitit-apimatic-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +154 -0
  4. data/bin/console +15 -0
  5. data/lib/splitit_web_api_v4/api_helper.rb +10 -0
  6. data/lib/splitit_web_api_v4/client.rb +83 -0
  7. data/lib/splitit_web_api_v4/configuration.rb +188 -0
  8. data/lib/splitit_web_api_v4/controllers/base_controller.rb +60 -0
  9. data/lib/splitit_web_api_v4/controllers/installment_plan_controller.rb +242 -0
  10. data/lib/splitit_web_api_v4/controllers/o_auth_authorization_controller.rb +42 -0
  11. data/lib/splitit_web_api_v4/exceptions/api_error_response_exception.rb +51 -0
  12. data/lib/splitit_web_api_v4/exceptions/api_exception.rb +21 -0
  13. data/lib/splitit_web_api_v4/exceptions/o_auth_provider_exception.rb +64 -0
  14. data/lib/splitit_web_api_v4/http/auth/api_key.rb +52 -0
  15. data/lib/splitit_web_api_v4/http/auth/o_auth2.rb +156 -0
  16. data/lib/splitit_web_api_v4/http/http_call_back.rb +10 -0
  17. data/lib/splitit_web_api_v4/http/http_method_enum.rb +10 -0
  18. data/lib/splitit_web_api_v4/http/http_request.rb +10 -0
  19. data/lib/splitit_web_api_v4/http/http_response.rb +10 -0
  20. data/lib/splitit_web_api_v4/http/proxy_settings.rb +22 -0
  21. data/lib/splitit_web_api_v4/models/amount_data.rb +70 -0
  22. data/lib/splitit_web_api_v4/models/api_error_model.rb +93 -0
  23. data/lib/splitit_web_api_v4/models/apr_data.rb +70 -0
  24. data/lib/splitit_web_api_v4/models/authorization_status_enum.rb +40 -0
  25. data/lib/splitit_web_api_v4/models/authorize_authorization_data.rb +154 -0
  26. data/lib/splitit_web_api_v4/models/authorize_request.rb +115 -0
  27. data/lib/splitit_web_api_v4/models/authorize_response.rb +221 -0
  28. data/lib/splitit_web_api_v4/models/base_model.rb +110 -0
  29. data/lib/splitit_web_api_v4/models/billing_address_data.rb +111 -0
  30. data/lib/splitit_web_api_v4/models/card_details.rb +108 -0
  31. data/lib/splitit_web_api_v4/models/card_validity_request.rb +62 -0
  32. data/lib/splitit_web_api_v4/models/card_validity_response.rb +80 -0
  33. data/lib/splitit_web_api_v4/models/checkout_url_data.rb +80 -0
  34. data/lib/splitit_web_api_v4/models/content_segment.rb +90 -0
  35. data/lib/splitit_web_api_v4/models/external_provider_types_enum.rb +48 -0
  36. data/lib/splitit_web_api_v4/models/inline_content.rb +71 -0
  37. data/lib/splitit_web_api_v4/models/installment_item.rb +101 -0
  38. data/lib/splitit_web_api_v4/models/installment_plan_details_response.rb +280 -0
  39. data/lib/splitit_web_api_v4/models/installment_plan_search_details_response.rb +71 -0
  40. data/lib/splitit_web_api_v4/models/installment_plan_search_request.rb +79 -0
  41. data/lib/splitit_web_api_v4/models/installment_plan_status_enum.rb +72 -0
  42. data/lib/splitit_web_api_v4/models/installment_status_enum.rb +60 -0
  43. data/lib/splitit_web_api_v4/models/masked_card_details.rb +82 -0
  44. data/lib/splitit_web_api_v4/models/metadata_item.rb +71 -0
  45. data/lib/splitit_web_api_v4/models/o_auth_provider_error_enum.rb +62 -0
  46. data/lib/splitit_web_api_v4/models/o_auth_scope_o_auth2_enum.rb +26 -0
  47. data/lib/splitit_web_api_v4/models/o_auth_token.rb +96 -0
  48. data/lib/splitit_web_api_v4/models/offer_item.rb +164 -0
  49. data/lib/splitit_web_api_v4/models/offers_billing_address.rb +108 -0
  50. data/lib/splitit_web_api_v4/models/offers_card_details.rb +108 -0
  51. data/lib/splitit_web_api_v4/models/offers_merchant_details.rb +82 -0
  52. data/lib/splitit_web_api_v4/models/offers_payment_method.rb +66 -0
  53. data/lib/splitit_web_api_v4/models/offers_payment_method_response.rb +88 -0
  54. data/lib/splitit_web_api_v4/models/offers_request.rb +145 -0
  55. data/lib/splitit_web_api_v4/models/offers_response.rb +156 -0
  56. data/lib/splitit_web_api_v4/models/offers_shopper_details.rb +112 -0
  57. data/lib/splitit_web_api_v4/models/offers_store_location.rb +108 -0
  58. data/lib/splitit_web_api_v4/models/payment_link_request.rb +195 -0
  59. data/lib/splitit_web_api_v4/models/payment_link_response.rb +107 -0
  60. data/lib/splitit_web_api_v4/models/payment_method.rb +66 -0
  61. data/lib/splitit_web_api_v4/models/payment_method_data.rb +78 -0
  62. data/lib/splitit_web_api_v4/models/payment_method_type_enum.rb +26 -0
  63. data/lib/splitit_web_api_v4/models/pis_error_codes_enum.rb +1021 -0
  64. data/lib/splitit_web_api_v4/models/plan_authorization_data.rb +172 -0
  65. data/lib/splitit_web_api_v4/models/plan_links_data.rb +91 -0
  66. data/lib/splitit_web_api_v4/models/plan_status_enum.rb +48 -0
  67. data/lib/splitit_web_api_v4/models/processing_data.rb +63 -0
  68. data/lib/splitit_web_api_v4/models/purchase_method_enum.rb +52 -0
  69. data/lib/splitit_web_api_v4/models/redirect_urls.rb +81 -0
  70. data/lib/splitit_web_api_v4/models/refund_item.rb +136 -0
  71. data/lib/splitit_web_api_v4/models/refund_request.rb +70 -0
  72. data/lib/splitit_web_api_v4/models/refund_response.rb +105 -0
  73. data/lib/splitit_web_api_v4/models/shipping_status_enum.rb +40 -0
  74. data/lib/splitit_web_api_v4/models/shopper_details_data.rb +113 -0
  75. data/lib/splitit_web_api_v4/models/three_ds_authentication_data.rb +90 -0
  76. data/lib/splitit_web_api_v4/models/three_ds_execute.rb +62 -0
  77. data/lib/splitit_web_api_v4/models/three_ds_redirect_data.rb +93 -0
  78. data/lib/splitit_web_api_v4/models/three_ds_request_data.rb +84 -0
  79. data/lib/splitit_web_api_v4/models/update_offers_payment_method.rb +66 -0
  80. data/lib/splitit_web_api_v4/models/update_offers_request.rb +105 -0
  81. data/lib/splitit_web_api_v4/models/update_order_request.rb +104 -0
  82. data/lib/splitit_web_api_v4/models/update_order_response.rb +126 -0
  83. data/lib/splitit_web_api_v4/models/validation_error.rb +71 -0
  84. data/lib/splitit_web_api_v4/utilities/date_time_helper.rb +11 -0
  85. data/lib/splitit_web_api_v4/utilities/file_wrapper.rb +28 -0
  86. data/lib/splitit_web_api_v4.rb +108 -0
  87. metadata +170 -0
@@ -0,0 +1,80 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module SplititWebApiV4
8
+ # CheckoutUrlData Model.
9
+ class CheckoutUrlData < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [String]
15
+ attr_accessor :url
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [DateTime]
19
+ attr_accessor :valid_until
20
+
21
+ # A mapping from model property names to API property names.
22
+ def self.names
23
+ @_hash = {} if @_hash.nil?
24
+ @_hash['url'] = 'Url'
25
+ @_hash['valid_until'] = 'ValidUntil'
26
+ @_hash
27
+ end
28
+
29
+ # An array for optional fields
30
+ def self.optionals
31
+ %w[
32
+ url
33
+ valid_until
34
+ ]
35
+ end
36
+
37
+ # An array for nullable fields
38
+ def self.nullables
39
+ []
40
+ end
41
+
42
+ def initialize(url = SKIP, valid_until = SKIP)
43
+ @url = url unless url == SKIP
44
+ @valid_until = valid_until unless valid_until == SKIP
45
+ end
46
+
47
+ # Creates an instance of the object from a hash.
48
+ def self.from_hash(hash)
49
+ return nil unless hash
50
+
51
+ # Extract variables from the hash.
52
+ url = hash.key?('Url') ? hash['Url'] : SKIP
53
+ valid_until = if hash.key?('ValidUntil')
54
+ (DateTimeHelper.from_rfc3339(hash['ValidUntil']) if hash['ValidUntil'])
55
+ else
56
+ SKIP
57
+ end
58
+
59
+ # Create object from extracted values.
60
+ CheckoutUrlData.new(url,
61
+ valid_until)
62
+ end
63
+
64
+ def to_custom_valid_until
65
+ DateTimeHelper.to_rfc3339(valid_until)
66
+ end
67
+
68
+ # Provides a human-readable string representation of the object.
69
+ def to_s
70
+ class_name = self.class.name.split('::').last
71
+ "<#{class_name} url: #{@url}, valid_until: #{@valid_until}>"
72
+ end
73
+
74
+ # Provides a debugging-friendly string with detailed object information.
75
+ def inspect
76
+ class_name = self.class.name.split('::').last
77
+ "<#{class_name} url: #{@url.inspect}, valid_until: #{@valid_until.inspect}>"
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,90 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # ContentSegment Model.
8
+ class ContentSegment < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [String]
14
+ attr_accessor :type
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [String]
18
+ attr_accessor :value
19
+
20
+ # TODO: Write general description for this method
21
+ # @return [String]
22
+ attr_accessor :label
23
+
24
+ # TODO: Write general description for this method
25
+ # @return [String]
26
+ attr_accessor :url
27
+
28
+ # A mapping from model property names to API property names.
29
+ def self.names
30
+ @_hash = {} if @_hash.nil?
31
+ @_hash['type'] = 'Type'
32
+ @_hash['value'] = 'Value'
33
+ @_hash['label'] = 'Label'
34
+ @_hash['url'] = 'Url'
35
+ @_hash
36
+ end
37
+
38
+ # An array for optional fields
39
+ def self.optionals
40
+ %w[
41
+ type
42
+ value
43
+ label
44
+ url
45
+ ]
46
+ end
47
+
48
+ # An array for nullable fields
49
+ def self.nullables
50
+ []
51
+ end
52
+
53
+ def initialize(type = SKIP, value = SKIP, label = SKIP, url = SKIP)
54
+ @type = type unless type == SKIP
55
+ @value = value unless value == SKIP
56
+ @label = label unless label == SKIP
57
+ @url = url unless url == SKIP
58
+ end
59
+
60
+ # Creates an instance of the object from a hash.
61
+ def self.from_hash(hash)
62
+ return nil unless hash
63
+
64
+ # Extract variables from the hash.
65
+ type = hash.key?('Type') ? hash['Type'] : SKIP
66
+ value = hash.key?('Value') ? hash['Value'] : SKIP
67
+ label = hash.key?('Label') ? hash['Label'] : SKIP
68
+ url = hash.key?('Url') ? hash['Url'] : SKIP
69
+
70
+ # Create object from extracted values.
71
+ ContentSegment.new(type,
72
+ value,
73
+ label,
74
+ url)
75
+ end
76
+
77
+ # Provides a human-readable string representation of the object.
78
+ def to_s
79
+ class_name = self.class.name.split('::').last
80
+ "<#{class_name} type: #{@type}, value: #{@value}, label: #{@label}, url: #{@url}>"
81
+ end
82
+
83
+ # Provides a debugging-friendly string with detailed object information.
84
+ def inspect
85
+ class_name = self.class.name.split('::').last
86
+ "<#{class_name} type: #{@type.inspect}, value: #{@value.inspect}, label: #{@label.inspect},"\
87
+ " url: #{@url.inspect}>"
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,48 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # ExternalProviderTypes.
8
+ class ExternalProviderTypesEnum
9
+ EXTERNAL_PROVIDER_TYPES_ENUM = [
10
+ # TODO: Write general description for MOCK
11
+ MOCK = 'Mock'.freeze,
12
+
13
+ # TODO: Write general description for VISA
14
+ VISA = 'Visa'.freeze,
15
+
16
+ # TODO: Write general description for SPLITIT
17
+ SPLITIT = 'Splitit'.freeze,
18
+
19
+ # TODO: Write general description for WORLDPAY
20
+ WORLDPAY = 'WorldPay'.freeze,
21
+
22
+ # TODO: Write general description for MASTERCARD
23
+ MASTERCARD = 'Mastercard'.freeze
24
+ ].freeze
25
+
26
+ def self.validate(value)
27
+ return false if value.nil?
28
+
29
+ EXTERNAL_PROVIDER_TYPES_ENUM.include?(value)
30
+ end
31
+
32
+ def self.from_value(value, default_value = MOCK)
33
+ return default_value if value.nil?
34
+
35
+ str = value.to_s.strip
36
+
37
+ case str.downcase
38
+ when 'mock' then MOCK
39
+ when 'visa' then VISA
40
+ when 'splitit' then SPLITIT
41
+ when 'worldpay' then WORLDPAY
42
+ when 'mastercard' then MASTERCARD
43
+ else
44
+ default_value
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,71 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SplititWebApiV4
7
+ # InlineContent Model.
8
+ class InlineContent < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Array[ContentSegment]]
14
+ attr_accessor :segments
15
+
16
+ # A mapping from model property names to API property names.
17
+ def self.names
18
+ @_hash = {} if @_hash.nil?
19
+ @_hash['segments'] = 'Segments'
20
+ @_hash
21
+ end
22
+
23
+ # An array for optional fields
24
+ def self.optionals
25
+ %w[
26
+ segments
27
+ ]
28
+ end
29
+
30
+ # An array for nullable fields
31
+ def self.nullables
32
+ []
33
+ end
34
+
35
+ def initialize(segments = SKIP)
36
+ @segments = segments unless segments == SKIP
37
+ end
38
+
39
+ # Creates an instance of the object from a hash.
40
+ def self.from_hash(hash)
41
+ return nil unless hash
42
+
43
+ # Extract variables from the hash.
44
+ # Parameter is an array, so we need to iterate through it
45
+ segments = nil
46
+ unless hash['Segments'].nil?
47
+ segments = []
48
+ hash['Segments'].each do |structure|
49
+ segments << (ContentSegment.from_hash(structure) if structure)
50
+ end
51
+ end
52
+
53
+ segments = SKIP unless hash.key?('Segments')
54
+
55
+ # Create object from extracted values.
56
+ InlineContent.new(segments)
57
+ end
58
+
59
+ # Provides a human-readable string representation of the object.
60
+ def to_s
61
+ class_name = self.class.name.split('::').last
62
+ "<#{class_name} segments: #{@segments}>"
63
+ end
64
+
65
+ # Provides a debugging-friendly string with detailed object information.
66
+ def inspect
67
+ class_name = self.class.name.split('::').last
68
+ "<#{class_name} segments: #{@segments.inspect}>"
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,101 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module SplititWebApiV4
8
+ # InstallmentItem Model.
9
+ class InstallmentItem < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [Integer]
15
+ attr_accessor :installment_number
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [AmountData]
19
+ attr_accessor :amount
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [InstallmentStatusEnum]
23
+ attr_accessor :status
24
+
25
+ # TODO: Write general description for this method
26
+ # @return [DateTime]
27
+ attr_accessor :process_date_time
28
+
29
+ # A mapping from model property names to API property names.
30
+ def self.names
31
+ @_hash = {} if @_hash.nil?
32
+ @_hash['installment_number'] = 'InstallmentNumber'
33
+ @_hash['amount'] = 'Amount'
34
+ @_hash['status'] = 'Status'
35
+ @_hash['process_date_time'] = 'ProcessDateTime'
36
+ @_hash
37
+ end
38
+
39
+ # An array for optional fields
40
+ def self.optionals
41
+ %w[
42
+ amount
43
+ process_date_time
44
+ ]
45
+ end
46
+
47
+ # An array for nullable fields
48
+ def self.nullables
49
+ []
50
+ end
51
+
52
+ def initialize(installment_number = nil, status = nil, amount = SKIP,
53
+ process_date_time = SKIP)
54
+ @installment_number = installment_number
55
+ @amount = amount unless amount == SKIP
56
+ @status = status
57
+ @process_date_time = process_date_time unless process_date_time == SKIP
58
+ end
59
+
60
+ # Creates an instance of the object from a hash.
61
+ def self.from_hash(hash)
62
+ return nil unless hash
63
+
64
+ # Extract variables from the hash.
65
+ installment_number =
66
+ hash.key?('InstallmentNumber') ? hash['InstallmentNumber'] : nil
67
+ status = hash.key?('Status') ? hash['Status'] : nil
68
+ amount = AmountData.from_hash(hash['Amount']) if hash['Amount']
69
+ process_date_time = if hash.key?('ProcessDateTime')
70
+ (DateTimeHelper.from_rfc3339(hash['ProcessDateTime']) if hash['ProcessDateTime'])
71
+ else
72
+ SKIP
73
+ end
74
+
75
+ # Create object from extracted values.
76
+ InstallmentItem.new(installment_number,
77
+ status,
78
+ amount,
79
+ process_date_time)
80
+ end
81
+
82
+ def to_custom_process_date_time
83
+ DateTimeHelper.to_rfc3339(process_date_time)
84
+ end
85
+
86
+ # Provides a human-readable string representation of the object.
87
+ def to_s
88
+ class_name = self.class.name.split('::').last
89
+ "<#{class_name} installment_number: #{@installment_number}, amount: #{@amount}, status:"\
90
+ " #{@status}, process_date_time: #{@process_date_time}>"
91
+ end
92
+
93
+ # Provides a debugging-friendly string with detailed object information.
94
+ def inspect
95
+ class_name = self.class.name.split('::').last
96
+ "<#{class_name} installment_number: #{@installment_number.inspect}, amount:"\
97
+ " #{@amount.inspect}, status: #{@status.inspect}, process_date_time:"\
98
+ " #{@process_date_time.inspect}>"
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,280 @@
1
+ # splitit_web_api_v4
2
+ #
3
+ # This file was automatically generated by APIMATIC
4
+ # v3.0 ( https://www.apimatic.io ).
5
+
6
+ require 'date'
7
+ module SplititWebApiV4
8
+ # InstallmentPlanDetailsResponse Model.
9
+ class InstallmentPlanDetailsResponse < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [DateTime]
15
+ attr_accessor :date_created
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [InstallmentPlanStatusEnum]
19
+ attr_accessor :status
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [String]
23
+ attr_accessor :installment_plan_number
24
+
25
+ # TODO: Write general description for this method
26
+ # @return [String]
27
+ attr_accessor :merchant_order_reference
28
+
29
+ # TODO: Write general description for this method
30
+ # @return [ExternalProviderTypesEnum]
31
+ attr_accessor :installment_provider
32
+
33
+ # TODO: Write general description for this method
34
+ # @return [PurchaseMethodEnum]
35
+ attr_accessor :purchase_method
36
+
37
+ # TODO: Write general description for this method
38
+ # @return [String]
39
+ attr_accessor :currency
40
+
41
+ # TODO: Write general description for this method
42
+ # @return [Float]
43
+ attr_accessor :purchase_amount
44
+
45
+ # TODO: Write general description for this method
46
+ # @return [Float]
47
+ attr_accessor :total_amount
48
+
49
+ # TODO: Write general description for this method
50
+ # @return [Float]
51
+ attr_accessor :total_fees
52
+
53
+ # TODO: Write general description for this method
54
+ # @return [AprData]
55
+ attr_accessor :apr
56
+
57
+ # TODO: Write general description for this method
58
+ # @return [PlanAuthorizationData]
59
+ attr_accessor :authorization
60
+
61
+ # TODO: Write general description for this method
62
+ # @return [ShopperDetailsData]
63
+ attr_accessor :shopper_details
64
+
65
+ # TODO: Write general description for this method
66
+ # @return [PaymentMethodData]
67
+ attr_accessor :payment_method
68
+
69
+ # TODO: Write general description for this method
70
+ # @return [Array[InstallmentItem]]
71
+ attr_accessor :installments
72
+
73
+ # TODO: Write general description for this method
74
+ # @return [Array[RefundItem]]
75
+ attr_accessor :refunds
76
+
77
+ # TODO: Write general description for this method
78
+ # @return [Array[PlanLinksData]]
79
+ attr_accessor :links
80
+
81
+ # TODO: Write general description for this method
82
+ # @return [Array[MetadataItem]]
83
+ attr_accessor :metadata
84
+
85
+ # A mapping from model property names to API property names.
86
+ def self.names
87
+ @_hash = {} if @_hash.nil?
88
+ @_hash['date_created'] = 'DateCreated'
89
+ @_hash['status'] = 'Status'
90
+ @_hash['installment_plan_number'] = 'InstallmentPlanNumber'
91
+ @_hash['merchant_order_reference'] = 'MerchantOrderReference'
92
+ @_hash['installment_provider'] = 'InstallmentProvider'
93
+ @_hash['purchase_method'] = 'PurchaseMethod'
94
+ @_hash['currency'] = 'Currency'
95
+ @_hash['purchase_amount'] = 'PurchaseAmount'
96
+ @_hash['total_amount'] = 'TotalAmount'
97
+ @_hash['total_fees'] = 'TotalFees'
98
+ @_hash['apr'] = 'Apr'
99
+ @_hash['authorization'] = 'Authorization'
100
+ @_hash['shopper_details'] = 'ShopperDetails'
101
+ @_hash['payment_method'] = 'PaymentMethod'
102
+ @_hash['installments'] = 'Installments'
103
+ @_hash['refunds'] = 'Refunds'
104
+ @_hash['links'] = 'Links'
105
+ @_hash['metadata'] = 'Metadata'
106
+ @_hash
107
+ end
108
+
109
+ # An array for optional fields
110
+ def self.optionals
111
+ %w[
112
+ installment_plan_number
113
+ merchant_order_reference
114
+ currency
115
+ apr
116
+ authorization
117
+ shopper_details
118
+ payment_method
119
+ installments
120
+ refunds
121
+ links
122
+ metadata
123
+ ]
124
+ end
125
+
126
+ # An array for nullable fields
127
+ def self.nullables
128
+ []
129
+ end
130
+
131
+ def initialize(date_created = nil, status = nil, installment_provider = nil,
132
+ purchase_method = nil, purchase_amount = nil,
133
+ total_amount = nil, total_fees = nil,
134
+ installment_plan_number = SKIP,
135
+ merchant_order_reference = SKIP, currency = SKIP, apr = SKIP,
136
+ authorization = SKIP, shopper_details = SKIP,
137
+ payment_method = SKIP, installments = SKIP, refunds = SKIP,
138
+ links = SKIP, metadata = SKIP)
139
+ @date_created = date_created
140
+ @status = status
141
+ @installment_plan_number = installment_plan_number unless installment_plan_number == SKIP
142
+ @merchant_order_reference = merchant_order_reference unless merchant_order_reference == SKIP
143
+ @installment_provider = installment_provider
144
+ @purchase_method = purchase_method
145
+ @currency = currency unless currency == SKIP
146
+ @purchase_amount = purchase_amount
147
+ @total_amount = total_amount
148
+ @total_fees = total_fees
149
+ @apr = apr unless apr == SKIP
150
+ @authorization = authorization unless authorization == SKIP
151
+ @shopper_details = shopper_details unless shopper_details == SKIP
152
+ @payment_method = payment_method unless payment_method == SKIP
153
+ @installments = installments unless installments == SKIP
154
+ @refunds = refunds unless refunds == SKIP
155
+ @links = links unless links == SKIP
156
+ @metadata = metadata unless metadata == SKIP
157
+ end
158
+
159
+ # Creates an instance of the object from a hash.
160
+ def self.from_hash(hash)
161
+ return nil unless hash
162
+
163
+ # Extract variables from the hash.
164
+ date_created = if hash.key?('DateCreated')
165
+ (DateTimeHelper.from_rfc3339(hash['DateCreated']) if hash['DateCreated'])
166
+ end
167
+ status = hash.key?('Status') ? hash['Status'] : nil
168
+ installment_provider =
169
+ hash.key?('InstallmentProvider') ? hash['InstallmentProvider'] : nil
170
+ purchase_method =
171
+ hash.key?('PurchaseMethod') ? hash['PurchaseMethod'] : nil
172
+ purchase_amount =
173
+ hash.key?('PurchaseAmount') ? hash['PurchaseAmount'] : nil
174
+ total_amount = hash.key?('TotalAmount') ? hash['TotalAmount'] : nil
175
+ total_fees = hash.key?('TotalFees') ? hash['TotalFees'] : nil
176
+ installment_plan_number =
177
+ hash.key?('InstallmentPlanNumber') ? hash['InstallmentPlanNumber'] : SKIP
178
+ merchant_order_reference =
179
+ hash.key?('MerchantOrderReference') ? hash['MerchantOrderReference'] : SKIP
180
+ currency = hash.key?('Currency') ? hash['Currency'] : SKIP
181
+ apr = AprData.from_hash(hash['Apr']) if hash['Apr']
182
+ authorization = PlanAuthorizationData.from_hash(hash['Authorization']) if
183
+ hash['Authorization']
184
+ shopper_details = ShopperDetailsData.from_hash(hash['ShopperDetails']) if
185
+ hash['ShopperDetails']
186
+ payment_method = PaymentMethodData.from_hash(hash['PaymentMethod']) if hash['PaymentMethod']
187
+ # Parameter is an array, so we need to iterate through it
188
+ installments = nil
189
+ unless hash['Installments'].nil?
190
+ installments = []
191
+ hash['Installments'].each do |structure|
192
+ installments << (InstallmentItem.from_hash(structure) if structure)
193
+ end
194
+ end
195
+
196
+ installments = SKIP unless hash.key?('Installments')
197
+ # Parameter is an array, so we need to iterate through it
198
+ refunds = nil
199
+ unless hash['Refunds'].nil?
200
+ refunds = []
201
+ hash['Refunds'].each do |structure|
202
+ refunds << (RefundItem.from_hash(structure) if structure)
203
+ end
204
+ end
205
+
206
+ refunds = SKIP unless hash.key?('Refunds')
207
+ # Parameter is an array, so we need to iterate through it
208
+ links = nil
209
+ unless hash['Links'].nil?
210
+ links = []
211
+ hash['Links'].each do |structure|
212
+ links << (PlanLinksData.from_hash(structure) if structure)
213
+ end
214
+ end
215
+
216
+ links = SKIP unless hash.key?('Links')
217
+ # Parameter is an array, so we need to iterate through it
218
+ metadata = nil
219
+ unless hash['Metadata'].nil?
220
+ metadata = []
221
+ hash['Metadata'].each do |structure|
222
+ metadata << (MetadataItem.from_hash(structure) if structure)
223
+ end
224
+ end
225
+
226
+ metadata = SKIP unless hash.key?('Metadata')
227
+
228
+ # Create object from extracted values.
229
+ InstallmentPlanDetailsResponse.new(date_created,
230
+ status,
231
+ installment_provider,
232
+ purchase_method,
233
+ purchase_amount,
234
+ total_amount,
235
+ total_fees,
236
+ installment_plan_number,
237
+ merchant_order_reference,
238
+ currency,
239
+ apr,
240
+ authorization,
241
+ shopper_details,
242
+ payment_method,
243
+ installments,
244
+ refunds,
245
+ links,
246
+ metadata)
247
+ end
248
+
249
+ def to_custom_date_created
250
+ DateTimeHelper.to_rfc3339(date_created)
251
+ end
252
+
253
+ # Provides a human-readable string representation of the object.
254
+ def to_s
255
+ class_name = self.class.name.split('::').last
256
+ "<#{class_name} date_created: #{@date_created}, status: #{@status},"\
257
+ " installment_plan_number: #{@installment_plan_number}, merchant_order_reference:"\
258
+ " #{@merchant_order_reference}, installment_provider: #{@installment_provider},"\
259
+ " purchase_method: #{@purchase_method}, currency: #{@currency}, purchase_amount:"\
260
+ " #{@purchase_amount}, total_amount: #{@total_amount}, total_fees: #{@total_fees}, apr:"\
261
+ " #{@apr}, authorization: #{@authorization}, shopper_details: #{@shopper_details},"\
262
+ " payment_method: #{@payment_method}, installments: #{@installments}, refunds: #{@refunds},"\
263
+ " links: #{@links}, metadata: #{@metadata}>"
264
+ end
265
+
266
+ # Provides a debugging-friendly string with detailed object information.
267
+ def inspect
268
+ class_name = self.class.name.split('::').last
269
+ "<#{class_name} date_created: #{@date_created.inspect}, status: #{@status.inspect},"\
270
+ " installment_plan_number: #{@installment_plan_number.inspect}, merchant_order_reference:"\
271
+ " #{@merchant_order_reference.inspect}, installment_provider:"\
272
+ " #{@installment_provider.inspect}, purchase_method: #{@purchase_method.inspect}, currency:"\
273
+ " #{@currency.inspect}, purchase_amount: #{@purchase_amount.inspect}, total_amount:"\
274
+ " #{@total_amount.inspect}, total_fees: #{@total_fees.inspect}, apr: #{@apr.inspect},"\
275
+ " authorization: #{@authorization.inspect}, shopper_details: #{@shopper_details.inspect},"\
276
+ " payment_method: #{@payment_method.inspect}, installments: #{@installments.inspect},"\
277
+ " refunds: #{@refunds.inspect}, links: #{@links.inspect}, metadata: #{@metadata.inspect}>"
278
+ end
279
+ end
280
+ end