square_connect 2.7.0.202 → 2.8.0.208
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.
- checksums.yaml +4 -4
- data/CHANGES.md +38 -0
- data/README.md +3 -1
- data/docs/CreateCheckoutRequest.md +1 -0
- data/docs/CreateOrderRequestLineItem.md +1 -1
- data/docs/CreateOrderRequestModifier.md +1 -1
- data/docs/CustomerSortField.md +13 -0
- data/docs/CustomersApi.md +5 -1
- data/docs/ListCustomersRequest.md +2 -0
- data/docs/OrderLineItemModifier.md +1 -1
- data/docs/V1Item.md +2 -0
- data/docs/V1Page.md +1 -1
- data/docs/V1Payment.md +2 -0
- data/docs/V1PaymentSurcharge.md +17 -0
- data/lib/square_connect.rb +2 -0
- data/lib/square_connect/api/customers_api.rb +12 -0
- data/lib/square_connect/api_client.rb +1 -1
- data/lib/square_connect/models/create_checkout_request.rb +30 -4
- data/lib/square_connect/models/create_order_request_line_item.rb +6 -6
- data/lib/square_connect/models/create_order_request_modifier.rb +1 -1
- data/lib/square_connect/models/customer_sort_field.rb +19 -0
- data/lib/square_connect/models/list_customers_request.rb +69 -4
- data/lib/square_connect/models/order_line_item.rb +5 -5
- data/lib/square_connect/models/order_line_item_modifier.rb +1 -1
- data/lib/square_connect/models/v1_item.rb +24 -4
- data/lib/square_connect/models/v1_page.rb +26 -1
- data/lib/square_connect/models/v1_payment.rb +26 -4
- data/lib/square_connect/models/v1_payment_surcharge.rb +290 -0
- data/lib/square_connect/version.rb +1 -1
- data/spec/models/customer_sort_field_spec.rb +33 -0
- data/spec/models/v1_payment_surcharge_spec.rb +85 -0
- metadata +12 -4
@@ -178,8 +178,8 @@ module SquareConnect
|
|
178
178
|
invalid_properties.push("invalid value for 'quantity', the character length must be great than or equal to 1.")
|
179
179
|
end
|
180
180
|
|
181
|
-
if !@note.nil? && @note.to_s.length >
|
182
|
-
invalid_properties.push("invalid value for 'note', the character length must be smaller than or equal to
|
181
|
+
if !@note.nil? && @note.to_s.length > 500
|
182
|
+
invalid_properties.push("invalid value for 'note', the character length must be smaller than or equal to 500.")
|
183
183
|
end
|
184
184
|
|
185
185
|
if !@catalog_object_id.nil? && @catalog_object_id.to_s.length > 192
|
@@ -200,7 +200,7 @@ module SquareConnect
|
|
200
200
|
return false if @quantity.nil?
|
201
201
|
return false if @quantity.to_s.length > 5
|
202
202
|
return false if @quantity.to_s.length < 1
|
203
|
-
return false if !@note.nil? && @note.to_s.length >
|
203
|
+
return false if !@note.nil? && @note.to_s.length > 500
|
204
204
|
return false if !@catalog_object_id.nil? && @catalog_object_id.to_s.length > 192
|
205
205
|
return false if !@variation_name.nil? && @variation_name.to_s.length > 255
|
206
206
|
return true
|
@@ -239,8 +239,8 @@ module SquareConnect
|
|
239
239
|
# @param [Object] note Value to be assigned
|
240
240
|
def note=(note)
|
241
241
|
|
242
|
-
if !note.nil? && note.to_s.length >
|
243
|
-
fail ArgumentError, "invalid value for 'note', the character length must be smaller than or equal to
|
242
|
+
if !note.nil? && note.to_s.length > 500
|
243
|
+
fail ArgumentError, "invalid value for 'note', the character length must be smaller than or equal to 500."
|
244
244
|
end
|
245
245
|
|
246
246
|
@note = note
|
@@ -18,7 +18,7 @@ module SquareConnect
|
|
18
18
|
# The name of the item modifier.
|
19
19
|
attr_accessor :name
|
20
20
|
|
21
|
-
# The base price
|
21
|
+
# The base price for the modifier. `base_price_money` is required for ad hoc modifiers. If both `catalog_object_id` and `base_price_money` are set, `base_price_money` will override the predefined [CatalogModifier](#type-catalogmodifier) price.
|
22
22
|
attr_accessor :base_price_money
|
23
23
|
|
24
24
|
# The total price of the item modifier for its line item. This is the modifier's base_price_money multiplied by the line item's quantity.
|
@@ -54,6 +54,12 @@ module SquareConnect
|
|
54
54
|
# Deprecated. This field is not used.
|
55
55
|
attr_accessor :taxable
|
56
56
|
|
57
|
+
# The ID of the item's category, if any.
|
58
|
+
attr_accessor :category_id
|
59
|
+
|
60
|
+
# If true, the item can be added to pickup orders from the merchant's online store. Default value: false
|
61
|
+
attr_accessor :available_for_pickup
|
62
|
+
|
57
63
|
class EnumAttributeValidator
|
58
64
|
attr_reader :datatype
|
59
65
|
attr_reader :allowable_values
|
@@ -92,7 +98,9 @@ module SquareConnect
|
|
92
98
|
:'variations' => :'variations',
|
93
99
|
:'modifier_lists' => :'modifier_lists',
|
94
100
|
:'fees' => :'fees',
|
95
|
-
:'taxable' => :'taxable'
|
101
|
+
:'taxable' => :'taxable',
|
102
|
+
:'category_id' => :'category_id',
|
103
|
+
:'available_for_pickup' => :'available_for_pickup'
|
96
104
|
}
|
97
105
|
end
|
98
106
|
|
@@ -112,7 +120,9 @@ module SquareConnect
|
|
112
120
|
:'variations' => :'Array<V1Variation>',
|
113
121
|
:'modifier_lists' => :'Array<V1Variation>',
|
114
122
|
:'fees' => :'Array<V1Fee>',
|
115
|
-
:'taxable' => :'BOOLEAN'
|
123
|
+
:'taxable' => :'BOOLEAN',
|
124
|
+
:'category_id' => :'String',
|
125
|
+
:'available_for_pickup' => :'BOOLEAN'
|
116
126
|
}
|
117
127
|
end
|
118
128
|
|
@@ -186,6 +196,14 @@ module SquareConnect
|
|
186
196
|
self.taxable = attributes[:'taxable']
|
187
197
|
end
|
188
198
|
|
199
|
+
if attributes.has_key?(:'category_id')
|
200
|
+
self.category_id = attributes[:'category_id']
|
201
|
+
end
|
202
|
+
|
203
|
+
if attributes.has_key?(:'available_for_pickup')
|
204
|
+
self.available_for_pickup = attributes[:'available_for_pickup']
|
205
|
+
end
|
206
|
+
|
189
207
|
end
|
190
208
|
|
191
209
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -255,7 +273,9 @@ module SquareConnect
|
|
255
273
|
variations == o.variations &&
|
256
274
|
modifier_lists == o.modifier_lists &&
|
257
275
|
fees == o.fees &&
|
258
|
-
taxable == o.taxable
|
276
|
+
taxable == o.taxable &&
|
277
|
+
category_id == o.category_id &&
|
278
|
+
available_for_pickup == o.available_for_pickup
|
259
279
|
end
|
260
280
|
|
261
281
|
# @see the `==` method
|
@@ -267,7 +287,7 @@ module SquareConnect
|
|
267
287
|
# Calculates hash code according to all attributes.
|
268
288
|
# @return [Fixnum] Hash code
|
269
289
|
def hash
|
270
|
-
[id, name, description, type, color, abbreviation, visibility, available_online, master_image, category, variations, modifier_lists, fees, taxable].hash
|
290
|
+
[id, name, description, type, color, abbreviation, visibility, available_online, master_image, category, variations, modifier_lists, fees, taxable, category_id, available_for_pickup].hash
|
271
291
|
end
|
272
292
|
|
273
293
|
# Builds the object from hash
|
@@ -18,7 +18,7 @@ module SquareConnect
|
|
18
18
|
# The page's name, if any.
|
19
19
|
attr_accessor :name
|
20
20
|
|
21
|
-
# The page's position in the merchant's list of pages. Always an integer between 0 and
|
21
|
+
# The page's position in the merchant's list of pages. Always an integer between 0 and 6, inclusive.
|
22
22
|
attr_accessor :page_index
|
23
23
|
|
24
24
|
# The cells included on the page.
|
@@ -77,15 +77,40 @@ module SquareConnect
|
|
77
77
|
# @return Array for valid properies with the reasons
|
78
78
|
def list_invalid_properties
|
79
79
|
invalid_properties = Array.new
|
80
|
+
if !@page_index.nil? && @page_index > 6
|
81
|
+
invalid_properties.push("invalid value for 'page_index', must be smaller than or equal to 6.")
|
82
|
+
end
|
83
|
+
|
84
|
+
if !@page_index.nil? && @page_index < 0
|
85
|
+
invalid_properties.push("invalid value for 'page_index', must be greater than or equal to 0.")
|
86
|
+
end
|
87
|
+
|
80
88
|
return invalid_properties
|
81
89
|
end
|
82
90
|
|
83
91
|
# Check to see if the all the properties in the model are valid
|
84
92
|
# @return true if the model is valid
|
85
93
|
def valid?
|
94
|
+
return false if !@page_index.nil? && @page_index > 6
|
95
|
+
return false if !@page_index.nil? && @page_index < 0
|
86
96
|
return true
|
87
97
|
end
|
88
98
|
|
99
|
+
# Custom attribute writer method with validation
|
100
|
+
# @param [Object] page_index Value to be assigned
|
101
|
+
def page_index=(page_index)
|
102
|
+
|
103
|
+
if !page_index.nil? && page_index > 6
|
104
|
+
fail ArgumentError, "invalid value for 'page_index', must be smaller than or equal to 6."
|
105
|
+
end
|
106
|
+
|
107
|
+
if !page_index.nil? && page_index < 0
|
108
|
+
fail ArgumentError, "invalid value for 'page_index', must be greater than or equal to 0."
|
109
|
+
end
|
110
|
+
|
111
|
+
@page_index = page_index
|
112
|
+
end
|
113
|
+
|
89
114
|
# Checks equality by comparing each attribute.
|
90
115
|
# @param [Object] Object to be compared
|
91
116
|
def ==(o)
|
@@ -84,6 +84,12 @@ module SquareConnect
|
|
84
84
|
# The items purchased in the payment.
|
85
85
|
attr_accessor :itemizations
|
86
86
|
|
87
|
+
# The total of all surcharges applied to the payment.
|
88
|
+
attr_accessor :surcharge_money
|
89
|
+
|
90
|
+
# A list of all surcharges associated with the payment.
|
91
|
+
attr_accessor :surcharges
|
92
|
+
|
87
93
|
|
88
94
|
# Attribute mapping from ruby-style variable name to JSON key.
|
89
95
|
def self.attribute_map
|
@@ -111,7 +117,9 @@ module SquareConnect
|
|
111
117
|
:'additive_tax' => :'additive_tax',
|
112
118
|
:'tender' => :'tender',
|
113
119
|
:'refunds' => :'refunds',
|
114
|
-
:'itemizations' => :'itemizations'
|
120
|
+
:'itemizations' => :'itemizations',
|
121
|
+
:'surcharge_money' => :'surcharge_money',
|
122
|
+
:'surcharges' => :'surcharges'
|
115
123
|
}
|
116
124
|
end
|
117
125
|
|
@@ -141,7 +149,9 @@ module SquareConnect
|
|
141
149
|
:'additive_tax' => :'Array<V1PaymentTax>',
|
142
150
|
:'tender' => :'Array<V1Tender>',
|
143
151
|
:'refunds' => :'Array<V1Refund>',
|
144
|
-
:'itemizations' => :'Array<V1PaymentItemization>'
|
152
|
+
:'itemizations' => :'Array<V1PaymentItemization>',
|
153
|
+
:'surcharge_money' => :'V1Money',
|
154
|
+
:'surcharges' => :'Array<V1PaymentSurcharge>'
|
145
155
|
}
|
146
156
|
end
|
147
157
|
|
@@ -259,6 +269,16 @@ module SquareConnect
|
|
259
269
|
end
|
260
270
|
end
|
261
271
|
|
272
|
+
if attributes.has_key?(:'surcharge_money')
|
273
|
+
self.surcharge_money = attributes[:'surcharge_money']
|
274
|
+
end
|
275
|
+
|
276
|
+
if attributes.has_key?(:'surcharges')
|
277
|
+
if (value = attributes[:'surcharges']).is_a?(Array)
|
278
|
+
self.surcharges = value
|
279
|
+
end
|
280
|
+
end
|
281
|
+
|
262
282
|
end
|
263
283
|
|
264
284
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -302,7 +322,9 @@ module SquareConnect
|
|
302
322
|
additive_tax == o.additive_tax &&
|
303
323
|
tender == o.tender &&
|
304
324
|
refunds == o.refunds &&
|
305
|
-
itemizations == o.itemizations
|
325
|
+
itemizations == o.itemizations &&
|
326
|
+
surcharge_money == o.surcharge_money &&
|
327
|
+
surcharges == o.surcharges
|
306
328
|
end
|
307
329
|
|
308
330
|
# @see the `==` method
|
@@ -314,7 +336,7 @@ module SquareConnect
|
|
314
336
|
# Calculates hash code according to all attributes.
|
315
337
|
# @return [Fixnum] Hash code
|
316
338
|
def hash
|
317
|
-
[id, merchant_id, created_at, creator_id, device, payment_url, receipt_url, inclusive_tax_money, additive_tax_money, tax_money, tip_money, discount_money, total_collected_money, processing_fee_money, net_total_money, refunded_money, swedish_rounding_money, gross_sales_money, net_sales_money, inclusive_tax, additive_tax, tender, refunds, itemizations].hash
|
339
|
+
[id, merchant_id, created_at, creator_id, device, payment_url, receipt_url, inclusive_tax_money, additive_tax_money, tax_money, tip_money, discount_money, total_collected_money, processing_fee_money, net_total_money, refunded_money, swedish_rounding_money, gross_sales_money, net_sales_money, inclusive_tax, additive_tax, tender, refunds, itemizations, surcharge_money, surcharges].hash
|
318
340
|
end
|
319
341
|
|
320
342
|
# Builds the object from hash
|
@@ -0,0 +1,290 @@
|
|
1
|
+
=begin
|
2
|
+
#Square Connect API
|
3
|
+
|
4
|
+
OpenAPI spec version: 2.0
|
5
|
+
Contact: developers@squareup.com
|
6
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
|
+
|
8
|
+
=end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
|
12
|
+
module SquareConnect
|
13
|
+
|
14
|
+
class V1PaymentSurcharge
|
15
|
+
# The name of the surcharge.
|
16
|
+
attr_accessor :name
|
17
|
+
|
18
|
+
# The amount of money applied to the order as a result of the surcharge.
|
19
|
+
attr_accessor :applied_money
|
20
|
+
|
21
|
+
# The amount of the surcharge as a percentage. The percentage is provided as a string representing the decimal equivalent of the percentage. For example, \"0.7\" corresponds to a 7% surcharge. Exactly one of rate or amount_money should be set.
|
22
|
+
attr_accessor :rate
|
23
|
+
|
24
|
+
# The amount of the surcharge as a Money object. Exactly one of rate or amount_money should be set.
|
25
|
+
attr_accessor :amount_money
|
26
|
+
|
27
|
+
# Indicates the source of the surcharge. For example, if it was applied as an automatic gratuity for a large group.
|
28
|
+
attr_accessor :type
|
29
|
+
|
30
|
+
# Indicates whether the surcharge is taxable.
|
31
|
+
attr_accessor :taxable
|
32
|
+
|
33
|
+
# The list of taxes that should be applied to the surcharge.
|
34
|
+
attr_accessor :taxes
|
35
|
+
|
36
|
+
attr_accessor :surcharge_id
|
37
|
+
|
38
|
+
class EnumAttributeValidator
|
39
|
+
attr_reader :datatype
|
40
|
+
attr_reader :allowable_values
|
41
|
+
|
42
|
+
def initialize(datatype, allowable_values)
|
43
|
+
@allowable_values = allowable_values.map do |value|
|
44
|
+
case datatype.to_s
|
45
|
+
when /Integer/i
|
46
|
+
value.to_i
|
47
|
+
when /Float/i
|
48
|
+
value.to_f
|
49
|
+
else
|
50
|
+
value
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def valid?(value)
|
56
|
+
!value || allowable_values.include?(value)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
61
|
+
def self.attribute_map
|
62
|
+
{
|
63
|
+
:'name' => :'name',
|
64
|
+
:'applied_money' => :'applied_money',
|
65
|
+
:'rate' => :'rate',
|
66
|
+
:'amount_money' => :'amount_money',
|
67
|
+
:'type' => :'type',
|
68
|
+
:'taxable' => :'taxable',
|
69
|
+
:'taxes' => :'taxes',
|
70
|
+
:'surcharge_id' => :'surcharge_id'
|
71
|
+
}
|
72
|
+
end
|
73
|
+
|
74
|
+
# Attribute type mapping.
|
75
|
+
def self.swagger_types
|
76
|
+
{
|
77
|
+
:'name' => :'String',
|
78
|
+
:'applied_money' => :'V1Money',
|
79
|
+
:'rate' => :'String',
|
80
|
+
:'amount_money' => :'V1Money',
|
81
|
+
:'type' => :'String',
|
82
|
+
:'taxable' => :'BOOLEAN',
|
83
|
+
:'taxes' => :'Array<V1PaymentTax>',
|
84
|
+
:'surcharge_id' => :'String'
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
# Initializes the object
|
89
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
90
|
+
def initialize(attributes = {})
|
91
|
+
return unless attributes.is_a?(Hash)
|
92
|
+
|
93
|
+
# convert string to symbol for hash key
|
94
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
95
|
+
|
96
|
+
if attributes.has_key?(:'name')
|
97
|
+
self.name = attributes[:'name']
|
98
|
+
end
|
99
|
+
|
100
|
+
if attributes.has_key?(:'applied_money')
|
101
|
+
self.applied_money = attributes[:'applied_money']
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.has_key?(:'rate')
|
105
|
+
self.rate = attributes[:'rate']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.has_key?(:'amount_money')
|
109
|
+
self.amount_money = attributes[:'amount_money']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.has_key?(:'type')
|
113
|
+
self.type = attributes[:'type']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.has_key?(:'taxable')
|
117
|
+
self.taxable = attributes[:'taxable']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.has_key?(:'taxes')
|
121
|
+
if (value = attributes[:'taxes']).is_a?(Array)
|
122
|
+
self.taxes = value
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.has_key?(:'surcharge_id')
|
127
|
+
self.surcharge_id = attributes[:'surcharge_id']
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
132
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
133
|
+
# @return Array for valid properies with the reasons
|
134
|
+
def list_invalid_properties
|
135
|
+
invalid_properties = Array.new
|
136
|
+
return invalid_properties
|
137
|
+
end
|
138
|
+
|
139
|
+
# Check to see if the all the properties in the model are valid
|
140
|
+
# @return true if the model is valid
|
141
|
+
def valid?
|
142
|
+
type_validator = EnumAttributeValidator.new('String', ["UNKNOWN", "AUTO_GRATUITY", "CUSTOM"])
|
143
|
+
return false unless type_validator.valid?(@type)
|
144
|
+
return true
|
145
|
+
end
|
146
|
+
|
147
|
+
# Custom attribute writer method checking allowed values (enum).
|
148
|
+
# @param [Object] type Object to be assigned
|
149
|
+
def type=(type)
|
150
|
+
validator = EnumAttributeValidator.new('String', ["UNKNOWN", "AUTO_GRATUITY", "CUSTOM"])
|
151
|
+
unless validator.valid?(type)
|
152
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
153
|
+
end
|
154
|
+
@type = type
|
155
|
+
end
|
156
|
+
|
157
|
+
# Checks equality by comparing each attribute.
|
158
|
+
# @param [Object] Object to be compared
|
159
|
+
def ==(o)
|
160
|
+
return true if self.equal?(o)
|
161
|
+
self.class == o.class &&
|
162
|
+
name == o.name &&
|
163
|
+
applied_money == o.applied_money &&
|
164
|
+
rate == o.rate &&
|
165
|
+
amount_money == o.amount_money &&
|
166
|
+
type == o.type &&
|
167
|
+
taxable == o.taxable &&
|
168
|
+
taxes == o.taxes &&
|
169
|
+
surcharge_id == o.surcharge_id
|
170
|
+
end
|
171
|
+
|
172
|
+
# @see the `==` method
|
173
|
+
# @param [Object] Object to be compared
|
174
|
+
def eql?(o)
|
175
|
+
self == o
|
176
|
+
end
|
177
|
+
|
178
|
+
# Calculates hash code according to all attributes.
|
179
|
+
# @return [Fixnum] Hash code
|
180
|
+
def hash
|
181
|
+
[name, applied_money, rate, amount_money, type, taxable, taxes, surcharge_id].hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Builds the object from hash
|
185
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
186
|
+
# @return [Object] Returns the model itself
|
187
|
+
def build_from_hash(attributes)
|
188
|
+
return nil unless attributes.is_a?(Hash)
|
189
|
+
self.class.swagger_types.each_pair do |key, type|
|
190
|
+
if type =~ /\AArray<(.*)>/i
|
191
|
+
# check to ensure the input is an array given that the the attribute
|
192
|
+
# is documented as an array but the input is not
|
193
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
194
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
195
|
+
end
|
196
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
197
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
198
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
199
|
+
end
|
200
|
+
|
201
|
+
self
|
202
|
+
end
|
203
|
+
|
204
|
+
# Deserializes the data based on type
|
205
|
+
# @param string type Data type
|
206
|
+
# @param string value Value to be deserialized
|
207
|
+
# @return [Object] Deserialized data
|
208
|
+
def _deserialize(type, value)
|
209
|
+
case type.to_sym
|
210
|
+
when :DateTime
|
211
|
+
DateTime.parse(value)
|
212
|
+
when :Date
|
213
|
+
Date.parse(value)
|
214
|
+
when :String
|
215
|
+
value.to_s
|
216
|
+
when :Integer
|
217
|
+
value.to_i
|
218
|
+
when :Float
|
219
|
+
value.to_f
|
220
|
+
when :BOOLEAN
|
221
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
222
|
+
true
|
223
|
+
else
|
224
|
+
false
|
225
|
+
end
|
226
|
+
when :Object
|
227
|
+
# generic object (usually a Hash), return directly
|
228
|
+
value
|
229
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
230
|
+
inner_type = Regexp.last_match[:inner_type]
|
231
|
+
value.map { |v| _deserialize(inner_type, v) }
|
232
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
233
|
+
k_type = Regexp.last_match[:k_type]
|
234
|
+
v_type = Regexp.last_match[:v_type]
|
235
|
+
{}.tap do |hash|
|
236
|
+
value.each do |k, v|
|
237
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
238
|
+
end
|
239
|
+
end
|
240
|
+
else # model
|
241
|
+
temp_model = SquareConnect.const_get(type).new
|
242
|
+
temp_model.build_from_hash(value)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
# Returns the string representation of the object
|
247
|
+
# @return [String] String presentation of the object
|
248
|
+
def to_s
|
249
|
+
to_hash.to_s
|
250
|
+
end
|
251
|
+
|
252
|
+
# to_body is an alias to to_hash (backward compatibility)
|
253
|
+
# @return [Hash] Returns the object in the form of hash
|
254
|
+
def to_body
|
255
|
+
to_hash
|
256
|
+
end
|
257
|
+
|
258
|
+
# Returns the object in the form of hash
|
259
|
+
# @return [Hash] Returns the object in the form of hash
|
260
|
+
def to_hash
|
261
|
+
hash = {}
|
262
|
+
self.class.attribute_map.each_pair do |attr, param|
|
263
|
+
value = self.send(attr)
|
264
|
+
next if value.nil?
|
265
|
+
hash[param] = _to_hash(value)
|
266
|
+
end
|
267
|
+
hash
|
268
|
+
end
|
269
|
+
|
270
|
+
# Outputs non-array value in the form of hash
|
271
|
+
# For object, use to_hash. Otherwise, just return the value
|
272
|
+
# @param [Object] value Any valid value
|
273
|
+
# @return [Hash] Returns the value in the form of hash
|
274
|
+
def _to_hash(value)
|
275
|
+
if value.is_a?(Array)
|
276
|
+
value.compact.map{ |v| _to_hash(v) }
|
277
|
+
elsif value.is_a?(Hash)
|
278
|
+
{}.tap do |hash|
|
279
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
280
|
+
end
|
281
|
+
elsif value.respond_to? :to_hash
|
282
|
+
value.to_hash
|
283
|
+
else
|
284
|
+
value
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|