square.rb 11.0.0.20210513 → 12.0.0.20210616

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.
@@ -0,0 +1,127 @@
1
+ module Square
2
+ # GiftCardActivitiesApi
3
+ class GiftCardActivitiesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists gift card activities. By default, you get gift card activities for
9
+ # all
10
+ # gift cards in the seller's account. You can optionally specify query
11
+ # parameters to
12
+ # filter the list. For example, you can get a list of gift card activities
13
+ # for a gift card,
14
+ # for all gift cards in a specific region, or for activities within a time
15
+ # window.
16
+ # @param [String] gift_card_id Optional parameter: If you provide a gift
17
+ # card ID, the endpoint returns activities that belong to the specified
18
+ # gift card. Otherwise, the endpoint returns all gift card activities for
19
+ # the seller.
20
+ # @param [String] type Optional parameter: If you provide a type, the
21
+ # endpoint returns gift card activities of this type. Otherwise, the
22
+ # endpoint returns all types of gift card activities.
23
+ # @param [String] location_id Optional parameter: If you provide a location
24
+ # ID, the endpoint returns gift card activities for that location.
25
+ # Otherwise, the endpoint returns gift card activities for all locations.
26
+ # @param [String] begin_time Optional parameter: The timestamp for the
27
+ # beginning of the reporting period, in RFC 3339 format. Inclusive. Default:
28
+ # The current time minus one year.
29
+ # @param [String] end_time Optional parameter: The timestamp for the end of
30
+ # the reporting period, in RFC 3339 format. Inclusive. Default: The current
31
+ # time.
32
+ # @param [Integer] limit Optional parameter: If you provide a limit value,
33
+ # the endpoint returns the specified number of results (or less) per page.
34
+ # A maximum value is 100. The default value is 50.
35
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
36
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
37
+ # set of results for the original query. If you do not provide the cursor,
38
+ # the call returns the first page of the results.
39
+ # @param [String] sort_order Optional parameter: The order in which the
40
+ # endpoint returns the activities, based on `created_at`. - `ASC` - Oldest
41
+ # to newest. - `DESC` - Newest to oldest (default).
42
+ # @return [ListGiftCardActivitiesResponse Hash] response from the API call
43
+ def list_gift_card_activities(gift_card_id: nil,
44
+ type: nil,
45
+ location_id: nil,
46
+ begin_time: nil,
47
+ end_time: nil,
48
+ limit: nil,
49
+ cursor: nil,
50
+ sort_order: nil)
51
+ # Prepare query url.
52
+ _query_builder = config.get_base_uri
53
+ _query_builder << '/v2/gift-cards/activities'
54
+ _query_builder = APIHelper.append_url_with_query_parameters(
55
+ _query_builder,
56
+ 'gift_card_id' => gift_card_id,
57
+ 'type' => type,
58
+ 'location_id' => location_id,
59
+ 'begin_time' => begin_time,
60
+ 'end_time' => end_time,
61
+ 'limit' => limit,
62
+ 'cursor' => cursor,
63
+ 'sort_order' => sort_order
64
+ )
65
+ _query_url = APIHelper.clean_url _query_builder
66
+
67
+ # Prepare headers.
68
+ _headers = {
69
+ 'accept' => 'application/json'
70
+ }
71
+
72
+ # Prepare and execute HttpRequest.
73
+ _request = config.http_client.get(
74
+ _query_url,
75
+ headers: _headers
76
+ )
77
+ OAuth2.apply(config, _request)
78
+ _response = execute_request(_request)
79
+
80
+ # Return appropriate response type.
81
+ decoded = APIHelper.json_deserialize(_response.raw_body)
82
+ _errors = APIHelper.map_response(decoded, ['errors'])
83
+ ApiResponse.new(
84
+ _response, data: decoded, errors: _errors
85
+ )
86
+ end
87
+
88
+ # Creates a gift card activity. For more information, see
89
+ # [GiftCardActivity](https://developer.squareup.com/docs/gift-cards/using-gi
90
+ # ft-cards-api#giftcardactivity) and
91
+ # [Using activated gift
92
+ # cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
93
+ # #using-activated-gift-cards).
94
+ # @param [CreateGiftCardActivityRequest] body Required parameter: An object
95
+ # containing the fields to POST for the request. See the corresponding
96
+ # object definition for field details.
97
+ # @return [CreateGiftCardActivityResponse Hash] response from the API call
98
+ def create_gift_card_activity(body:)
99
+ # Prepare query url.
100
+ _query_builder = config.get_base_uri
101
+ _query_builder << '/v2/gift-cards/activities'
102
+ _query_url = APIHelper.clean_url _query_builder
103
+
104
+ # Prepare headers.
105
+ _headers = {
106
+ 'accept' => 'application/json',
107
+ 'content-type' => 'application/json; charset=utf-8'
108
+ }
109
+
110
+ # Prepare and execute HttpRequest.
111
+ _request = config.http_client.post(
112
+ _query_url,
113
+ headers: _headers,
114
+ parameters: body.to_json
115
+ )
116
+ OAuth2.apply(config, _request)
117
+ _response = execute_request(_request)
118
+
119
+ # Return appropriate response type.
120
+ decoded = APIHelper.json_deserialize(_response.raw_body)
121
+ _errors = APIHelper.map_response(decoded, ['errors'])
122
+ ApiResponse.new(
123
+ _response, data: decoded, errors: _errors
124
+ )
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,291 @@
1
+ module Square
2
+ # GiftCardsApi
3
+ class GiftCardsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists all gift cards. You can specify optional filters to retrieve
9
+ # a subset of the gift cards.
10
+ # @param [String] type Optional parameter: If a type is provided, gift cards
11
+ # of this type are returned (see [GiftCardType]($m/GiftCardType)). If no
12
+ # type is provided, it returns gift cards of all types.
13
+ # @param [String] state Optional parameter: If the state is provided, it
14
+ # returns the gift cards in the specified state (see
15
+ # [GiftCardStatus]($m/GiftCardStatus)). Otherwise, it returns the gift cards
16
+ # of all states.
17
+ # @param [Integer] limit Optional parameter: If a value is provided, it
18
+ # returns only that number of results per page. The maximum number of
19
+ # results allowed per page is 50. The default value is 30.
20
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
21
+ # a previous call to this endpoint. Provide this cursor to retrieve the next
22
+ # set of results for the original query. If a cursor is not provided, it
23
+ # returns the first page of the results. For more information, see
24
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
25
+ # ion).
26
+ # @param [String] customer_id Optional parameter: If a value is provided,
27
+ # returns only the gift cards linked to the specified customer
28
+ # @return [ListGiftCardsResponse Hash] response from the API call
29
+ def list_gift_cards(type: nil,
30
+ state: nil,
31
+ limit: nil,
32
+ cursor: nil,
33
+ customer_id: nil)
34
+ # Prepare query url.
35
+ _query_builder = config.get_base_uri
36
+ _query_builder << '/v2/gift-cards'
37
+ _query_builder = APIHelper.append_url_with_query_parameters(
38
+ _query_builder,
39
+ 'type' => type,
40
+ 'state' => state,
41
+ 'limit' => limit,
42
+ 'cursor' => cursor,
43
+ 'customer_id' => customer_id
44
+ )
45
+ _query_url = APIHelper.clean_url _query_builder
46
+
47
+ # Prepare headers.
48
+ _headers = {
49
+ 'accept' => 'application/json'
50
+ }
51
+
52
+ # Prepare and execute HttpRequest.
53
+ _request = config.http_client.get(
54
+ _query_url,
55
+ headers: _headers
56
+ )
57
+ OAuth2.apply(config, _request)
58
+ _response = execute_request(_request)
59
+
60
+ # Return appropriate response type.
61
+ decoded = APIHelper.json_deserialize(_response.raw_body)
62
+ _errors = APIHelper.map_response(decoded, ['errors'])
63
+ ApiResponse.new(
64
+ _response, data: decoded, errors: _errors
65
+ )
66
+ end
67
+
68
+ # Creates a digital gift card. You must activate the gift card before
69
+ # it can be used. For more information, see
70
+ # [Selling gift
71
+ # cards](https://developer.squareup.com/docs/gift-cards/using-gift-cards-api
72
+ # #selling-square-gift-cards).
73
+ # @param [CreateGiftCardRequest] body Required parameter: An object
74
+ # containing the fields to POST for the request. See the corresponding
75
+ # object definition for field details.
76
+ # @return [CreateGiftCardResponse Hash] response from the API call
77
+ def create_gift_card(body:)
78
+ # Prepare query url.
79
+ _query_builder = config.get_base_uri
80
+ _query_builder << '/v2/gift-cards'
81
+ _query_url = APIHelper.clean_url _query_builder
82
+
83
+ # Prepare headers.
84
+ _headers = {
85
+ 'accept' => 'application/json',
86
+ 'content-type' => 'application/json; charset=utf-8'
87
+ }
88
+
89
+ # Prepare and execute HttpRequest.
90
+ _request = config.http_client.post(
91
+ _query_url,
92
+ headers: _headers,
93
+ parameters: body.to_json
94
+ )
95
+ OAuth2.apply(config, _request)
96
+ _response = execute_request(_request)
97
+
98
+ # Return appropriate response type.
99
+ decoded = APIHelper.json_deserialize(_response.raw_body)
100
+ _errors = APIHelper.map_response(decoded, ['errors'])
101
+ ApiResponse.new(
102
+ _response, data: decoded, errors: _errors
103
+ )
104
+ end
105
+
106
+ # Retrieves a gift card using the gift card account number (GAN).
107
+ # @param [RetrieveGiftCardFromGANRequest] body Required parameter: An object
108
+ # containing the fields to POST for the request. See the corresponding
109
+ # object definition for field details.
110
+ # @return [RetrieveGiftCardFromGANResponse Hash] response from the API call
111
+ def retrieve_gift_card_from_gan(body:)
112
+ # Prepare query url.
113
+ _query_builder = config.get_base_uri
114
+ _query_builder << '/v2/gift-cards/from-gan'
115
+ _query_url = APIHelper.clean_url _query_builder
116
+
117
+ # Prepare headers.
118
+ _headers = {
119
+ 'accept' => 'application/json',
120
+ 'content-type' => 'application/json; charset=utf-8'
121
+ }
122
+
123
+ # Prepare and execute HttpRequest.
124
+ _request = config.http_client.post(
125
+ _query_url,
126
+ headers: _headers,
127
+ parameters: body.to_json
128
+ )
129
+ OAuth2.apply(config, _request)
130
+ _response = execute_request(_request)
131
+
132
+ # Return appropriate response type.
133
+ decoded = APIHelper.json_deserialize(_response.raw_body)
134
+ _errors = APIHelper.map_response(decoded, ['errors'])
135
+ ApiResponse.new(
136
+ _response, data: decoded, errors: _errors
137
+ )
138
+ end
139
+
140
+ # Retrieves a gift card using a nonce (a secure token) that represents the
141
+ # gift card.
142
+ # @param [RetrieveGiftCardFromNonceRequest] body Required parameter: An
143
+ # object containing the fields to POST for the request. See the
144
+ # corresponding object definition for field details.
145
+ # @return [RetrieveGiftCardFromNonceResponse Hash] response from the API call
146
+ def retrieve_gift_card_from_nonce(body:)
147
+ # Prepare query url.
148
+ _query_builder = config.get_base_uri
149
+ _query_builder << '/v2/gift-cards/from-nonce'
150
+ _query_url = APIHelper.clean_url _query_builder
151
+
152
+ # Prepare headers.
153
+ _headers = {
154
+ 'accept' => 'application/json',
155
+ 'content-type' => 'application/json; charset=utf-8'
156
+ }
157
+
158
+ # Prepare and execute HttpRequest.
159
+ _request = config.http_client.post(
160
+ _query_url,
161
+ headers: _headers,
162
+ parameters: body.to_json
163
+ )
164
+ OAuth2.apply(config, _request)
165
+ _response = execute_request(_request)
166
+
167
+ # Return appropriate response type.
168
+ decoded = APIHelper.json_deserialize(_response.raw_body)
169
+ _errors = APIHelper.map_response(decoded, ['errors'])
170
+ ApiResponse.new(
171
+ _response, data: decoded, errors: _errors
172
+ )
173
+ end
174
+
175
+ # Links a customer to a gift card
176
+ # @param [String] gift_card_id Required parameter: The ID of the gift card
177
+ # to link.
178
+ # @param [LinkCustomerToGiftCardRequest] body Required parameter: An object
179
+ # containing the fields to POST for the request. See the corresponding
180
+ # object definition for field details.
181
+ # @return [LinkCustomerToGiftCardResponse Hash] response from the API call
182
+ def link_customer_to_gift_card(gift_card_id:,
183
+ body:)
184
+ # Prepare query url.
185
+ _query_builder = config.get_base_uri
186
+ _query_builder << '/v2/gift-cards/{gift_card_id}/link-customer'
187
+ _query_builder = APIHelper.append_url_with_template_parameters(
188
+ _query_builder,
189
+ 'gift_card_id' => { 'value' => gift_card_id, 'encode' => true }
190
+ )
191
+ _query_url = APIHelper.clean_url _query_builder
192
+
193
+ # Prepare headers.
194
+ _headers = {
195
+ 'accept' => 'application/json',
196
+ 'content-type' => 'application/json; charset=utf-8'
197
+ }
198
+
199
+ # Prepare and execute HttpRequest.
200
+ _request = config.http_client.post(
201
+ _query_url,
202
+ headers: _headers,
203
+ parameters: body.to_json
204
+ )
205
+ OAuth2.apply(config, _request)
206
+ _response = execute_request(_request)
207
+
208
+ # Return appropriate response type.
209
+ decoded = APIHelper.json_deserialize(_response.raw_body)
210
+ _errors = APIHelper.map_response(decoded, ['errors'])
211
+ ApiResponse.new(
212
+ _response, data: decoded, errors: _errors
213
+ )
214
+ end
215
+
216
+ # Unlinks a customer from a gift card
217
+ # @param [String] gift_card_id Required parameter: Example:
218
+ # @param [UnlinkCustomerFromGiftCardRequest] body Required parameter: An
219
+ # object containing the fields to POST for the request. See the
220
+ # corresponding object definition for field details.
221
+ # @return [UnlinkCustomerFromGiftCardResponse Hash] response from the API call
222
+ def unlink_customer_from_gift_card(gift_card_id:,
223
+ body:)
224
+ # Prepare query url.
225
+ _query_builder = config.get_base_uri
226
+ _query_builder << '/v2/gift-cards/{gift_card_id}/unlink-customer'
227
+ _query_builder = APIHelper.append_url_with_template_parameters(
228
+ _query_builder,
229
+ 'gift_card_id' => { 'value' => gift_card_id, 'encode' => true }
230
+ )
231
+ _query_url = APIHelper.clean_url _query_builder
232
+
233
+ # Prepare headers.
234
+ _headers = {
235
+ 'accept' => 'application/json',
236
+ 'content-type' => 'application/json; charset=utf-8'
237
+ }
238
+
239
+ # Prepare and execute HttpRequest.
240
+ _request = config.http_client.post(
241
+ _query_url,
242
+ headers: _headers,
243
+ parameters: body.to_json
244
+ )
245
+ OAuth2.apply(config, _request)
246
+ _response = execute_request(_request)
247
+
248
+ # Return appropriate response type.
249
+ decoded = APIHelper.json_deserialize(_response.raw_body)
250
+ _errors = APIHelper.map_response(decoded, ['errors'])
251
+ ApiResponse.new(
252
+ _response, data: decoded, errors: _errors
253
+ )
254
+ end
255
+
256
+ # Retrieves a gift card using its ID.
257
+ # @param [String] id Required parameter: The ID of the gift card to
258
+ # retrieve.
259
+ # @return [RetrieveGiftCardResponse Hash] response from the API call
260
+ def retrieve_gift_card(id:)
261
+ # Prepare query url.
262
+ _query_builder = config.get_base_uri
263
+ _query_builder << '/v2/gift-cards/{id}'
264
+ _query_builder = APIHelper.append_url_with_template_parameters(
265
+ _query_builder,
266
+ 'id' => { 'value' => id, 'encode' => true }
267
+ )
268
+ _query_url = APIHelper.clean_url _query_builder
269
+
270
+ # Prepare headers.
271
+ _headers = {
272
+ 'accept' => 'application/json'
273
+ }
274
+
275
+ # Prepare and execute HttpRequest.
276
+ _request = config.http_client.get(
277
+ _query_url,
278
+ headers: _headers
279
+ )
280
+ OAuth2.apply(config, _request)
281
+ _response = execute_request(_request)
282
+
283
+ # Return appropriate response type.
284
+ decoded = APIHelper.json_deserialize(_response.raw_body)
285
+ _errors = APIHelper.map_response(decoded, ['errors'])
286
+ ApiResponse.new(
287
+ _response, data: decoded, errors: _errors
288
+ )
289
+ end
290
+ end
291
+ end
@@ -7,9 +7,9 @@ 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
15
  # expire after __30 days__.
@@ -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).
28
+ # page in the [developer dashboard](https://developer.squareup.com/apps).
29
29
  # @param [String] client_id Required parameter: Your application ID,
30
- # available from the [application
31
- # dashboard](https://connect.squareup.com/apps).
30
+ # available from 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.
@@ -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 in the [developer dashboard](https://developer.squareup.com/apps).
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.