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,204 @@
|
|
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
|
+
# Represents one of a business's locations.
|
15
|
+
class Location
|
16
|
+
# The location's unique ID.
|
17
|
+
attr_accessor :id
|
18
|
+
|
19
|
+
# The name given to the location.
|
20
|
+
attr_accessor :name
|
21
|
+
|
22
|
+
# The address of this location.
|
23
|
+
attr_accessor :address
|
24
|
+
|
25
|
+
# The IANA Timezone Database identifier for the location's timezone.
|
26
|
+
attr_accessor :timezone
|
27
|
+
|
28
|
+
# Indicates which Square features are enabled for the location.\n\nCurrently, there is only one value that might be present in this array:\n`CREDIT_CARD_PROCESSING`.
|
29
|
+
attr_accessor :capabilities
|
30
|
+
|
31
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
32
|
+
def self.attribute_map
|
33
|
+
{
|
34
|
+
|
35
|
+
:'id' => :'id',
|
36
|
+
|
37
|
+
:'name' => :'name',
|
38
|
+
|
39
|
+
:'address' => :'address',
|
40
|
+
|
41
|
+
:'timezone' => :'timezone',
|
42
|
+
|
43
|
+
:'capabilities' => :'capabilities'
|
44
|
+
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attribute type mapping.
|
49
|
+
def self.swagger_types
|
50
|
+
{
|
51
|
+
:'id' => :'String',
|
52
|
+
:'name' => :'String',
|
53
|
+
:'address' => :'Address',
|
54
|
+
:'timezone' => :'String',
|
55
|
+
:'capabilities' => :'Array<String>'
|
56
|
+
|
57
|
+
}
|
58
|
+
end
|
59
|
+
|
60
|
+
def initialize(attributes = {})
|
61
|
+
return unless attributes.is_a?(Hash)
|
62
|
+
|
63
|
+
# convert string to symbol for hash key
|
64
|
+
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
65
|
+
|
66
|
+
|
67
|
+
if attributes[:'id']
|
68
|
+
self.id = attributes[:'id']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes[:'name']
|
72
|
+
self.name = attributes[:'name']
|
73
|
+
end
|
74
|
+
|
75
|
+
if attributes[:'address']
|
76
|
+
self.address = attributes[:'address']
|
77
|
+
end
|
78
|
+
|
79
|
+
if attributes[:'timezone']
|
80
|
+
self.timezone = attributes[:'timezone']
|
81
|
+
end
|
82
|
+
|
83
|
+
if attributes[:'capabilities']
|
84
|
+
if (value = attributes[:'capabilities']).is_a?(Array)
|
85
|
+
self.capabilities = value
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
# Check equality by comparing each attribute.
|
92
|
+
def ==(o)
|
93
|
+
return true if self.equal?(o)
|
94
|
+
self.class == o.class &&
|
95
|
+
id == o.id &&
|
96
|
+
name == o.name &&
|
97
|
+
address == o.address &&
|
98
|
+
timezone == o.timezone &&
|
99
|
+
capabilities == o.capabilities
|
100
|
+
end
|
101
|
+
|
102
|
+
# @see the `==` method
|
103
|
+
def eql?(o)
|
104
|
+
self == o
|
105
|
+
end
|
106
|
+
|
107
|
+
# Calculate hash code according to all attributes.
|
108
|
+
def hash
|
109
|
+
[id, name, address, timezone, capabilities].hash
|
110
|
+
end
|
111
|
+
|
112
|
+
# build the object from hash
|
113
|
+
def build_from_hash(attributes)
|
114
|
+
return nil unless attributes.is_a?(Hash)
|
115
|
+
self.class.swagger_types.each_pair do |key, type|
|
116
|
+
if type =~ /^Array<(.*)>/i
|
117
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
118
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
119
|
+
else
|
120
|
+
#TODO show warning in debug mode
|
121
|
+
end
|
122
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
123
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
124
|
+
else
|
125
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
self
|
130
|
+
end
|
131
|
+
|
132
|
+
def _deserialize(type, value)
|
133
|
+
case type.to_sym
|
134
|
+
when :DateTime
|
135
|
+
DateTime.parse(value)
|
136
|
+
when :Date
|
137
|
+
Date.parse(value)
|
138
|
+
when :String
|
139
|
+
value.to_s
|
140
|
+
when :Integer
|
141
|
+
value.to_i
|
142
|
+
when :Float
|
143
|
+
value.to_f
|
144
|
+
when :BOOLEAN
|
145
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
146
|
+
true
|
147
|
+
else
|
148
|
+
false
|
149
|
+
end
|
150
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
151
|
+
inner_type = Regexp.last_match[:inner_type]
|
152
|
+
value.map { |v| _deserialize(inner_type, v) }
|
153
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
154
|
+
k_type = Regexp.last_match[:k_type]
|
155
|
+
v_type = Regexp.last_match[:v_type]
|
156
|
+
{}.tap do |hash|
|
157
|
+
value.each do |k, v|
|
158
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else # model
|
162
|
+
_model = SquareConnect.const_get(type).new
|
163
|
+
_model.build_from_hash(value)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def to_s
|
168
|
+
to_hash.to_s
|
169
|
+
end
|
170
|
+
|
171
|
+
# to_body is an alias to to_body (backward compatibility))
|
172
|
+
def to_body
|
173
|
+
to_hash
|
174
|
+
end
|
175
|
+
|
176
|
+
# return the object in the form of hash
|
177
|
+
def to_hash
|
178
|
+
hash = {}
|
179
|
+
self.class.attribute_map.each_pair do |attr, param|
|
180
|
+
value = self.send(attr)
|
181
|
+
next if value.nil?
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
hash
|
185
|
+
end
|
186
|
+
|
187
|
+
# Method to output non-array value in the form of hash
|
188
|
+
# For object, use to_hash. Otherwise, just return the value
|
189
|
+
def _to_hash(value)
|
190
|
+
if value.is_a?(Array)
|
191
|
+
value.compact.map{ |v| _to_hash(v) }
|
192
|
+
elsif value.is_a?(Hash)
|
193
|
+
{}.tap do |hash|
|
194
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
195
|
+
end
|
196
|
+
elsif value.respond_to? :to_hash
|
197
|
+
value.to_hash
|
198
|
+
else
|
199
|
+
value
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|
@@ -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
|
+
#
|
15
|
+
class LocationCapability
|
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,178 @@
|
|
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 Money
|
16
|
+
# Amount in the lowest denominated value of this Currency. E.g. in USD\nthese are cents, in JPY they are Yen (which do not have a 'cent' concept).
|
17
|
+
attr_accessor :amount
|
18
|
+
|
19
|
+
#
|
20
|
+
attr_accessor :currency
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
|
26
|
+
:'amount' => :'amount',
|
27
|
+
|
28
|
+
:'currency' => :'currency'
|
29
|
+
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.swagger_types
|
35
|
+
{
|
36
|
+
:'amount' => :'Integer',
|
37
|
+
:'currency' => :'String'
|
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[:'amount']
|
50
|
+
self.amount = attributes[:'amount']
|
51
|
+
end
|
52
|
+
|
53
|
+
if attributes[:'currency']
|
54
|
+
self.currency = attributes[:'currency']
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
# Custom attribute writer method checking allowed values (enum).
|
60
|
+
def currency=(currency)
|
61
|
+
allowed_values = ["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BOV", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHE", "CHF", "CHW", "CLF", "CLP", "CNY", "COP", "COU", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LTL", "LVL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRO", "MUR", "MVR", "MWK", "MXN", "MXV", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SRD", "SSP", "STD", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "USN", "USS", "UYI", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XAG", "XAU", "XBA", "XBB", "XBC", "XBD", "XCD", "XDR", "XOF", "XPD", "XPF", "XPT", "XTS", "XXX", "YER", "ZAR", "ZMK", "ZMW", "BTC"]
|
62
|
+
if currency && !allowed_values.include?(currency)
|
63
|
+
fail "invalid value for 'currency', must be one of #{allowed_values}"
|
64
|
+
end
|
65
|
+
@currency = currency
|
66
|
+
end
|
67
|
+
|
68
|
+
# Check equality by comparing each attribute.
|
69
|
+
def ==(o)
|
70
|
+
return true if self.equal?(o)
|
71
|
+
self.class == o.class &&
|
72
|
+
amount == o.amount &&
|
73
|
+
currency == o.currency
|
74
|
+
end
|
75
|
+
|
76
|
+
# @see the `==` method
|
77
|
+
def eql?(o)
|
78
|
+
self == o
|
79
|
+
end
|
80
|
+
|
81
|
+
# Calculate hash code according to all attributes.
|
82
|
+
def hash
|
83
|
+
[amount, currency].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
# build the object from hash
|
87
|
+
def build_from_hash(attributes)
|
88
|
+
return nil unless attributes.is_a?(Hash)
|
89
|
+
self.class.swagger_types.each_pair do |key, type|
|
90
|
+
if type =~ /^Array<(.*)>/i
|
91
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
92
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
93
|
+
else
|
94
|
+
#TODO show warning in debug mode
|
95
|
+
end
|
96
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
97
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
98
|
+
else
|
99
|
+
# data not found in attributes(hash), not an issue as the data can be optional
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
self
|
104
|
+
end
|
105
|
+
|
106
|
+
def _deserialize(type, value)
|
107
|
+
case type.to_sym
|
108
|
+
when :DateTime
|
109
|
+
DateTime.parse(value)
|
110
|
+
when :Date
|
111
|
+
Date.parse(value)
|
112
|
+
when :String
|
113
|
+
value.to_s
|
114
|
+
when :Integer
|
115
|
+
value.to_i
|
116
|
+
when :Float
|
117
|
+
value.to_f
|
118
|
+
when :BOOLEAN
|
119
|
+
if value.to_s =~ /^(true|t|yes|y|1)$/i
|
120
|
+
true
|
121
|
+
else
|
122
|
+
false
|
123
|
+
end
|
124
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
125
|
+
inner_type = Regexp.last_match[:inner_type]
|
126
|
+
value.map { |v| _deserialize(inner_type, v) }
|
127
|
+
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
|
128
|
+
k_type = Regexp.last_match[:k_type]
|
129
|
+
v_type = Regexp.last_match[:v_type]
|
130
|
+
{}.tap do |hash|
|
131
|
+
value.each do |k, v|
|
132
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
133
|
+
end
|
134
|
+
end
|
135
|
+
else # model
|
136
|
+
_model = SquareConnect.const_get(type).new
|
137
|
+
_model.build_from_hash(value)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def to_s
|
142
|
+
to_hash.to_s
|
143
|
+
end
|
144
|
+
|
145
|
+
# to_body is an alias to to_body (backward compatibility))
|
146
|
+
def to_body
|
147
|
+
to_hash
|
148
|
+
end
|
149
|
+
|
150
|
+
# return the object in the form of hash
|
151
|
+
def to_hash
|
152
|
+
hash = {}
|
153
|
+
self.class.attribute_map.each_pair do |attr, param|
|
154
|
+
value = self.send(attr)
|
155
|
+
next if value.nil?
|
156
|
+
hash[param] = _to_hash(value)
|
157
|
+
end
|
158
|
+
hash
|
159
|
+
end
|
160
|
+
|
161
|
+
# Method to output non-array value in the form of hash
|
162
|
+
# For object, use to_hash. Otherwise, just return the value
|
163
|
+
def _to_hash(value)
|
164
|
+
if value.is_a?(Array)
|
165
|
+
value.compact.map{ |v| _to_hash(v) }
|
166
|
+
elsif value.is_a?(Hash)
|
167
|
+
{}.tap do |hash|
|
168
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
169
|
+
end
|
170
|
+
elsif value.respond_to? :to_hash
|
171
|
+
value.to_hash
|
172
|
+
else
|
173
|
+
value
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|