cybersource_rest_client 0.0.29 → 0.0.33

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/AuthenticationSDK/authentication/oauth/OAuthToken.rb +15 -0
  3. data/lib/AuthenticationSDK/core/Authorization.rb +4 -1
  4. data/lib/AuthenticationSDK/core/MerchantConfig.rb +93 -19
  5. data/lib/AuthenticationSDK/util/Constants.rb +78 -76
  6. data/lib/cybersource_rest_client.rb +19 -9
  7. data/lib/cybersource_rest_client/api/customer_payment_instrument_api.rb +3 -3
  8. data/lib/cybersource_rest_client/api/instrument_identifier_api.rb +3 -3
  9. data/lib/cybersource_rest_client/api/o_auth_api.rb +104 -0
  10. data/lib/cybersource_rest_client/api/payments_api.rb +2 -2
  11. data/lib/cybersource_rest_client/api/refund_api.rb +4 -4
  12. data/lib/cybersource_rest_client/api/void_api.rb +4 -4
  13. data/lib/cybersource_rest_client/api_client.rb +31 -8
  14. data/lib/cybersource_rest_client/configuration.rb +2 -2
  15. data/lib/cybersource_rest_client/models/access_token_response.rb +244 -0
  16. data/lib/cybersource_rest_client/models/add_negative_list_request.rb +1 -1
  17. data/lib/cybersource_rest_client/models/bad_request_error.rb +192 -0
  18. data/lib/cybersource_rest_client/models/create_access_token_request.rb +254 -0
  19. data/lib/cybersource_rest_client/models/fraud_marking_action_request.rb +1 -1
  20. data/lib/cybersource_rest_client/models/invoicing_v2_invoices_all_get200_response_customer_information.rb +20 -4
  21. data/lib/cybersource_rest_client/models/invoicingv2invoices_customer_information.rb +20 -4
  22. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer.rb → payment_instrument_list.rb} +3 -3
  23. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__embedded.rb → payment_instrument_list__embedded.rb} +1 -1
  24. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__links.rb → payment_instrument_list__links.rb} +6 -6
  25. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__links_first.rb → payment_instrument_list__links_first.rb} +1 -1
  26. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__links_last.rb → payment_instrument_list__links_last.rb} +1 -1
  27. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__links_next.rb → payment_instrument_list__links_next.rb} +1 -1
  28. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__links_prev.rb → payment_instrument_list__links_prev.rb} +1 -1
  29. data/lib/cybersource_rest_client/models/{payment_instrument_list_for_customer__links_self.rb → payment_instrument_list__links_self.rb} +1 -1
  30. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response.rb +10 -1
  31. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_consumer_authentication_information.rb +11 -1
  32. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_order_information.rb +13 -4
  33. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_order_information_reward_points_details.rb +270 -0
  34. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_payment_account_information.rb +183 -0
  35. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_payment_account_information_card.rb +242 -0
  36. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_payment_information.rb +1 -1
  37. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_payment_information_tokenized_card.rb +1 -1
  38. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_processing_information.rb +1 -1
  39. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_processor_information.rb +17 -1
  40. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_processor_information_routing.rb +3 -3
  41. data/lib/cybersource_rest_client/models/pts_v2_payouts_post201_response_merchant_information_merchant_descriptor.rb +6 -0
  42. data/lib/cybersource_rest_client/models/pts_v2_payouts_post201_response_recipient_information_card.rb +1 -1
  43. data/lib/cybersource_rest_client/models/ptsv2credits_processing_information.rb +1 -1
  44. data/lib/cybersource_rest_client/models/ptsv2payments_client_reference_information.rb +1 -1
  45. data/lib/cybersource_rest_client/models/ptsv2payments_consumer_authentication_information.rb +60 -2
  46. data/lib/cybersource_rest_client/models/ptsv2payments_health_care_information_amount_details.rb +1 -1
  47. data/lib/cybersource_rest_client/models/ptsv2payments_merchant_information_merchant_descriptor.rb +6 -0
  48. data/lib/cybersource_rest_client/models/ptsv2payments_payment_information_card.rb +4 -4
  49. data/lib/cybersource_rest_client/models/ptsv2payments_payment_information_fluid_data.rb +3 -3
  50. data/lib/cybersource_rest_client/models/ptsv2payments_payment_information_tokenized_card.rb +1 -1
  51. data/lib/cybersource_rest_client/models/ptsv2payments_point_of_sale_information.rb +36 -38
  52. data/lib/cybersource_rest_client/models/ptsv2payments_processing_information.rb +15 -5
  53. data/lib/cybersource_rest_client/models/ptsv2payments_processing_information_authorization_options.rb +7 -7
  54. data/lib/cybersource_rest_client/models/ptsv2payments_recurring_payment_information.rb +24 -4
  55. data/lib/cybersource_rest_client/models/ptsv2payments_risk_information.rb +15 -4
  56. data/lib/cybersource_rest_client/models/ptsv2payments_risk_information_auxiliary_data.rb +207 -0
  57. data/lib/cybersource_rest_client/models/ptsv2paymentsidcaptures_payment_information_card.rb +1 -1
  58. data/lib/cybersource_rest_client/models/ptsv2paymentsidcaptures_processing_information.rb +15 -5
  59. data/lib/cybersource_rest_client/models/ptsv2paymentsidrefunds_payment_information_card.rb +4 -4
  60. data/lib/cybersource_rest_client/models/ptsv2paymentsidrefunds_processing_information.rb +1 -1
  61. data/lib/cybersource_rest_client/models/ptsv2paymentsidreversals_client_reference_information.rb +17 -1
  62. data/lib/cybersource_rest_client/models/ptsv2paymentsidreversals_processing_information.rb +1 -1
  63. data/lib/cybersource_rest_client/models/ptsv2payouts_merchant_information_merchant_descriptor.rb +6 -0
  64. data/lib/cybersource_rest_client/models/ptsv2payouts_payment_information_card.rb +4 -4
  65. data/lib/cybersource_rest_client/models/resource_not_found_error.rb +192 -0
  66. data/lib/cybersource_rest_client/models/riskv1authenticationresults_consumer_authentication_information.rb +1 -1
  67. data/lib/cybersource_rest_client/models/riskv1authenticationresults_payment_information_card.rb +3 -3
  68. data/lib/cybersource_rest_client/models/riskv1authenticationresults_payment_information_tokenized_card.rb +1 -1
  69. data/lib/cybersource_rest_client/models/riskv1authentications_payment_information_card.rb +3 -3
  70. data/lib/cybersource_rest_client/models/riskv1authentications_payment_information_tokenized_card.rb +1 -1
  71. data/lib/cybersource_rest_client/models/riskv1authenticationsetups_payment_information_card.rb +3 -3
  72. data/lib/cybersource_rest_client/models/riskv1authenticationsetups_payment_information_fluid_data.rb +3 -3
  73. data/lib/cybersource_rest_client/models/riskv1authenticationsetups_payment_information_tokenized_card.rb +1 -1
  74. data/lib/cybersource_rest_client/models/riskv1authenticationsetups_processing_information.rb +1 -1
  75. data/lib/cybersource_rest_client/models/riskv1decisions_client_reference_information.rb +17 -1
  76. data/lib/cybersource_rest_client/models/riskv1decisions_consumer_authentication_information.rb +1 -1
  77. data/lib/cybersource_rest_client/models/riskv1decisions_device_information.rb +1 -11
  78. data/lib/cybersource_rest_client/models/riskv1decisions_payment_information_card.rb +3 -3
  79. data/lib/cybersource_rest_client/models/riskv1decisions_payment_information_tokenized_card.rb +1 -1
  80. data/lib/cybersource_rest_client/models/riskv1decisions_risk_information.rb +15 -4
  81. data/lib/cybersource_rest_client/models/riskv1liststypeentries_client_reference_information.rb +224 -0
  82. data/lib/cybersource_rest_client/models/riskv1liststypeentries_payment_information_card.rb +1 -1
  83. data/lib/cybersource_rest_client/models/tss_v2_transactions_get200_response_payment_information_card.rb +5 -5
  84. data/lib/cybersource_rest_client/models/tss_v2_transactions_get200_response_processing_information_authorization_options.rb +13 -4
  85. data/lib/cybersource_rest_client/models/tss_v2_transactions_post201_response__embedded_payment_information_card.rb +3 -3
  86. data/lib/cybersource_rest_client/models/tss_v2_transactions_post201_response__embedded_processing_information.rb +1 -1
  87. data/lib/cybersource_rest_client/models/unauthorized_client_error.rb +192 -0
  88. data/lib/cybersource_rest_client/models/validate_export_compliance_request.rb +1 -1
  89. data/lib/cybersource_rest_client/models/verify_customer_address_request.rb +1 -1
  90. metadata +120 -101
  91. data/lib/AuthenticationSDK/resource/TRRReports.json +0 -12
  92. data/lib/AuthenticationSDK/resource/cybs.yml +0 -31
  93. data/lib/AuthenticationSDK/resource/request.json +0 -54
  94. data/lib/AuthenticationSDK/resource/request_capture.json +0 -11
  95. data/lib/AuthenticationSDK/resource/testrest.p12 +0 -0
  96. data/lib/AuthenticationSDK/spec/Authorization_spec.rb +0 -274
  97. data/lib/AuthenticationSDK/spec/MerchantConfigData.rb +0 -59
  98. data/lib/AuthenticationSDK/spec/MerchantConfig_spec.rb +0 -116
  99. data/lib/AuthenticationSDK/spec/PostRequestData.json +0 -54
  100. data/lib/AuthenticationSDK/spec/PutRequestData.json +0 -12
  101. data/lib/AuthenticationSDK/spec/ResponseCodeMessage_spec.rb +0 -60
  102. data/lib/AuthenticationSDK/spec/spec_helper.rb +0 -12
  103. data/lib/cybersource_rest_client/models/pts_v2_payments_post201_response_payment_information_card.rb +0 -184
@@ -43,7 +43,7 @@ module CyberSource
43
43
  {
44
44
  :'order_information' => :'Riskv1liststypeentriesOrderInformation',
45
45
  :'payment_information' => :'Riskv1liststypeentriesPaymentInformation',
46
- :'client_reference_information' => :'Riskv1decisionsClientReferenceInformation',
46
+ :'client_reference_information' => :'Riskv1liststypeentriesClientReferenceInformation',
47
47
  :'device_information' => :'Riskv1liststypeentriesDeviceInformation',
48
48
  :'risk_information' => :'Riskv1liststypeentriesRiskInformation',
49
49
  :'buyer_information' => :'Riskv1liststypeentriesBuyerInformation'
@@ -0,0 +1,192 @@
1
+ =begin
2
+ #OAuth2 API
3
+
4
+ #OAuth2 Token Service (OAuth2)
5
+
6
+ OpenAPI spec version: v3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CyberSource
16
+ class BadRequestError
17
+ attr_accessor :error
18
+
19
+ attr_accessor :error_description
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'error' => :'error',
25
+ :'error_description' => :'error_description'
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.swagger_types
31
+ {
32
+ :'error' => :'String',
33
+ :'error_description' => :'String'
34
+ }
35
+ end
36
+
37
+ # Initializes the object
38
+ # @param [Hash] attributes Model attributes in the form of hash
39
+ def initialize(attributes = {})
40
+ return unless attributes.is_a?(Hash)
41
+
42
+ # convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
44
+
45
+ if attributes.has_key?(:'error')
46
+ self.error = attributes[:'error']
47
+ end
48
+
49
+ if attributes.has_key?(:'error_description')
50
+ self.error_description = attributes[:'error_description']
51
+ end
52
+ end
53
+
54
+ # Show invalid properties with the reasons. Usually used together with valid?
55
+ # @return Array for valid properties with the reasons
56
+ def list_invalid_properties
57
+ invalid_properties = Array.new
58
+ invalid_properties
59
+ end
60
+
61
+ # Check to see if the all the properties in the model are valid
62
+ # @return true if the model is valid
63
+ def valid?
64
+ true
65
+ end
66
+
67
+ # Checks equality by comparing each attribute.
68
+ # @param [Object] Object to be compared
69
+ def ==(o)
70
+ return true if self.equal?(o)
71
+ self.class == o.class &&
72
+ error == o.error &&
73
+ error_description == o.error_description
74
+ end
75
+
76
+ # @see the `==` method
77
+ # @param [Object] Object to be compared
78
+ def eql?(o)
79
+ self == o
80
+ end
81
+
82
+ # Calculates hash code according to all attributes.
83
+ # @return [Fixnum] Hash code
84
+ def hash
85
+ [error, error_description].hash
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.swagger_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :BOOLEAN
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ temp_model = CyberSource.const_get(type).new
146
+ temp_model.build_from_hash(value)
147
+ end
148
+ end
149
+
150
+ # Returns the string representation of the object
151
+ # @return [String] String presentation of the object
152
+ def to_s
153
+ to_hash.to_s
154
+ end
155
+
156
+ # to_body is an alias to to_hash (backward compatibility)
157
+ # @return [Hash] Returns the object in the form of hash
158
+ def to_body
159
+ to_hash
160
+ end
161
+
162
+ # Returns the object in the form of hash
163
+ # @return [Hash] Returns the object in the form of hash
164
+ def to_hash
165
+ hash = {}
166
+ self.class.attribute_map.each_pair do |attr, param|
167
+ value = self.send(attr)
168
+ next if value.nil?
169
+ hash[param] = _to_hash(value)
170
+ end
171
+ hash
172
+ end
173
+
174
+ # Outputs non-array value in the form of hash
175
+ # For object, use to_hash. Otherwise, just return the value
176
+ # @param [Object] value Any valid value
177
+ # @return [Hash] Returns the value in the form of hash
178
+ def _to_hash(value)
179
+ if value.is_a?(Array)
180
+ value.compact.map { |v| _to_hash(v) }
181
+ elsif value.is_a?(Hash)
182
+ {}.tap do |hash|
183
+ value.each { |k, v| hash[k] = _to_hash(v) }
184
+ end
185
+ elsif value.respond_to? :to_hash
186
+ value.to_hash
187
+ else
188
+ value
189
+ end
190
+ end
191
+ end
192
+ end
@@ -0,0 +1,254 @@
1
+ =begin
2
+ #OAuth2 API
3
+
4
+ #OAuth2 Token Service (OAuth2)
5
+
6
+ OpenAPI spec version: v3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.2.3
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CyberSource
16
+ class CreateAccessTokenRequest
17
+ # The client ID that you received when you registered your application in the CyberSource Business Center. This identifies your client application.
18
+ attr_accessor :client_id
19
+
20
+ # The client secret that you received when you registered your application in the CyberSource Business Center.
21
+ attr_accessor :client_secret
22
+
23
+ # The grant type value determines which type of flow is used to obtain the access token. The first time your application requests a token, use the value `authorization_code`. When you use this value, you must also include the `code` field in the request. For subsequent request, use `refresh_token`. When you use this value, you must also include the `refresh_token` field in the request. Valid values: - authorization_code - refresh_token
24
+ attr_accessor :grant_type
25
+
26
+ # This value is sent by CyberSource in the redirect URL. For security reasons, the code expires in 10 minutes. If it expires, you must repeat the redirect to request another. Conditional. This value is equired if grant_type is `authorization_code`.
27
+ attr_accessor :code
28
+
29
+ # Conditional. Required if grant_type is `refresh_token`.
30
+ attr_accessor :refresh_token
31
+
32
+ # Attribute mapping from ruby-style variable name to JSON key.
33
+ def self.attribute_map
34
+ {
35
+ :'client_id' => :'client_id',
36
+ :'client_secret' => :'client_secret',
37
+ :'grant_type' => :'grant_type',
38
+ :'code' => :'code',
39
+ :'refresh_token' => :'refresh_token'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.swagger_types
45
+ {
46
+ :'client_id' => :'String',
47
+ :'client_secret' => :'String',
48
+ :'grant_type' => :'String',
49
+ :'code' => :'String',
50
+ :'refresh_token' => :'String'
51
+ }
52
+ end
53
+
54
+ # Initializes the object
55
+ # @param [Hash] attributes Model attributes in the form of hash
56
+ def initialize(attributes = {})
57
+ return unless attributes.is_a?(Hash)
58
+
59
+ # convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
61
+
62
+ if attributes.has_key?(:'client_id')
63
+ self.client_id = attributes[:'client_id']
64
+ end
65
+
66
+ if attributes.has_key?(:'client_secret')
67
+ self.client_secret = attributes[:'client_secret']
68
+ end
69
+
70
+ if attributes.has_key?(:'grant_type')
71
+ self.grant_type = attributes[:'grant_type']
72
+ end
73
+
74
+ if attributes.has_key?(:'code')
75
+ self.code = attributes[:'code']
76
+ end
77
+
78
+ if attributes.has_key?(:'refresh_token')
79
+ self.refresh_token = attributes[:'refresh_token']
80
+ end
81
+ end
82
+
83
+ # Show invalid properties with the reasons. Usually used together with valid?
84
+ # @return Array for valid properties with the reasons
85
+ def list_invalid_properties
86
+ invalid_properties = Array.new
87
+ if @client_id.nil?
88
+ invalid_properties.push('invalid value for "client_id", client_id cannot be nil.')
89
+ end
90
+
91
+ if @client_secret.nil?
92
+ invalid_properties.push('invalid value for "client_secret", client_secret cannot be nil.')
93
+ end
94
+
95
+ invalid_properties
96
+ end
97
+
98
+ # Check to see if the all the properties in the model are valid
99
+ # @return true if the model is valid
100
+ def valid?
101
+ return false if @client_id.nil?
102
+ return false if @client_secret.nil?
103
+ true
104
+ end
105
+
106
+ # Custom attribute writer method with validation
107
+ # @param [Object] client_id Value to be assigned
108
+ def client_id=(client_id)
109
+ if client_id.nil?
110
+ fail ArgumentError, 'client_id cannot be nil'
111
+ end
112
+
113
+ @client_id = client_id
114
+ end
115
+
116
+ # Custom attribute writer method with validation
117
+ # @param [Object] client_secret Value to be assigned
118
+ def client_secret=(client_secret)
119
+ if client_secret.nil?
120
+ fail ArgumentError, 'client_secret cannot be nil'
121
+ end
122
+
123
+ @client_secret = client_secret
124
+ end
125
+
126
+ # Checks equality by comparing each attribute.
127
+ # @param [Object] Object to be compared
128
+ def ==(o)
129
+ return true if self.equal?(o)
130
+ self.class == o.class &&
131
+ client_id == o.client_id &&
132
+ client_secret == o.client_secret &&
133
+ grant_type == o.grant_type &&
134
+ code == o.code &&
135
+ refresh_token == o.refresh_token
136
+ end
137
+
138
+ # @see the `==` method
139
+ # @param [Object] Object to be compared
140
+ def eql?(o)
141
+ self == o
142
+ end
143
+
144
+ # Calculates hash code according to all attributes.
145
+ # @return [Fixnum] Hash code
146
+ def hash
147
+ [client_id, client_secret, grant_type, code, refresh_token].hash
148
+ end
149
+
150
+ # Builds the object from hash
151
+ # @param [Hash] attributes Model attributes in the form of hash
152
+ # @return [Object] Returns the model itself
153
+ def build_from_hash(attributes)
154
+ return nil unless attributes.is_a?(Hash)
155
+ self.class.swagger_types.each_pair do |key, type|
156
+ if type =~ /\AArray<(.*)>/i
157
+ # check to ensure the input is an array given that the the attribute
158
+ # is documented as an array but the input is not
159
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
160
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
161
+ end
162
+ elsif !attributes[self.class.attribute_map[key]].nil?
163
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
164
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
165
+ end
166
+
167
+ self
168
+ end
169
+
170
+ # Deserializes the data based on type
171
+ # @param string type Data type
172
+ # @param string value Value to be deserialized
173
+ # @return [Object] Deserialized data
174
+ def _deserialize(type, value)
175
+ case type.to_sym
176
+ when :DateTime
177
+ DateTime.parse(value)
178
+ when :Date
179
+ Date.parse(value)
180
+ when :String
181
+ value.to_s
182
+ when :Integer
183
+ value.to_i
184
+ when :Float
185
+ value.to_f
186
+ when :BOOLEAN
187
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
188
+ true
189
+ else
190
+ false
191
+ end
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ else # model
207
+ temp_model = CyberSource.const_get(type).new
208
+ temp_model.build_from_hash(value)
209
+ end
210
+ end
211
+
212
+ # Returns the string representation of the object
213
+ # @return [String] String presentation of the object
214
+ def to_s
215
+ to_hash.to_s
216
+ end
217
+
218
+ # to_body is an alias to to_hash (backward compatibility)
219
+ # @return [Hash] Returns the object in the form of hash
220
+ def to_body
221
+ to_hash
222
+ end
223
+
224
+ # Returns the object in the form of hash
225
+ # @return [Hash] Returns the object in the form of hash
226
+ def to_hash
227
+ hash = {}
228
+ self.class.attribute_map.each_pair do |attr, param|
229
+ value = self.send(attr)
230
+ next if value.nil?
231
+ hash[param] = _to_hash(value)
232
+ end
233
+ hash
234
+ end
235
+
236
+ # Outputs non-array value in the form of hash
237
+ # For object, use to_hash. Otherwise, just return the value
238
+ # @param [Object] value Any valid value
239
+ # @return [Hash] Returns the value in the form of hash
240
+ def _to_hash(value)
241
+ if value.is_a?(Array)
242
+ value.compact.map { |v| _to_hash(v) }
243
+ elsif value.is_a?(Hash)
244
+ {}.tap do |hash|
245
+ value.each { |k, v| hash[k] = _to_hash(v) }
246
+ end
247
+ elsif value.respond_to? :to_hash
248
+ value.to_hash
249
+ else
250
+ value
251
+ end
252
+ end
253
+ end
254
+ end