square.rb 5.1.0.20200325 → 6.0.0.20200625

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.
@@ -40,6 +40,9 @@ require_relative 'square/api/bank_accounts_api.rb'
40
40
  require_relative 'square/api/cash_drawers_api.rb'
41
41
  require_relative 'square/api/catalog_api.rb'
42
42
  require_relative 'square/api/customers_api.rb'
43
+ require_relative 'square/api/customer_groups_api.rb'
44
+ require_relative 'square/api/customer_segments_api.rb'
45
+ require_relative 'square/api/devices_api.rb'
43
46
  require_relative 'square/api/disputes_api.rb'
44
47
  require_relative 'square/api/employees_api.rb'
45
48
  require_relative 'square/api/inventory_api.rb'
@@ -49,6 +52,9 @@ require_relative 'square/api/reporting_api.rb'
49
52
  require_relative 'square/api/checkout_api.rb'
50
53
  require_relative 'square/api/orders_api.rb'
51
54
  require_relative 'square/api/transactions_api.rb'
55
+ require_relative 'square/api/loyalty_api.rb'
52
56
  require_relative 'square/api/merchants_api.rb'
53
57
  require_relative 'square/api/payments_api.rb'
54
58
  require_relative 'square/api/refunds_api.rb'
59
+ require_relative 'square/api/team_api.rb'
60
+ require_relative 'square/api/terminal_api.rb'
@@ -8,8 +8,8 @@ module Square
8
8
  @http_call_back = http_call_back
9
9
 
10
10
  @global_headers = {
11
- 'user-agent' => 'Square-Ruby-SDK/5.1.0.20200325',
12
- 'Square-Version' => '2020-03-25'
11
+ 'user-agent' => 'Square-Ruby-SDK/6.0.0.20200625',
12
+ 'Square-Version' => '2020-06-25'
13
13
  }
14
14
  end
15
15
 
@@ -139,34 +139,7 @@ module Square
139
139
  # [CatalogObject](#type-catalogobject) at a later time.
140
140
  # CreateCatalogImage accepts HTTP multipart/form-data requests with a JSON
141
141
  # part and an image file part in
142
- # JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB. The
143
- # following is an example of such an HTTP request:
144
- # ```
145
- # POST /v2/catalog/images
146
- # Accept: application/json
147
- # Content-Type: multipart/form-data;boundary="boundary"
148
- # Square-Version: XXXX-XX-XX
149
- # Authorization: Bearer {ACCESS_TOKEN}
150
- # --boundary
151
- # Content-Disposition: form-data; name="request"
152
- # Content-Type: application/json
153
- # {
154
- # "idempotency_key":"528dea59-7bfb-43c1-bd48-4a6bba7dd61f86",
155
- # "object_id": "ND6EA5AAJEO5WL3JNNIAQA32",
156
- # "image":{
157
- # "id":"#TEMP_ID",
158
- # "type":"IMAGE",
159
- # "image_data":{
160
- # "caption":"A picture of a cup of coffee"
161
- # }
162
- # }
163
- # }
164
- # --boundary
165
- # Content-Disposition: form-data; name="image"; filename="Coffee.jpg"
166
- # Content-Type: image/jpeg
167
- # {ACTUAL_IMAGE_BYTES}
168
- # --boundary
169
- # ```
142
+ # JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
170
143
  # Additional information and an example cURL request can be found in the
171
144
  # [Create a Catalog Image
172
145
  # recipe](https://developer.squareup.com/docs/more-apis/catalog/cookbook/cre
@@ -400,7 +373,7 @@ module Square
400
373
  # `false`
401
374
  # @return [RetrieveCatalogObjectResponse Hash] response from the API call
402
375
  def retrieve_catalog_object(object_id:,
403
- include_related_objects: nil)
376
+ include_related_objects: false)
404
377
  # Prepare query url.
405
378
  _query_builder = config.get_base_uri
406
379
  _query_builder << '/v2/catalog/object/{object_id}'
@@ -433,22 +406,20 @@ module Square
433
406
  ApiResponse.new(_response, data: decoded, errors: _errors)
434
407
  end
435
408
 
436
- # Queries the targeted catalog using a variety of query types:
437
- # [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
438
- # [CatalogQueryExact](#type-catalogqueryexact),
439
- # [CatalogQueryRange](#type-catalogqueryrange),
440
- # [CatalogQueryText](#type-catalogquerytext),
441
- # [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and
442
- # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
443
- # .
444
- # --
445
- # --
446
- # Future end of the above comment:
447
- # [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax),
409
+ # Queries the targeted catalog using a variety of query expressions.
410
+ # Supported query expressions are of the following types:
411
+ # - [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
412
+ # - [CatalogQueryExact](#type-catalogqueryexact),
413
+ # - [CatalogQueryRange](#type-catalogqueryrange),
414
+ # - [CatalogQueryText](#type-catalogquerytext),
415
+ # - [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax),
416
+ # -
448
417
  # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
449
418
  # ,
419
+ # -
450
420
  # [CatalogQueryItemsForItemOptions](#type-catalogqueryitemsforitemoptions),
451
421
  # and
422
+ # -
452
423
  # [CatalogQueryItemVariationsForItemOptionValues](#type-catalogqueryitemvari
453
424
  # ationsforitemoptionvalues).
454
425
  # @param [SearchCatalogObjectsRequest] body Required parameter: An object
@@ -0,0 +1,182 @@
1
+ module Square
2
+ # CustomerGroupsApi
3
+ class CustomerGroupsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Retrieves the list of customer groups of a business.
9
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
10
+ # a previous call to this endpoint. Provide this to retrieve the next set of
11
+ # results for your original query. See the [Pagination
12
+ # guide](https://developer.squareup.com/docs/working-with-apis/pagination)
13
+ # for more information.
14
+ # @return [ListCustomerGroupsResponse Hash] response from the API call
15
+ def list_customer_groups(cursor: nil)
16
+ # Prepare query url.
17
+ _query_builder = config.get_base_uri
18
+ _query_builder << '/v2/customers/groups'
19
+ _query_builder = APIHelper.append_url_with_query_parameters(
20
+ _query_builder,
21
+ 'cursor' => cursor
22
+ )
23
+ _query_url = APIHelper.clean_url _query_builder
24
+
25
+ # Prepare headers.
26
+ _headers = {
27
+ 'accept' => 'application/json'
28
+ }
29
+
30
+ # Prepare and execute HttpRequest.
31
+ _request = config.http_client.get(
32
+ _query_url,
33
+ headers: _headers
34
+ )
35
+ OAuth2.apply(config, _request)
36
+ _response = execute_request(_request)
37
+
38
+ # Return appropriate response type.
39
+ decoded = APIHelper.json_deserialize(_response.raw_body)
40
+ _errors = APIHelper.map_response(decoded, ['errors'])
41
+ ApiResponse.new(_response, data: decoded, errors: _errors)
42
+ end
43
+
44
+ # Creates a new customer group for a business.
45
+ # The request must include the `name` value of the group.
46
+ # @param [CreateCustomerGroupRequest] body Required parameter: An object
47
+ # containing the fields to POST for the request. See the corresponding
48
+ # object definition for field details.
49
+ # @return [CreateCustomerGroupResponse Hash] response from the API call
50
+ def create_customer_group(body:)
51
+ # Prepare query url.
52
+ _query_builder = config.get_base_uri
53
+ _query_builder << '/v2/customers/groups'
54
+ _query_url = APIHelper.clean_url _query_builder
55
+
56
+ # Prepare headers.
57
+ _headers = {
58
+ 'accept' => 'application/json',
59
+ 'content-type' => 'application/json; charset=utf-8'
60
+ }
61
+
62
+ # Prepare and execute HttpRequest.
63
+ _request = config.http_client.post(
64
+ _query_url,
65
+ headers: _headers,
66
+ parameters: body.to_json
67
+ )
68
+ OAuth2.apply(config, _request)
69
+ _response = execute_request(_request)
70
+
71
+ # Return appropriate response type.
72
+ decoded = APIHelper.json_deserialize(_response.raw_body)
73
+ _errors = APIHelper.map_response(decoded, ['errors'])
74
+ ApiResponse.new(_response, data: decoded, errors: _errors)
75
+ end
76
+
77
+ # Deletes a customer group as identified by the `group_id` value.
78
+ # @param [String] group_id Required parameter: The ID of the customer group
79
+ # to delete.
80
+ # @return [DeleteCustomerGroupResponse Hash] response from the API call
81
+ def delete_customer_group(group_id:)
82
+ # Prepare query url.
83
+ _query_builder = config.get_base_uri
84
+ _query_builder << '/v2/customers/groups/{group_id}'
85
+ _query_builder = APIHelper.append_url_with_template_parameters(
86
+ _query_builder,
87
+ 'group_id' => group_id
88
+ )
89
+ _query_url = APIHelper.clean_url _query_builder
90
+
91
+ # Prepare headers.
92
+ _headers = {
93
+ 'accept' => 'application/json'
94
+ }
95
+
96
+ # Prepare and execute HttpRequest.
97
+ _request = config.http_client.delete(
98
+ _query_url,
99
+ headers: _headers
100
+ )
101
+ OAuth2.apply(config, _request)
102
+ _response = execute_request(_request)
103
+
104
+ # Return appropriate response type.
105
+ decoded = APIHelper.json_deserialize(_response.raw_body)
106
+ _errors = APIHelper.map_response(decoded, ['errors'])
107
+ ApiResponse.new(_response, data: decoded, errors: _errors)
108
+ end
109
+
110
+ # Retrieves a specific customer group as identified by the `group_id` value.
111
+ # @param [String] group_id Required parameter: The ID of the customer group
112
+ # to retrieve.
113
+ # @return [RetrieveCustomerGroupResponse Hash] response from the API call
114
+ def retrieve_customer_group(group_id:)
115
+ # Prepare query url.
116
+ _query_builder = config.get_base_uri
117
+ _query_builder << '/v2/customers/groups/{group_id}'
118
+ _query_builder = APIHelper.append_url_with_template_parameters(
119
+ _query_builder,
120
+ 'group_id' => group_id
121
+ )
122
+ _query_url = APIHelper.clean_url _query_builder
123
+
124
+ # Prepare headers.
125
+ _headers = {
126
+ 'accept' => 'application/json'
127
+ }
128
+
129
+ # Prepare and execute HttpRequest.
130
+ _request = config.http_client.get(
131
+ _query_url,
132
+ headers: _headers
133
+ )
134
+ OAuth2.apply(config, _request)
135
+ _response = execute_request(_request)
136
+
137
+ # Return appropriate response type.
138
+ decoded = APIHelper.json_deserialize(_response.raw_body)
139
+ _errors = APIHelper.map_response(decoded, ['errors'])
140
+ ApiResponse.new(_response, data: decoded, errors: _errors)
141
+ end
142
+
143
+ # Updates a customer group as identified by the `group_id` value.
144
+ # @param [String] group_id Required parameter: The ID of the customer group
145
+ # to update.
146
+ # @param [UpdateCustomerGroupRequest] body Required parameter: An object
147
+ # containing the fields to POST for the request. See the corresponding
148
+ # object definition for field details.
149
+ # @return [UpdateCustomerGroupResponse Hash] response from the API call
150
+ def update_customer_group(group_id:,
151
+ body:)
152
+ # Prepare query url.
153
+ _query_builder = config.get_base_uri
154
+ _query_builder << '/v2/customers/groups/{group_id}'
155
+ _query_builder = APIHelper.append_url_with_template_parameters(
156
+ _query_builder,
157
+ 'group_id' => group_id
158
+ )
159
+ _query_url = APIHelper.clean_url _query_builder
160
+
161
+ # Prepare headers.
162
+ _headers = {
163
+ 'accept' => 'application/json',
164
+ 'content-type' => 'application/json; charset=utf-8'
165
+ }
166
+
167
+ # Prepare and execute HttpRequest.
168
+ _request = config.http_client.put(
169
+ _query_url,
170
+ headers: _headers,
171
+ parameters: body.to_json
172
+ )
173
+ OAuth2.apply(config, _request)
174
+ _response = execute_request(_request)
175
+
176
+ # Return appropriate response type.
177
+ decoded = APIHelper.json_deserialize(_response.raw_body)
178
+ _errors = APIHelper.map_response(decoded, ['errors'])
179
+ ApiResponse.new(_response, data: decoded, errors: _errors)
180
+ end
181
+ end
182
+ end
@@ -0,0 +1,78 @@
1
+ module Square
2
+ # CustomerSegmentsApi
3
+ class CustomerSegmentsApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Retrieves the list of customer segments of a business.
9
+ # @param [String] cursor Optional parameter: A pagination cursor returned by
10
+ # previous calls to __ListCustomerSegments__. Used to retrieve the next set
11
+ # of query results. See the [Pagination
12
+ # guide](https://developer.squareup.com/docs/docs/working-with-apis/paginati
13
+ # on) for more information.
14
+ # @return [ListCustomerSegmentsResponse Hash] response from the API call
15
+ def list_customer_segments(cursor: nil)
16
+ # Prepare query url.
17
+ _query_builder = config.get_base_uri
18
+ _query_builder << '/v2/customers/segments'
19
+ _query_builder = APIHelper.append_url_with_query_parameters(
20
+ _query_builder,
21
+ 'cursor' => cursor
22
+ )
23
+ _query_url = APIHelper.clean_url _query_builder
24
+
25
+ # Prepare headers.
26
+ _headers = {
27
+ 'accept' => 'application/json'
28
+ }
29
+
30
+ # Prepare and execute HttpRequest.
31
+ _request = config.http_client.get(
32
+ _query_url,
33
+ headers: _headers
34
+ )
35
+ OAuth2.apply(config, _request)
36
+ _response = execute_request(_request)
37
+
38
+ # Return appropriate response type.
39
+ decoded = APIHelper.json_deserialize(_response.raw_body)
40
+ _errors = APIHelper.map_response(decoded, ['errors'])
41
+ ApiResponse.new(_response, data: decoded, errors: _errors)
42
+ end
43
+
44
+ # Retrieves a specific customer segment as identified by the `segment_id`
45
+ # value.
46
+ # @param [String] segment_id Required parameter: The Square-issued ID of the
47
+ # customer segment.
48
+ # @return [RetrieveCustomerSegmentResponse Hash] response from the API call
49
+ def retrieve_customer_segment(segment_id:)
50
+ # Prepare query url.
51
+ _query_builder = config.get_base_uri
52
+ _query_builder << '/v2/customers/segments/{segment_id}'
53
+ _query_builder = APIHelper.append_url_with_template_parameters(
54
+ _query_builder,
55
+ 'segment_id' => segment_id
56
+ )
57
+ _query_url = APIHelper.clean_url _query_builder
58
+
59
+ # Prepare headers.
60
+ _headers = {
61
+ 'accept' => 'application/json'
62
+ }
63
+
64
+ # Prepare and execute HttpRequest.
65
+ _request = config.http_client.get(
66
+ _query_url,
67
+ headers: _headers
68
+ )
69
+ OAuth2.apply(config, _request)
70
+ _response = execute_request(_request)
71
+
72
+ # Return appropriate response type.
73
+ decoded = APIHelper.json_deserialize(_response.raw_body)
74
+ _errors = APIHelper.map_response(decoded, ['errors'])
75
+ ApiResponse.new(_response, data: decoded, errors: _errors)
76
+ end
77
+ end
78
+ end
@@ -5,7 +5,13 @@ module Square
5
5
  super(config, http_call_back: http_call_back)
6
6
  end
7
7
 
8
- # Lists a business's customers.
8
+ # Lists customer profiles associated with a Square account.
9
+ # Under normal operating conditions, newly created or updated customer
10
+ # profiles become available
11
+ # for the listing operation in well under 30 seconds. Occasionally,
12
+ # propagation of the new or updated
13
+ # profiles can take closer to one minute or longer, espeically during
14
+ # network incidents and outages.
9
15
  # @param [String] cursor Optional parameter: A pagination cursor returned by
10
16
  # a previous call to this endpoint. Provide this to retrieve the next set of
11
17
  # results for your original query. See the [Pagination
@@ -91,10 +97,17 @@ module Square
91
97
  ApiResponse.new(_response, data: decoded, errors: _errors)
92
98
  end
93
99
 
94
- # Searches the customer profiles associated with a Square account.
95
- # Calling SearchCustomers without an explicit query parameter returns all
100
+ # Searches the customer profiles associated with a Square account using
101
+ # one or more supported query filters.
102
+ # Calling `SearchCustomers` without any explicit query filter returns all
96
103
  # customer profiles ordered alphabetically based on `given_name` and
97
104
  # `family_name`.
105
+ # Under normal operating conditions, newly created or updated customer
106
+ # profiles become available
107
+ # for the search operation in well under 30 seconds. Occasionally,
108
+ # propagation of the new or updated
109
+ # profiles can take closer to one minute or longer, espeically during
110
+ # network incidents and outages.
98
111
  # @param [SearchCustomersRequest] body Required parameter: An object
99
112
  # containing the fields to POST for the request. See the corresponding
100
113
  # object definition for field details.
@@ -323,5 +336,83 @@ module Square
323
336
  _errors = APIHelper.map_response(decoded, ['errors'])
324
337
  ApiResponse.new(_response, data: decoded, errors: _errors)
325
338
  end
339
+
340
+ # Removes a group membership from a customer.
341
+ # The customer is identified by the `customer_id` value
342
+ # and the customer group is identified by the `group_id` value.
343
+ # @param [String] customer_id Required parameter: The ID of the customer to
344
+ # remove from the group.
345
+ # @param [String] group_id Required parameter: The ID of the customer group
346
+ # to remove the customer from.
347
+ # @return [RemoveGroupFromCustomerResponse Hash] response from the API call
348
+ def remove_group_from_customer(customer_id:,
349
+ group_id:)
350
+ # Prepare query url.
351
+ _query_builder = config.get_base_uri
352
+ _query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
353
+ _query_builder = APIHelper.append_url_with_template_parameters(
354
+ _query_builder,
355
+ 'customer_id' => customer_id,
356
+ 'group_id' => group_id
357
+ )
358
+ _query_url = APIHelper.clean_url _query_builder
359
+
360
+ # Prepare headers.
361
+ _headers = {
362
+ 'accept' => 'application/json'
363
+ }
364
+
365
+ # Prepare and execute HttpRequest.
366
+ _request = config.http_client.delete(
367
+ _query_url,
368
+ headers: _headers
369
+ )
370
+ OAuth2.apply(config, _request)
371
+ _response = execute_request(_request)
372
+
373
+ # Return appropriate response type.
374
+ decoded = APIHelper.json_deserialize(_response.raw_body)
375
+ _errors = APIHelper.map_response(decoded, ['errors'])
376
+ ApiResponse.new(_response, data: decoded, errors: _errors)
377
+ end
378
+
379
+ # Adds a group membership to a customer.
380
+ # The customer is identified by the `customer_id` value
381
+ # and the customer group is identified by the `group_id` value.
382
+ # @param [String] customer_id Required parameter: The ID of the customer to
383
+ # add to a group.
384
+ # @param [String] group_id Required parameter: The ID of the customer group
385
+ # to add the customer to.
386
+ # @return [AddGroupToCustomerResponse Hash] response from the API call
387
+ def add_group_to_customer(customer_id:,
388
+ group_id:)
389
+ # Prepare query url.
390
+ _query_builder = config.get_base_uri
391
+ _query_builder << '/v2/customers/{customer_id}/groups/{group_id}'
392
+ _query_builder = APIHelper.append_url_with_template_parameters(
393
+ _query_builder,
394
+ 'customer_id' => customer_id,
395
+ 'group_id' => group_id
396
+ )
397
+ _query_url = APIHelper.clean_url _query_builder
398
+
399
+ # Prepare headers.
400
+ _headers = {
401
+ 'accept' => 'application/json'
402
+ }
403
+
404
+ # Prepare and execute HttpRequest.
405
+ _request = config.http_client.put(
406
+ _query_url,
407
+ headers: _headers
408
+ )
409
+ OAuth2.apply(config, _request)
410
+ _response = execute_request(_request)
411
+
412
+ # Return appropriate response type.
413
+ decoded = APIHelper.json_deserialize(_response.raw_body)
414
+ _errors = APIHelper.map_response(decoded, ['errors'])
415
+ ApiResponse.new(_response, data: decoded, errors: _errors)
416
+ end
326
417
  end
327
418
  end