square_connect 2.0.0 → 2.0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +7 -0
- data/README.md +151 -9
- data/Rakefile +8 -0
- data/docs/Address.md +26 -0
- data/docs/CaptureTransactionRequest.md +11 -0
- data/docs/CaptureTransactionResponse.md +12 -0
- data/docs/Card.md +18 -0
- data/docs/CardBrand.md +20 -0
- data/docs/ChargeRequest.md +22 -0
- data/docs/ChargeResponse.md +13 -0
- data/docs/Checkout.md +20 -0
- data/docs/CheckoutApi.md +62 -0
- data/docs/Country.md +261 -0
- data/docs/CreateCheckoutRequest.md +18 -0
- data/docs/CreateCheckoutResponse.md +13 -0
- data/docs/CreateCustomerCardRequest.md +14 -0
- data/docs/CreateCustomerCardResponse.md +13 -0
- data/docs/CreateCustomerRequest.md +20 -0
- data/docs/CreateCustomerResponse.md +13 -0
- data/docs/CreateOrderRequest.md +13 -0
- data/docs/CreateOrderRequestLineItem.md +14 -0
- data/docs/CreateOrderRequestOrder.md +13 -0
- data/docs/CreateRefundRequest.md +15 -0
- data/docs/CreateRefundResponse.md +13 -0
- data/docs/Currency.md +191 -0
- data/docs/Customer.md +26 -0
- data/docs/CustomerApi.md +267 -0
- data/docs/CustomerCardApi.md +116 -0
- data/docs/CustomerGroupInfo.md +13 -0
- data/docs/CustomerPreferences.md +12 -0
- data/docs/DeleteCustomerCardRequest.md +11 -0
- data/docs/DeleteCustomerCardResponse.md +12 -0
- data/docs/DeleteCustomerRequest.md +11 -0
- data/docs/DeleteCustomerResponse.md +12 -0
- data/docs/Error.md +15 -0
- data/docs/ErrorCategory.md +17 -0
- data/docs/ErrorCode.md +83 -0
- data/docs/ListCustomersRequest.md +12 -0
- data/docs/ListCustomersResponse.md +14 -0
- data/docs/ListLocationsRequest.md +11 -0
- data/docs/ListLocationsResponse.md +13 -0
- data/docs/ListRefundsRequest.md +15 -0
- data/docs/ListRefundsResponse.md +14 -0
- data/docs/ListTransactionsRequest.md +15 -0
- data/docs/ListTransactionsResponse.md +14 -0
- data/docs/Location.md +16 -0
- data/docs/LocationApi.md +56 -0
- data/docs/LocationCapability.md +12 -0
- data/docs/Money.md +13 -0
- data/docs/Order.md +16 -0
- data/docs/OrderLineItem.md +16 -0
- data/docs/Refund.md +20 -0
- data/docs/RefundApi.md +126 -0
- data/docs/RefundStatus.md +15 -0
- data/docs/RetrieveCustomerRequest.md +11 -0
- data/docs/RetrieveCustomerResponse.md +13 -0
- data/docs/RetrieveTransactionRequest.md +11 -0
- data/docs/RetrieveTransactionResponse.md +13 -0
- data/docs/SortOrder.md +13 -0
- data/docs/Tender.md +22 -0
- data/docs/TenderCardDetails.md +14 -0
- data/docs/TenderCardDetailsEntryMethod.md +16 -0
- data/docs/TenderCardDetailsStatus.md +15 -0
- data/docs/TenderCashDetails.md +13 -0
- data/docs/TenderType.md +17 -0
- data/docs/Transaction.md +21 -0
- data/docs/TransactionApi.md +285 -0
- data/docs/TransactionProduct.md +19 -0
- data/docs/UpdateCustomerRequest.md +20 -0
- data/docs/UpdateCustomerResponse.md +13 -0
- data/docs/VoidTransactionRequest.md +11 -0
- data/docs/VoidTransactionResponse.md +12 -0
- data/lib/square_connect.rb +33 -16
- data/lib/square_connect/api/checkout_api.rb +82 -0
- data/lib/square_connect/api/customer_api.rb +121 -162
- data/lib/square_connect/api/customer_card_api.rb +31 -50
- data/lib/square_connect/api/location_api.rb +12 -20
- data/lib/square_connect/api/refund_api.rb +70 -90
- data/lib/square_connect/api/transaction_api.rb +119 -165
- data/lib/square_connect/api_client.rb +64 -17
- data/lib/square_connect/api_error.rb +7 -3
- data/lib/square_connect/configuration.rb +31 -1
- data/lib/square_connect/models/address.rb +149 -78
- data/lib/square_connect/models/capture_transaction_request.rb +176 -0
- data/lib/square_connect/models/capture_transaction_response.rb +54 -26
- data/lib/square_connect/models/card.rb +98 -52
- data/lib/square_connect/models/card_brand.rb +12 -133
- data/lib/square_connect/models/charge_request.rb +106 -67
- data/lib/square_connect/models/charge_response.rb +57 -30
- data/lib/square_connect/models/checkout.rb +266 -0
- data/lib/square_connect/models/country.rb +253 -133
- data/lib/square_connect/models/create_checkout_request.rb +316 -0
- data/lib/square_connect/models/create_checkout_response.rb +198 -0
- data/lib/square_connect/models/create_customer_card_request.rb +66 -35
- data/lib/square_connect/models/create_customer_card_response.rb +58 -31
- data/lib/square_connect/models/create_customer_request.rb +79 -59
- data/lib/square_connect/models/create_customer_response.rb +58 -31
- data/lib/square_connect/models/create_order_request.rb +234 -0
- data/lib/square_connect/models/create_order_request_line_item.rb +268 -0
- data/lib/square_connect/models/create_order_request_order.rb +219 -0
- data/lib/square_connect/models/create_refund_request.rb +79 -39
- data/lib/square_connect/models/create_refund_response.rb +57 -30
- data/lib/square_connect/models/currency.rb +183 -133
- data/lib/square_connect/models/customer.rb +130 -77
- data/lib/square_connect/models/customer_group_info.rb +206 -0
- data/lib/square_connect/models/customer_preferences.rb +186 -0
- data/lib/square_connect/models/delete_customer_card_request.rb +176 -0
- data/lib/square_connect/models/delete_customer_card_response.rb +55 -27
- data/lib/square_connect/models/delete_customer_request.rb +176 -0
- data/lib/square_connect/models/delete_customer_response.rb +55 -27
- data/lib/square_connect/models/error.rb +107 -45
- data/lib/square_connect/models/error_category.rb +9 -133
- data/lib/square_connect/models/error_code.rb +75 -133
- data/lib/square_connect/models/list_customers_request.rb +55 -27
- data/lib/square_connect/models/list_customers_response.rb +61 -35
- data/lib/square_connect/models/list_locations_request.rb +176 -0
- data/lib/square_connect/models/list_locations_response.rb +57 -30
- data/lib/square_connect/models/list_refunds_request.rb +91 -42
- data/lib/square_connect/models/list_refunds_response.rb +59 -33
- data/lib/square_connect/models/list_transactions_request.rb +91 -42
- data/lib/square_connect/models/list_transactions_response.rb +59 -33
- data/lib/square_connect/models/location.rb +86 -41
- data/lib/square_connect/models/location_capability.rb +4 -133
- data/lib/square_connect/models/money.rb +85 -34
- data/lib/square_connect/models/order.rb +228 -0
- data/lib/square_connect/models/order_line_item.rb +226 -0
- data/lib/square_connect/models/refund.rb +138 -59
- data/lib/square_connect/models/refund_status.rb +7 -133
- data/lib/square_connect/models/retrieve_customer_request.rb +176 -0
- data/lib/square_connect/models/retrieve_customer_response.rb +58 -31
- data/lib/square_connect/models/retrieve_transaction_request.rb +176 -0
- data/lib/square_connect/models/retrieve_transaction_response.rb +57 -30
- data/lib/square_connect/models/sort_order.rb +5 -133
- data/lib/square_connect/models/tender.rb +112 -65
- data/lib/square_connect/models/tender_card_details.rb +93 -40
- data/lib/square_connect/models/tender_card_details_entry_method.rb +8 -133
- data/lib/square_connect/models/tender_card_details_status.rb +7 -133
- data/lib/square_connect/models/tender_cash_details.rb +58 -31
- data/lib/square_connect/models/tender_type.rb +9 -133
- data/lib/square_connect/models/transaction.rb +132 -56
- data/lib/square_connect/models/transaction_product.rb +11 -133
- data/lib/square_connect/models/update_customer_request.rb +79 -59
- data/lib/square_connect/models/update_customer_response.rb +58 -31
- data/lib/square_connect/models/void_transaction_request.rb +176 -0
- data/lib/square_connect/models/void_transaction_response.rb +54 -26
- data/lib/square_connect/version.rb +2 -3
- data/spec/api/checkout_api_spec.rb +53 -0
- data/spec/api/customer_api_spec.rb +121 -0
- data/spec/api/customer_card_api_spec.rb +71 -0
- data/spec/api/location_api_spec.rb +58 -0
- data/spec/api/refund_api_spec.rb +75 -0
- data/spec/api/transaction_api_spec.rb +128 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/address_spec.rb +186 -0
- data/spec/models/capture_transaction_request_spec.rb +36 -0
- data/spec/models/capture_transaction_response_spec.rb +46 -0
- data/spec/models/card_brand_spec.rb +36 -0
- data/spec/models/card_spec.rb +106 -0
- data/spec/models/charge_request_spec.rb +146 -0
- data/spec/models/charge_response_spec.rb +56 -0
- data/spec/models/checkout_spec.rb +126 -0
- data/spec/models/country_spec.rb +36 -0
- data/spec/models/create_checkout_request_spec.rb +106 -0
- data/spec/models/create_checkout_response_spec.rb +56 -0
- data/spec/models/create_customer_card_request_spec.rb +66 -0
- data/spec/models/create_customer_card_response_spec.rb +56 -0
- data/spec/models/create_customer_request_spec.rb +126 -0
- data/spec/models/create_customer_response_spec.rb +56 -0
- data/spec/models/create_order_request_line_item_spec.rb +66 -0
- data/spec/models/create_order_request_order_spec.rb +56 -0
- data/spec/models/create_order_request_spec.rb +56 -0
- data/spec/models/create_refund_request_spec.rb +76 -0
- data/spec/models/create_refund_response_spec.rb +56 -0
- data/spec/models/currency_spec.rb +36 -0
- data/spec/models/customer_group_info_spec.rb +56 -0
- data/spec/models/customer_preferences_spec.rb +46 -0
- data/spec/models/customer_spec.rb +186 -0
- data/spec/models/delete_customer_card_request_spec.rb +36 -0
- data/spec/models/delete_customer_card_response_spec.rb +46 -0
- data/spec/models/delete_customer_request_spec.rb +36 -0
- data/spec/models/delete_customer_response_spec.rb +46 -0
- data/spec/models/error_category_spec.rb +36 -0
- data/spec/models/error_code_spec.rb +36 -0
- data/spec/models/error_spec.rb +76 -0
- data/spec/models/list_customers_request_spec.rb +46 -0
- data/spec/models/list_customers_response_spec.rb +66 -0
- data/spec/models/list_locations_request_spec.rb +36 -0
- data/spec/models/list_locations_response_spec.rb +56 -0
- data/spec/models/list_refunds_request_spec.rb +76 -0
- data/spec/models/list_refunds_response_spec.rb +66 -0
- data/spec/models/list_transactions_request_spec.rb +76 -0
- data/spec/models/list_transactions_response_spec.rb +66 -0
- data/spec/models/location_capability_spec.rb +36 -0
- data/spec/models/location_spec.rb +86 -0
- data/spec/models/money_spec.rb +56 -0
- data/spec/models/order_line_item_spec.rb +86 -0
- data/spec/models/order_spec.rb +86 -0
- data/spec/models/refund_spec.rb +126 -0
- data/spec/models/refund_status_spec.rb +36 -0
- data/spec/models/retrieve_customer_request_spec.rb +36 -0
- data/spec/models/retrieve_customer_response_spec.rb +56 -0
- data/spec/models/retrieve_transaction_request_spec.rb +36 -0
- data/spec/models/retrieve_transaction_response_spec.rb +56 -0
- data/spec/models/sort_order_spec.rb +36 -0
- data/spec/models/tender_card_details_entry_method_spec.rb +36 -0
- data/spec/models/tender_card_details_spec.rb +66 -0
- data/spec/models/tender_card_details_status_spec.rb +36 -0
- data/spec/models/tender_cash_details_spec.rb +56 -0
- data/spec/models/tender_spec.rb +146 -0
- data/spec/models/tender_type_spec.rb +36 -0
- data/spec/models/transaction_product_spec.rb +36 -0
- data/spec/models/transaction_spec.rb +136 -0
- data/spec/models/update_customer_request_spec.rb +126 -0
- data/spec/models/update_customer_response_spec.rb +56 -0
- data/spec/models/void_transaction_request_spec.rb +36 -0
- data/spec/models/void_transaction_response_spec.rb +46 -0
- data/spec/spec_helper.rb +115 -0
- data/square_connect.gemspec +22 -11
- data/travis-ci/accounts.enc +0 -0
- metadata +264 -31
@@ -1,17 +1,16 @@
|
|
1
1
|
=begin
|
2
|
-
Square Connect API
|
2
|
+
#Square Connect API
|
3
3
|
|
4
4
|
OpenAPI spec version: 2.0
|
5
5
|
|
6
6
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
7
7
|
|
8
|
-
|
9
8
|
=end
|
10
9
|
|
11
10
|
require 'date'
|
12
11
|
|
13
12
|
module SquareConnect
|
14
|
-
#
|
13
|
+
# Represents one of a business's customers, which can have one or more cards on file associated with it.
|
15
14
|
class Customer
|
16
15
|
# The customer's unique ID.
|
17
16
|
attr_accessor :id
|
@@ -19,69 +18,64 @@ module SquareConnect
|
|
19
18
|
# The time when the customer was created, in RFC 3339 format.
|
20
19
|
attr_accessor :created_at
|
21
20
|
|
22
|
-
# The time when the customer was updated, in RFC 3339 format.
|
21
|
+
# The time when the customer was last updated, in RFC 3339 format.
|
23
22
|
attr_accessor :updated_at
|
24
23
|
|
25
|
-
#
|
24
|
+
# The non-confidential details of the customer's cards on file.
|
26
25
|
attr_accessor :cards
|
27
26
|
|
28
|
-
#
|
27
|
+
# The customer's given (i.e., first) name.
|
29
28
|
attr_accessor :given_name
|
30
29
|
|
31
|
-
#
|
30
|
+
# The customer's family (i.e., last) name.
|
32
31
|
attr_accessor :family_name
|
33
32
|
|
34
|
-
#
|
33
|
+
# The customer's nickname.
|
35
34
|
attr_accessor :nickname
|
36
35
|
|
37
|
-
#
|
36
|
+
# The name of the customer's company.
|
38
37
|
attr_accessor :company_name
|
39
38
|
|
40
|
-
#
|
39
|
+
# The customer's email address.
|
41
40
|
attr_accessor :email_address
|
42
41
|
|
43
|
-
#
|
42
|
+
# The customer's physical address.
|
44
43
|
attr_accessor :address
|
45
44
|
|
46
|
-
#
|
45
|
+
# The customer's phone number.
|
47
46
|
attr_accessor :phone_number
|
48
47
|
|
49
|
-
#
|
48
|
+
# A second ID you can set to associate the customer with an entity in another system.
|
50
49
|
attr_accessor :reference_id
|
51
50
|
|
52
|
-
#
|
51
|
+
# A note to associate with the customer.
|
53
52
|
attr_accessor :note
|
54
53
|
|
54
|
+
# The customer's preferences.
|
55
|
+
attr_accessor :preferences
|
56
|
+
|
57
|
+
# The groups the customer belongs to.
|
58
|
+
attr_accessor :groups
|
59
|
+
|
60
|
+
|
55
61
|
# Attribute mapping from ruby-style variable name to JSON key.
|
56
62
|
def self.attribute_map
|
57
63
|
{
|
58
|
-
|
59
64
|
:'id' => :'id',
|
60
|
-
|
61
65
|
:'created_at' => :'created_at',
|
62
|
-
|
63
66
|
:'updated_at' => :'updated_at',
|
64
|
-
|
65
67
|
:'cards' => :'cards',
|
66
|
-
|
67
68
|
:'given_name' => :'given_name',
|
68
|
-
|
69
69
|
:'family_name' => :'family_name',
|
70
|
-
|
71
70
|
:'nickname' => :'nickname',
|
72
|
-
|
73
71
|
:'company_name' => :'company_name',
|
74
|
-
|
75
72
|
:'email_address' => :'email_address',
|
76
|
-
|
77
73
|
:'address' => :'address',
|
78
|
-
|
79
74
|
:'phone_number' => :'phone_number',
|
80
|
-
|
81
75
|
:'reference_id' => :'reference_id',
|
82
|
-
|
83
|
-
:'
|
84
|
-
|
76
|
+
:'note' => :'note',
|
77
|
+
:'preferences' => :'preferences',
|
78
|
+
:'groups' => :'groups'
|
85
79
|
}
|
86
80
|
end
|
87
81
|
|
@@ -100,75 +94,116 @@ module SquareConnect
|
|
100
94
|
:'address' => :'Address',
|
101
95
|
:'phone_number' => :'String',
|
102
96
|
:'reference_id' => :'String',
|
103
|
-
:'note' => :'String'
|
104
|
-
|
97
|
+
:'note' => :'String',
|
98
|
+
:'preferences' => :'CustomerPreferences',
|
99
|
+
:'groups' => :'Array<CustomerGroupInfo>'
|
105
100
|
}
|
106
101
|
end
|
107
102
|
|
103
|
+
# Initializes the object
|
104
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
108
105
|
def initialize(attributes = {})
|
109
106
|
return unless attributes.is_a?(Hash)
|
110
107
|
|
111
108
|
# convert string to symbol for hash key
|
112
|
-
attributes = attributes.
|
109
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
113
110
|
|
114
|
-
|
115
|
-
if attributes[:'id']
|
111
|
+
if attributes.has_key?(:'id')
|
116
112
|
self.id = attributes[:'id']
|
117
113
|
end
|
118
|
-
|
119
|
-
if attributes
|
114
|
+
|
115
|
+
if attributes.has_key?(:'created_at')
|
120
116
|
self.created_at = attributes[:'created_at']
|
121
117
|
end
|
122
|
-
|
123
|
-
if attributes
|
118
|
+
|
119
|
+
if attributes.has_key?(:'updated_at')
|
124
120
|
self.updated_at = attributes[:'updated_at']
|
125
121
|
end
|
126
|
-
|
127
|
-
if attributes
|
122
|
+
|
123
|
+
if attributes.has_key?(:'cards')
|
128
124
|
if (value = attributes[:'cards']).is_a?(Array)
|
129
125
|
self.cards = value
|
130
126
|
end
|
131
127
|
end
|
132
|
-
|
133
|
-
if attributes
|
128
|
+
|
129
|
+
if attributes.has_key?(:'given_name')
|
134
130
|
self.given_name = attributes[:'given_name']
|
135
131
|
end
|
136
|
-
|
137
|
-
if attributes
|
132
|
+
|
133
|
+
if attributes.has_key?(:'family_name')
|
138
134
|
self.family_name = attributes[:'family_name']
|
139
135
|
end
|
140
|
-
|
141
|
-
if attributes
|
136
|
+
|
137
|
+
if attributes.has_key?(:'nickname')
|
142
138
|
self.nickname = attributes[:'nickname']
|
143
139
|
end
|
144
|
-
|
145
|
-
if attributes
|
140
|
+
|
141
|
+
if attributes.has_key?(:'company_name')
|
146
142
|
self.company_name = attributes[:'company_name']
|
147
143
|
end
|
148
|
-
|
149
|
-
if attributes
|
144
|
+
|
145
|
+
if attributes.has_key?(:'email_address')
|
150
146
|
self.email_address = attributes[:'email_address']
|
151
147
|
end
|
152
|
-
|
153
|
-
if attributes
|
148
|
+
|
149
|
+
if attributes.has_key?(:'address')
|
154
150
|
self.address = attributes[:'address']
|
155
151
|
end
|
156
|
-
|
157
|
-
if attributes
|
152
|
+
|
153
|
+
if attributes.has_key?(:'phone_number')
|
158
154
|
self.phone_number = attributes[:'phone_number']
|
159
155
|
end
|
160
|
-
|
161
|
-
if attributes
|
156
|
+
|
157
|
+
if attributes.has_key?(:'reference_id')
|
162
158
|
self.reference_id = attributes[:'reference_id']
|
163
159
|
end
|
164
|
-
|
165
|
-
if attributes
|
160
|
+
|
161
|
+
if attributes.has_key?(:'note')
|
166
162
|
self.note = attributes[:'note']
|
167
163
|
end
|
168
|
-
|
164
|
+
|
165
|
+
if attributes.has_key?(:'preferences')
|
166
|
+
self.preferences = attributes[:'preferences']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.has_key?(:'groups')
|
170
|
+
if (value = attributes[:'groups']).is_a?(Array)
|
171
|
+
self.groups = value
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
178
|
+
# @return Array for valid properies with the reasons
|
179
|
+
def list_invalid_properties
|
180
|
+
invalid_properties = Array.new
|
181
|
+
if @id.nil?
|
182
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
183
|
+
end
|
184
|
+
|
185
|
+
if @created_at.nil?
|
186
|
+
invalid_properties.push("invalid value for 'created_at', created_at cannot be nil.")
|
187
|
+
end
|
188
|
+
|
189
|
+
if @updated_at.nil?
|
190
|
+
invalid_properties.push("invalid value for 'updated_at', updated_at cannot be nil.")
|
191
|
+
end
|
192
|
+
|
193
|
+
return invalid_properties
|
194
|
+
end
|
195
|
+
|
196
|
+
# Check to see if the all the properties in the model are valid
|
197
|
+
# @return true if the model is valid
|
198
|
+
def valid?
|
199
|
+
return false if @id.nil?
|
200
|
+
return false if @created_at.nil?
|
201
|
+
return false if @updated_at.nil?
|
202
|
+
return true
|
169
203
|
end
|
170
204
|
|
171
|
-
#
|
205
|
+
# Checks equality by comparing each attribute.
|
206
|
+
# @param [Object] Object to be compared
|
172
207
|
def ==(o)
|
173
208
|
return true if self.equal?(o)
|
174
209
|
self.class == o.class &&
|
@@ -184,39 +219,47 @@ module SquareConnect
|
|
184
219
|
address == o.address &&
|
185
220
|
phone_number == o.phone_number &&
|
186
221
|
reference_id == o.reference_id &&
|
187
|
-
note == o.note
|
222
|
+
note == o.note &&
|
223
|
+
preferences == o.preferences &&
|
224
|
+
groups == o.groups
|
188
225
|
end
|
189
226
|
|
190
227
|
# @see the `==` method
|
228
|
+
# @param [Object] Object to be compared
|
191
229
|
def eql?(o)
|
192
230
|
self == o
|
193
231
|
end
|
194
232
|
|
195
|
-
#
|
233
|
+
# Calculates hash code according to all attributes.
|
234
|
+
# @return [Fixnum] Hash code
|
196
235
|
def hash
|
197
|
-
[id, created_at, updated_at, cards, given_name, family_name, nickname, company_name, email_address, address, phone_number, reference_id, note].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
|
198
237
|
end
|
199
238
|
|
200
|
-
#
|
239
|
+
# Builds the object from hash
|
240
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
241
|
+
# @return [Object] Returns the model itself
|
201
242
|
def build_from_hash(attributes)
|
202
243
|
return nil unless attributes.is_a?(Hash)
|
203
244
|
self.class.swagger_types.each_pair do |key, type|
|
204
|
-
if type =~
|
245
|
+
if type =~ /\AArray<(.*)>/i
|
246
|
+
# check to ensure the input is an array given that the the attribute
|
247
|
+
# is documented as an array but the input is not
|
205
248
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
206
249
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
207
|
-
else
|
208
|
-
#TODO show warning in debug mode
|
209
250
|
end
|
210
251
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
211
252
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
212
|
-
else
|
213
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
214
|
-
end
|
253
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
215
254
|
end
|
216
255
|
|
217
256
|
self
|
218
257
|
end
|
219
258
|
|
259
|
+
# Deserializes the data based on type
|
260
|
+
# @param string type Data type
|
261
|
+
# @param string value Value to be deserialized
|
262
|
+
# @return [Object] Deserialized data
|
220
263
|
def _deserialize(type, value)
|
221
264
|
case type.to_sym
|
222
265
|
when :DateTime
|
@@ -230,15 +273,18 @@ module SquareConnect
|
|
230
273
|
when :Float
|
231
274
|
value.to_f
|
232
275
|
when :BOOLEAN
|
233
|
-
if value.to_s =~
|
276
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
234
277
|
true
|
235
278
|
else
|
236
279
|
false
|
237
280
|
end
|
281
|
+
when :Object
|
282
|
+
# generic object (usually a Hash), return directly
|
283
|
+
value
|
238
284
|
when /\AArray<(?<inner_type>.+)>\z/
|
239
285
|
inner_type = Regexp.last_match[:inner_type]
|
240
286
|
value.map { |v| _deserialize(inner_type, v) }
|
241
|
-
when /\AHash<(?<k_type
|
287
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
242
288
|
k_type = Regexp.last_match[:k_type]
|
243
289
|
v_type = Regexp.last_match[:v_type]
|
244
290
|
{}.tap do |hash|
|
@@ -247,21 +293,25 @@ module SquareConnect
|
|
247
293
|
end
|
248
294
|
end
|
249
295
|
else # model
|
250
|
-
|
251
|
-
|
296
|
+
temp_model = SquareConnect.const_get(type).new
|
297
|
+
temp_model.build_from_hash(value)
|
252
298
|
end
|
253
299
|
end
|
254
300
|
|
301
|
+
# Returns the string representation of the object
|
302
|
+
# @return [String] String presentation of the object
|
255
303
|
def to_s
|
256
304
|
to_hash.to_s
|
257
305
|
end
|
258
306
|
|
259
|
-
# to_body is an alias to
|
307
|
+
# to_body is an alias to to_hash (backward compatibility)
|
308
|
+
# @return [Hash] Returns the object in the form of hash
|
260
309
|
def to_body
|
261
310
|
to_hash
|
262
311
|
end
|
263
312
|
|
264
|
-
#
|
313
|
+
# Returns the object in the form of hash
|
314
|
+
# @return [Hash] Returns the object in the form of hash
|
265
315
|
def to_hash
|
266
316
|
hash = {}
|
267
317
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -272,8 +322,10 @@ module SquareConnect
|
|
272
322
|
hash
|
273
323
|
end
|
274
324
|
|
275
|
-
#
|
325
|
+
# Outputs non-array value in the form of hash
|
276
326
|
# For object, use to_hash. Otherwise, just return the value
|
327
|
+
# @param [Object] value Any valid value
|
328
|
+
# @return [Hash] Returns the value in the form of hash
|
277
329
|
def _to_hash(value)
|
278
330
|
if value.is_a?(Array)
|
279
331
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -289,4 +341,5 @@ module SquareConnect
|
|
289
341
|
end
|
290
342
|
|
291
343
|
end
|
344
|
+
|
292
345
|
end
|
@@ -0,0 +1,206 @@
|
|
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
|
+
=end
|
9
|
+
|
10
|
+
require 'date'
|
11
|
+
|
12
|
+
module SquareConnect
|
13
|
+
# Contains some brief information about a customer group with its identifier included.
|
14
|
+
class CustomerGroupInfo
|
15
|
+
# The ID of the customer group.
|
16
|
+
attr_accessor :id
|
17
|
+
|
18
|
+
# The name of the customer group.
|
19
|
+
attr_accessor :name
|
20
|
+
|
21
|
+
|
22
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
23
|
+
def self.attribute_map
|
24
|
+
{
|
25
|
+
:'id' => :'id',
|
26
|
+
:'name' => :'name'
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
# Attribute type mapping.
|
31
|
+
def self.swagger_types
|
32
|
+
{
|
33
|
+
:'id' => :'String',
|
34
|
+
:'name' => :'String'
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
# Initializes the object
|
39
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
40
|
+
def initialize(attributes = {})
|
41
|
+
return unless attributes.is_a?(Hash)
|
42
|
+
|
43
|
+
# convert string to symbol for hash key
|
44
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
45
|
+
|
46
|
+
if attributes.has_key?(:'id')
|
47
|
+
self.id = attributes[:'id']
|
48
|
+
end
|
49
|
+
|
50
|
+
if attributes.has_key?(:'name')
|
51
|
+
self.name = attributes[:'name']
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
57
|
+
# @return Array for valid properies with the reasons
|
58
|
+
def list_invalid_properties
|
59
|
+
invalid_properties = Array.new
|
60
|
+
if @id.nil?
|
61
|
+
invalid_properties.push("invalid value for 'id', id cannot be nil.")
|
62
|
+
end
|
63
|
+
|
64
|
+
if @name.nil?
|
65
|
+
invalid_properties.push("invalid value for 'name', name cannot be nil.")
|
66
|
+
end
|
67
|
+
|
68
|
+
return invalid_properties
|
69
|
+
end
|
70
|
+
|
71
|
+
# Check to see if the all the properties in the model are valid
|
72
|
+
# @return true if the model is valid
|
73
|
+
def valid?
|
74
|
+
return false if @id.nil?
|
75
|
+
return false if @name.nil?
|
76
|
+
return true
|
77
|
+
end
|
78
|
+
|
79
|
+
# Checks equality by comparing each attribute.
|
80
|
+
# @param [Object] Object to be compared
|
81
|
+
def ==(o)
|
82
|
+
return true if self.equal?(o)
|
83
|
+
self.class == o.class &&
|
84
|
+
id == o.id &&
|
85
|
+
name == o.name
|
86
|
+
end
|
87
|
+
|
88
|
+
# @see the `==` method
|
89
|
+
# @param [Object] Object to be compared
|
90
|
+
def eql?(o)
|
91
|
+
self == o
|
92
|
+
end
|
93
|
+
|
94
|
+
# Calculates hash code according to all attributes.
|
95
|
+
# @return [Fixnum] Hash code
|
96
|
+
def hash
|
97
|
+
[id, name].hash
|
98
|
+
end
|
99
|
+
|
100
|
+
# Builds the object from hash
|
101
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
|
+
# @return [Object] Returns the model itself
|
103
|
+
def build_from_hash(attributes)
|
104
|
+
return nil unless attributes.is_a?(Hash)
|
105
|
+
self.class.swagger_types.each_pair do |key, type|
|
106
|
+
if type =~ /\AArray<(.*)>/i
|
107
|
+
# check to ensure the input is an array given that the the attribute
|
108
|
+
# is documented as an array but the input is not
|
109
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
110
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
111
|
+
end
|
112
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
113
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
114
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
115
|
+
end
|
116
|
+
|
117
|
+
self
|
118
|
+
end
|
119
|
+
|
120
|
+
# Deserializes the data based on type
|
121
|
+
# @param string type Data type
|
122
|
+
# @param string value Value to be deserialized
|
123
|
+
# @return [Object] Deserialized data
|
124
|
+
def _deserialize(type, value)
|
125
|
+
case type.to_sym
|
126
|
+
when :DateTime
|
127
|
+
DateTime.parse(value)
|
128
|
+
when :Date
|
129
|
+
Date.parse(value)
|
130
|
+
when :String
|
131
|
+
value.to_s
|
132
|
+
when :Integer
|
133
|
+
value.to_i
|
134
|
+
when :Float
|
135
|
+
value.to_f
|
136
|
+
when :BOOLEAN
|
137
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
138
|
+
true
|
139
|
+
else
|
140
|
+
false
|
141
|
+
end
|
142
|
+
when :Object
|
143
|
+
# generic object (usually a Hash), return directly
|
144
|
+
value
|
145
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
146
|
+
inner_type = Regexp.last_match[:inner_type]
|
147
|
+
value.map { |v| _deserialize(inner_type, v) }
|
148
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
149
|
+
k_type = Regexp.last_match[:k_type]
|
150
|
+
v_type = Regexp.last_match[:v_type]
|
151
|
+
{}.tap do |hash|
|
152
|
+
value.each do |k, v|
|
153
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
else # model
|
157
|
+
temp_model = SquareConnect.const_get(type).new
|
158
|
+
temp_model.build_from_hash(value)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
# Returns the string representation of the object
|
163
|
+
# @return [String] String presentation of the object
|
164
|
+
def to_s
|
165
|
+
to_hash.to_s
|
166
|
+
end
|
167
|
+
|
168
|
+
# to_body is an alias to to_hash (backward compatibility)
|
169
|
+
# @return [Hash] Returns the object in the form of hash
|
170
|
+
def to_body
|
171
|
+
to_hash
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the object in the form of hash
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_hash
|
177
|
+
hash = {}
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
179
|
+
value = self.send(attr)
|
180
|
+
next if value.nil?
|
181
|
+
hash[param] = _to_hash(value)
|
182
|
+
end
|
183
|
+
hash
|
184
|
+
end
|
185
|
+
|
186
|
+
# Outputs non-array value in the form of hash
|
187
|
+
# For object, use to_hash. Otherwise, just return the value
|
188
|
+
# @param [Object] value Any valid value
|
189
|
+
# @return [Hash] Returns the value in the form of hash
|
190
|
+
def _to_hash(value)
|
191
|
+
if value.is_a?(Array)
|
192
|
+
value.compact.map{ |v| _to_hash(v) }
|
193
|
+
elsif value.is_a?(Hash)
|
194
|
+
{}.tap do |hash|
|
195
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
196
|
+
end
|
197
|
+
elsif value.respond_to? :to_hash
|
198
|
+
value.to_hash
|
199
|
+
else
|
200
|
+
value
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|