square.rb 9.1.0.20210317 → 12.0.0.20210616

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -3
  3. data/lib/square.rb +5 -0
  4. data/lib/square/api/bank_accounts_api.rb +5 -5
  5. data/lib/square/api/base_api.rb +1 -1
  6. data/lib/square/api/bookings_api.rb +3 -5
  7. data/lib/square/api/cards_api.rb +170 -0
  8. data/lib/square/api/cash_drawers_api.rb +2 -2
  9. data/lib/square/api/catalog_api.rb +40 -41
  10. data/lib/square/api/customer_groups_api.rb +4 -4
  11. data/lib/square/api/customer_segments_api.rb +4 -4
  12. data/lib/square/api/customers_api.rb +45 -26
  13. data/lib/square/api/devices_api.rb +2 -1
  14. data/lib/square/api/disputes_api.rb +100 -91
  15. data/lib/square/api/gift_card_activities_api.rb +127 -0
  16. data/lib/square/api/gift_cards_api.rb +291 -0
  17. data/lib/square/api/inventory_api.rb +16 -16
  18. data/lib/square/api/invoices_api.rb +14 -14
  19. data/lib/square/api/locations_api.rb +1 -2
  20. data/lib/square/api/loyalty_api.rb +66 -14
  21. data/lib/square/api/merchants_api.rb +1 -1
  22. data/lib/square/api/o_auth_api.rb +8 -9
  23. data/lib/square/api/orders_api.rb +35 -33
  24. data/lib/square/api/payments_api.rb +4 -1
  25. data/lib/square/api/refunds_api.rb +4 -1
  26. data/lib/square/api/sites_api.rb +42 -0
  27. data/lib/square/api/snippets_api.rb +146 -0
  28. data/lib/square/api/subscriptions_api.rb +36 -1
  29. data/lib/square/api/team_api.rb +40 -40
  30. data/lib/square/api/transactions_api.rb +32 -20
  31. data/lib/square/api/v1_employees_api.rb +2 -1
  32. data/lib/square/api/v1_transactions_api.rb +9 -0
  33. data/lib/square/api_helper.rb +5 -5
  34. data/lib/square/client.rb +37 -3
  35. data/lib/square/configuration.rb +23 -8
  36. data/lib/square/http/faraday_client.rb +5 -2
  37. data/test/api/test_locations_api.rb +1 -1
  38. metadata +11 -6
@@ -0,0 +1,146 @@
1
+ module Square
2
+ # SnippetsApi
3
+ class SnippetsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Removes your snippet from a Square Online site.
9
+ # You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
10
+ # that belong to a seller.
11
+ # __Note:__ Square Online APIs are publicly available as part of an early
12
+ # access program. For more information, see [Early access program for Square
13
+ # Online
14
+ # APIs](https://developer.squareup.com/docs/online-api#early-access-program-
15
+ # for-square-online-apis).
16
+ # @param [String] site_id Required parameter: The ID of the site that
17
+ # contains the snippet.
18
+ # @return [DeleteSnippetResponse Hash] response from the API call
19
+ def delete_snippet(site_id:)
20
+ # Prepare query url.
21
+ _query_builder = config.get_base_uri
22
+ _query_builder << '/v2/sites/{site_id}/snippet'
23
+ _query_builder = APIHelper.append_url_with_template_parameters(
24
+ _query_builder,
25
+ 'site_id' => { 'value' => site_id, 'encode' => true }
26
+ )
27
+ _query_url = APIHelper.clean_url _query_builder
28
+
29
+ # Prepare headers.
30
+ _headers = {
31
+ 'accept' => 'application/json'
32
+ }
33
+
34
+ # Prepare and execute HttpRequest.
35
+ _request = config.http_client.delete(
36
+ _query_url,
37
+ headers: _headers
38
+ )
39
+ OAuth2.apply(config, _request)
40
+ _response = execute_request(_request)
41
+
42
+ # Return appropriate response type.
43
+ decoded = APIHelper.json_deserialize(_response.raw_body)
44
+ _errors = APIHelper.map_response(decoded, ['errors'])
45
+ ApiResponse.new(
46
+ _response, data: decoded, errors: _errors
47
+ )
48
+ end
49
+
50
+ # Retrieves your snippet from a Square Online site. A site can contain
51
+ # snippets from multiple snippet applications, but you can retrieve only the
52
+ # snippet that was added by your application.
53
+ # You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
54
+ # that belong to a seller.
55
+ # __Note:__ Square Online APIs are publicly available as part of an early
56
+ # access program. For more information, see [Early access program for Square
57
+ # Online
58
+ # APIs](https://developer.squareup.com/docs/online-api#early-access-program-
59
+ # for-square-online-apis).
60
+ # @param [String] site_id Required parameter: The ID of the site that
61
+ # contains the snippet.
62
+ # @return [RetrieveSnippetResponse Hash] response from the API call
63
+ def retrieve_snippet(site_id:)
64
+ # Prepare query url.
65
+ _query_builder = config.get_base_uri
66
+ _query_builder << '/v2/sites/{site_id}/snippet'
67
+ _query_builder = APIHelper.append_url_with_template_parameters(
68
+ _query_builder,
69
+ 'site_id' => { 'value' => site_id, 'encode' => true }
70
+ )
71
+ _query_url = APIHelper.clean_url _query_builder
72
+
73
+ # Prepare headers.
74
+ _headers = {
75
+ 'accept' => 'application/json'
76
+ }
77
+
78
+ # Prepare and execute HttpRequest.
79
+ _request = config.http_client.get(
80
+ _query_url,
81
+ headers: _headers
82
+ )
83
+ OAuth2.apply(config, _request)
84
+ _response = execute_request(_request)
85
+
86
+ # Return appropriate response type.
87
+ decoded = APIHelper.json_deserialize(_response.raw_body)
88
+ _errors = APIHelper.map_response(decoded, ['errors'])
89
+ ApiResponse.new(
90
+ _response, data: decoded, errors: _errors
91
+ )
92
+ end
93
+
94
+ # Adds a snippet to a Square Online site or updates the existing snippet on
95
+ # the site.
96
+ # The snippet code is appended to the end of the `head` element on every
97
+ # page of the site, except checkout pages. A snippet application can add one
98
+ # snippet to a given site.
99
+ # You can call [ListSites]($e/Sites/ListSites) to get the IDs of the sites
100
+ # that belong to a seller.
101
+ # __Note:__ Square Online APIs are publicly available as part of an early
102
+ # access program. For more information, see [Early access program for Square
103
+ # Online
104
+ # APIs](https://developer.squareup.com/docs/online-api#early-access-program-
105
+ # for-square-online-apis).
106
+ # @param [String] site_id Required parameter: The ID of the site where you
107
+ # want to add or update the snippet.
108
+ # @param [UpsertSnippetRequest] body Required parameter: An object
109
+ # containing the fields to POST for the request. See the corresponding
110
+ # object definition for field details.
111
+ # @return [UpsertSnippetResponse Hash] response from the API call
112
+ def upsert_snippet(site_id:,
113
+ body:)
114
+ # Prepare query url.
115
+ _query_builder = config.get_base_uri
116
+ _query_builder << '/v2/sites/{site_id}/snippet'
117
+ _query_builder = APIHelper.append_url_with_template_parameters(
118
+ _query_builder,
119
+ 'site_id' => { 'value' => site_id, 'encode' => true }
120
+ )
121
+ _query_url = APIHelper.clean_url _query_builder
122
+
123
+ # Prepare headers.
124
+ _headers = {
125
+ 'accept' => 'application/json',
126
+ 'content-type' => 'application/json; charset=utf-8'
127
+ }
128
+
129
+ # Prepare and execute HttpRequest.
130
+ _request = config.http_client.post(
131
+ _query_url,
132
+ headers: _headers,
133
+ parameters: body.to_json
134
+ )
135
+ OAuth2.apply(config, _request)
136
+ _response = execute_request(_request)
137
+
138
+ # Return appropriate response type.
139
+ decoded = APIHelper.json_deserialize(_response.raw_body)
140
+ _errors = APIHelper.map_response(decoded, ['errors'])
141
+ ApiResponse.new(
142
+ _response, data: decoded, errors: _errors
143
+ )
144
+ end
145
+ end
146
+ end
@@ -220,7 +220,7 @@ module Square
220
220
  # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
221
221
  # ion).
222
222
  # @param [Integer] limit Optional parameter: The upper limit on the number
223
- # of subscription events to return in the response. Default: `200`
223
+ # of subscription events to return in the response. Default: `200`
224
224
  # @return [ListSubscriptionEventsResponse Hash] response from the API call
225
225
  def list_subscription_events(subscription_id:,
226
226
  cursor: nil,
@@ -259,5 +259,40 @@ module Square
259
259
  _response, data: decoded, errors: _errors
260
260
  )
261
261
  end
262
+
263
+ # Resumes a deactivated subscription.
264
+ # @param [String] subscription_id Required parameter: The ID of the
265
+ # subscription to resume.
266
+ # @return [ResumeSubscriptionResponse Hash] response from the API call
267
+ def resume_subscription(subscription_id:)
268
+ # Prepare query url.
269
+ _query_builder = config.get_base_uri
270
+ _query_builder << '/v2/subscriptions/{subscription_id}/resume'
271
+ _query_builder = APIHelper.append_url_with_template_parameters(
272
+ _query_builder,
273
+ 'subscription_id' => { 'value' => subscription_id, 'encode' => true }
274
+ )
275
+ _query_url = APIHelper.clean_url _query_builder
276
+
277
+ # Prepare headers.
278
+ _headers = {
279
+ 'accept' => 'application/json'
280
+ }
281
+
282
+ # Prepare and execute HttpRequest.
283
+ _request = config.http_client.post(
284
+ _query_url,
285
+ headers: _headers
286
+ )
287
+ OAuth2.apply(config, _request)
288
+ _response = execute_request(_request)
289
+
290
+ # Return appropriate response type.
291
+ decoded = APIHelper.json_deserialize(_response.raw_body)
292
+ _errors = APIHelper.map_response(decoded, ['errors'])
293
+ ApiResponse.new(
294
+ _response, data: decoded, errors: _errors
295
+ )
296
+ end
262
297
  end
263
298
  end
@@ -5,12 +5,12 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a single `TeamMember` object. The `TeamMember` will be returned on
9
- # successful creates.
8
+ # Creates a single `TeamMember` object. The `TeamMember` object is returned
9
+ # on successful creates.
10
10
  # You must provide the following values in your request to this endpoint:
11
11
  # - `given_name`
12
12
  # - `family_name`
13
- # Learn about [Troubleshooting the Teams
13
+ # Learn about [Troubleshooting the Team
14
14
  # API](https://developer.squareup.com/docs/team/troubleshooting#createteamme
15
15
  # mber).
16
16
  # @param [CreateTeamMemberRequest] body Required parameter: An object
@@ -47,15 +47,15 @@ module Square
47
47
  end
48
48
 
49
49
  # Creates multiple `TeamMember` objects. The created `TeamMember` objects
50
- # will be returned on successful creates.
51
- # This process is non-transactional and will process as much of the request
52
- # as is possible. If one of the creates in
53
- # the request cannot be successfully processed, the request will NOT be
54
- # marked as failed, but the body of the response
55
- # will contain explicit error information for this particular create.
56
- # Learn about [Troubleshooting the Teams
57
- # API](https://developer.squareup.com/docs/team/troubleshooting#bulkcreatete
58
- # ammembers).
50
+ # are returned on successful creates.
51
+ # This process is non-transactional and processes as much of the request as
52
+ # possible. If one of the creates in
53
+ # the request cannot be successfully processed, the request is not marked as
54
+ # failed, but the body of the response
55
+ # contains explicit error information for the failed create.
56
+ # Learn about [Troubleshooting the Team
57
+ # API](https://developer.squareup.com/docs/team/troubleshooting#bulk-create-
58
+ # team-members).
59
59
  # @param [BulkCreateTeamMembersRequest] body Required parameter: An object
60
60
  # containing the fields to POST for the request. See the corresponding
61
61
  # object definition for field details.
@@ -90,15 +90,15 @@ module Square
90
90
  end
91
91
 
92
92
  # Updates multiple `TeamMember` objects. The updated `TeamMember` objects
93
- # will be returned on successful updates.
94
- # This process is non-transactional and will process as much of the request
95
- # as is possible. If one of the updates in
96
- # the request cannot be successfully processed, the request will NOT be
97
- # marked as failed, but the body of the response
98
- # will contain explicit error information for this particular update.
99
- # Learn about [Troubleshooting the Teams
100
- # API](https://developer.squareup.com/docs/team/troubleshooting#bulkupdatete
101
- # ammembers).
93
+ # are returned on successful updates.
94
+ # This process is non-transactional and processes as much of the request as
95
+ # possible. If one of the updates in
96
+ # the request cannot be successfully processed, the request is not marked as
97
+ # failed, but the body of the response
98
+ # contains explicit error information for the failed update.
99
+ # Learn about [Troubleshooting the Team
100
+ # API](https://developer.squareup.com/docs/team/troubleshooting#bulk-update-
101
+ # team-members).
102
102
  # @param [BulkUpdateTeamMembersRequest] body Required parameter: An object
103
103
  # containing the fields to POST for the request. See the corresponding
104
104
  # object definition for field details.
@@ -133,8 +133,8 @@ module Square
133
133
  end
134
134
 
135
135
  # Returns a paginated list of `TeamMember` objects for a business.
136
- # The list to be returned can be filtered by:
137
- # - location IDs **and**
136
+ # The list can be filtered by the following:
137
+ # - location IDs
138
138
  # - `status`
139
139
  # @param [SearchTeamMembersRequest] body Required parameter: An object
140
140
  # containing the fields to POST for the request. See the corresponding
@@ -169,10 +169,10 @@ module Square
169
169
  )
170
170
  end
171
171
 
172
- # Retrieve a `TeamMember` object for the given `TeamMember.id`.
173
- # Learn about [Troubleshooting the Teams
174
- # API](https://developer.squareup.com/docs/team/troubleshooting#retrieveteam
175
- # member).
172
+ # Retrieves a `TeamMember` object for the given `TeamMember.id`.
173
+ # Learn about [Troubleshooting the Team
174
+ # API](https://developer.squareup.com/docs/team/troubleshooting#retrieve-a-t
175
+ # eam-member).
176
176
  # @param [String] team_member_id Required parameter: The ID of the team
177
177
  # member to retrieve.
178
178
  # @return [RetrieveTeamMemberResponse Hash] response from the API call
@@ -207,11 +207,11 @@ module Square
207
207
  )
208
208
  end
209
209
 
210
- # Updates a single `TeamMember` object. The `TeamMember` will be returned on
211
- # successful updates.
212
- # Learn about [Troubleshooting the Teams
213
- # API](https://developer.squareup.com/docs/team/troubleshooting#updateteamme
214
- # mber).
210
+ # Updates a single `TeamMember` object. The `TeamMember` object is returned
211
+ # on successful updates.
212
+ # Learn about [Troubleshooting the Team
213
+ # API](https://developer.squareup.com/docs/team/troubleshooting#update-a-tea
214
+ # m-member).
215
215
  # @param [String] team_member_id Required parameter: The ID of the team
216
216
  # member to update.
217
217
  # @param [UpdateTeamMemberRequest] body Required parameter: An object
@@ -252,13 +252,13 @@ module Square
252
252
  )
253
253
  end
254
254
 
255
- # Retrieve a `WageSetting` object for a team member specified
255
+ # Retrieves a `WageSetting` object for a team member specified
256
256
  # by `TeamMember.id`.
257
- # Learn about [Troubleshooting the Teams
257
+ # Learn about [Troubleshooting the Team
258
258
  # API](https://developer.squareup.com/docs/team/troubleshooting#retrievewage
259
259
  # setting).
260
260
  # @param [String] team_member_id Required parameter: The ID of the team
261
- # member to retrieve wage setting for
261
+ # member for which to retrieve the wage setting.
262
262
  # @return [RetrieveWageSettingResponse Hash] response from the API call
263
263
  def retrieve_wage_setting(team_member_id:)
264
264
  # Prepare query url.
@@ -295,12 +295,12 @@ module Square
295
295
  # `WageSetting` with the specified `team_member_id` does not exist.
296
296
  # Otherwise,
297
297
  # it fully replaces the `WageSetting` object for the team member.
298
- # The `WageSetting` will be returned upon successful update.
299
- # Learn about [Troubleshooting the Teams
300
- # API](https://developer.squareup.com/docs/team/troubleshooting#updatewagese
301
- # tting).
298
+ # The `WageSetting` is returned on a successful update.
299
+ # Learn about [Troubleshooting the Team
300
+ # API](https://developer.squareup.com/docs/team/troubleshooting#create-or-up
301
+ # date-a-wage-setting).
302
302
  # @param [String] team_member_id Required parameter: The ID of the team
303
- # member to update the `WageSetting` object for.
303
+ # member for which to update the `WageSetting` object.
304
304
  # @param [UpdateWageSettingRequest] body Required parameter: An object
305
305
  # containing the fields to POST for the request. See the corresponding
306
306
  # object definition for field details.
@@ -12,24 +12,29 @@ module Square
12
12
  # Point of Sale applications.
13
13
  # Refunds with a `status` of `PENDING` are not currently included in this
14
14
  # endpoint's response.
15
- # Max results per [page](#paginatingresults): 50
15
+ # Max results per
16
+ # [page](https://developer.squareup.com/docs/working-with-apis/pagination):
17
+ # 50
16
18
  # @param [String] location_id Required parameter: The ID of the location to
17
19
  # list refunds for.
18
20
  # @param [String] begin_time Optional parameter: The beginning of the
19
21
  # requested reporting period, in RFC 3339 format. See [Date
20
- # ranges](#dateranges) for details on date inclusivity/exclusivity. Default
21
- # value: The current time minus one year.
22
+ # ranges](https://developer.squareup.com/docs/build-basics/working-with-date
23
+ # s) for details on date inclusivity/exclusivity. Default value: The
24
+ # current time minus one year.
22
25
  # @param [String] end_time Optional parameter: The end of the requested
23
- # reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
24
- # details on date inclusivity/exclusivity. Default value: The current
25
- # time.
26
+ # reporting period, in RFC 3339 format. See [Date
27
+ # ranges](https://developer.squareup.com/docs/build-basics/working-with-date
28
+ # s) for details on date inclusivity/exclusivity. Default value: The
29
+ # current time.
26
30
  # @param [SortOrder] sort_order Optional parameter: The order in which
27
31
  # results are listed in the response (`ASC` for oldest first, `DESC` for
28
32
  # newest first). Default value: `DESC`
29
33
  # @param [String] cursor Optional parameter: A pagination cursor returned by
30
34
  # a previous call to this endpoint. Provide this to retrieve the next set of
31
35
  # results for your original query. See [Paginating
32
- # results](#paginatingresults) for more information.
36
+ # results](https://developer.squareup.com/docs/working-with-apis/pagination)
37
+ # for more information.
33
38
  # @return [ListRefundsResponse Hash] response from the API call
34
39
  def list_refunds(location_id:,
35
40
  begin_time: nil,
@@ -78,24 +83,29 @@ module Square
78
83
  # Transactions include payment information from sales and exchanges and
79
84
  # refund
80
85
  # information from returns and exchanges.
81
- # Max results per [page](#paginatingresults): 50
86
+ # Max results per
87
+ # [page](https://developer.squareup.com/docs/working-with-apis/pagination):
88
+ # 50
82
89
  # @param [String] location_id Required parameter: The ID of the location to
83
90
  # list transactions for.
84
91
  # @param [String] begin_time Optional parameter: The beginning of the
85
92
  # requested reporting period, in RFC 3339 format. See [Date
86
- # ranges](#dateranges) for details on date inclusivity/exclusivity. Default
87
- # value: The current time minus one year.
93
+ # ranges](https://developer.squareup.com/docs/build-basics/working-with-date
94
+ # s) for details on date inclusivity/exclusivity. Default value: The
95
+ # current time minus one year.
88
96
  # @param [String] end_time Optional parameter: The end of the requested
89
- # reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
90
- # details on date inclusivity/exclusivity. Default value: The current
91
- # time.
97
+ # reporting period, in RFC 3339 format. See [Date
98
+ # ranges](https://developer.squareup.com/docs/build-basics/working-with-date
99
+ # s) for details on date inclusivity/exclusivity. Default value: The
100
+ # current time.
92
101
  # @param [SortOrder] sort_order Optional parameter: The order in which
93
102
  # results are listed in the response (`ASC` for oldest first, `DESC` for
94
103
  # newest first). Default value: `DESC`
95
104
  # @param [String] cursor Optional parameter: A pagination cursor returned by
96
105
  # a previous call to this endpoint. Provide this to retrieve the next set of
97
106
  # results for your original query. See [Paginating
98
- # results](#paginatingresults) for more information.
107
+ # results](https://developer.squareup.com/docs/working-with-apis/pagination)
108
+ # for more information.
99
109
  # @return [ListTransactionsResponse Hash] response from the API call
100
110
  def list_transactions(location_id:,
101
111
  begin_time: nil,
@@ -142,8 +152,9 @@ module Square
142
152
 
143
153
  # Charges a card represented by a card nonce or a customer's card on file.
144
154
  # Your request to this endpoint must include _either_:
145
- # - A value for the `card_nonce` parameter (to charge a card nonce generated
146
- # with the `SqPaymentForm`)
155
+ # - A value for the `card_nonce` parameter (to charge a card payment token
156
+ # generated
157
+ # with the Web Payments SDK)
147
158
  # - Values for the `customer_card_id` and `customer_id` parameters (to
148
159
  # charge
149
160
  # a customer's card on file)
@@ -156,9 +167,9 @@ module Square
156
167
  # When this response is returned, the amount of Square's processing fee
157
168
  # might not yet be
158
169
  # calculated. To obtain the processing fee, wait about ten seconds and call
159
- # [RetrieveTransaction](#endpoint-retrievetransaction). See the
170
+ # [RetrieveTransaction]($e/Transactions/RetrieveTransaction). See the
160
171
  # `processing_fee_money`
161
- # field of each [Tender included](#type-tender) in the transaction.
172
+ # field of each [Tender included]($m/Tender) in the transaction.
162
173
  # @param [String] location_id Required parameter: The ID of the location to
163
174
  # associate the created transaction with.
164
175
  # @param [ChargeRequest] body Required parameter: An object containing the
@@ -241,7 +252,7 @@ module Square
241
252
  end
242
253
 
243
254
  # Captures a transaction that was created with the
244
- # [Charge](#endpoint-charge)
255
+ # [Charge]($e/Transactions/Charge)
245
256
  # endpoint with a `delay_capture` value of `true`.
246
257
  # See [Delayed capture
247
258
  # transactions](https://developer.squareup.com/docs/payments/transactions/ov
@@ -337,7 +348,8 @@ module Square
337
348
  )
338
349
  end
339
350
 
340
- # Cancels a transaction that was created with the [Charge](#endpoint-charge)
351
+ # Cancels a transaction that was created with the
352
+ # [Charge]($e/Transactions/Charge)
341
353
  # endpoint with a `delay_capture` value of `true`.
342
354
  # See [Delayed capture
343
355
  # transactions](https://developer.squareup.com/docs/payments/transactions/ov