square_connect 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES.md +5 -0
- data/CONTRIBUTING.md +5 -0
- data/LICENSE.txt +202 -0
- data/README.md +47 -0
- data/lib/square_connect.rb +88 -0
- data/lib/square_connect/api/customer_api.rb +354 -0
- data/lib/square_connect/api/customer_card_api.rb +163 -0
- data/lib/square_connect/api/location_api.rb +82 -0
- data/lib/square_connect/api/refund_api.rb +179 -0
- data/lib/square_connect/api/transaction_api.rb +387 -0
- data/lib/square_connect/api_client.rb +337 -0
- data/lib/square_connect/api_error.rb +31 -0
- data/lib/square_connect/configuration.rb +163 -0
- data/lib/square_connect/models/address.rb +288 -0
- data/lib/square_connect/models/capture_transaction_response.rb +160 -0
- data/lib/square_connect/models/card.rb +233 -0
- data/lib/square_connect/models/card_brand.rb +147 -0
- data/lib/square_connect/models/charge_request.rb +257 -0
- data/lib/square_connect/models/charge_response.rb +171 -0
- data/lib/square_connect/models/country.rb +147 -0
- data/lib/square_connect/models/create_customer_card_request.rb +180 -0
- data/lib/square_connect/models/create_customer_card_response.rb +171 -0
- data/lib/square_connect/models/create_customer_request.rb +246 -0
- data/lib/square_connect/models/create_customer_response.rb +171 -0
- data/lib/square_connect/models/create_refund_request.rb +191 -0
- data/lib/square_connect/models/create_refund_response.rb +171 -0
- data/lib/square_connect/models/currency.rb +147 -0
- data/lib/square_connect/models/customer.rb +292 -0
- data/lib/square_connect/models/delete_customer_card_response.rb +160 -0
- data/lib/square_connect/models/delete_customer_response.rb +160 -0
- data/lib/square_connect/models/error.rb +209 -0
- data/lib/square_connect/models/error_category.rb +147 -0
- data/lib/square_connect/models/error_code.rb +147 -0
- data/lib/square_connect/models/list_customers_request.rb +158 -0
- data/lib/square_connect/models/list_customers_response.rb +184 -0
- data/lib/square_connect/models/list_locations_response.rb +173 -0
- data/lib/square_connect/models/list_refunds_request.rb +200 -0
- data/lib/square_connect/models/list_refunds_response.rb +184 -0
- data/lib/square_connect/models/list_transactions_request.rb +200 -0
- data/lib/square_connect/models/list_transactions_response.rb +184 -0
- data/lib/square_connect/models/location.rb +204 -0
- data/lib/square_connect/models/location_capability.rb +147 -0
- data/lib/square_connect/models/money.rb +178 -0
- data/lib/square_connect/models/refund.rb +255 -0
- data/lib/square_connect/models/refund_status.rb +147 -0
- data/lib/square_connect/models/retrieve_customer_response.rb +171 -0
- data/lib/square_connect/models/retrieve_transaction_response.rb +171 -0
- data/lib/square_connect/models/sort_order.rb +147 -0
- data/lib/square_connect/models/tender.rb +277 -0
- data/lib/square_connect/models/tender_card_details.rb +198 -0
- data/lib/square_connect/models/tender_card_details_entry_method.rb +147 -0
- data/lib/square_connect/models/tender_card_details_status.rb +147 -0
- data/lib/square_connect/models/tender_cash_details.rb +169 -0
- data/lib/square_connect/models/tender_type.rb +147 -0
- data/lib/square_connect/models/transaction.rb +237 -0
- data/lib/square_connect/models/transaction_product.rb +147 -0
- data/lib/square_connect/models/update_customer_request.rb +246 -0
- data/lib/square_connect/models/update_customer_response.rb +171 -0
- data/lib/square_connect/models/void_transaction_response.rb +160 -0
- data/lib/square_connect/version.rb +13 -0
- data/square_connect.gemspec +32 -0
- metadata +286 -0
@@ -0,0 +1,147 @@
|
|
1
|
+
=begin
|
2
|
+
Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
module SquareConnect
|
14
|
+
# The name of the product used to accept payment for this transaction
|
15
|
+
class TransactionProduct
|
16
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
17
|
+
def self.attribute_map
|
18
|
+
{
|
19
|
+
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# Attribute type mapping.
|
24
|
+
def self.swagger_types
|
25
|
+
{
|
26
|
+
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(attributes = {})
|
31
|
+
return unless attributes.is_a?(Hash)
|
32
|
+
|
33
|
+
# convert string to symbol for hash key
|
34
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
35
|
+
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
# Check equality by comparing each attribute.
|
40
|
+
def ==(o)
|
41
|
+
return true if self.equal?(o)
|
42
|
+
self.class == o.class
|
43
|
+
end
|
44
|
+
|
45
|
+
# @see the `==` method
|
46
|
+
def eql?(o)
|
47
|
+
self == o
|
48
|
+
end
|
49
|
+
|
50
|
+
# Calculate hash code according to all attributes.
|
51
|
+
def hash
|
52
|
+
[].hash
|
53
|
+
end
|
54
|
+
|
55
|
+
# build the object from hash
|
56
|
+
def build_from_hash(attributes)
|
57
|
+
return nil unless attributes.is_a?(Hash)
|
58
|
+
self.class.swagger_types.each_pair do |key, type|
|
59
|
+
if type =~ /^Array<(.*)>/i
|
60
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
61
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
62
|
+
else
|
63
|
+
#TODO show warning in debug mode
|
64
|
+
end
|
65
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
66
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
67
|
+
else
|
68
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
self
|
73
|
+
end
|
74
|
+
|
75
|
+
def _deserialize(type, value)
|
76
|
+
case type.to_sym
|
77
|
+
when :DateTime
|
78
|
+
DateTime.parse(value)
|
79
|
+
when :Date
|
80
|
+
Date.parse(value)
|
81
|
+
when :String
|
82
|
+
value.to_s
|
83
|
+
when :Integer
|
84
|
+
value.to_i
|
85
|
+
when :Float
|
86
|
+
value.to_f
|
87
|
+
when :BOOLEAN
|
88
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
89
|
+
true
|
90
|
+
else
|
91
|
+
false
|
92
|
+
end
|
93
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
94
|
+
inner_type = Regexp.last_match[:inner_type]
|
95
|
+
value.map { |v| _deserialize(inner_type, v) }
|
96
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
97
|
+
k_type = Regexp.last_match[:k_type]
|
98
|
+
v_type = Regexp.last_match[:v_type]
|
99
|
+
{}.tap do |hash|
|
100
|
+
value.each do |k, v|
|
101
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
else # model
|
105
|
+
_model = SquareConnect.const_get(type).new
|
106
|
+
_model.build_from_hash(value)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def to_s
|
111
|
+
to_hash.to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
# to_body is an alias to to_body (backward compatibility))
|
115
|
+
def to_body
|
116
|
+
to_hash
|
117
|
+
end
|
118
|
+
|
119
|
+
# return the object in the form of hash
|
120
|
+
def to_hash
|
121
|
+
hash = {}
|
122
|
+
self.class.attribute_map.each_pair do |attr, param|
|
123
|
+
value = self.send(attr)
|
124
|
+
next if value.nil?
|
125
|
+
hash[param] = _to_hash(value)
|
126
|
+
end
|
127
|
+
hash
|
128
|
+
end
|
129
|
+
|
130
|
+
# Method to output non-array value in the form of hash
|
131
|
+
# For object, use to_hash. Otherwise, just return the value
|
132
|
+
def _to_hash(value)
|
133
|
+
if value.is_a?(Array)
|
134
|
+
value.compact.map{ |v| _to_hash(v) }
|
135
|
+
elsif value.is_a?(Hash)
|
136
|
+
{}.tap do |hash|
|
137
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
138
|
+
end
|
139
|
+
elsif value.respond_to? :to_hash
|
140
|
+
value.to_hash
|
141
|
+
else
|
142
|
+
value
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
@@ -0,0 +1,246 @@
|
|
1
|
+
=begin
|
2
|
+
Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
module SquareConnect
|
14
|
+
#
|
15
|
+
class UpdateCustomerRequest
|
16
|
+
#
|
17
|
+
attr_accessor :given_name
|
18
|
+
|
19
|
+
#
|
20
|
+
attr_accessor :family_name
|
21
|
+
|
22
|
+
#
|
23
|
+
attr_accessor :company_name
|
24
|
+
|
25
|
+
#
|
26
|
+
attr_accessor :nickname
|
27
|
+
|
28
|
+
#
|
29
|
+
attr_accessor :email_address
|
30
|
+
|
31
|
+
#
|
32
|
+
attr_accessor :address
|
33
|
+
|
34
|
+
#
|
35
|
+
attr_accessor :phone_number
|
36
|
+
|
37
|
+
#
|
38
|
+
attr_accessor :reference_id
|
39
|
+
|
40
|
+
#
|
41
|
+
attr_accessor :note
|
42
|
+
|
43
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
44
|
+
def self.attribute_map
|
45
|
+
{
|
46
|
+
|
47
|
+
:'given_name' => :'given_name',
|
48
|
+
|
49
|
+
:'family_name' => :'family_name',
|
50
|
+
|
51
|
+
:'company_name' => :'company_name',
|
52
|
+
|
53
|
+
:'nickname' => :'nickname',
|
54
|
+
|
55
|
+
:'email_address' => :'email_address',
|
56
|
+
|
57
|
+
:'address' => :'address',
|
58
|
+
|
59
|
+
:'phone_number' => :'phone_number',
|
60
|
+
|
61
|
+
:'reference_id' => :'reference_id',
|
62
|
+
|
63
|
+
:'note' => :'note'
|
64
|
+
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
# Attribute type mapping.
|
69
|
+
def self.swagger_types
|
70
|
+
{
|
71
|
+
:'given_name' => :'String',
|
72
|
+
:'family_name' => :'String',
|
73
|
+
:'company_name' => :'String',
|
74
|
+
:'nickname' => :'String',
|
75
|
+
:'email_address' => :'String',
|
76
|
+
:'address' => :'Address',
|
77
|
+
:'phone_number' => :'String',
|
78
|
+
:'reference_id' => :'String',
|
79
|
+
:'note' => :'String'
|
80
|
+
|
81
|
+
}
|
82
|
+
end
|
83
|
+
|
84
|
+
def initialize(attributes = {})
|
85
|
+
return unless attributes.is_a?(Hash)
|
86
|
+
|
87
|
+
# convert string to symbol for hash key
|
88
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
89
|
+
|
90
|
+
|
91
|
+
if attributes[:'given_name']
|
92
|
+
self.given_name = attributes[:'given_name']
|
93
|
+
end
|
94
|
+
|
95
|
+
if attributes[:'family_name']
|
96
|
+
self.family_name = attributes[:'family_name']
|
97
|
+
end
|
98
|
+
|
99
|
+
if attributes[:'company_name']
|
100
|
+
self.company_name = attributes[:'company_name']
|
101
|
+
end
|
102
|
+
|
103
|
+
if attributes[:'nickname']
|
104
|
+
self.nickname = attributes[:'nickname']
|
105
|
+
end
|
106
|
+
|
107
|
+
if attributes[:'email_address']
|
108
|
+
self.email_address = attributes[:'email_address']
|
109
|
+
end
|
110
|
+
|
111
|
+
if attributes[:'address']
|
112
|
+
self.address = attributes[:'address']
|
113
|
+
end
|
114
|
+
|
115
|
+
if attributes[:'phone_number']
|
116
|
+
self.phone_number = attributes[:'phone_number']
|
117
|
+
end
|
118
|
+
|
119
|
+
if attributes[:'reference_id']
|
120
|
+
self.reference_id = attributes[:'reference_id']
|
121
|
+
end
|
122
|
+
|
123
|
+
if attributes[:'note']
|
124
|
+
self.note = attributes[:'note']
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
# Check equality by comparing each attribute.
|
130
|
+
def ==(o)
|
131
|
+
return true if self.equal?(o)
|
132
|
+
self.class == o.class &&
|
133
|
+
given_name == o.given_name &&
|
134
|
+
family_name == o.family_name &&
|
135
|
+
company_name == o.company_name &&
|
136
|
+
nickname == o.nickname &&
|
137
|
+
email_address == o.email_address &&
|
138
|
+
address == o.address &&
|
139
|
+
phone_number == o.phone_number &&
|
140
|
+
reference_id == o.reference_id &&
|
141
|
+
note == o.note
|
142
|
+
end
|
143
|
+
|
144
|
+
# @see the `==` method
|
145
|
+
def eql?(o)
|
146
|
+
self == o
|
147
|
+
end
|
148
|
+
|
149
|
+
# Calculate hash code according to all attributes.
|
150
|
+
def hash
|
151
|
+
[given_name, family_name, company_name, nickname, email_address, address, phone_number, reference_id, note].hash
|
152
|
+
end
|
153
|
+
|
154
|
+
# build the object from hash
|
155
|
+
def build_from_hash(attributes)
|
156
|
+
return nil unless attributes.is_a?(Hash)
|
157
|
+
self.class.swagger_types.each_pair do |key, type|
|
158
|
+
if type =~ /^Array<(.*)>/i
|
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
|
+
else
|
162
|
+
#TODO show warning in debug mode
|
163
|
+
end
|
164
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
165
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
166
|
+
else
|
167
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
self
|
172
|
+
end
|
173
|
+
|
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 =~ /^(true|t|yes|y|1)$/i
|
188
|
+
true
|
189
|
+
else
|
190
|
+
false
|
191
|
+
end
|
192
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
193
|
+
inner_type = Regexp.last_match[:inner_type]
|
194
|
+
value.map { |v| _deserialize(inner_type, v) }
|
195
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
196
|
+
k_type = Regexp.last_match[:k_type]
|
197
|
+
v_type = Regexp.last_match[:v_type]
|
198
|
+
{}.tap do |hash|
|
199
|
+
value.each do |k, v|
|
200
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
201
|
+
end
|
202
|
+
end
|
203
|
+
else # model
|
204
|
+
_model = SquareConnect.const_get(type).new
|
205
|
+
_model.build_from_hash(value)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
def to_s
|
210
|
+
to_hash.to_s
|
211
|
+
end
|
212
|
+
|
213
|
+
# to_body is an alias to to_body (backward compatibility))
|
214
|
+
def to_body
|
215
|
+
to_hash
|
216
|
+
end
|
217
|
+
|
218
|
+
# return the object in the form of hash
|
219
|
+
def to_hash
|
220
|
+
hash = {}
|
221
|
+
self.class.attribute_map.each_pair do |attr, param|
|
222
|
+
value = self.send(attr)
|
223
|
+
next if value.nil?
|
224
|
+
hash[param] = _to_hash(value)
|
225
|
+
end
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Method to output non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
def _to_hash(value)
|
232
|
+
if value.is_a?(Array)
|
233
|
+
value.compact.map{ |v| _to_hash(v) }
|
234
|
+
elsif value.is_a?(Hash)
|
235
|
+
{}.tap do |hash|
|
236
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
237
|
+
end
|
238
|
+
elsif value.respond_to? :to_hash
|
239
|
+
value.to_hash
|
240
|
+
else
|
241
|
+
value
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
=begin
|
2
|
+
Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
|
9
|
+
=end
|
10
|
+
|
11
|
+
require 'date'
|
12
|
+
|
13
|
+
module SquareConnect
|
14
|
+
# Defines the fields that are included in the response body of\na request to the **UpdateCustomer** endpoint.\n\nOne of `errors` or `customer` is present in a given response (never both).
|
15
|
+
class UpdateCustomerResponse
|
16
|
+
#
|
17
|
+
attr_accessor :errors
|
18
|
+
|
19
|
+
#
|
20
|
+
attr_accessor :customer
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
|
26
|
+
:'errors' => :'errors',
|
27
|
+
|
28
|
+
:'customer' => :'customer'
|
29
|
+
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.swagger_types
|
35
|
+
{
|
36
|
+
:'errors' => :'Array<Error>',
|
37
|
+
:'customer' => :'Customer'
|
38
|
+
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def initialize(attributes = {})
|
43
|
+
return unless attributes.is_a?(Hash)
|
44
|
+
|
45
|
+
# convert string to symbol for hash key
|
46
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
47
|
+
|
48
|
+
|
49
|
+
if attributes[:'errors']
|
50
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
51
|
+
self.errors = value
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if attributes[:'customer']
|
56
|
+
self.customer = attributes[:'customer']
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
# Check equality by comparing each attribute.
|
62
|
+
def ==(o)
|
63
|
+
return true if self.equal?(o)
|
64
|
+
self.class == o.class &&
|
65
|
+
errors == o.errors &&
|
66
|
+
customer == o.customer
|
67
|
+
end
|
68
|
+
|
69
|
+
# @see the `==` method
|
70
|
+
def eql?(o)
|
71
|
+
self == o
|
72
|
+
end
|
73
|
+
|
74
|
+
# Calculate hash code according to all attributes.
|
75
|
+
def hash
|
76
|
+
[errors, customer].hash
|
77
|
+
end
|
78
|
+
|
79
|
+
# build the object from hash
|
80
|
+
def build_from_hash(attributes)
|
81
|
+
return nil unless attributes.is_a?(Hash)
|
82
|
+
self.class.swagger_types.each_pair do |key, type|
|
83
|
+
if type =~ /^Array<(.*)>/i
|
84
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
85
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
86
|
+
else
|
87
|
+
#TODO show warning in debug mode
|
88
|
+
end
|
89
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
90
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
91
|
+
else
|
92
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
self
|
97
|
+
end
|
98
|
+
|
99
|
+
def _deserialize(type, value)
|
100
|
+
case type.to_sym
|
101
|
+
when :DateTime
|
102
|
+
DateTime.parse(value)
|
103
|
+
when :Date
|
104
|
+
Date.parse(value)
|
105
|
+
when :String
|
106
|
+
value.to_s
|
107
|
+
when :Integer
|
108
|
+
value.to_i
|
109
|
+
when :Float
|
110
|
+
value.to_f
|
111
|
+
when :BOOLEAN
|
112
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
113
|
+
true
|
114
|
+
else
|
115
|
+
false
|
116
|
+
end
|
117
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
118
|
+
inner_type = Regexp.last_match[:inner_type]
|
119
|
+
value.map { |v| _deserialize(inner_type, v) }
|
120
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
121
|
+
k_type = Regexp.last_match[:k_type]
|
122
|
+
v_type = Regexp.last_match[:v_type]
|
123
|
+
{}.tap do |hash|
|
124
|
+
value.each do |k, v|
|
125
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
else # model
|
129
|
+
_model = SquareConnect.const_get(type).new
|
130
|
+
_model.build_from_hash(value)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def to_s
|
135
|
+
to_hash.to_s
|
136
|
+
end
|
137
|
+
|
138
|
+
# to_body is an alias to to_body (backward compatibility))
|
139
|
+
def to_body
|
140
|
+
to_hash
|
141
|
+
end
|
142
|
+
|
143
|
+
# return the object in the form of hash
|
144
|
+
def to_hash
|
145
|
+
hash = {}
|
146
|
+
self.class.attribute_map.each_pair do |attr, param|
|
147
|
+
value = self.send(attr)
|
148
|
+
next if value.nil?
|
149
|
+
hash[param] = _to_hash(value)
|
150
|
+
end
|
151
|
+
hash
|
152
|
+
end
|
153
|
+
|
154
|
+
# Method to output non-array value in the form of hash
|
155
|
+
# For object, use to_hash. Otherwise, just return the value
|
156
|
+
def _to_hash(value)
|
157
|
+
if value.is_a?(Array)
|
158
|
+
value.compact.map{ |v| _to_hash(v) }
|
159
|
+
elsif value.is_a?(Hash)
|
160
|
+
{}.tap do |hash|
|
161
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
162
|
+
end
|
163
|
+
elsif value.respond_to? :to_hash
|
164
|
+
value.to_hash
|
165
|
+
else
|
166
|
+
value
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
end
|
171
|
+
end
|