square_connect 2.0.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.
- 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,184 @@
|
|
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 **ListTenderRefunds** endpoint.\n\nOne of `errors` or `refunds` is present in a given response (never both).
|
15
|
+
class ListRefundsResponse
|
16
|
+
# Any errors that occurred during the request.
|
17
|
+
attr_accessor :errors
|
18
|
+
|
19
|
+
# An array of refunds that match your query.
|
20
|
+
attr_accessor :refunds
|
21
|
+
|
22
|
+
# A pagination cursor for retrieving the next set of results,\nif any remain.\n\nProvide this value as the `cursor` parameter in a subsequent request\nto the **ListTenderRefunds** endpoint.
|
23
|
+
attr_accessor :cursor
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
|
29
|
+
:'errors' => :'errors',
|
30
|
+
|
31
|
+
:'refunds' => :'refunds',
|
32
|
+
|
33
|
+
:'cursor' => :'cursor'
|
34
|
+
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.swagger_types
|
40
|
+
{
|
41
|
+
:'errors' => :'Array<Error>',
|
42
|
+
:'refunds' => :'Array<Refund>',
|
43
|
+
:'cursor' => :'String'
|
44
|
+
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize(attributes = {})
|
49
|
+
return unless attributes.is_a?(Hash)
|
50
|
+
|
51
|
+
# convert string to symbol for hash key
|
52
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
53
|
+
|
54
|
+
|
55
|
+
if attributes[:'errors']
|
56
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
57
|
+
self.errors = value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes[:'refunds']
|
62
|
+
if (value = attributes[:'refunds']).is_a?(Array)
|
63
|
+
self.refunds = value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes[:'cursor']
|
68
|
+
self.cursor = attributes[:'cursor']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Check equality by comparing each attribute.
|
74
|
+
def ==(o)
|
75
|
+
return true if self.equal?(o)
|
76
|
+
self.class == o.class &&
|
77
|
+
errors == o.errors &&
|
78
|
+
refunds == o.refunds &&
|
79
|
+
cursor == o.cursor
|
80
|
+
end
|
81
|
+
|
82
|
+
# @see the `==` method
|
83
|
+
def eql?(o)
|
84
|
+
self == o
|
85
|
+
end
|
86
|
+
|
87
|
+
# Calculate hash code according to all attributes.
|
88
|
+
def hash
|
89
|
+
[errors, refunds, cursor].hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# build the object from hash
|
93
|
+
def build_from_hash(attributes)
|
94
|
+
return nil unless attributes.is_a?(Hash)
|
95
|
+
self.class.swagger_types.each_pair do |key, type|
|
96
|
+
if type =~ /^Array<(.*)>/i
|
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
|
+
else
|
100
|
+
#TODO show warning in debug mode
|
101
|
+
end
|
102
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
103
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
104
|
+
else
|
105
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
self
|
110
|
+
end
|
111
|
+
|
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 =~ /^(true|t|yes|y|1)$/i
|
126
|
+
true
|
127
|
+
else
|
128
|
+
false
|
129
|
+
end
|
130
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
131
|
+
inner_type = Regexp.last_match[:inner_type]
|
132
|
+
value.map { |v| _deserialize(inner_type, v) }
|
133
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
134
|
+
k_type = Regexp.last_match[:k_type]
|
135
|
+
v_type = Regexp.last_match[:v_type]
|
136
|
+
{}.tap do |hash|
|
137
|
+
value.each do |k, v|
|
138
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
else # model
|
142
|
+
_model = SquareConnect.const_get(type).new
|
143
|
+
_model.build_from_hash(value)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def to_s
|
148
|
+
to_hash.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
# to_body is an alias to to_body (backward compatibility))
|
152
|
+
def to_body
|
153
|
+
to_hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# return the object in the form of hash
|
157
|
+
def to_hash
|
158
|
+
hash = {}
|
159
|
+
self.class.attribute_map.each_pair do |attr, param|
|
160
|
+
value = self.send(attr)
|
161
|
+
next if value.nil?
|
162
|
+
hash[param] = _to_hash(value)
|
163
|
+
end
|
164
|
+
hash
|
165
|
+
end
|
166
|
+
|
167
|
+
# Method to output non-array value in the form of hash
|
168
|
+
# For object, use to_hash. Otherwise, just return the value
|
169
|
+
def _to_hash(value)
|
170
|
+
if value.is_a?(Array)
|
171
|
+
value.compact.map{ |v| _to_hash(v) }
|
172
|
+
elsif value.is_a?(Hash)
|
173
|
+
{}.tap do |hash|
|
174
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
175
|
+
end
|
176
|
+
elsif value.respond_to? :to_hash
|
177
|
+
value.to_hash
|
178
|
+
else
|
179
|
+
value
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,200 @@
|
|
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 query parameters that can be included in\na request to the **ListTransactions** endpoint.
|
15
|
+
class ListTransactionsRequest
|
16
|
+
# The beginning of the requested reporting period, in RFC 3339 format.
|
17
|
+
attr_accessor :begin_time
|
18
|
+
|
19
|
+
# The end of the requested reporting period, in RFC 3339 format.
|
20
|
+
attr_accessor :end_time
|
21
|
+
|
22
|
+
# The order in which results are listed in the response (`ASC` for\nchronological, `DESC` for reverse-chronological).
|
23
|
+
attr_accessor :sort_order
|
24
|
+
|
25
|
+
# A pagination cursor to retrieve the next set of results for your\noriginal query to the endpoint.
|
26
|
+
attr_accessor :cursor
|
27
|
+
|
28
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
+
def self.attribute_map
|
30
|
+
{
|
31
|
+
|
32
|
+
:'begin_time' => :'begin_time',
|
33
|
+
|
34
|
+
:'end_time' => :'end_time',
|
35
|
+
|
36
|
+
:'sort_order' => :'sort_order',
|
37
|
+
|
38
|
+
:'cursor' => :'cursor'
|
39
|
+
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
# Attribute type mapping.
|
44
|
+
def self.swagger_types
|
45
|
+
{
|
46
|
+
:'begin_time' => :'String',
|
47
|
+
:'end_time' => :'String',
|
48
|
+
:'sort_order' => :'String',
|
49
|
+
:'cursor' => :'String'
|
50
|
+
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
def initialize(attributes = {})
|
55
|
+
return unless attributes.is_a?(Hash)
|
56
|
+
|
57
|
+
# convert string to symbol for hash key
|
58
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
59
|
+
|
60
|
+
|
61
|
+
if attributes[:'begin_time']
|
62
|
+
self.begin_time = attributes[:'begin_time']
|
63
|
+
end
|
64
|
+
|
65
|
+
if attributes[:'end_time']
|
66
|
+
self.end_time = attributes[:'end_time']
|
67
|
+
end
|
68
|
+
|
69
|
+
if attributes[:'sort_order']
|
70
|
+
self.sort_order = attributes[:'sort_order']
|
71
|
+
end
|
72
|
+
|
73
|
+
if attributes[:'cursor']
|
74
|
+
self.cursor = attributes[:'cursor']
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
# Custom attribute writer method checking allowed values (enum).
|
80
|
+
def sort_order=(sort_order)
|
81
|
+
allowed_values = ["DESC", "ASC"]
|
82
|
+
if sort_order && !allowed_values.include?(sort_order)
|
83
|
+
fail "invalid value for 'sort_order', must be one of #{allowed_values}"
|
84
|
+
end
|
85
|
+
@sort_order = sort_order
|
86
|
+
end
|
87
|
+
|
88
|
+
# Check equality by comparing each attribute.
|
89
|
+
def ==(o)
|
90
|
+
return true if self.equal?(o)
|
91
|
+
self.class == o.class &&
|
92
|
+
begin_time == o.begin_time &&
|
93
|
+
end_time == o.end_time &&
|
94
|
+
sort_order == o.sort_order &&
|
95
|
+
cursor == o.cursor
|
96
|
+
end
|
97
|
+
|
98
|
+
# @see the `==` method
|
99
|
+
def eql?(o)
|
100
|
+
self == o
|
101
|
+
end
|
102
|
+
|
103
|
+
# Calculate hash code according to all attributes.
|
104
|
+
def hash
|
105
|
+
[begin_time, end_time, sort_order, cursor].hash
|
106
|
+
end
|
107
|
+
|
108
|
+
# build the object from hash
|
109
|
+
def build_from_hash(attributes)
|
110
|
+
return nil unless attributes.is_a?(Hash)
|
111
|
+
self.class.swagger_types.each_pair do |key, type|
|
112
|
+
if type =~ /^Array<(.*)>/i
|
113
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
114
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
115
|
+
else
|
116
|
+
#TODO show warning in debug mode
|
117
|
+
end
|
118
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
119
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
120
|
+
else
|
121
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
self
|
126
|
+
end
|
127
|
+
|
128
|
+
def _deserialize(type, value)
|
129
|
+
case type.to_sym
|
130
|
+
when :DateTime
|
131
|
+
DateTime.parse(value)
|
132
|
+
when :Date
|
133
|
+
Date.parse(value)
|
134
|
+
when :String
|
135
|
+
value.to_s
|
136
|
+
when :Integer
|
137
|
+
value.to_i
|
138
|
+
when :Float
|
139
|
+
value.to_f
|
140
|
+
when :BOOLEAN
|
141
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
142
|
+
true
|
143
|
+
else
|
144
|
+
false
|
145
|
+
end
|
146
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
147
|
+
inner_type = Regexp.last_match[:inner_type]
|
148
|
+
value.map { |v| _deserialize(inner_type, v) }
|
149
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
150
|
+
k_type = Regexp.last_match[:k_type]
|
151
|
+
v_type = Regexp.last_match[:v_type]
|
152
|
+
{}.tap do |hash|
|
153
|
+
value.each do |k, v|
|
154
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
else # model
|
158
|
+
_model = SquareConnect.const_get(type).new
|
159
|
+
_model.build_from_hash(value)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def to_s
|
164
|
+
to_hash.to_s
|
165
|
+
end
|
166
|
+
|
167
|
+
# to_body is an alias to to_body (backward compatibility))
|
168
|
+
def to_body
|
169
|
+
to_hash
|
170
|
+
end
|
171
|
+
|
172
|
+
# return the object in the form of hash
|
173
|
+
def to_hash
|
174
|
+
hash = {}
|
175
|
+
self.class.attribute_map.each_pair do |attr, param|
|
176
|
+
value = self.send(attr)
|
177
|
+
next if value.nil?
|
178
|
+
hash[param] = _to_hash(value)
|
179
|
+
end
|
180
|
+
hash
|
181
|
+
end
|
182
|
+
|
183
|
+
# Method to output non-array value in the form of hash
|
184
|
+
# For object, use to_hash. Otherwise, just return the value
|
185
|
+
def _to_hash(value)
|
186
|
+
if value.is_a?(Array)
|
187
|
+
value.compact.map{ |v| _to_hash(v) }
|
188
|
+
elsif value.is_a?(Hash)
|
189
|
+
{}.tap do |hash|
|
190
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
191
|
+
end
|
192
|
+
elsif value.respond_to? :to_hash
|
193
|
+
value.to_hash
|
194
|
+
else
|
195
|
+
value
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,184 @@
|
|
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 **ListTransactions** endpoint.\n\nOne of `errors` or `transactions` is present in a given response (never both).
|
15
|
+
class ListTransactionsResponse
|
16
|
+
# Any errors that occurred during the request.
|
17
|
+
attr_accessor :errors
|
18
|
+
|
19
|
+
# An array of transactions that match your query.
|
20
|
+
attr_accessor :transactions
|
21
|
+
|
22
|
+
# A pagination cursor for retrieving the next set of results,\nif any remain.\n\nProvide this value as the `cursor` parameter in a subsequent request\nto the **ListTransactions** endpoint.
|
23
|
+
attr_accessor :cursor
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
|
29
|
+
:'errors' => :'errors',
|
30
|
+
|
31
|
+
:'transactions' => :'transactions',
|
32
|
+
|
33
|
+
:'cursor' => :'cursor'
|
34
|
+
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Attribute type mapping.
|
39
|
+
def self.swagger_types
|
40
|
+
{
|
41
|
+
:'errors' => :'Array<Error>',
|
42
|
+
:'transactions' => :'Array<Transaction>',
|
43
|
+
:'cursor' => :'String'
|
44
|
+
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize(attributes = {})
|
49
|
+
return unless attributes.is_a?(Hash)
|
50
|
+
|
51
|
+
# convert string to symbol for hash key
|
52
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
53
|
+
|
54
|
+
|
55
|
+
if attributes[:'errors']
|
56
|
+
if (value = attributes[:'errors']).is_a?(Array)
|
57
|
+
self.errors = value
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if attributes[:'transactions']
|
62
|
+
if (value = attributes[:'transactions']).is_a?(Array)
|
63
|
+
self.transactions = value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes[:'cursor']
|
68
|
+
self.cursor = attributes[:'cursor']
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# Check equality by comparing each attribute.
|
74
|
+
def ==(o)
|
75
|
+
return true if self.equal?(o)
|
76
|
+
self.class == o.class &&
|
77
|
+
errors == o.errors &&
|
78
|
+
transactions == o.transactions &&
|
79
|
+
cursor == o.cursor
|
80
|
+
end
|
81
|
+
|
82
|
+
# @see the `==` method
|
83
|
+
def eql?(o)
|
84
|
+
self == o
|
85
|
+
end
|
86
|
+
|
87
|
+
# Calculate hash code according to all attributes.
|
88
|
+
def hash
|
89
|
+
[errors, transactions, cursor].hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# build the object from hash
|
93
|
+
def build_from_hash(attributes)
|
94
|
+
return nil unless attributes.is_a?(Hash)
|
95
|
+
self.class.swagger_types.each_pair do |key, type|
|
96
|
+
if type =~ /^Array<(.*)>/i
|
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
|
+
else
|
100
|
+
#TODO show warning in debug mode
|
101
|
+
end
|
102
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
103
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
104
|
+
else
|
105
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
self
|
110
|
+
end
|
111
|
+
|
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 =~ /^(true|t|yes|y|1)$/i
|
126
|
+
true
|
127
|
+
else
|
128
|
+
false
|
129
|
+
end
|
130
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
131
|
+
inner_type = Regexp.last_match[:inner_type]
|
132
|
+
value.map { |v| _deserialize(inner_type, v) }
|
133
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
134
|
+
k_type = Regexp.last_match[:k_type]
|
135
|
+
v_type = Regexp.last_match[:v_type]
|
136
|
+
{}.tap do |hash|
|
137
|
+
value.each do |k, v|
|
138
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
else # model
|
142
|
+
_model = SquareConnect.const_get(type).new
|
143
|
+
_model.build_from_hash(value)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def to_s
|
148
|
+
to_hash.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
# to_body is an alias to to_body (backward compatibility))
|
152
|
+
def to_body
|
153
|
+
to_hash
|
154
|
+
end
|
155
|
+
|
156
|
+
# return the object in the form of hash
|
157
|
+
def to_hash
|
158
|
+
hash = {}
|
159
|
+
self.class.attribute_map.each_pair do |attr, param|
|
160
|
+
value = self.send(attr)
|
161
|
+
next if value.nil?
|
162
|
+
hash[param] = _to_hash(value)
|
163
|
+
end
|
164
|
+
hash
|
165
|
+
end
|
166
|
+
|
167
|
+
# Method to output non-array value in the form of hash
|
168
|
+
# For object, use to_hash. Otherwise, just return the value
|
169
|
+
def _to_hash(value)
|
170
|
+
if value.is_a?(Array)
|
171
|
+
value.compact.map{ |v| _to_hash(v) }
|
172
|
+
elsif value.is_a?(Hash)
|
173
|
+
{}.tap do |hash|
|
174
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
175
|
+
end
|
176
|
+
elsif value.respond_to? :to_hash
|
177
|
+
value.to_hash
|
178
|
+
else
|
179
|
+
value
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|