square_connect 2.8.0.215 → 2.9.0.220
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +20 -0
- data/README.md +11 -1
- data/docs/Customer.md +1 -0
- data/docs/CustomerCreationSource.md +30 -0
- data/docs/CustomerCreationSourceFilter.md +13 -0
- data/docs/CustomerFilter.md +14 -0
- data/docs/CustomerInclusionExclusion.md +13 -0
- data/docs/CustomerQuery.md +13 -0
- data/docs/CustomerSort.md +13 -0
- data/docs/CustomersApi.md +57 -4
- data/docs/ErrorCode.md +2 -0
- data/docs/ListCustomersRequest.md +2 -2
- data/docs/OrderLineItem.md +1 -1
- data/docs/OrderLineItemDiscountScope.md +1 -1
- data/docs/SearchCustomersRequest.md +14 -0
- data/docs/SearchCustomersResponse.md +14 -0
- data/docs/TimeRange.md +13 -0
- data/docs/V1AdjustInventoryRequest.md +1 -1
- data/docs/V1Payment.md +1 -1
- data/docs/VoidTransactionResponse.md +1 -1
- data/lib/square_connect.rb +9 -0
- data/lib/square_connect/api/customers_api.rb +57 -4
- data/lib/square_connect/api_client.rb +1 -1
- data/lib/square_connect/models/customer.rb +47 -4
- data/lib/square_connect/models/customer_creation_source.rb +36 -0
- data/lib/square_connect/models/customer_creation_source_filter.rb +231 -0
- data/lib/square_connect/models/customer_filter.rb +206 -0
- data/lib/square_connect/models/customer_inclusion_exclusion.rb +19 -0
- data/lib/square_connect/models/customer_query.rb +196 -0
- data/lib/square_connect/models/customer_sort.rb +241 -0
- data/lib/square_connect/models/error.rb +2 -2
- data/lib/square_connect/models/error_code.rb +2 -0
- data/lib/square_connect/models/list_customers_request.rb +2 -2
- data/lib/square_connect/models/order_line_item.rb +1 -1
- data/lib/square_connect/models/search_customers_request.rb +206 -0
- data/lib/square_connect/models/search_customers_response.rb +210 -0
- data/lib/square_connect/models/time_range.rb +196 -0
- data/lib/square_connect/models/v1_adjust_inventory_request.rb +34 -1
- data/lib/square_connect/models/void_transaction_response.rb +1 -1
- data/lib/square_connect/version.rb +1 -1
- data/spec/models/customer_creation_source_filter_spec.rb +53 -0
- data/spec/models/customer_creation_source_spec.rb +33 -0
- data/spec/models/customer_filter_spec.rb +51 -0
- data/spec/models/customer_inclusion_exclusion_spec.rb +33 -0
- data/spec/models/customer_query_spec.rb +45 -0
- data/spec/models/customer_sort_spec.rb +53 -0
- data/spec/models/search_customers_request_spec.rb +51 -0
- data/spec/models/search_customers_response_spec.rb +51 -0
- data/spec/models/time_range_spec.rb +45 -0
- metadata +39 -3
@@ -241,8 +241,8 @@ module SquareConnect
|
|
241
241
|
# Lists a business's customers.
|
242
242
|
# @param [Hash] opts the optional parameters
|
243
243
|
# @option opts [String] :cursor A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Paginating results](#paginatingresults) for more information.
|
244
|
-
# @option opts [String] :sort_field Indicates how Customers should be sorted. Default: `DEFAULT`.
|
245
|
-
# @option opts [String] :sort_order Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`.
|
244
|
+
# @option opts [String] :sort_field Indicates how Customers should be sorted. Default: `DEFAULT`. See [CustomerSortField](#type-customersortfield) for possible values.
|
245
|
+
# @option opts [String] :sort_order Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`. See [SortOrder](#type-sortorder) for possible values.
|
246
246
|
# @return [ListCustomersResponse]
|
247
247
|
def list_customers(opts = {})
|
248
248
|
data, _status_code, _headers = list_customers_with_http_info(opts)
|
@@ -253,8 +253,8 @@ module SquareConnect
|
|
253
253
|
# Lists a business's customers.
|
254
254
|
# @param [Hash] opts the optional parameters
|
255
255
|
# @option opts [String] :cursor A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Paginating results](#paginatingresults) for more information.
|
256
|
-
# @option opts [String] :sort_field Indicates how Customers should be sorted. Default: `DEFAULT`.
|
257
|
-
# @option opts [String] :sort_order Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`.
|
256
|
+
# @option opts [String] :sort_field Indicates how Customers should be sorted. Default: `DEFAULT`. See [CustomerSortField](#type-customersortfield) for possible values.
|
257
|
+
# @option opts [String] :sort_order Indicates whether Customers should be sorted in ascending (`ASC`) or descending (`DESC`) order. Default: `ASC`. See [SortOrder](#type-sortorder) for possible values.
|
258
258
|
# @return [Array<(ListCustomersResponse, Fixnum, Hash)>] ListCustomersResponse data, response status code and response headers
|
259
259
|
def list_customers_with_http_info(opts = {})
|
260
260
|
if @api_client.config.debugging
|
@@ -354,6 +354,59 @@ module SquareConnect
|
|
354
354
|
return data, status_code, headers
|
355
355
|
end
|
356
356
|
|
357
|
+
# SearchCustomers
|
358
|
+
# Searches a business's customers.
|
359
|
+
# @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
|
360
|
+
# @param [Hash] opts the optional parameters
|
361
|
+
# @return [SearchCustomersResponse]
|
362
|
+
def search_customers(body, opts = {})
|
363
|
+
data, _status_code, _headers = search_customers_with_http_info(body, opts)
|
364
|
+
return data
|
365
|
+
end
|
366
|
+
|
367
|
+
# SearchCustomers
|
368
|
+
# Searches a business's customers.
|
369
|
+
# @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
|
370
|
+
# @param [Hash] opts the optional parameters
|
371
|
+
# @return [Array<(SearchCustomersResponse, Fixnum, Hash)>] SearchCustomersResponse data, response status code and response headers
|
372
|
+
def search_customers_with_http_info(body, opts = {})
|
373
|
+
if @api_client.config.debugging
|
374
|
+
@api_client.config.logger.debug "Calling API: CustomersApi.search_customers ..."
|
375
|
+
end
|
376
|
+
# verify the required parameter 'body' is set
|
377
|
+
fail ArgumentError, "Missing the required parameter 'body' when calling CustomersApi.search_customers" if body.nil?
|
378
|
+
# resource path
|
379
|
+
local_var_path = "/v2/customers/search".sub('{format}','json')
|
380
|
+
|
381
|
+
# query parameters
|
382
|
+
query_params = {}
|
383
|
+
|
384
|
+
# header parameters
|
385
|
+
header_params = {}
|
386
|
+
# HTTP header 'Accept' (if needed)
|
387
|
+
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
|
388
|
+
# HTTP header 'Content-Type'
|
389
|
+
header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
|
390
|
+
|
391
|
+
# form parameters
|
392
|
+
form_params = {}
|
393
|
+
|
394
|
+
# http body (model)
|
395
|
+
post_body = @api_client.object_to_http_body(body)
|
396
|
+
auth_names = ['oauth2']
|
397
|
+
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
|
398
|
+
:header_params => header_params,
|
399
|
+
:query_params => query_params,
|
400
|
+
:form_params => form_params,
|
401
|
+
:body => post_body,
|
402
|
+
:auth_names => auth_names,
|
403
|
+
:return_type => 'SearchCustomersResponse')
|
404
|
+
if @api_client.config.debugging
|
405
|
+
@api_client.config.logger.debug "API called: CustomersApi#search_customers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
|
406
|
+
end
|
407
|
+
return data, status_code, headers
|
408
|
+
end
|
409
|
+
|
357
410
|
# UpdateCustomer
|
358
411
|
# Updates the details of an existing customer. The ID of the customer may change if the customer has been merged into another customer. You cannot edit a customer's cards on file with this endpoint. To make changes to a card on file, you must delete the existing card on file with the [DeleteCustomerCard](#endpoint-deletecustomercard) endpoint, then create a new one with the [CreateCustomerCard](#endpoint-createcustomercard) endpoint.
|
359
412
|
# @param customer_id The ID of the customer to update.
|
@@ -30,7 +30,7 @@ module SquareConnect
|
|
30
30
|
@config = config
|
31
31
|
|
32
32
|
# Construct user agent string. Returns slightly different string for JRuby
|
33
|
-
@user_agent = "Square-Connect-Ruby/2.
|
33
|
+
@user_agent = "Square-Connect-Ruby/2.9.0"
|
34
34
|
|
35
35
|
@default_headers = {
|
36
36
|
'Content-Type' => "application/json",
|
@@ -57,6 +57,30 @@ module SquareConnect
|
|
57
57
|
# The groups the customer belongs to.
|
58
58
|
attr_accessor :groups
|
59
59
|
|
60
|
+
# A creation source represents the method used to create the customer profile.
|
61
|
+
attr_accessor :creation_source
|
62
|
+
|
63
|
+
class EnumAttributeValidator
|
64
|
+
attr_reader :datatype
|
65
|
+
attr_reader :allowable_values
|
66
|
+
|
67
|
+
def initialize(datatype, allowable_values)
|
68
|
+
@allowable_values = allowable_values.map do |value|
|
69
|
+
case datatype.to_s
|
70
|
+
when /Integer/i
|
71
|
+
value.to_i
|
72
|
+
when /Float/i
|
73
|
+
value.to_f
|
74
|
+
else
|
75
|
+
value
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def valid?(value)
|
81
|
+
!value || allowable_values.include?(value)
|
82
|
+
end
|
83
|
+
end
|
60
84
|
|
61
85
|
# Attribute mapping from ruby-style variable name to JSON key.
|
62
86
|
def self.attribute_map
|
@@ -75,7 +99,8 @@ module SquareConnect
|
|
75
99
|
:'reference_id' => :'reference_id',
|
76
100
|
:'note' => :'note',
|
77
101
|
:'preferences' => :'preferences',
|
78
|
-
:'groups' => :'groups'
|
102
|
+
:'groups' => :'groups',
|
103
|
+
:'creation_source' => :'creation_source'
|
79
104
|
}
|
80
105
|
end
|
81
106
|
|
@@ -96,7 +121,8 @@ module SquareConnect
|
|
96
121
|
:'reference_id' => :'String',
|
97
122
|
:'note' => :'String',
|
98
123
|
:'preferences' => :'CustomerPreferences',
|
99
|
-
:'groups' => :'Array<CustomerGroupInfo>'
|
124
|
+
:'groups' => :'Array<CustomerGroupInfo>',
|
125
|
+
:'creation_source' => :'String'
|
100
126
|
}
|
101
127
|
end
|
102
128
|
|
@@ -172,6 +198,10 @@ module SquareConnect
|
|
172
198
|
end
|
173
199
|
end
|
174
200
|
|
201
|
+
if attributes.has_key?(:'creation_source')
|
202
|
+
self.creation_source = attributes[:'creation_source']
|
203
|
+
end
|
204
|
+
|
175
205
|
end
|
176
206
|
|
177
207
|
# Show invalid properties with the reasons. Usually used together with valid?
|
@@ -199,9 +229,21 @@ module SquareConnect
|
|
199
229
|
return false if @id.nil?
|
200
230
|
return false if @created_at.nil?
|
201
231
|
return false if @updated_at.nil?
|
232
|
+
creation_source_validator = EnumAttributeValidator.new('String', ["OTHER", "APPOINTMENTS", "COUPON", "DELETION_RECOVERY", "DIRECTORY", "EGIFTING", "EMAIL_COLLECTION", "FEEDBACK", "IMPORT", "INVOICES", "LOYALTY", "MARKETING", "MERGE", "ONLINE_STORE", "INSTANT_PROFILE", "TERMINAL", "THIRD_PARTY", "THIRD_PARTY_IMPORT", "UNMERGE_RECOVERY"])
|
233
|
+
return false unless creation_source_validator.valid?(@creation_source)
|
202
234
|
return true
|
203
235
|
end
|
204
236
|
|
237
|
+
# Custom attribute writer method checking allowed values (enum).
|
238
|
+
# @param [Object] creation_source Object to be assigned
|
239
|
+
def creation_source=(creation_source)
|
240
|
+
validator = EnumAttributeValidator.new('String', ["OTHER", "APPOINTMENTS", "COUPON", "DELETION_RECOVERY", "DIRECTORY", "EGIFTING", "EMAIL_COLLECTION", "FEEDBACK", "IMPORT", "INVOICES", "LOYALTY", "MARKETING", "MERGE", "ONLINE_STORE", "INSTANT_PROFILE", "TERMINAL", "THIRD_PARTY", "THIRD_PARTY_IMPORT", "UNMERGE_RECOVERY"])
|
241
|
+
unless validator.valid?(creation_source)
|
242
|
+
fail ArgumentError, "invalid value for 'creation_source', must be one of #{validator.allowable_values}."
|
243
|
+
end
|
244
|
+
@creation_source = creation_source
|
245
|
+
end
|
246
|
+
|
205
247
|
# Checks equality by comparing each attribute.
|
206
248
|
# @param [Object] Object to be compared
|
207
249
|
def ==(o)
|
@@ -221,7 +263,8 @@ module SquareConnect
|
|
221
263
|
reference_id == o.reference_id &&
|
222
264
|
note == o.note &&
|
223
265
|
preferences == o.preferences &&
|
224
|
-
groups == o.groups
|
266
|
+
groups == o.groups &&
|
267
|
+
creation_source == o.creation_source
|
225
268
|
end
|
226
269
|
|
227
270
|
# @see the `==` method
|
@@ -233,7 +276,7 @@ module SquareConnect
|
|
233
276
|
# Calculates hash code according to all attributes.
|
234
277
|
# @return [Fixnum] Hash code
|
235
278
|
def hash
|
236
|
-
[id, created_at, updated_at, cards, given_name, family_name, nickname, company_name, email_address, address, phone_number, reference_id, note, preferences, groups].hash
|
279
|
+
[id, created_at, updated_at, cards, given_name, family_name, nickname, company_name, email_address, address, phone_number, reference_id, note, preferences, groups, creation_source].hash
|
237
280
|
end
|
238
281
|
|
239
282
|
# Builds the object from hash
|
@@ -0,0 +1,36 @@
|
|
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
|
+
class CustomerCreationSource
|
14
|
+
|
15
|
+
OTHER = "OTHER".freeze
|
16
|
+
APPOINTMENTS = "APPOINTMENTS".freeze
|
17
|
+
COUPON = "COUPON".freeze
|
18
|
+
DELETION_RECOVERY = "DELETION_RECOVERY".freeze
|
19
|
+
DIRECTORY = "DIRECTORY".freeze
|
20
|
+
EGIFTING = "EGIFTING".freeze
|
21
|
+
EMAIL_COLLECTION = "EMAIL_COLLECTION".freeze
|
22
|
+
FEEDBACK = "FEEDBACK".freeze
|
23
|
+
IMPORT = "IMPORT".freeze
|
24
|
+
INVOICES = "INVOICES".freeze
|
25
|
+
LOYALTY = "LOYALTY".freeze
|
26
|
+
MARKETING = "MARKETING".freeze
|
27
|
+
MERGE = "MERGE".freeze
|
28
|
+
ONLINE_STORE = "ONLINE_STORE".freeze
|
29
|
+
INSTANT_PROFILE = "INSTANT_PROFILE".freeze
|
30
|
+
TERMINAL = "TERMINAL".freeze
|
31
|
+
THIRD_PARTY = "THIRD_PARTY".freeze
|
32
|
+
THIRD_PARTY_IMPORT = "THIRD_PARTY_IMPORT".freeze
|
33
|
+
UNMERGE_RECOVERY = "UNMERGE_RECOVERY".freeze
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,231 @@
|
|
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
|
+
# Creation source filter. If one or more creation sources are set, customer profiles are included in, or excluded from, the result if they match at least one of the filter criteria.
|
14
|
+
class CustomerCreationSourceFilter
|
15
|
+
# The list of creation sources used as filtering criteria.
|
16
|
+
attr_accessor :values
|
17
|
+
|
18
|
+
# Indicates whether a customer profile matching the filter criteria should be included in the result or excluded from the result. Default: `INCLUDE`. See [CustomerInclusionExclusion](#type-customerinclusionexclusion) for possible values.
|
19
|
+
attr_accessor :rule
|
20
|
+
|
21
|
+
class EnumAttributeValidator
|
22
|
+
attr_reader :datatype
|
23
|
+
attr_reader :allowable_values
|
24
|
+
|
25
|
+
def initialize(datatype, allowable_values)
|
26
|
+
@allowable_values = allowable_values.map do |value|
|
27
|
+
case datatype.to_s
|
28
|
+
when /Integer/i
|
29
|
+
value.to_i
|
30
|
+
when /Float/i
|
31
|
+
value.to_f
|
32
|
+
else
|
33
|
+
value
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def valid?(value)
|
39
|
+
!value || allowable_values.include?(value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
44
|
+
def self.attribute_map
|
45
|
+
{
|
46
|
+
:'values' => :'values',
|
47
|
+
:'rule' => :'rule'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
# Attribute type mapping.
|
52
|
+
def self.swagger_types
|
53
|
+
{
|
54
|
+
:'values' => :'Array<String>',
|
55
|
+
:'rule' => :'String'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
# Initializes the object
|
60
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
61
|
+
def initialize(attributes = {})
|
62
|
+
return unless attributes.is_a?(Hash)
|
63
|
+
|
64
|
+
# convert string to symbol for hash key
|
65
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
66
|
+
|
67
|
+
if attributes.has_key?(:'values')
|
68
|
+
if (value = attributes[:'values']).is_a?(Array)
|
69
|
+
self.values = value
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes.has_key?(:'rule')
|
74
|
+
self.rule = attributes[:'rule']
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
80
|
+
# @return Array for valid properies with the reasons
|
81
|
+
def list_invalid_properties
|
82
|
+
invalid_properties = Array.new
|
83
|
+
return invalid_properties
|
84
|
+
end
|
85
|
+
|
86
|
+
# Check to see if the all the properties in the model are valid
|
87
|
+
# @return true if the model is valid
|
88
|
+
def valid?
|
89
|
+
rule_validator = EnumAttributeValidator.new('String', ["INCLUDE", "EXCLUDE"])
|
90
|
+
return false unless rule_validator.valid?(@rule)
|
91
|
+
return true
|
92
|
+
end
|
93
|
+
|
94
|
+
# Custom attribute writer method checking allowed values (enum).
|
95
|
+
# @param [Object] rule Object to be assigned
|
96
|
+
def rule=(rule)
|
97
|
+
validator = EnumAttributeValidator.new('String', ["INCLUDE", "EXCLUDE"])
|
98
|
+
unless validator.valid?(rule)
|
99
|
+
fail ArgumentError, "invalid value for 'rule', must be one of #{validator.allowable_values}."
|
100
|
+
end
|
101
|
+
@rule = rule
|
102
|
+
end
|
103
|
+
|
104
|
+
# Checks equality by comparing each attribute.
|
105
|
+
# @param [Object] Object to be compared
|
106
|
+
def ==(o)
|
107
|
+
return true if self.equal?(o)
|
108
|
+
self.class == o.class &&
|
109
|
+
values == o.values &&
|
110
|
+
rule == o.rule
|
111
|
+
end
|
112
|
+
|
113
|
+
# @see the `==` method
|
114
|
+
# @param [Object] Object to be compared
|
115
|
+
def eql?(o)
|
116
|
+
self == o
|
117
|
+
end
|
118
|
+
|
119
|
+
# Calculates hash code according to all attributes.
|
120
|
+
# @return [Fixnum] Hash code
|
121
|
+
def hash
|
122
|
+
[values, rule].hash
|
123
|
+
end
|
124
|
+
|
125
|
+
# Builds the object from hash
|
126
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
127
|
+
# @return [Object] Returns the model itself
|
128
|
+
def build_from_hash(attributes)
|
129
|
+
return nil unless attributes.is_a?(Hash)
|
130
|
+
self.class.swagger_types.each_pair do |key, type|
|
131
|
+
if type =~ /\AArray<(.*)>/i
|
132
|
+
# check to ensure the input is an array given that the the attribute
|
133
|
+
# is documented as an array but the input is not
|
134
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
135
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
136
|
+
end
|
137
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
138
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
139
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
140
|
+
end
|
141
|
+
|
142
|
+
self
|
143
|
+
end
|
144
|
+
|
145
|
+
# Deserializes the data based on type
|
146
|
+
# @param string type Data type
|
147
|
+
# @param string value Value to be deserialized
|
148
|
+
# @return [Object] Deserialized data
|
149
|
+
def _deserialize(type, value)
|
150
|
+
case type.to_sym
|
151
|
+
when :DateTime
|
152
|
+
DateTime.parse(value)
|
153
|
+
when :Date
|
154
|
+
Date.parse(value)
|
155
|
+
when :String
|
156
|
+
value.to_s
|
157
|
+
when :Integer
|
158
|
+
value.to_i
|
159
|
+
when :Float
|
160
|
+
value.to_f
|
161
|
+
when :BOOLEAN
|
162
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
163
|
+
true
|
164
|
+
else
|
165
|
+
false
|
166
|
+
end
|
167
|
+
when :Object
|
168
|
+
# generic object (usually a Hash), return directly
|
169
|
+
value
|
170
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
171
|
+
inner_type = Regexp.last_match[:inner_type]
|
172
|
+
value.map { |v| _deserialize(inner_type, v) }
|
173
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
174
|
+
k_type = Regexp.last_match[:k_type]
|
175
|
+
v_type = Regexp.last_match[:v_type]
|
176
|
+
{}.tap do |hash|
|
177
|
+
value.each do |k, v|
|
178
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
else # model
|
182
|
+
temp_model = SquareConnect.const_get(type).new
|
183
|
+
temp_model.build_from_hash(value)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
# Returns the string representation of the object
|
188
|
+
# @return [String] String presentation of the object
|
189
|
+
def to_s
|
190
|
+
to_hash.to_s
|
191
|
+
end
|
192
|
+
|
193
|
+
# to_body is an alias to to_hash (backward compatibility)
|
194
|
+
# @return [Hash] Returns the object in the form of hash
|
195
|
+
def to_body
|
196
|
+
to_hash
|
197
|
+
end
|
198
|
+
|
199
|
+
# Returns the object in the form of hash
|
200
|
+
# @return [Hash] Returns the object in the form of hash
|
201
|
+
def to_hash
|
202
|
+
hash = {}
|
203
|
+
self.class.attribute_map.each_pair do |attr, param|
|
204
|
+
value = self.send(attr)
|
205
|
+
next if value.nil?
|
206
|
+
hash[param] = _to_hash(value)
|
207
|
+
end
|
208
|
+
hash
|
209
|
+
end
|
210
|
+
|
211
|
+
# Outputs non-array value in the form of hash
|
212
|
+
# For object, use to_hash. Otherwise, just return the value
|
213
|
+
# @param [Object] value Any valid value
|
214
|
+
# @return [Hash] Returns the value in the form of hash
|
215
|
+
def _to_hash(value)
|
216
|
+
if value.is_a?(Array)
|
217
|
+
value.compact.map{ |v| _to_hash(v) }
|
218
|
+
elsif value.is_a?(Hash)
|
219
|
+
{}.tap do |hash|
|
220
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
221
|
+
end
|
222
|
+
elsif value.respond_to? :to_hash
|
223
|
+
value.to_hash
|
224
|
+
else
|
225
|
+
value
|
226
|
+
end
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|