square_connect 2.0.0 → 2.0.2.13

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.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -0
  3. data/README.md +151 -9
  4. data/Rakefile +8 -0
  5. data/docs/Address.md +26 -0
  6. data/docs/CaptureTransactionRequest.md +11 -0
  7. data/docs/CaptureTransactionResponse.md +12 -0
  8. data/docs/Card.md +18 -0
  9. data/docs/CardBrand.md +20 -0
  10. data/docs/ChargeRequest.md +22 -0
  11. data/docs/ChargeResponse.md +13 -0
  12. data/docs/Checkout.md +20 -0
  13. data/docs/CheckoutApi.md +62 -0
  14. data/docs/Country.md +261 -0
  15. data/docs/CreateCheckoutRequest.md +18 -0
  16. data/docs/CreateCheckoutResponse.md +13 -0
  17. data/docs/CreateCustomerCardRequest.md +14 -0
  18. data/docs/CreateCustomerCardResponse.md +13 -0
  19. data/docs/CreateCustomerRequest.md +20 -0
  20. data/docs/CreateCustomerResponse.md +13 -0
  21. data/docs/CreateOrderRequest.md +13 -0
  22. data/docs/CreateOrderRequestLineItem.md +14 -0
  23. data/docs/CreateOrderRequestOrder.md +13 -0
  24. data/docs/CreateRefundRequest.md +15 -0
  25. data/docs/CreateRefundResponse.md +13 -0
  26. data/docs/Currency.md +191 -0
  27. data/docs/Customer.md +26 -0
  28. data/docs/CustomerApi.md +267 -0
  29. data/docs/CustomerCardApi.md +116 -0
  30. data/docs/CustomerGroupInfo.md +13 -0
  31. data/docs/CustomerPreferences.md +12 -0
  32. data/docs/DeleteCustomerCardRequest.md +11 -0
  33. data/docs/DeleteCustomerCardResponse.md +12 -0
  34. data/docs/DeleteCustomerRequest.md +11 -0
  35. data/docs/DeleteCustomerResponse.md +12 -0
  36. data/docs/Error.md +15 -0
  37. data/docs/ErrorCategory.md +17 -0
  38. data/docs/ErrorCode.md +83 -0
  39. data/docs/ListCustomersRequest.md +12 -0
  40. data/docs/ListCustomersResponse.md +14 -0
  41. data/docs/ListLocationsRequest.md +11 -0
  42. data/docs/ListLocationsResponse.md +13 -0
  43. data/docs/ListRefundsRequest.md +15 -0
  44. data/docs/ListRefundsResponse.md +14 -0
  45. data/docs/ListTransactionsRequest.md +15 -0
  46. data/docs/ListTransactionsResponse.md +14 -0
  47. data/docs/Location.md +16 -0
  48. data/docs/LocationApi.md +56 -0
  49. data/docs/LocationCapability.md +12 -0
  50. data/docs/Money.md +13 -0
  51. data/docs/Order.md +16 -0
  52. data/docs/OrderLineItem.md +16 -0
  53. data/docs/Refund.md +20 -0
  54. data/docs/RefundApi.md +126 -0
  55. data/docs/RefundStatus.md +15 -0
  56. data/docs/RetrieveCustomerRequest.md +11 -0
  57. data/docs/RetrieveCustomerResponse.md +13 -0
  58. data/docs/RetrieveTransactionRequest.md +11 -0
  59. data/docs/RetrieveTransactionResponse.md +13 -0
  60. data/docs/SortOrder.md +13 -0
  61. data/docs/Tender.md +22 -0
  62. data/docs/TenderCardDetails.md +14 -0
  63. data/docs/TenderCardDetailsEntryMethod.md +16 -0
  64. data/docs/TenderCardDetailsStatus.md +15 -0
  65. data/docs/TenderCashDetails.md +13 -0
  66. data/docs/TenderType.md +17 -0
  67. data/docs/Transaction.md +21 -0
  68. data/docs/TransactionApi.md +285 -0
  69. data/docs/TransactionProduct.md +19 -0
  70. data/docs/UpdateCustomerRequest.md +20 -0
  71. data/docs/UpdateCustomerResponse.md +13 -0
  72. data/docs/VoidTransactionRequest.md +11 -0
  73. data/docs/VoidTransactionResponse.md +12 -0
  74. data/lib/square_connect.rb +33 -16
  75. data/lib/square_connect/api/checkout_api.rb +82 -0
  76. data/lib/square_connect/api/customer_api.rb +121 -162
  77. data/lib/square_connect/api/customer_card_api.rb +31 -50
  78. data/lib/square_connect/api/location_api.rb +12 -20
  79. data/lib/square_connect/api/refund_api.rb +70 -90
  80. data/lib/square_connect/api/transaction_api.rb +119 -165
  81. data/lib/square_connect/api_client.rb +64 -17
  82. data/lib/square_connect/api_error.rb +7 -3
  83. data/lib/square_connect/configuration.rb +31 -1
  84. data/lib/square_connect/models/address.rb +149 -78
  85. data/lib/square_connect/models/capture_transaction_request.rb +176 -0
  86. data/lib/square_connect/models/capture_transaction_response.rb +54 -26
  87. data/lib/square_connect/models/card.rb +98 -52
  88. data/lib/square_connect/models/card_brand.rb +12 -133
  89. data/lib/square_connect/models/charge_request.rb +106 -67
  90. data/lib/square_connect/models/charge_response.rb +57 -30
  91. data/lib/square_connect/models/checkout.rb +266 -0
  92. data/lib/square_connect/models/country.rb +253 -133
  93. data/lib/square_connect/models/create_checkout_request.rb +316 -0
  94. data/lib/square_connect/models/create_checkout_response.rb +198 -0
  95. data/lib/square_connect/models/create_customer_card_request.rb +66 -35
  96. data/lib/square_connect/models/create_customer_card_response.rb +58 -31
  97. data/lib/square_connect/models/create_customer_request.rb +79 -59
  98. data/lib/square_connect/models/create_customer_response.rb +58 -31
  99. data/lib/square_connect/models/create_order_request.rb +234 -0
  100. data/lib/square_connect/models/create_order_request_line_item.rb +268 -0
  101. data/lib/square_connect/models/create_order_request_order.rb +219 -0
  102. data/lib/square_connect/models/create_refund_request.rb +79 -39
  103. data/lib/square_connect/models/create_refund_response.rb +57 -30
  104. data/lib/square_connect/models/currency.rb +183 -133
  105. data/lib/square_connect/models/customer.rb +130 -77
  106. data/lib/square_connect/models/customer_group_info.rb +206 -0
  107. data/lib/square_connect/models/customer_preferences.rb +186 -0
  108. data/lib/square_connect/models/delete_customer_card_request.rb +176 -0
  109. data/lib/square_connect/models/delete_customer_card_response.rb +55 -27
  110. data/lib/square_connect/models/delete_customer_request.rb +176 -0
  111. data/lib/square_connect/models/delete_customer_response.rb +55 -27
  112. data/lib/square_connect/models/error.rb +107 -45
  113. data/lib/square_connect/models/error_category.rb +9 -133
  114. data/lib/square_connect/models/error_code.rb +75 -133
  115. data/lib/square_connect/models/list_customers_request.rb +55 -27
  116. data/lib/square_connect/models/list_customers_response.rb +61 -35
  117. data/lib/square_connect/models/list_locations_request.rb +176 -0
  118. data/lib/square_connect/models/list_locations_response.rb +57 -30
  119. data/lib/square_connect/models/list_refunds_request.rb +91 -42
  120. data/lib/square_connect/models/list_refunds_response.rb +59 -33
  121. data/lib/square_connect/models/list_transactions_request.rb +91 -42
  122. data/lib/square_connect/models/list_transactions_response.rb +59 -33
  123. data/lib/square_connect/models/location.rb +86 -41
  124. data/lib/square_connect/models/location_capability.rb +4 -133
  125. data/lib/square_connect/models/money.rb +85 -34
  126. data/lib/square_connect/models/order.rb +228 -0
  127. data/lib/square_connect/models/order_line_item.rb +226 -0
  128. data/lib/square_connect/models/refund.rb +138 -59
  129. data/lib/square_connect/models/refund_status.rb +7 -133
  130. data/lib/square_connect/models/retrieve_customer_request.rb +176 -0
  131. data/lib/square_connect/models/retrieve_customer_response.rb +58 -31
  132. data/lib/square_connect/models/retrieve_transaction_request.rb +176 -0
  133. data/lib/square_connect/models/retrieve_transaction_response.rb +57 -30
  134. data/lib/square_connect/models/sort_order.rb +5 -133
  135. data/lib/square_connect/models/tender.rb +112 -65
  136. data/lib/square_connect/models/tender_card_details.rb +93 -40
  137. data/lib/square_connect/models/tender_card_details_entry_method.rb +8 -133
  138. data/lib/square_connect/models/tender_card_details_status.rb +7 -133
  139. data/lib/square_connect/models/tender_cash_details.rb +58 -31
  140. data/lib/square_connect/models/tender_type.rb +9 -133
  141. data/lib/square_connect/models/transaction.rb +132 -56
  142. data/lib/square_connect/models/transaction_product.rb +11 -133
  143. data/lib/square_connect/models/update_customer_request.rb +79 -59
  144. data/lib/square_connect/models/update_customer_response.rb +58 -31
  145. data/lib/square_connect/models/void_transaction_request.rb +176 -0
  146. data/lib/square_connect/models/void_transaction_response.rb +54 -26
  147. data/lib/square_connect/version.rb +2 -3
  148. data/spec/api/checkout_api_spec.rb +53 -0
  149. data/spec/api/customer_api_spec.rb +121 -0
  150. data/spec/api/customer_card_api_spec.rb +71 -0
  151. data/spec/api/location_api_spec.rb +58 -0
  152. data/spec/api/refund_api_spec.rb +75 -0
  153. data/spec/api/transaction_api_spec.rb +128 -0
  154. data/spec/api_client_spec.rb +226 -0
  155. data/spec/configuration_spec.rb +42 -0
  156. data/spec/models/address_spec.rb +186 -0
  157. data/spec/models/capture_transaction_request_spec.rb +36 -0
  158. data/spec/models/capture_transaction_response_spec.rb +46 -0
  159. data/spec/models/card_brand_spec.rb +36 -0
  160. data/spec/models/card_spec.rb +106 -0
  161. data/spec/models/charge_request_spec.rb +146 -0
  162. data/spec/models/charge_response_spec.rb +56 -0
  163. data/spec/models/checkout_spec.rb +126 -0
  164. data/spec/models/country_spec.rb +36 -0
  165. data/spec/models/create_checkout_request_spec.rb +106 -0
  166. data/spec/models/create_checkout_response_spec.rb +56 -0
  167. data/spec/models/create_customer_card_request_spec.rb +66 -0
  168. data/spec/models/create_customer_card_response_spec.rb +56 -0
  169. data/spec/models/create_customer_request_spec.rb +126 -0
  170. data/spec/models/create_customer_response_spec.rb +56 -0
  171. data/spec/models/create_order_request_line_item_spec.rb +66 -0
  172. data/spec/models/create_order_request_order_spec.rb +56 -0
  173. data/spec/models/create_order_request_spec.rb +56 -0
  174. data/spec/models/create_refund_request_spec.rb +76 -0
  175. data/spec/models/create_refund_response_spec.rb +56 -0
  176. data/spec/models/currency_spec.rb +36 -0
  177. data/spec/models/customer_group_info_spec.rb +56 -0
  178. data/spec/models/customer_preferences_spec.rb +46 -0
  179. data/spec/models/customer_spec.rb +186 -0
  180. data/spec/models/delete_customer_card_request_spec.rb +36 -0
  181. data/spec/models/delete_customer_card_response_spec.rb +46 -0
  182. data/spec/models/delete_customer_request_spec.rb +36 -0
  183. data/spec/models/delete_customer_response_spec.rb +46 -0
  184. data/spec/models/error_category_spec.rb +36 -0
  185. data/spec/models/error_code_spec.rb +36 -0
  186. data/spec/models/error_spec.rb +76 -0
  187. data/spec/models/list_customers_request_spec.rb +46 -0
  188. data/spec/models/list_customers_response_spec.rb +66 -0
  189. data/spec/models/list_locations_request_spec.rb +36 -0
  190. data/spec/models/list_locations_response_spec.rb +56 -0
  191. data/spec/models/list_refunds_request_spec.rb +76 -0
  192. data/spec/models/list_refunds_response_spec.rb +66 -0
  193. data/spec/models/list_transactions_request_spec.rb +76 -0
  194. data/spec/models/list_transactions_response_spec.rb +66 -0
  195. data/spec/models/location_capability_spec.rb +36 -0
  196. data/spec/models/location_spec.rb +86 -0
  197. data/spec/models/money_spec.rb +56 -0
  198. data/spec/models/order_line_item_spec.rb +86 -0
  199. data/spec/models/order_spec.rb +86 -0
  200. data/spec/models/refund_spec.rb +126 -0
  201. data/spec/models/refund_status_spec.rb +36 -0
  202. data/spec/models/retrieve_customer_request_spec.rb +36 -0
  203. data/spec/models/retrieve_customer_response_spec.rb +56 -0
  204. data/spec/models/retrieve_transaction_request_spec.rb +36 -0
  205. data/spec/models/retrieve_transaction_response_spec.rb +56 -0
  206. data/spec/models/sort_order_spec.rb +36 -0
  207. data/spec/models/tender_card_details_entry_method_spec.rb +36 -0
  208. data/spec/models/tender_card_details_spec.rb +66 -0
  209. data/spec/models/tender_card_details_status_spec.rb +36 -0
  210. data/spec/models/tender_cash_details_spec.rb +56 -0
  211. data/spec/models/tender_spec.rb +146 -0
  212. data/spec/models/tender_type_spec.rb +36 -0
  213. data/spec/models/transaction_product_spec.rb +36 -0
  214. data/spec/models/transaction_spec.rb +136 -0
  215. data/spec/models/update_customer_request_spec.rb +126 -0
  216. data/spec/models/update_customer_response_spec.rb +56 -0
  217. data/spec/models/void_transaction_request_spec.rb +36 -0
  218. data/spec/models/void_transaction_response_spec.rb +46 -0
  219. data/spec/spec_helper.rb +115 -0
  220. data/square_connect.gemspec +22 -11
  221. data/travis-ci/accounts.enc +0 -0
  222. 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
- @user_agent = "square-connect-ruby-#{VERSION}"
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
- 'Accept' => "application/json",
34
- 'User-Agent' => @user_agent
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
- fail ApiError.new(:code => response.code,
56
- :response_headers => response.headers,
57
- :response_body => response.body)
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
- !!(mime =~ /\Aapplication\/json(;.*)?\z/i)
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
- _body = nil
344
+ local_body = nil
298
345
  if model.is_a?(Array)
299
- _body = model.map{|m| object_to_hash(m) }
346
+ local_body = model.map{|m| object_to_hash(m) }
300
347
  else
301
- _body = object_to_hash(model)
348
+ local_body = object_to_hash(model)
302
349
  end
303
- _body.to_json
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
- super arg
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
- :'country' => :'country'
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.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
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[:'address_line_2']
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[:'address_line_3']
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[:'locality']
143
+
144
+ if attributes.has_key?(:'locality')
122
145
  self.locality = attributes[:'locality']
123
146
  end
124
-
125
- if attributes[:'sublocality']
147
+
148
+ if attributes.has_key?(:'sublocality')
126
149
  self.sublocality = attributes[:'sublocality']
127
150
  end
128
-
129
- if attributes[:'sublocality_2']
151
+
152
+ if attributes.has_key?(:'sublocality_2')
130
153
  self.sublocality_2 = attributes[:'sublocality_2']
131
154
  end
132
-
133
- if attributes[:'sublocality_3']
155
+
156
+ if attributes.has_key?(:'sublocality_3')
134
157
  self.sublocality_3 = attributes[:'sublocality_3']
135
158
  end
136
-
137
- if attributes[:'administrative_district_level_1']
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[:'administrative_district_level_2']
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[:'administrative_district_level_3']
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[:'postal_code']
171
+
172
+ if attributes.has_key?(:'postal_code')
150
173
  self.postal_code = attributes[:'postal_code']
151
174
  end
152
-
153
- if attributes[:'country']
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
- allowed_values = ["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"]
162
- if country && !allowed_values.include?(country)
163
- fail "invalid value for 'country', must be one of #{allowed_values}"
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
- # Check equality by comparing each attribute.
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
- # Calculate hash code according to all attributes.
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
- # build the object from hash
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 =~ /^Array<(.*)>/i
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 =~ /^(true|t|yes|y|1)$/i
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>.+), (?<v_type>.+)>\z/
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
- _model = SquareConnect.const_get(type).new
247
- _model.build_from_hash(value)
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 to_body (backward compatibility))
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
- # return the object in the form of hash
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
- # Method to output non-array value in the form of hash
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