jamm 1.7.0 → 2.1.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.
@@ -0,0 +1,46 @@
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ class ChargeStatus
18
+ UNSPECIFIED = "CHARGE_STATUS_UNSPECIFIED".freeze
19
+ SUCCESS = "CHARGE_STATUS_SUCCESS".freeze
20
+ FAILURE = "CHARGE_STATUS_FAILURE".freeze
21
+ WAITING_EKYC = "CHARGE_STATUS_WAITING_EKYC".freeze
22
+ BLOCKING = "CHARGE_STATUS_BLOCKING".freeze
23
+ CANCELLED = "CHARGE_STATUS_CANCELLED".freeze
24
+ REFUNDED = "CHARGE_STATUS_REFUNDED".freeze
25
+ PENDING = "CHARGE_STATUS_PENDING".freeze
26
+
27
+ def self.all_vars
28
+ @all_vars ||= [UNSPECIFIED, SUCCESS, FAILURE, WAITING_EKYC, BLOCKING, CANCELLED, REFUNDED, PENDING].freeze
29
+ end
30
+
31
+ # Builds the enum from string
32
+ # @param [String] The enum value in the form of the string
33
+ # @return [String] The enum value
34
+ def self.build_from_hash(value)
35
+ new.build_from_hash(value)
36
+ end
37
+
38
+ # Builds the enum from string
39
+ # @param [String] The enum value in the form of the string
40
+ # @return [String] The enum value
41
+ def build_from_hash(value)
42
+ return value if ChargeStatus.all_vars.include?(value)
43
+ raise "Invalid ENUM value #{value} for class #ChargeStatus"
44
+ end
45
+ end
46
+ end
@@ -20,13 +20,14 @@ module Api
20
20
  CHARGE_UPDATED = "EVENT_TYPE_CHARGE_UPDATED".freeze
21
21
  CHARGE_SUCCESS = "EVENT_TYPE_CHARGE_SUCCESS".freeze
22
22
  CHARGE_FAIL = "EVENT_TYPE_CHARGE_FAIL".freeze
23
- CHARGE_CANCEL = "EVENT_TYPE_CHARGE_CANCEL".freeze
23
+ REFUND_SUCCEEDED = "EVENT_TYPE_REFUND_SUCCEEDED".freeze
24
+ REFUND_FAILED = "EVENT_TYPE_REFUND_FAILED".freeze
24
25
  CONTRACT_ACTIVATED = "EVENT_TYPE_CONTRACT_ACTIVATED".freeze
25
26
  USER_ACCOUNT_DELETED = "EVENT_TYPE_USER_ACCOUNT_DELETED".freeze
26
27
  TESTING = "EVENT_TYPE_TESTING".freeze
27
28
 
28
29
  def self.all_vars
29
- @all_vars ||= [UNSPECIFIED, CHARGE_CREATED, CHARGE_UPDATED, CHARGE_SUCCESS, CHARGE_FAIL, CHARGE_CANCEL, CONTRACT_ACTIVATED, USER_ACCOUNT_DELETED, TESTING].freeze
30
+ @all_vars ||= [UNSPECIFIED, CHARGE_CREATED, CHARGE_UPDATED, CHARGE_SUCCESS, CHARGE_FAIL, REFUND_SUCCEEDED, REFUND_FAILED, CONTRACT_ACTIVATED, USER_ACCOUNT_DELETED, TESTING].freeze
30
31
  end
31
32
 
32
33
  # Builds the enum from string
@@ -19,12 +19,15 @@ module Api
19
19
  # Amount of the charge in Japanese Yen. The amount must be the total price of the product/service including tax. 決済金額。日本円で指定してください。 金額は商品/サービスの合計金額 (税込) を指定してください。 @gotags: validate:\"gte=1,lte=500000\"
20
20
  attr_accessor :price
21
21
 
22
- # Description is an arbitrary string for merchant to track the charge. This information is displayed on Merchant Dashboard. 決済の説明。ショップが決済を追跡するための任意の文字列です。 @gotags: validate:\"required\"
22
+ # Description is an arbitrary string for merchant to track the charge. This information is displayed on Merchant Dashboard. 決済の説明。ショップが決済を追跡するための任意の文字列です。 @gotags: validate:\"required,max=1024\"
23
23
  attr_accessor :description
24
24
 
25
25
  # Arbitrary key-value additional information about the charge. You can see this information in our merchant dashboard. Chargeに関する任意のキーと値の追加情報。 加盟店ダッシュボードで確認できます。
26
26
  attr_accessor :metadata
27
27
 
28
+ # Fee charged by the platform (in JPY). Must be >= the Jamm fee for the merchant. Only meaningful when the caller is a platform. Ignored for direct merchant calls. プラットフォームが徴収する手数料(日本円)。加盟店のJamm手数料以上である必要があります。
29
+ attr_accessor :platform_fee
30
+
28
31
  # Merchant can optionally set the expiry date for the payment. Defaults to 90 minutes if not specified. 決済の有効期限。未指定の場合は90分後に自動失効します。
29
32
  attr_accessor :expires_at
30
33
 
@@ -34,6 +37,7 @@ module Api
34
37
  :'price' => :'price',
35
38
  :'description' => :'description',
36
39
  :'metadata' => :'metadata',
40
+ :'platform_fee' => :'platformFee',
37
41
  :'expires_at' => :'expiresAt'
38
42
  }
39
43
  end
@@ -49,6 +53,7 @@ module Api
49
53
  :'price' => :'Integer',
50
54
  :'description' => :'String',
51
55
  :'metadata' => :'Hash<String, String>',
56
+ :'platform_fee' => :'Integer',
52
57
  :'expires_at' => :'Time'
53
58
  }
54
59
  end
@@ -88,6 +93,10 @@ module Api
88
93
  end
89
94
  end
90
95
 
96
+ if attributes.key?(:'platform_fee')
97
+ self.platform_fee = attributes[:'platform_fee']
98
+ end
99
+
91
100
  if attributes.key?(:'expires_at')
92
101
  self.expires_at = attributes[:'expires_at']
93
102
  end
@@ -116,6 +125,7 @@ module Api
116
125
  price == o.price &&
117
126
  description == o.description &&
118
127
  metadata == o.metadata &&
128
+ platform_fee == o.platform_fee &&
119
129
  expires_at == o.expires_at
120
130
  end
121
131
 
@@ -128,7 +138,7 @@ module Api
128
138
  # Calculates hash code according to all attributes.
129
139
  # @return [Integer] Hash code
130
140
  def hash
131
- [price, description, metadata, expires_at].hash
141
+ [price, description, metadata, platform_fee, expires_at].hash
132
142
  end
133
143
 
134
144
  # Builds the object from hash
@@ -23,13 +23,16 @@ module Api
23
23
 
24
24
  attr_accessor :user_account_message
25
25
 
26
+ attr_accessor :refund_info
27
+
26
28
  # Attribute mapping from ruby-style variable name to JSON key.
27
29
  def self.attribute_map
28
30
  {
29
31
  :'merchant_webhook_message' => :'merchantWebhookMessage',
30
32
  :'charge_message' => :'chargeMessage',
31
33
  :'contract_message' => :'contractMessage',
32
- :'user_account_message' => :'userAccountMessage'
34
+ :'user_account_message' => :'userAccountMessage',
35
+ :'refund_info' => :'refundInfo'
33
36
  }
34
37
  end
35
38
 
@@ -44,7 +47,8 @@ module Api
44
47
  :'merchant_webhook_message' => :'MerchantWebhookMessage',
45
48
  :'charge_message' => :'ChargeMessage',
46
49
  :'contract_message' => :'ContractMessage',
47
- :'user_account_message' => :'UserAccountMessage'
50
+ :'user_account_message' => :'UserAccountMessage',
51
+ :'refund_info' => :'RefundInfo'
48
52
  }
49
53
  end
50
54
 
@@ -84,6 +88,10 @@ module Api
84
88
  if attributes.key?(:'user_account_message')
85
89
  self.user_account_message = attributes[:'user_account_message']
86
90
  end
91
+
92
+ if attributes.key?(:'refund_info')
93
+ self.refund_info = attributes[:'refund_info']
94
+ end
87
95
  end
88
96
 
89
97
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -109,7 +117,8 @@ module Api
109
117
  merchant_webhook_message == o.merchant_webhook_message &&
110
118
  charge_message == o.charge_message &&
111
119
  contract_message == o.contract_message &&
112
- user_account_message == o.user_account_message
120
+ user_account_message == o.user_account_message &&
121
+ refund_info == o.refund_info
113
122
  end
114
123
 
115
124
  # @see the `==` method
@@ -121,7 +130,7 @@ module Api
121
130
  # Calculates hash code according to all attributes.
122
131
  # @return [Integer] Hash code
123
132
  def hash
124
- [merchant_webhook_message, charge_message, contract_message, user_account_message].hash
133
+ [merchant_webhook_message, charge_message, contract_message, user_account_message, refund_info].hash
125
134
  end
126
135
 
127
136
  # Builds the object from hash
@@ -0,0 +1,224 @@
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ # This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge.
18
+ class OffSessionPaymentAsyncRequest
19
+ attr_accessor :customer
20
+
21
+ attr_accessor :charge
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'customer' => :'customer',
27
+ :'charge' => :'charge'
28
+ }
29
+ end
30
+
31
+ # Returns all the JSON keys this model knows about
32
+ def self.acceptable_attributes
33
+ attribute_map.values
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.openapi_types
38
+ {
39
+ :'customer' => :'String',
40
+ :'charge' => :'InitialCharge'
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new([
47
+ ])
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Api::OffSessionPaymentAsyncRequest` initialize method"
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Api::OffSessionPaymentAsyncRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
61
+ end
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:'customer')
66
+ self.customer = attributes[:'customer']
67
+ end
68
+
69
+ if attributes.key?(:'charge')
70
+ self.charge = attributes[:'charge']
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
78
+ invalid_properties = Array.new
79
+ invalid_properties
80
+ end
81
+
82
+ # Check to see if the all the properties in the model are valid
83
+ # @return true if the model is valid
84
+ def valid?
85
+ warn '[DEPRECATED] the `valid?` method is obsolete'
86
+ true
87
+ end
88
+
89
+ # Checks equality by comparing each attribute.
90
+ # @param [Object] Object to be compared
91
+ def ==(o)
92
+ return true if self.equal?(o)
93
+ self.class == o.class &&
94
+ customer == o.customer &&
95
+ charge == o.charge
96
+ end
97
+
98
+ # @see the `==` method
99
+ # @param [Object] Object to be compared
100
+ def eql?(o)
101
+ self == o
102
+ end
103
+
104
+ # Calculates hash code according to all attributes.
105
+ # @return [Integer] Hash code
106
+ def hash
107
+ [customer, charge].hash
108
+ end
109
+
110
+ # Builds the object from hash
111
+ # @param [Hash] attributes Model attributes in the form of hash
112
+ # @return [Object] Returns the model itself
113
+ def self.build_from_hash(attributes)
114
+ return nil unless attributes.is_a?(Hash)
115
+ attributes = attributes.transform_keys(&:to_sym)
116
+ transformed_hash = {}
117
+ openapi_types.each_pair do |key, type|
118
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
119
+ transformed_hash["#{key}"] = nil
120
+ elsif type =~ /\AArray<(.*)>/i
121
+ # check to ensure the input is an array given that the attribute
122
+ # is documented as an array but the input is not
123
+ if attributes[attribute_map[key]].is_a?(Array)
124
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
125
+ end
126
+ elsif !attributes[attribute_map[key]].nil?
127
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
128
+ end
129
+ end
130
+ new(transformed_hash)
131
+ end
132
+
133
+ # Deserializes the data based on type
134
+ # @param string type Data type
135
+ # @param string value Value to be deserialized
136
+ # @return [Object] Deserialized data
137
+ def self._deserialize(type, value)
138
+ case type.to_sym
139
+ when :Time
140
+ Time.parse(value)
141
+ when :Date
142
+ Date.parse(value)
143
+ when :String
144
+ value.to_s
145
+ when :Integer
146
+ value.to_i
147
+ when :Float
148
+ value.to_f
149
+ when :Boolean
150
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
151
+ true
152
+ else
153
+ false
154
+ end
155
+ when :Object
156
+ # generic object (usually a Hash), return directly
157
+ value
158
+ when /\AArray<(?<inner_type>.+)>\z/
159
+ inner_type = Regexp.last_match[:inner_type]
160
+ value.map { |v| _deserialize(inner_type, v) }
161
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
162
+ k_type = Regexp.last_match[:k_type]
163
+ v_type = Regexp.last_match[:v_type]
164
+ {}.tap do |hash|
165
+ value.each do |k, v|
166
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
167
+ end
168
+ end
169
+ else # model
170
+ # models (e.g. Pet) or oneOf
171
+ klass = Api.const_get(type)
172
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
173
+ end
174
+ end
175
+
176
+ # Returns the string representation of the object
177
+ # @return [String] String presentation of the object
178
+ def to_s
179
+ to_hash.to_s
180
+ end
181
+
182
+ # to_body is an alias to to_hash (backward compatibility)
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_body
185
+ to_hash
186
+ end
187
+
188
+ # Returns the object in the form of hash
189
+ # @return [Hash] Returns the object in the form of hash
190
+ def to_hash
191
+ hash = {}
192
+ self.class.attribute_map.each_pair do |attr, param|
193
+ value = self.send(attr)
194
+ if value.nil?
195
+ is_nullable = self.class.openapi_nullable.include?(attr)
196
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
197
+ end
198
+
199
+ hash[param] = _to_hash(value)
200
+ end
201
+ hash
202
+ end
203
+
204
+ # Outputs non-array value in the form of hash
205
+ # For object, use to_hash. Otherwise, just return the value
206
+ # @param [Object] value Any valid value
207
+ # @return [Hash] Returns the value in the form of hash
208
+ def _to_hash(value)
209
+ if value.is_a?(Array)
210
+ value.compact.map { |v| _to_hash(v) }
211
+ elsif value.is_a?(Hash)
212
+ {}.tap do |hash|
213
+ value.each { |k, v| hash[k] = _to_hash(v) }
214
+ end
215
+ elsif value.respond_to? :to_hash
216
+ value.to_hash
217
+ else
218
+ value
219
+ end
220
+ end
221
+
222
+ end
223
+
224
+ end
@@ -0,0 +1,257 @@
1
+ =begin
2
+ #Jamm API
3
+
4
+ #No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
5
+
6
+ The version of the OpenAPI document: 1.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.9.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Api
17
+ # This message represents the asynchronous response after initiating an off-session payment.
18
+ class OffSessionPaymentAsyncResponse
19
+ attr_accessor :request_id
20
+
21
+ attr_accessor :status
22
+
23
+ attr_accessor :charge_id
24
+
25
+ class EnumAttributeValidator
26
+ attr_reader :datatype
27
+ attr_reader :allowable_values
28
+
29
+ def initialize(datatype, allowable_values)
30
+ @allowable_values = allowable_values.map do |value|
31
+ case datatype.to_s
32
+ when /Integer/i
33
+ value.to_i
34
+ when /Float/i
35
+ value.to_f
36
+ else
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def valid?(value)
43
+ !value || allowable_values.include?(value)
44
+ end
45
+ end
46
+
47
+ # Attribute mapping from ruby-style variable name to JSON key.
48
+ def self.attribute_map
49
+ {
50
+ :'request_id' => :'requestId',
51
+ :'status' => :'status',
52
+ :'charge_id' => :'chargeId'
53
+ }
54
+ end
55
+
56
+ # Returns all the JSON keys this model knows about
57
+ def self.acceptable_attributes
58
+ attribute_map.values
59
+ end
60
+
61
+ # Attribute type mapping.
62
+ def self.openapi_types
63
+ {
64
+ :'request_id' => :'String',
65
+ :'status' => :'AsyncStatus',
66
+ :'charge_id' => :'String'
67
+ }
68
+ end
69
+
70
+ # List of attributes with nullable: true
71
+ def self.openapi_nullable
72
+ Set.new([
73
+ ])
74
+ end
75
+
76
+ # Initializes the object
77
+ # @param [Hash] attributes Model attributes in the form of hash
78
+ def initialize(attributes = {})
79
+ if (!attributes.is_a?(Hash))
80
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Api::OffSessionPaymentAsyncResponse` initialize method"
81
+ end
82
+
83
+ # check to see if the attribute exists and convert string to symbol for hash key
84
+ attributes = attributes.each_with_object({}) { |(k, v), h|
85
+ if (!self.class.attribute_map.key?(k.to_sym))
86
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Api::OffSessionPaymentAsyncResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+ h[k.to_sym] = v
89
+ }
90
+
91
+ if attributes.key?(:'request_id')
92
+ self.request_id = attributes[:'request_id']
93
+ end
94
+
95
+ if attributes.key?(:'status')
96
+ self.status = attributes[:'status']
97
+ else
98
+ self.status = 'ASYNC_STATUS_UNSPECIFIED'
99
+ end
100
+
101
+ if attributes.key?(:'charge_id')
102
+ self.charge_id = attributes[:'charge_id']
103
+ end
104
+ end
105
+
106
+ # Show invalid properties with the reasons. Usually used together with valid?
107
+ # @return Array for valid properties with the reasons
108
+ def list_invalid_properties
109
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
110
+ invalid_properties = Array.new
111
+ invalid_properties
112
+ end
113
+
114
+ # Check to see if the all the properties in the model are valid
115
+ # @return true if the model is valid
116
+ def valid?
117
+ warn '[DEPRECATED] the `valid?` method is obsolete'
118
+ true
119
+ end
120
+
121
+ # Checks equality by comparing each attribute.
122
+ # @param [Object] Object to be compared
123
+ def ==(o)
124
+ return true if self.equal?(o)
125
+ self.class == o.class &&
126
+ request_id == o.request_id &&
127
+ status == o.status &&
128
+ charge_id == o.charge_id
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [request_id, status, charge_id].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = Api.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end