square.rb 8.0.0.20201216 → 26.1.0.20230119

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +79 -221
  4. data/lib/square/api/apple_pay_api.rb +15 -8
  5. data/lib/square/api/bank_accounts_api.rb +5 -5
  6. data/lib/square/api/base_api.rb +27 -9
  7. data/lib/square/api/booking_custom_attributes_api.rb +555 -0
  8. data/lib/square/api/bookings_api.rb +107 -15
  9. data/lib/square/api/cards_api.rb +171 -0
  10. data/lib/square/api/cash_drawers_api.rb +2 -2
  11. data/lib/square/api/catalog_api.rb +167 -73
  12. data/lib/square/api/checkout_api.rb +205 -3
  13. data/lib/square/api/customer_custom_attributes_api.rb +561 -0
  14. data/lib/square/api/customer_groups_api.rb +17 -8
  15. data/lib/square/api/customer_segments_api.rb +15 -6
  16. data/lib/square/api/customers_api.rb +67 -33
  17. data/lib/square/api/devices_api.rb +3 -2
  18. data/lib/square/api/disputes_api.rb +109 -105
  19. data/lib/square/api/gift_card_activities_api.rb +132 -0
  20. data/lib/square/api/gift_cards_api.rb +298 -0
  21. data/lib/square/api/inventory_api.rb +263 -24
  22. data/lib/square/api/invoices_api.rb +21 -21
  23. data/lib/square/api/labor_api.rb +70 -68
  24. data/lib/square/api/location_custom_attributes_api.rb +584 -0
  25. data/lib/square/api/locations_api.rb +21 -14
  26. data/lib/square/api/loyalty_api.rb +333 -50
  27. data/lib/square/api/merchants_api.rb +11 -9
  28. data/lib/square/api/mobile_authorization_api.rb +4 -4
  29. data/lib/square/api/o_auth_api.rb +78 -25
  30. data/lib/square/api/order_custom_attributes_api.rb +601 -0
  31. data/lib/square/api/orders_api.rb +84 -45
  32. data/lib/square/api/payments_api.rb +72 -24
  33. data/lib/square/api/payouts_api.rb +173 -0
  34. data/lib/square/api/refunds_api.rb +18 -7
  35. data/lib/square/api/sites_api.rb +43 -0
  36. data/lib/square/api/snippets_api.rb +146 -0
  37. data/lib/square/api/subscriptions_api.rb +190 -15
  38. data/lib/square/api/team_api.rb +46 -46
  39. data/lib/square/api/terminal_api.rb +172 -22
  40. data/lib/square/api/transactions_api.rb +15 -191
  41. data/lib/square/api/v1_transactions_api.rb +52 -124
  42. data/lib/square/api/vendors_api.rb +257 -0
  43. data/lib/square/api/webhook_subscriptions_api.rb +327 -0
  44. data/lib/square/api_helper.rb +217 -57
  45. data/lib/square/client.rb +90 -18
  46. data/lib/square/configuration.rb +64 -20
  47. data/lib/square/exceptions/validation_exception.rb +13 -0
  48. data/lib/square/http/api_response.rb +7 -9
  49. data/lib/square/http/faraday_client.rb +40 -9
  50. data/lib/square/http/http_client.rb +31 -12
  51. data/lib/square/http/http_request.rb +6 -2
  52. data/lib/square/utilities/date_time_helper.rb +151 -0
  53. data/lib/square/utilities/file_wrapper.rb +1 -2
  54. data/lib/square.rb +56 -44
  55. data/test/api/test_locations_api.rb +2 -5
  56. data/test/test_helper.rb +2 -2
  57. metadata +83 -15
  58. data/lib/square/api/v1_employees_api.rb +0 -751
  59. data/lib/square/api/v1_items_api.rb +0 -1766
@@ -7,16 +7,16 @@ module Square
7
7
 
8
8
  # `RenewToken` is deprecated. For information about refreshing OAuth access
9
9
  # tokens, see
10
- # [Renew OAuth
11
- # Token](https://developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-
12
- # tokens).
10
+ # [Migrate from Renew to Refresh OAuth
11
+ # Tokens](https://developer.squareup.com/docs/oauth-api/migrate-to-refresh-t
12
+ # okens).
13
13
  # Renews an OAuth access token before it expires.
14
14
  # OAuth access tokens besides your application's personal access token
15
- # expire after __30 days__.
16
- # You can also renew expired tokens within __15 days__ of their expiration.
15
+ # expire after 30 days.
16
+ # You can also renew expired tokens within 15 days of their expiration.
17
17
  # You cannot renew an access token that has been expired for more than 15
18
18
  # days.
19
- # Instead, the associated user must re-complete the OAuth flow from the
19
+ # Instead, the associated user must recomplete the OAuth flow from the
20
20
  # beginning.
21
21
  # __Important:__ The `Authorization` header for this endpoint must have the
22
22
  # following format:
@@ -25,10 +25,10 @@ module Square
25
25
  # ```
26
26
  # Replace `APPLICATION_SECRET` with the application secret on the
27
27
  # Credentials
28
- # page in the [application dashboard](https://connect.squareup.com/apps).
29
- # @param [String] client_id Required parameter: Your application ID,
30
- # available from the [application
31
- # dashboard](https://connect.squareup.com/apps).
28
+ # page in the [Developer Dashboard](https://developer.squareup.com/apps).
29
+ # @param [String] client_id Required parameter: Your application ID, which
30
+ # is available in the OAuth page in the [Developer
31
+ # Dashboard](https://developer.squareup.com/apps).
32
32
  # @param [RenewTokenRequest] body Required parameter: An object containing
33
33
  # the fields to POST for the request. See the corresponding object
34
34
  # definition for field details.
@@ -51,7 +51,7 @@ module Square
51
51
  # Prepare headers.
52
52
  _headers = {
53
53
  'accept' => 'application/json',
54
- 'content-type' => 'application/json; charset=utf-8',
54
+ 'Content-Type' => 'application/json',
55
55
  'Authorization' => authorization
56
56
  }
57
57
 
@@ -83,9 +83,8 @@ module Square
83
83
  # ```
84
84
  # Authorization: Client APPLICATION_SECRET
85
85
  # ```
86
- # Replace `APPLICATION_SECRET` with the application secret on the
87
- # Credentials
88
- # page in the [Developer Dashboard](https://developer.squareup.com/apps).
86
+ # Replace `APPLICATION_SECRET` with the application secret on the OAuth
87
+ # page for your application on the Developer Dashboard.
89
88
  # @param [RevokeTokenRequest] body Required parameter: An object containing
90
89
  # the fields to POST for the request. See the corresponding object
91
90
  # definition for field details.
@@ -102,7 +101,7 @@ module Square
102
101
  # Prepare headers.
103
102
  _headers = {
104
103
  'accept' => 'application/json',
105
- 'content-type' => 'application/json; charset=utf-8',
104
+ 'Content-Type' => 'application/json',
106
105
  'Authorization' => authorization
107
106
  }
108
107
 
@@ -122,15 +121,22 @@ module Square
122
121
  )
123
122
  end
124
123
 
125
- # Returns an OAuth access token.
126
- # The endpoint supports distinct methods of obtaining OAuth access tokens.
127
- # Applications specify a method by adding the `grant_type` parameter
128
- # in the request and also provide relevant information.
129
- # __Note:__ Regardless of the method application specified,
130
- # the endpoint always returns two items; an OAuth access token and
131
- # a refresh token in the response.
132
- # __OAuth tokens should only live on secure servers. Application clients
133
- # should never interact directly with OAuth tokens__.
124
+ # Returns an OAuth access token and a refresh token unless the
125
+ # `short_lived` parameter is set to `true`, in which case the endpoint
126
+ # returns only an access token.
127
+ # The `grant_type` parameter specifies the type of OAuth request. If
128
+ # `grant_type` is `authorization_code`, you must include the authorization
129
+ # code you received when a seller granted you authorization. If `grant_type`
130
+ # is `refresh_token`, you must provide a valid refresh token. If you are
131
+ # using
132
+ # an old version of the Square APIs (prior to March 13, 2019), `grant_type`
133
+ # can be `migration_token` and you must provide a valid migration token.
134
+ # You can use the `scopes` parameter to limit the set of permissions granted
135
+ # to the access token and refresh token. You can use the `short_lived`
136
+ # parameter
137
+ # to create an access token that expires in 24 hours.
138
+ # __Note:__ OAuth tokens should be encrypted and stored on a secure server.
139
+ # Application clients should never interact directly with OAuth tokens.
134
140
  # @param [ObtainTokenRequest] body Required parameter: An object containing
135
141
  # the fields to POST for the request. See the corresponding object
136
142
  # definition for field details.
@@ -144,7 +150,7 @@ module Square
144
150
  # Prepare headers.
145
151
  _headers = {
146
152
  'accept' => 'application/json',
147
- 'content-type' => 'application/json; charset=utf-8'
153
+ 'Content-Type' => 'application/json'
148
154
  }
149
155
 
150
156
  # Prepare and execute HttpRequest.
@@ -162,5 +168,52 @@ module Square
162
168
  _response, data: decoded, errors: _errors
163
169
  )
164
170
  end
171
+
172
+ # Returns information about an [OAuth access
173
+ # token](https://developer.squareup.com/docs/build-basics/access-tokens#get-
174
+ # an-oauth-access-token) or an application’s [personal access
175
+ # token](https://developer.squareup.com/docs/build-basics/access-tokens#get-
176
+ # a-personal-access-token).
177
+ # Add the access token to the Authorization header of the request.
178
+ # __Important:__ The `Authorization` header you provide to this endpoint
179
+ # must have the following format:
180
+ # ```
181
+ # Authorization: Bearer ACCESS_TOKEN
182
+ # ```
183
+ # where `ACCESS_TOKEN` is a
184
+ # [valid production authorization
185
+ # credential](https://developer.squareup.com/docs/build-basics/access-tokens
186
+ # ).
187
+ # If the access token is expired or not a valid access token, the endpoint
188
+ # returns an `UNAUTHORIZED` error.
189
+ # @param [String] authorization Required parameter: Client
190
+ # APPLICATION_SECRET
191
+ # @return [RetrieveTokenStatusResponse Hash] response from the API call
192
+ def retrieve_token_status(authorization:)
193
+ # Prepare query url.
194
+ _query_builder = config.get_base_uri
195
+ _query_builder << '/oauth2/token/status'
196
+ _query_url = APIHelper.clean_url _query_builder
197
+
198
+ # Prepare headers.
199
+ _headers = {
200
+ 'accept' => 'application/json',
201
+ 'Authorization' => authorization
202
+ }
203
+
204
+ # Prepare and execute HttpRequest.
205
+ _request = config.http_client.post(
206
+ _query_url,
207
+ headers: _headers
208
+ )
209
+ _response = execute_request(_request)
210
+
211
+ # Return appropriate response type.
212
+ decoded = APIHelper.json_deserialize(_response.raw_body)
213
+ _errors = APIHelper.map_response(decoded, ['errors'])
214
+ ApiResponse.new(
215
+ _response, data: decoded, errors: _errors
216
+ )
217
+ end
165
218
  end
166
219
  end