square.rb 9.0.0.20210226 → 11.0.0.20210513

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.
@@ -6,6 +6,9 @@ module Square
6
6
  end
7
7
 
8
8
  # Retrieves a list of payments taken by the account making the request.
9
+ # Results are eventually consistent, and new payments or changes to payments
10
+ # might take several
11
+ # seconds to appear.
9
12
  # The maximum results per page is 100.
10
13
  # @param [String] begin_time Optional parameter: The timestamp for the
11
14
  # beginning of the reporting period, in RFC 3339 format. Inclusive. Default:
@@ -83,16 +86,14 @@ module Square
83
86
  )
84
87
  end
85
88
 
86
- # Charges a payment source (for example, a card
87
- # represented by customer's card on file or a card nonce). In addition
88
- # to the payment source, the request must include the
89
- # amount to accept for the payment.
90
- # There are several optional parameters that you can include in the request
91
- # (for example, tip money, whether to autocomplete the payment, or a
92
- # reference ID
93
- # to correlate this payment with another system).
94
- # The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
95
- # to enable application fees.
89
+ # Creates a payment using the provided source. You can use this endpoint
90
+ # to charge a card (credit/debit card or
91
+ # Square gift card) or record a payment that the seller received outside of
92
+ # Square
93
+ # (cash payment from a buyer or a payment that an external entity
94
+ # processed on behalf of the seller).
95
+ # The endpoint creates a
96
+ # `Payment` object and returns it in the response.
96
97
  # @param [CreatePaymentRequest] body Required parameter: An object
97
98
  # containing the fields to POST for the request. See the corresponding
98
99
  # object definition for field details.
@@ -209,11 +210,53 @@ module Square
209
210
  )
210
211
  end
211
212
 
212
- # Cancels (voids) a payment. If you set `autocomplete` to `false` when
213
- # creating a payment,
214
- # you can cancel the payment using this endpoint.
215
- # @param [String] payment_id Required parameter: The `payment_id`
216
- # identifying the payment to be canceled.
213
+ # Updates a payment with the APPROVED status.
214
+ # You can update the `amount_money` and `tip_money` using this endpoint.
215
+ # @param [String] payment_id Required parameter: The ID of the payment to
216
+ # update.
217
+ # @param [UpdatePaymentRequest] body Required parameter: An object
218
+ # containing the fields to POST for the request. See the corresponding
219
+ # object definition for field details.
220
+ # @return [UpdatePaymentResponse Hash] response from the API call
221
+ def update_payment(payment_id:,
222
+ body:)
223
+ # Prepare query url.
224
+ _query_builder = config.get_base_uri
225
+ _query_builder << '/v2/payments/{payment_id}'
226
+ _query_builder = APIHelper.append_url_with_template_parameters(
227
+ _query_builder,
228
+ 'payment_id' => { 'value' => payment_id, 'encode' => true }
229
+ )
230
+ _query_url = APIHelper.clean_url _query_builder
231
+
232
+ # Prepare headers.
233
+ _headers = {
234
+ 'accept' => 'application/json',
235
+ 'content-type' => 'application/json; charset=utf-8'
236
+ }
237
+
238
+ # Prepare and execute HttpRequest.
239
+ _request = config.http_client.put(
240
+ _query_url,
241
+ headers: _headers,
242
+ parameters: body.to_json
243
+ )
244
+ OAuth2.apply(config, _request)
245
+ _response = execute_request(_request)
246
+
247
+ # Return appropriate response type.
248
+ decoded = APIHelper.json_deserialize(_response.raw_body)
249
+ _errors = APIHelper.map_response(decoded, ['errors'])
250
+ ApiResponse.new(
251
+ _response, data: decoded, errors: _errors
252
+ )
253
+ end
254
+
255
+ # Cancels (voids) a payment. You can use this endpoint to cancel a payment
256
+ # with
257
+ # the APPROVED `status`.
258
+ # @param [String] payment_id Required parameter: The ID of the payment to
259
+ # cancel.
217
260
  # @return [CancelPaymentResponse Hash] response from the API call
218
261
  def cancel_payment(payment_id:)
219
262
  # Prepare query url.
@@ -249,9 +292,8 @@ module Square
249
292
  # Completes (captures) a payment.
250
293
  # By default, payments are set to complete immediately after they are
251
294
  # created.
252
- # If you set `autocomplete` to `false` when creating a payment, you can
253
- # complete (capture)
254
- # the payment using this endpoint.
295
+ # You can use this endpoint to complete a payment with the APPROVED
296
+ # `status`.
255
297
  # @param [String] payment_id Required parameter: The unique ID identifying
256
298
  # the payment to be completed.
257
299
  # @return [CompletePaymentResponse Hash] response from the API call
@@ -6,6 +6,9 @@ module Square
6
6
  end
7
7
 
8
8
  # Retrieves a list of refunds for the account making the request.
9
+ # Results are eventually consistent, and new refunds or changes to refunds
10
+ # might take several
11
+ # seconds to appear.
9
12
  # The maximum results per page is 100.
10
13
  # @param [String] begin_time Optional parameter: The timestamp for the
11
14
  # beginning of the requested reporting period, in RFC 3339 format. Default:
@@ -26,7 +29,7 @@ module Square
26
29
  # associated with the seller.
27
30
  # @param [String] status Optional parameter: If provided, only refunds with
28
31
  # the given status are returned. For a list of refund status values, see
29
- # [PaymentRefund](#type-paymentrefund). Default: If omitted, refunds are
32
+ # [PaymentRefund]($m/PaymentRefund). Default: If omitted, refunds are
30
33
  # returned regardless of their status.
31
34
  # @param [String] source_type Optional parameter: If provided, only refunds
32
35
  # with the given source type are returned. - `CARD` - List refunds only for
@@ -83,7 +86,12 @@ module Square
83
86
  end
84
87
 
85
88
  # Refunds a payment. You can refund the entire payment amount or a
86
- # portion of it.
89
+ # portion of it. You can use this endpoint to refund a card payment or
90
+ # record a
91
+ # refund of a cash or external payment. For more information, see
92
+ # [Refund
93
+ # Payment](https://developer.squareup.com/docs/payments-api/refund-payments)
94
+ # .
87
95
  # @param [RefundPaymentRequest] body Required parameter: An object
88
96
  # containing the fields to POST for the request. See the corresponding
89
97
  # object definition for field details.
@@ -0,0 +1,42 @@
1
+ module Square
2
+ # SitesApi
3
+ class SitesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists the Square Online sites that belong to a seller.
9
+ # __Note:__ Square Online APIs are publicly available as part of an early
10
+ # access program. For more information, see [Early access program for Square
11
+ # Online
12
+ # APIs](https://developer.squareup.com/docs/online-api#early-access-program-
13
+ # for-square-online-apis).
14
+ # @return [ListSitesResponse Hash] response from the API call
15
+ def list_sites
16
+ # Prepare query url.
17
+ _query_builder = config.get_base_uri
18
+ _query_builder << '/v2/sites'
19
+ _query_url = APIHelper.clean_url _query_builder
20
+
21
+ # Prepare headers.
22
+ _headers = {
23
+ 'accept' => 'application/json'
24
+ }
25
+
26
+ # Prepare and execute HttpRequest.
27
+ _request = config.http_client.get(
28
+ _query_url,
29
+ headers: _headers
30
+ )
31
+ OAuth2.apply(config, _request)
32
+ _response = execute_request(_request)
33
+
34
+ # Return appropriate response type.
35
+ decoded = APIHelper.json_deserialize(_response.raw_body)
36
+ _errors = APIHelper.map_response(decoded, ['errors'])
37
+ ApiResponse.new(
38
+ _response, data: decoded, errors: _errors
39
+ )
40
+ end
41
+ end
42
+ end
@@ -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
@@ -54,8 +54,8 @@ module Square
54
54
  # marked as failed, but the body of the response
55
55
  # will contain explicit error information for this particular create.
56
56
  # Learn about [Troubleshooting the Teams
57
- # API](https://developer.squareup.com/docs/team/troubleshooting#bulkcreatete
58
- # ammembers).
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.
@@ -97,8 +97,8 @@ module Square
97
97
  # marked as failed, but the body of the response
98
98
  # will contain explicit error information for this particular update.
99
99
  # Learn about [Troubleshooting the Teams
100
- # API](https://developer.squareup.com/docs/team/troubleshooting#bulkupdatete
101
- # ammembers).
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.
@@ -171,8 +171,8 @@ module Square
171
171
 
172
172
  # Retrieve a `TeamMember` object for the given `TeamMember.id`.
173
173
  # Learn about [Troubleshooting the Teams
174
- # API](https://developer.squareup.com/docs/team/troubleshooting#retrieveteam
175
- # member).
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
@@ -210,8 +210,8 @@ module Square
210
210
  # Updates a single `TeamMember` object. The `TeamMember` will be returned on
211
211
  # successful updates.
212
212
  # Learn about [Troubleshooting the Teams
213
- # API](https://developer.squareup.com/docs/team/troubleshooting#updateteamme
214
- # mber).
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
@@ -297,8 +297,8 @@ module Square
297
297
  # it fully replaces the `WageSetting` object for the team member.
298
298
  # The `WageSetting` will be returned upon successful update.
299
299
  # Learn about [Troubleshooting the Teams
300
- # API](https://developer.squareup.com/docs/team/troubleshooting#updatewagese
301
- # tting).
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
303
  # member to update the `WageSetting` object for.
304
304
  # @param [UpdateWageSettingRequest] body Required parameter: An object
@@ -5,8 +5,9 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Creates a new Terminal checkout request and sends it to the specified
9
- # device to take a payment for the requested amount.
8
+ # Creates a Terminal checkout request and sends it to the specified device
9
+ # to take a payment
10
+ # for the requested amount.
10
11
  # @param [CreateTerminalCheckoutRequest] body Required parameter: An object
11
12
  # containing the fields to POST for the request. See the corresponding
12
13
  # object definition for field details.
@@ -75,9 +76,9 @@ module Square
75
76
  )
76
77
  end
77
78
 
78
- # Retrieves a Terminal checkout request by checkout_id.
79
- # @param [String] checkout_id Required parameter: Unique ID for the desired
80
- # `TerminalCheckout`
79
+ # Retrieves a Terminal checkout request by `checkout_id`.
80
+ # @param [String] checkout_id Required parameter: The unique ID for the
81
+ # desired `TerminalCheckout`.
81
82
  # @return [GetTerminalCheckoutResponse Hash] response from the API call
82
83
  def get_terminal_checkout(checkout_id:)
83
84
  # Prepare query url.
@@ -112,8 +113,8 @@ module Square
112
113
 
113
114
  # Cancels a Terminal checkout request if the status of the request permits
114
115
  # it.
115
- # @param [String] checkout_id Required parameter: Unique ID for the desired
116
- # `TerminalCheckout`
116
+ # @param [String] checkout_id Required parameter: The unique ID for the
117
+ # desired `TerminalCheckout`.
117
118
  # @return [CancelTerminalCheckoutResponse Hash] response from the API call
118
119
  def cancel_terminal_checkout(checkout_id:)
119
120
  # Prepare query url.
@@ -181,7 +182,7 @@ module Square
181
182
  )
182
183
  end
183
184
 
184
- # Retrieves a filtered list of Terminal Interac refund requests created by
185
+ # Retrieves a filtered list of Interac Terminal refund requests created by
185
186
  # the seller making the request.
186
187
  # @param [SearchTerminalRefundsRequest] body Required parameter: An object
187
188
  # containing the fields to POST for the request. See the corresponding
@@ -216,9 +217,9 @@ module Square
216
217
  )
217
218
  end
218
219
 
219
- # Retrieves an Interac terminal refund object by ID.
220
- # @param [String] terminal_refund_id Required parameter: Unique ID for the
221
- # desired `TerminalRefund`
220
+ # Retrieves an Interac Terminal refund object by ID.
221
+ # @param [String] terminal_refund_id Required parameter: The unique ID for
222
+ # the desired `TerminalRefund`.
222
223
  # @return [GetTerminalRefundResponse Hash] response from the API call
223
224
  def get_terminal_refund(terminal_refund_id:)
224
225
  # Prepare query url.
@@ -251,10 +252,10 @@ module Square
251
252
  )
252
253
  end
253
254
 
254
- # Cancels an Interac terminal refund request by refund request ID if the
255
+ # Cancels an Interac Terminal refund request by refund request ID if the
255
256
  # status of the request permits it.
256
- # @param [String] terminal_refund_id Required parameter: Unique ID for the
257
- # desired `TerminalRefund`
257
+ # @param [String] terminal_refund_id Required parameter: The unique ID for
258
+ # the desired `TerminalRefund`.
258
259
  # @return [CancelTerminalRefundResponse Hash] response from the API call
259
260
  def cancel_terminal_refund(terminal_refund_id:)
260
261
  # Prepare query url.