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.
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
@@ -0,0 +1,71 @@
1
+ =begin
2
+ Square Connect API
3
+
4
+ No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for SquareConnect::CustomerCardApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'CustomerCardApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = SquareConnect::CustomerCardApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of CustomerCardApi' do
30
+ it 'should create an instact of CustomerCardApi' do
31
+ @instance.should be_a(SquareConnect::CustomerCardApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_customer_card
36
+ # CreateCustomerCard
37
+ # Adds a card on file to an existing customer.
38
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
39
+ # @param customer_id The ID of the customer to link the card on file to.
40
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
41
+ # @param [Hash] opts the optional parameters
42
+ # @return [CreateCustomerCardResponse]
43
+ describe 'create_customer_card test' do
44
+ it "should work" do
45
+ # assertion here
46
+ # should be_a()
47
+ # should be_nil
48
+ # should ==
49
+ # should_not ==
50
+ end
51
+ end
52
+
53
+ # unit tests for delete_customer_card
54
+ # DeleteCustomerCard
55
+ # Removes a card on file from a customer.
56
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
57
+ # @param customer_id The ID of the customer that the card on file belongs to.
58
+ # @param card_id The ID of the card on file to delete.
59
+ # @param [Hash] opts the optional parameters
60
+ # @return [DeleteCustomerCardResponse]
61
+ describe 'delete_customer_card test' do
62
+ it "should work" do
63
+ # assertion here
64
+ # should be_a()
65
+ # should be_nil
66
+ # should ==
67
+ # should_not ==
68
+ end
69
+ end
70
+
71
+ end
@@ -0,0 +1,58 @@
1
+ =begin
2
+ Square Connect API
3
+
4
+ No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for SquareConnect::LocationApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'LocationApi' do
20
+
21
+ let(:accounts) { load_accounts() }
22
+
23
+ before do
24
+ # run before each test
25
+ @instance = SquareConnect::LocationApi.new
26
+ end
27
+
28
+ after do
29
+ # run after each test
30
+ end
31
+
32
+ describe 'test an instance of LocationApi' do
33
+ it 'should create an instact of LocationApi' do
34
+ @instance.should be_a(SquareConnect::LocationApi)
35
+ end
36
+ end
37
+
38
+ # unit tests for list_locations
39
+ # ListLocations
40
+ # Provides the details for all of a business's locations. Most other Connect API endpoints have a required `location_id` path parameter. The `id` field of the [`Location`](#type-location) objects returned by this endpoint correspond to that `location_id` parameter.
41
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
42
+ # @param [Hash] opts the optional parameters
43
+ # @return [ListLocationsResponse]
44
+ describe 'list_locations test' do
45
+ context "Sandbox" do
46
+ let(:account) { accounts["US-Prod-Sandbox"] }
47
+ it "should work" do
48
+ access_token = account["access_token"]
49
+ result = @instance.list_locations(access_token)
50
+ locations = result.locations
51
+ expect(locations.length).to be > 0
52
+ expect(locations[0]).to be_an_instance_of(SquareConnect::Location)
53
+ expect(locations[0].id).to eq("CBASEEffqN8pnVNXwoCL0dSGMVAgAQ")
54
+ end
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,75 @@
1
+ =begin
2
+ Square Connect API
3
+
4
+ No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for SquareConnect::RefundApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'RefundApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = SquareConnect::RefundApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of RefundApi' do
30
+ it 'should create an instact of RefundApi' do
31
+ @instance.should be_a(SquareConnect::RefundApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for create_refund
36
+ # CreateRefund
37
+ # Initiates a refund for a previously charged tender.
38
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
39
+ # @param location_id The ID of the original transaction's associated location.
40
+ # @param transaction_id The ID of the original transaction that includes the tender to refund.
41
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
42
+ # @param [Hash] opts the optional parameters
43
+ # @return [CreateRefundResponse]
44
+ describe 'create_refund test' do
45
+ it "should work" do
46
+ # assertion here
47
+ # should be_a()
48
+ # should be_nil
49
+ # should ==
50
+ # should_not ==
51
+ end
52
+ end
53
+
54
+ # unit tests for list_refunds
55
+ # ListRefunds
56
+ # Lists refunds for one of a business's locations. Refunds with a `status` of `PENDING` are not currently included in this endpoint's response. Max results per [page](#paginatingresults): 50
57
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
58
+ # @param location_id The ID of the location to list refunds for.
59
+ # @param [Hash] opts the optional parameters
60
+ # @option opts [String] :begin_time The beginning of the requested reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for details on date inclusivity/exclusivity. Default value: The current time minus one year.
61
+ # @option opts [String] :end_time The end of the requested reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for details on date inclusivity/exclusivity. Default value: The current time.
62
+ # @option opts [String] :sort_order The order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first). Default value: `DESC`
63
+ # @option opts [String] :cursor A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Paginating results](#paginatingresults) for more information.
64
+ # @return [ListRefundsResponse]
65
+ describe 'list_refunds test' do
66
+ it "should work" do
67
+ # assertion here
68
+ # should be_a()
69
+ # should be_nil
70
+ # should ==
71
+ # should_not ==
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,128 @@
1
+ =begin
2
+ Square Connect API
3
+
4
+ No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+ require 'json'
15
+
16
+ # Unit tests for SquareConnect::TransactionApi
17
+ # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
+ # Please update as you see appropriate
19
+ describe 'TransactionApi' do
20
+ before do
21
+ # run before each test
22
+ @instance = SquareConnect::TransactionApi.new
23
+ end
24
+
25
+ after do
26
+ # run after each test
27
+ end
28
+
29
+ describe 'test an instance of TransactionApi' do
30
+ it 'should create an instact of TransactionApi' do
31
+ @instance.should be_a(SquareConnect::TransactionApi)
32
+ end
33
+ end
34
+
35
+ # unit tests for capture_transaction
36
+ # CaptureTransaction
37
+ # Captures a transaction that was created with the [Charge](#endpoint-charge) endpoint with a `delay_capture` value of `true`. See [Delayed capture transactions](/articles/delayed-capture-transactions/) for more information.
38
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
39
+ # @param location_id
40
+ # @param transaction_id
41
+ # @param [Hash] opts the optional parameters
42
+ # @return [CaptureTransactionResponse]
43
+ describe 'capture_transaction test' do
44
+ it "should work" do
45
+ # assertion here
46
+ # should be_a()
47
+ # should be_nil
48
+ # should ==
49
+ # should_not ==
50
+ end
51
+ end
52
+
53
+ # unit tests for charge
54
+ # Charge
55
+ # Charges a card represented by a card nonce or a customer's card on file. Your request to this endpoint must include _either_: - A value for the `card_nonce` parameter (to charge a card nonce generated with the `SqPaymentForm`) - Values for the `customer_card_id` and `customer_id` parameters (to charge a customer's card on file) In order for an e-commerce payment to potentially qualify for [Square chargeback protection](https://squareup.com/help/article/5394), you _must_ provide values for the following parameters in your request: - `buyer_email_address` - At least one of `billing_address` or `shipping_address` When this response is returned, the amount of Square's processing fee might not yet be calculated. To obtain the processing fee, wait about ten seconds and call [RetrieveTransaction](#endpoint-retrievetransaction). See the `processing_fee_money` field of each [Tender included](#type-tender) in the transaction.
56
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
57
+ # @param location_id The ID of the location to associate the created transaction with.
58
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
59
+ # @param [Hash] opts the optional parameters
60
+ # @return [ChargeResponse]
61
+ describe 'charge test' do
62
+ it "should work" do
63
+ # assertion here
64
+ # should be_a()
65
+ # should be_nil
66
+ # should ==
67
+ # should_not ==
68
+ end
69
+ end
70
+
71
+ # unit tests for list_transactions
72
+ # ListTransactions
73
+ # Lists transactions for a particular location. Max results per [page](#paginatingresults): 50
74
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
75
+ # @param location_id The ID of the location to list transactions for.
76
+ # @param [Hash] opts the optional parameters
77
+ # @option opts [String] :begin_time The beginning of the requested reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for details on date inclusivity/exclusivity. Default value: The current time minus one year.
78
+ # @option opts [String] :end_time The end of the requested reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for details on date inclusivity/exclusivity. Default value: The current time.
79
+ # @option opts [String] :sort_order The order in which results are listed in the response (`ASC` for oldest first, `DESC` for newest first). Default value: `DESC`
80
+ # @option opts [String] :cursor A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See [Paginating results](#paginatingresults) for more information.
81
+ # @return [ListTransactionsResponse]
82
+ describe 'list_transactions test' do
83
+ it "should work" do
84
+ # assertion here
85
+ # should be_a()
86
+ # should be_nil
87
+ # should ==
88
+ # should_not ==
89
+ end
90
+ end
91
+
92
+ # unit tests for retrieve_transaction
93
+ # RetrieveTransaction
94
+ # Retrieves details for a single transaction.
95
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
96
+ # @param location_id The ID of the transaction's associated location.
97
+ # @param transaction_id The ID of the transaction to retrieve.
98
+ # @param [Hash] opts the optional parameters
99
+ # @return [RetrieveTransactionResponse]
100
+ describe 'retrieve_transaction test' do
101
+ it "should work" do
102
+ # assertion here
103
+ # should be_a()
104
+ # should be_nil
105
+ # should ==
106
+ # should_not ==
107
+ end
108
+ end
109
+
110
+ # unit tests for void_transaction
111
+ # VoidTransaction
112
+ # Cancels a transaction that was created with the [Charge](#endpoint-charge) endpoint with a `delay_capture` value of `true`. See [Delayed capture transactions](/articles/delayed-capture-transactions/) for more information.
113
+ # @param authorization The value to provide in the Authorization header of your request. This value should follow the format `Bearer YOUR_ACCESS_TOKEN_HERE`.
114
+ # @param location_id
115
+ # @param transaction_id
116
+ # @param [Hash] opts the optional parameters
117
+ # @return [VoidTransactionResponse]
118
+ describe 'void_transaction test' do
119
+ it "should work" do
120
+ # assertion here
121
+ # should be_a()
122
+ # should be_nil
123
+ # should ==
124
+ # should_not ==
125
+ end
126
+ end
127
+
128
+ end
@@ -0,0 +1,226 @@
1
+ =begin
2
+ Square Connect API
3
+
4
+ No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
+
6
+ OpenAPI spec version: 2.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+
10
+
11
+ =end
12
+
13
+ require 'spec_helper'
14
+
15
+ describe SquareConnect::ApiClient do
16
+ context 'initialization' do
17
+ context 'URL stuff' do
18
+ context 'host' do
19
+ it 'removes http from host' do
20
+ SquareConnect.configure { |c| c.host = 'http://example.com' }
21
+ expect(SquareConnect::Configuration.default.host).to eq('example.com')
22
+ end
23
+
24
+ it 'removes https from host' do
25
+ SquareConnect.configure { |c| c.host = 'https://wookiee.com' }
26
+ expect(SquareConnect::ApiClient.default.config.host).to eq('wookiee.com')
27
+ end
28
+
29
+ it 'removes trailing path from host' do
30
+ SquareConnect.configure { |c| c.host = 'hobo.com/v4' }
31
+ expect(SquareConnect::Configuration.default.host).to eq('hobo.com')
32
+ end
33
+ end
34
+
35
+ context 'base_path' do
36
+ it "prepends a slash to base_path" do
37
+ SquareConnect.configure { |c| c.base_path = 'v4/dog' }
38
+ expect(SquareConnect::Configuration.default.base_path).to eq('/v4/dog')
39
+ end
40
+
41
+ it "doesn't prepend a slash if one is already there" do
42
+ SquareConnect.configure { |c| c.base_path = '/v4/dog' }
43
+ expect(SquareConnect::Configuration.default.base_path).to eq('/v4/dog')
44
+ end
45
+
46
+ it "ends up as a blank string if nil" do
47
+ SquareConnect.configure { |c| c.base_path = nil }
48
+ expect(SquareConnect::Configuration.default.base_path).to eq('')
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ describe "params_encoding in #build_request" do
55
+ let(:config) { SquareConnect::Configuration.new }
56
+ let(:api_client) { SquareConnect::ApiClient.new(config) }
57
+
58
+ it "defaults to nil" do
59
+ expect(SquareConnect::Configuration.default.params_encoding).to eq(nil)
60
+ expect(config.params_encoding).to eq(nil)
61
+
62
+ request = api_client.build_request(:get, '/test')
63
+ expect(request.options[:params_encoding]).to eq(nil)
64
+ end
65
+
66
+ it "can be customized" do
67
+ config.params_encoding = :multi
68
+ request = api_client.build_request(:get, '/test')
69
+ expect(request.options[:params_encoding]).to eq(:multi)
70
+ end
71
+ end
72
+
73
+ describe "timeout in #build_request" do
74
+ let(:config) { SquareConnect::Configuration.new }
75
+ let(:api_client) { SquareConnect::ApiClient.new(config) }
76
+
77
+ it "defaults to 0" do
78
+ expect(SquareConnect::Configuration.default.timeout).to eq(0)
79
+ expect(config.timeout).to eq(0)
80
+
81
+ request = api_client.build_request(:get, '/test')
82
+ expect(request.options[:timeout]).to eq(0)
83
+ end
84
+
85
+ it "can be customized" do
86
+ config.timeout = 100
87
+ request = api_client.build_request(:get, '/test')
88
+ expect(request.options[:timeout]).to eq(100)
89
+ end
90
+ end
91
+
92
+ describe "#deserialize" do
93
+ it "handles Array<Integer>" do
94
+ api_client = SquareConnect::ApiClient.new
95
+ headers = {'Content-Type' => 'application/json'}
96
+ response = double('response', headers: headers, body: '[12, 34]')
97
+ data = api_client.deserialize(response, 'Array<Integer>')
98
+ expect(data).to be_instance_of(Array)
99
+ expect(data).to eq([12, 34])
100
+ end
101
+
102
+ it "handles Array<Array<Integer>>" do
103
+ api_client = SquareConnect::ApiClient.new
104
+ headers = {'Content-Type' => 'application/json'}
105
+ response = double('response', headers: headers, body: '[[12, 34], [56]]')
106
+ data = api_client.deserialize(response, 'Array<Array<Integer>>')
107
+ expect(data).to be_instance_of(Array)
108
+ expect(data).to eq([[12, 34], [56]])
109
+ end
110
+
111
+ it "handles Hash<String, String>" do
112
+ api_client = SquareConnect::ApiClient.new
113
+ headers = {'Content-Type' => 'application/json'}
114
+ response = double('response', headers: headers, body: '{"message": "Hello"}')
115
+ data = api_client.deserialize(response, 'Hash<String, String>')
116
+ expect(data).to be_instance_of(Hash)
117
+ expect(data).to eq({:message => 'Hello'})
118
+ end
119
+ end
120
+
121
+ describe "#object_to_hash" do
122
+ it "ignores nils and includes empty arrays" do
123
+ # uncomment below to test object_to_hash for model
124
+ #api_client = SquareConnect::ApiClient.new
125
+ #_model = SquareConnect::ModelName.new
126
+ # update the model attribute below
127
+ #_model.id = 1
128
+ # update the expected value (hash) below
129
+ #expected = {id: 1, name: '', tags: []}
130
+ #expect(api_client.object_to_hash(_model)).to eq(expected)
131
+ end
132
+ end
133
+
134
+ describe "#build_collection_param" do
135
+ let(:param) { ['aa', 'bb', 'cc'] }
136
+ let(:api_client) { SquareConnect::ApiClient.new }
137
+
138
+ it "works for csv" do
139
+ expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
140
+ end
141
+
142
+ it "works for ssv" do
143
+ expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
144
+ end
145
+
146
+ it "works for tsv" do
147
+ expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
148
+ end
149
+
150
+ it "works for pipes" do
151
+ expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
152
+ end
153
+
154
+ it "works for multi" do
155
+ expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
156
+ end
157
+
158
+ it "fails for invalid collection format" do
159
+ expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
160
+ end
161
+ end
162
+
163
+ describe "#json_mime?" do
164
+ let(:api_client) { SquareConnect::ApiClient.new }
165
+
166
+ it "works" do
167
+ expect(api_client.json_mime?(nil)).to eq false
168
+ expect(api_client.json_mime?('')).to eq false
169
+
170
+ expect(api_client.json_mime?('application/json')).to eq true
171
+ expect(api_client.json_mime?('application/json; charset=UTF8')).to eq true
172
+ expect(api_client.json_mime?('APPLICATION/JSON')).to eq true
173
+
174
+ expect(api_client.json_mime?('application/xml')).to eq false
175
+ expect(api_client.json_mime?('text/plain')).to eq false
176
+ expect(api_client.json_mime?('application/jsonp')).to eq false
177
+ end
178
+ end
179
+
180
+ describe "#select_header_accept" do
181
+ let(:api_client) { SquareConnect::ApiClient.new }
182
+
183
+ it "works" do
184
+ expect(api_client.select_header_accept(nil)).to be_nil
185
+ expect(api_client.select_header_accept([])).to be_nil
186
+
187
+ expect(api_client.select_header_accept(['application/json'])).to eq('application/json')
188
+ expect(api_client.select_header_accept(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
189
+ expect(api_client.select_header_accept(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
190
+
191
+ expect(api_client.select_header_accept(['application/xml'])).to eq('application/xml')
192
+ expect(api_client.select_header_accept(['text/html', 'application/xml'])).to eq('text/html,application/xml')
193
+ end
194
+ end
195
+
196
+ describe "#select_header_content_type" do
197
+ let(:api_client) { SquareConnect::ApiClient.new }
198
+
199
+ it "works" do
200
+ expect(api_client.select_header_content_type(nil)).to eq('application/json')
201
+ expect(api_client.select_header_content_type([])).to eq('application/json')
202
+
203
+ expect(api_client.select_header_content_type(['application/json'])).to eq('application/json')
204
+ expect(api_client.select_header_content_type(['application/xml', 'application/json; charset=UTF8'])).to eq('application/json; charset=UTF8')
205
+ expect(api_client.select_header_content_type(['APPLICATION/JSON', 'text/html'])).to eq('APPLICATION/JSON')
206
+ expect(api_client.select_header_content_type(['application/xml'])).to eq('application/xml')
207
+ expect(api_client.select_header_content_type(['text/plain', 'application/xml'])).to eq('text/plain')
208
+ end
209
+ end
210
+
211
+ describe "#sanitize_filename" do
212
+ let(:api_client) { SquareConnect::ApiClient.new }
213
+
214
+ it "works" do
215
+ expect(api_client.sanitize_filename('sun')).to eq('sun')
216
+ expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
217
+ expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')
218
+ expect(api_client.sanitize_filename('/var/tmp/sun.gif')).to eq('sun.gif')
219
+ expect(api_client.sanitize_filename('./sun.gif')).to eq('sun.gif')
220
+ expect(api_client.sanitize_filename('..\sun.gif')).to eq('sun.gif')
221
+ expect(api_client.sanitize_filename('\var\tmp\sun.gif')).to eq('sun.gif')
222
+ expect(api_client.sanitize_filename('c:\var\tmp\sun.gif')).to eq('sun.gif')
223
+ expect(api_client.sanitize_filename('.\sun.gif')).to eq('sun.gif')
224
+ end
225
+ end
226
+ end