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,11 +1,10 @@
|
|
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'
|
@@ -25,13 +24,18 @@ module SquareConnect
|
|
25
24
|
# @return [Hash]
|
26
25
|
attr_accessor :default_headers
|
27
26
|
|
27
|
+
# Initializes the ApiClient
|
28
|
+
# @option config [Configuration] Configuration for initializing the object, default to Configuration.default
|
28
29
|
def initialize(config = Configuration.default)
|
29
30
|
@config = config
|
30
|
-
|
31
|
+
|
32
|
+
# Construct user agent string. Returns slightly different string for JRuby
|
33
|
+
@user_agent = "Square-Connect-Ruby/2.0.2"
|
34
|
+
|
31
35
|
@default_headers = {
|
32
36
|
'Content-Type' => "application/json",
|
33
|
-
'
|
34
|
-
'
|
37
|
+
'User-Agent' => @user_agent,
|
38
|
+
'Accept' => "application/json"
|
35
39
|
}
|
36
40
|
end
|
37
41
|
|
@@ -52,9 +56,18 @@ module SquareConnect
|
|
52
56
|
end
|
53
57
|
|
54
58
|
unless response.success?
|
55
|
-
|
56
|
-
|
57
|
-
|
59
|
+
if response.timed_out?
|
60
|
+
fail ApiError.new('Connection timed out')
|
61
|
+
elsif response.code == 0
|
62
|
+
# Errors from libcurl will be made visible here
|
63
|
+
fail ApiError.new(:code => 0,
|
64
|
+
:message => response.return_message)
|
65
|
+
else
|
66
|
+
fail ApiError.new(:code => response.code,
|
67
|
+
:response_headers => response.headers,
|
68
|
+
:response_body => response.body),
|
69
|
+
"#{response.status_message} - #{response.body}"
|
70
|
+
end
|
58
71
|
end
|
59
72
|
|
60
73
|
if opts[:return_type]
|
@@ -65,6 +78,15 @@ module SquareConnect
|
|
65
78
|
return data, response.code, response.headers
|
66
79
|
end
|
67
80
|
|
81
|
+
# Builds the HTTP request
|
82
|
+
#
|
83
|
+
# @param [String] http_method HTTP method/verb (e.g. POST)
|
84
|
+
# @param [String] path URL path (e.g. /account/new)
|
85
|
+
# @option opts [Hash] :header_params Header parameters
|
86
|
+
# @option opts [Hash] :query_params Query parameters
|
87
|
+
# @option opts [Hash] :form_params Query parameters
|
88
|
+
# @option opts [Object] :body HTTP body (JSON/XML)
|
89
|
+
# @return [Typhoeus::Request] A Typhoeus Request
|
68
90
|
def build_request(http_method, path, opts = {})
|
69
91
|
url = build_request_url(path)
|
70
92
|
http_method = http_method.to_sym.downcase
|
@@ -80,19 +102,24 @@ module SquareConnect
|
|
80
102
|
query_params = opts[:query_params] || {}
|
81
103
|
form_params = opts[:form_params] || {}
|
82
104
|
|
83
|
-
|
105
|
+
|
106
|
+
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
|
107
|
+
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
|
84
108
|
|
85
109
|
req_opts = {
|
86
110
|
:method => http_method,
|
87
111
|
:headers => header_params,
|
88
112
|
:params => query_params,
|
113
|
+
:params_encoding => @config.params_encoding,
|
89
114
|
:timeout => @config.timeout,
|
90
115
|
:ssl_verifypeer => @config.verify_ssl,
|
116
|
+
:ssl_verifyhost => _verify_ssl_host,
|
91
117
|
:sslcert => @config.cert_file,
|
92
118
|
:sslkey => @config.key_file,
|
93
119
|
:verbose => @config.debugging
|
94
120
|
}
|
95
121
|
|
122
|
+
# set custom cert, if provided
|
96
123
|
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
97
124
|
|
98
125
|
if [:post, :patch, :put, :delete].include?(http_method)
|
@@ -111,12 +138,16 @@ module SquareConnect
|
|
111
138
|
# application/json
|
112
139
|
# application/json; charset=UTF8
|
113
140
|
# APPLICATION/JSON
|
141
|
+
# */*
|
142
|
+
# @param [String] mime MIME
|
143
|
+
# @return [Boolean] True if the MIME is application/json
|
114
144
|
def json_mime?(mime)
|
115
|
-
|
145
|
+
(mime == "*/*") || !(mime =~ /\Aapplication\/json(;.*)?\z/i).nil?
|
116
146
|
end
|
117
147
|
|
118
148
|
# Deserialize the response to the given return type.
|
119
149
|
#
|
150
|
+
# @param [Response] response HTTP response
|
120
151
|
# @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
|
121
152
|
def deserialize(response, return_type)
|
122
153
|
body = response.body
|
@@ -147,6 +178,9 @@ module SquareConnect
|
|
147
178
|
end
|
148
179
|
|
149
180
|
# Convert data to the given return type.
|
181
|
+
# @param [Object] data Data to be converted
|
182
|
+
# @param [String] return_type Return type
|
183
|
+
# @return [Mixed] Data in a particular type
|
150
184
|
def convert_to_type(data, return_type)
|
151
185
|
return nil if data.nil?
|
152
186
|
case return_type
|
@@ -165,7 +199,7 @@ module SquareConnect
|
|
165
199
|
# parse date time (expecting ISO 8601 format)
|
166
200
|
Date.parse data
|
167
201
|
when 'Object'
|
168
|
-
# generic object, return directly
|
202
|
+
# generic object (usually a Hash), return directly
|
169
203
|
data
|
170
204
|
when /\AArray<(.+)>\z/
|
171
205
|
# e.g. Array<Pet>
|
@@ -192,7 +226,7 @@ module SquareConnect
|
|
192
226
|
# @return [Tempfile] the file downloaded
|
193
227
|
def download_file(response)
|
194
228
|
content_disposition = response.headers['Content-Disposition']
|
195
|
-
if content_disposition
|
229
|
+
if content_disposition and content_disposition =~ /filename=/i
|
196
230
|
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
197
231
|
prefix = sanitize_filename(filename)
|
198
232
|
else
|
@@ -219,7 +253,7 @@ module SquareConnect
|
|
219
253
|
# @param [String] filename the filename to be sanitized
|
220
254
|
# @return [String] the sanitized filename
|
221
255
|
def sanitize_filename(filename)
|
222
|
-
filename.gsub
|
256
|
+
filename.gsub(/.*[\/\\]/, '')
|
223
257
|
end
|
224
258
|
|
225
259
|
def build_request_url(path)
|
@@ -228,6 +262,12 @@ module SquareConnect
|
|
228
262
|
URI.encode(@config.base_url + path)
|
229
263
|
end
|
230
264
|
|
265
|
+
# Builds the HTTP request body
|
266
|
+
#
|
267
|
+
# @param [Hash] header_params Header parameters
|
268
|
+
# @param [Hash] form_params Query parameters
|
269
|
+
# @param [Object] body HTTP body (JSON/XML)
|
270
|
+
# @return [String] HTTP body data in the form of string
|
231
271
|
def build_request_body(header_params, form_params, body)
|
232
272
|
# http form
|
233
273
|
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
@@ -251,6 +291,10 @@ module SquareConnect
|
|
251
291
|
end
|
252
292
|
|
253
293
|
# Update hearder and query params based on authentication settings.
|
294
|
+
#
|
295
|
+
# @param [Hash] header_params Header parameters
|
296
|
+
# @param [Hash] query_params Query parameters
|
297
|
+
# @param [String] auth_names Authentication scheme name
|
254
298
|
def update_params_for_auth!(header_params, query_params, auth_names)
|
255
299
|
Array(auth_names).each do |auth_name|
|
256
300
|
auth_setting = @config.auth_settings[auth_name]
|
@@ -263,6 +307,9 @@ module SquareConnect
|
|
263
307
|
end
|
264
308
|
end
|
265
309
|
|
310
|
+
# Sets user agent in HTTP header
|
311
|
+
#
|
312
|
+
# @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
|
266
313
|
def user_agent=(user_agent)
|
267
314
|
@user_agent = user_agent
|
268
315
|
@default_headers['User-Agent'] = @user_agent
|
@@ -294,13 +341,13 @@ module SquareConnect
|
|
294
341
|
# @return [String] JSON string representation of the object
|
295
342
|
def object_to_http_body(model)
|
296
343
|
return model if model.nil? || model.is_a?(String)
|
297
|
-
|
344
|
+
local_body = nil
|
298
345
|
if model.is_a?(Array)
|
299
|
-
|
346
|
+
local_body = model.map{|m| object_to_hash(m) }
|
300
347
|
else
|
301
|
-
|
348
|
+
local_body = object_to_hash(model)
|
302
349
|
end
|
303
|
-
|
350
|
+
local_body.to_json
|
304
351
|
end
|
305
352
|
|
306
353
|
# Convert object(non-array) to hash.
|
@@ -1,11 +1,10 @@
|
|
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
|
module SquareConnect
|
@@ -19,7 +18,12 @@ module SquareConnect
|
|
19
18
|
# ApiError.new(:code => 404, :message => "Not Found")
|
20
19
|
def initialize(arg = nil)
|
21
20
|
if arg.is_a? Hash
|
22
|
-
|
21
|
+
if arg.key?(:message) || arg.key?('message')
|
22
|
+
super(arg[:message] || arg['message'])
|
23
|
+
else
|
24
|
+
super arg
|
25
|
+
end
|
26
|
+
|
23
27
|
arg.each do |k, v|
|
24
28
|
instance_variable_set "@#{k}", v
|
25
29
|
end
|
@@ -1,3 +1,12 @@
|
|
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
|
+
|
1
10
|
require 'uri'
|
2
11
|
|
3
12
|
module SquareConnect
|
@@ -64,7 +73,7 @@ module SquareConnect
|
|
64
73
|
# Default to 0 (never times out).
|
65
74
|
attr_accessor :timeout
|
66
75
|
|
67
|
-
### TLS/SSL
|
76
|
+
### TLS/SSL setting
|
68
77
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
69
78
|
# Default to true.
|
70
79
|
#
|
@@ -73,6 +82,16 @@ module SquareConnect
|
|
73
82
|
# @return [true, false]
|
74
83
|
attr_accessor :verify_ssl
|
75
84
|
|
85
|
+
### TLS/SSL setting
|
86
|
+
# Set this to false to skip verifying SSL host name
|
87
|
+
# Default to true.
|
88
|
+
#
|
89
|
+
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
90
|
+
#
|
91
|
+
# @return [true, false]
|
92
|
+
attr_accessor :verify_ssl_host
|
93
|
+
|
94
|
+
### TLS/SSL setting
|
76
95
|
# Set this to customize the certificate file to verify the peer.
|
77
96
|
#
|
78
97
|
# @return [String] the path to the certificate file
|
@@ -81,12 +100,21 @@ module SquareConnect
|
|
81
100
|
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
82
101
|
attr_accessor :ssl_ca_cert
|
83
102
|
|
103
|
+
### TLS/SSL setting
|
84
104
|
# Client certificate file (for client certificate)
|
85
105
|
attr_accessor :cert_file
|
86
106
|
|
107
|
+
### TLS/SSL setting
|
87
108
|
# Client private key file (for client certificate)
|
88
109
|
attr_accessor :key_file
|
89
110
|
|
111
|
+
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
112
|
+
# Default to nil.
|
113
|
+
#
|
114
|
+
# @see The params_encoding option of Ethon. Related source code:
|
115
|
+
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
116
|
+
attr_accessor :params_encoding
|
117
|
+
|
90
118
|
attr_accessor :inject_format
|
91
119
|
|
92
120
|
attr_accessor :force_ending_format
|
@@ -99,6 +127,8 @@ module SquareConnect
|
|
99
127
|
@api_key_prefix = {}
|
100
128
|
@timeout = 0
|
101
129
|
@verify_ssl = true
|
130
|
+
@verify_ssl_host = true
|
131
|
+
@params_encoding = nil
|
102
132
|
@cert_file = nil
|
103
133
|
@key_file = nil
|
104
134
|
@debugging = false
|
@@ -1,82 +1,102 @@
|
|
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 a physical address.
|
15
14
|
class Address
|
16
|
-
#
|
15
|
+
# The first line of the address. Fields that start with `address_line` provide the address's most specific details, like street number, street name, and building name. They do *not* provide less specific details like city, state/province, or country (these details are provided in other fields).
|
17
16
|
attr_accessor :address_line_1
|
18
17
|
|
19
|
-
#
|
18
|
+
# The second line of the address, if any.
|
20
19
|
attr_accessor :address_line_2
|
21
20
|
|
22
|
-
#
|
21
|
+
# The third line of the address, if any.
|
23
22
|
attr_accessor :address_line_3
|
24
23
|
|
25
|
-
#
|
24
|
+
# The city or town of the address.
|
26
25
|
attr_accessor :locality
|
27
26
|
|
28
|
-
#
|
27
|
+
# A civil region within the address's `locality`, if any.
|
29
28
|
attr_accessor :sublocality
|
30
29
|
|
31
|
-
#
|
30
|
+
# A civil region within the address's `sublocality`, if any.
|
32
31
|
attr_accessor :sublocality_2
|
33
32
|
|
34
|
-
#
|
33
|
+
# A civil region within the address's `sublocality_2`, if any.
|
35
34
|
attr_accessor :sublocality_3
|
36
35
|
|
37
|
-
#
|
36
|
+
# A civil entity within the address's country. In the US, this is the state.
|
38
37
|
attr_accessor :administrative_district_level_1
|
39
38
|
|
40
|
-
#
|
39
|
+
# A civil entity within the address's `administrative_district_level_1`. In the US, this is the county.
|
41
40
|
attr_accessor :administrative_district_level_2
|
42
41
|
|
43
|
-
#
|
42
|
+
# A civil entity within the address's `administrative_district_level_2`, if any.
|
44
43
|
attr_accessor :administrative_district_level_3
|
45
44
|
|
46
|
-
#
|
45
|
+
# The address's postal code.
|
47
46
|
attr_accessor :postal_code
|
48
47
|
|
49
|
-
#
|
48
|
+
# The address's country, in ISO 3166-1-alpha-2 format.
|
50
49
|
attr_accessor :country
|
51
50
|
|
51
|
+
# Optional first name when it's representing recipient.
|
52
|
+
attr_accessor :first_name
|
53
|
+
|
54
|
+
# Optional last name when it's representing recipient.
|
55
|
+
attr_accessor :last_name
|
56
|
+
|
57
|
+
# Optional organization name when it's representing recipient.
|
58
|
+
attr_accessor :organization
|
59
|
+
|
60
|
+
class EnumAttributeValidator
|
61
|
+
attr_reader :datatype
|
62
|
+
attr_reader :allowable_values
|
63
|
+
|
64
|
+
def initialize(datatype, allowable_values)
|
65
|
+
@allowable_values = allowable_values.map do |value|
|
66
|
+
case datatype.to_s
|
67
|
+
when /Integer/i
|
68
|
+
value.to_i
|
69
|
+
when /Float/i
|
70
|
+
value.to_f
|
71
|
+
else
|
72
|
+
value
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def valid?(value)
|
78
|
+
!value || allowable_values.include?(value)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
52
82
|
# Attribute mapping from ruby-style variable name to JSON key.
|
53
83
|
def self.attribute_map
|
54
84
|
{
|
55
|
-
|
56
85
|
:'address_line_1' => :'address_line_1',
|
57
|
-
|
58
86
|
:'address_line_2' => :'address_line_2',
|
59
|
-
|
60
87
|
:'address_line_3' => :'address_line_3',
|
61
|
-
|
62
88
|
:'locality' => :'locality',
|
63
|
-
|
64
89
|
:'sublocality' => :'sublocality',
|
65
|
-
|
66
90
|
:'sublocality_2' => :'sublocality_2',
|
67
|
-
|
68
91
|
:'sublocality_3' => :'sublocality_3',
|
69
|
-
|
70
92
|
:'administrative_district_level_1' => :'administrative_district_level_1',
|
71
|
-
|
72
93
|
:'administrative_district_level_2' => :'administrative_district_level_2',
|
73
|
-
|
74
94
|
:'administrative_district_level_3' => :'administrative_district_level_3',
|
75
|
-
|
76
95
|
:'postal_code' => :'postal_code',
|
77
|
-
|
78
|
-
:'
|
79
|
-
|
96
|
+
:'country' => :'country',
|
97
|
+
:'first_name' => :'first_name',
|
98
|
+
:'last_name' => :'last_name',
|
99
|
+
:'organization' => :'organization'
|
80
100
|
}
|
81
101
|
end
|
82
102
|
|
@@ -94,78 +114,110 @@ module SquareConnect
|
|
94
114
|
:'administrative_district_level_2' => :'String',
|
95
115
|
:'administrative_district_level_3' => :'String',
|
96
116
|
:'postal_code' => :'String',
|
97
|
-
:'country' => :'String'
|
98
|
-
|
117
|
+
:'country' => :'String',
|
118
|
+
:'first_name' => :'String',
|
119
|
+
:'last_name' => :'String',
|
120
|
+
:'organization' => :'String'
|
99
121
|
}
|
100
122
|
end
|
101
123
|
|
124
|
+
# Initializes the object
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
102
126
|
def initialize(attributes = {})
|
103
127
|
return unless attributes.is_a?(Hash)
|
104
128
|
|
105
129
|
# convert string to symbol for hash key
|
106
|
-
attributes = attributes.
|
130
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
107
131
|
|
108
|
-
|
109
|
-
if attributes[:'address_line_1']
|
132
|
+
if attributes.has_key?(:'address_line_1')
|
110
133
|
self.address_line_1 = attributes[:'address_line_1']
|
111
134
|
end
|
112
|
-
|
113
|
-
if attributes
|
135
|
+
|
136
|
+
if attributes.has_key?(:'address_line_2')
|
114
137
|
self.address_line_2 = attributes[:'address_line_2']
|
115
138
|
end
|
116
|
-
|
117
|
-
if attributes
|
139
|
+
|
140
|
+
if attributes.has_key?(:'address_line_3')
|
118
141
|
self.address_line_3 = attributes[:'address_line_3']
|
119
142
|
end
|
120
|
-
|
121
|
-
if attributes
|
143
|
+
|
144
|
+
if attributes.has_key?(:'locality')
|
122
145
|
self.locality = attributes[:'locality']
|
123
146
|
end
|
124
|
-
|
125
|
-
if attributes
|
147
|
+
|
148
|
+
if attributes.has_key?(:'sublocality')
|
126
149
|
self.sublocality = attributes[:'sublocality']
|
127
150
|
end
|
128
|
-
|
129
|
-
if attributes
|
151
|
+
|
152
|
+
if attributes.has_key?(:'sublocality_2')
|
130
153
|
self.sublocality_2 = attributes[:'sublocality_2']
|
131
154
|
end
|
132
|
-
|
133
|
-
if attributes
|
155
|
+
|
156
|
+
if attributes.has_key?(:'sublocality_3')
|
134
157
|
self.sublocality_3 = attributes[:'sublocality_3']
|
135
158
|
end
|
136
|
-
|
137
|
-
if attributes
|
159
|
+
|
160
|
+
if attributes.has_key?(:'administrative_district_level_1')
|
138
161
|
self.administrative_district_level_1 = attributes[:'administrative_district_level_1']
|
139
162
|
end
|
140
|
-
|
141
|
-
if attributes
|
163
|
+
|
164
|
+
if attributes.has_key?(:'administrative_district_level_2')
|
142
165
|
self.administrative_district_level_2 = attributes[:'administrative_district_level_2']
|
143
166
|
end
|
144
|
-
|
145
|
-
if attributes
|
167
|
+
|
168
|
+
if attributes.has_key?(:'administrative_district_level_3')
|
146
169
|
self.administrative_district_level_3 = attributes[:'administrative_district_level_3']
|
147
170
|
end
|
148
|
-
|
149
|
-
if attributes
|
171
|
+
|
172
|
+
if attributes.has_key?(:'postal_code')
|
150
173
|
self.postal_code = attributes[:'postal_code']
|
151
174
|
end
|
152
|
-
|
153
|
-
if attributes
|
175
|
+
|
176
|
+
if attributes.has_key?(:'country')
|
154
177
|
self.country = attributes[:'country']
|
155
178
|
end
|
156
|
-
|
179
|
+
|
180
|
+
if attributes.has_key?(:'first_name')
|
181
|
+
self.first_name = attributes[:'first_name']
|
182
|
+
end
|
183
|
+
|
184
|
+
if attributes.has_key?(:'last_name')
|
185
|
+
self.last_name = attributes[:'last_name']
|
186
|
+
end
|
187
|
+
|
188
|
+
if attributes.has_key?(:'organization')
|
189
|
+
self.organization = attributes[:'organization']
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
195
|
+
# @return Array for valid properies with the reasons
|
196
|
+
def list_invalid_properties
|
197
|
+
invalid_properties = Array.new
|
198
|
+
return invalid_properties
|
199
|
+
end
|
200
|
+
|
201
|
+
# Check to see if the all the properties in the model are valid
|
202
|
+
# @return true if the model is valid
|
203
|
+
def valid?
|
204
|
+
country_validator = EnumAttributeValidator.new('String', ["ZZ", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"])
|
205
|
+
return false unless country_validator.valid?(@country)
|
206
|
+
return true
|
157
207
|
end
|
158
208
|
|
159
209
|
# Custom attribute writer method checking allowed values (enum).
|
210
|
+
# @param [Object] country Object to be assigned
|
160
211
|
def country=(country)
|
161
|
-
|
162
|
-
|
163
|
-
fail "invalid value for 'country', must be one of #{
|
212
|
+
validator = EnumAttributeValidator.new('String', ["ZZ", "AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS", "YE", "YT", "ZA", "ZM", "ZW"])
|
213
|
+
unless validator.valid?(country)
|
214
|
+
fail ArgumentError, "invalid value for 'country', must be one of #{validator.allowable_values}."
|
164
215
|
end
|
165
216
|
@country = country
|
166
217
|
end
|
167
218
|
|
168
|
-
#
|
219
|
+
# Checks equality by comparing each attribute.
|
220
|
+
# @param [Object] Object to be compared
|
169
221
|
def ==(o)
|
170
222
|
return true if self.equal?(o)
|
171
223
|
self.class == o.class &&
|
@@ -180,39 +232,48 @@ module SquareConnect
|
|
180
232
|
administrative_district_level_2 == o.administrative_district_level_2 &&
|
181
233
|
administrative_district_level_3 == o.administrative_district_level_3 &&
|
182
234
|
postal_code == o.postal_code &&
|
183
|
-
country == o.country
|
235
|
+
country == o.country &&
|
236
|
+
first_name == o.first_name &&
|
237
|
+
last_name == o.last_name &&
|
238
|
+
organization == o.organization
|
184
239
|
end
|
185
240
|
|
186
241
|
# @see the `==` method
|
242
|
+
# @param [Object] Object to be compared
|
187
243
|
def eql?(o)
|
188
244
|
self == o
|
189
245
|
end
|
190
246
|
|
191
|
-
#
|
247
|
+
# Calculates hash code according to all attributes.
|
248
|
+
# @return [Fixnum] Hash code
|
192
249
|
def hash
|
193
|
-
[address_line_1, address_line_2, address_line_3, locality, sublocality, sublocality_2, sublocality_3, administrative_district_level_1, administrative_district_level_2, administrative_district_level_3, postal_code, country].hash
|
250
|
+
[address_line_1, address_line_2, address_line_3, locality, sublocality, sublocality_2, sublocality_3, administrative_district_level_1, administrative_district_level_2, administrative_district_level_3, postal_code, country, first_name, last_name, organization].hash
|
194
251
|
end
|
195
252
|
|
196
|
-
#
|
253
|
+
# Builds the object from hash
|
254
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
255
|
+
# @return [Object] Returns the model itself
|
197
256
|
def build_from_hash(attributes)
|
198
257
|
return nil unless attributes.is_a?(Hash)
|
199
258
|
self.class.swagger_types.each_pair do |key, type|
|
200
|
-
if type =~
|
259
|
+
if type =~ /\AArray<(.*)>/i
|
260
|
+
# check to ensure the input is an array given that the the attribute
|
261
|
+
# is documented as an array but the input is not
|
201
262
|
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
202
263
|
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
203
|
-
else
|
204
|
-
#TODO show warning in debug mode
|
205
264
|
end
|
206
265
|
elsif !attributes[self.class.attribute_map[key]].nil?
|
207
266
|
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
208
|
-
else
|
209
|
-
# data not found in attributes(hash), not an issue as the data can be optional
|
210
|
-
end
|
267
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
211
268
|
end
|
212
269
|
|
213
270
|
self
|
214
271
|
end
|
215
272
|
|
273
|
+
# Deserializes the data based on type
|
274
|
+
# @param string type Data type
|
275
|
+
# @param string value Value to be deserialized
|
276
|
+
# @return [Object] Deserialized data
|
216
277
|
def _deserialize(type, value)
|
217
278
|
case type.to_sym
|
218
279
|
when :DateTime
|
@@ -226,15 +287,18 @@ module SquareConnect
|
|
226
287
|
when :Float
|
227
288
|
value.to_f
|
228
289
|
when :BOOLEAN
|
229
|
-
if value.to_s =~
|
290
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
230
291
|
true
|
231
292
|
else
|
232
293
|
false
|
233
294
|
end
|
295
|
+
when :Object
|
296
|
+
# generic object (usually a Hash), return directly
|
297
|
+
value
|
234
298
|
when /\AArray<(?<inner_type>.+)>\z/
|
235
299
|
inner_type = Regexp.last_match[:inner_type]
|
236
300
|
value.map { |v| _deserialize(inner_type, v) }
|
237
|
-
when /\AHash<(?<k_type
|
301
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
238
302
|
k_type = Regexp.last_match[:k_type]
|
239
303
|
v_type = Regexp.last_match[:v_type]
|
240
304
|
{}.tap do |hash|
|
@@ -243,21 +307,25 @@ module SquareConnect
|
|
243
307
|
end
|
244
308
|
end
|
245
309
|
else # model
|
246
|
-
|
247
|
-
|
310
|
+
temp_model = SquareConnect.const_get(type).new
|
311
|
+
temp_model.build_from_hash(value)
|
248
312
|
end
|
249
313
|
end
|
250
314
|
|
315
|
+
# Returns the string representation of the object
|
316
|
+
# @return [String] String presentation of the object
|
251
317
|
def to_s
|
252
318
|
to_hash.to_s
|
253
319
|
end
|
254
320
|
|
255
|
-
# to_body is an alias to
|
321
|
+
# to_body is an alias to to_hash (backward compatibility)
|
322
|
+
# @return [Hash] Returns the object in the form of hash
|
256
323
|
def to_body
|
257
324
|
to_hash
|
258
325
|
end
|
259
326
|
|
260
|
-
#
|
327
|
+
# Returns the object in the form of hash
|
328
|
+
# @return [Hash] Returns the object in the form of hash
|
261
329
|
def to_hash
|
262
330
|
hash = {}
|
263
331
|
self.class.attribute_map.each_pair do |attr, param|
|
@@ -268,8 +336,10 @@ module SquareConnect
|
|
268
336
|
hash
|
269
337
|
end
|
270
338
|
|
271
|
-
#
|
339
|
+
# Outputs non-array value in the form of hash
|
272
340
|
# For object, use to_hash. Otherwise, just return the value
|
341
|
+
# @param [Object] value Any valid value
|
342
|
+
# @return [Hash] Returns the value in the form of hash
|
273
343
|
def _to_hash(value)
|
274
344
|
if value.is_a?(Array)
|
275
345
|
value.compact.map{ |v| _to_hash(v) }
|
@@ -285,4 +355,5 @@ module SquareConnect
|
|
285
355
|
end
|
286
356
|
|
287
357
|
end
|
358
|
+
|
288
359
|
end
|