square.rb 13.1.0.20210818 → 14.1.0.20210915

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a624808dd5bb0375fef64adf65cbe8203c6b582bd38e34afb69b4b0c0f4fd8a4
4
- data.tar.gz: 849966858b71f5a2b2f4abb9811561156172b591cf2a3c93886bee88c5ecff83
3
+ metadata.gz: cb09b4404e4f7f5cb0923e135ada308b9a9c3482106b0ab8cc2e80eee63f8de0
4
+ data.tar.gz: fc7d73e6a5d955857fe4bfb4341a75cdd80764f3cced0e19afbbb37cdca4d9bb
5
5
  SHA512:
6
- metadata.gz: bcb9330214a8a813a1d6bf405db19dcd2264f70f1745b793c9cf7c844f340dc056cf7a141a0e12ca65187ee02d1c856ee59621ab2143f18e518bdc734bc9f35c
7
- data.tar.gz: 5a93c48a1751fae253c1819fd0c4925b47e3998be01ad9af2acae45cbac6c4a6d9979bf4e0e36baa9475bd54c396135c5d136981fc4b87ec0c04d507cf259698
6
+ metadata.gz: fcf0ff7ca1313121f98083f32cdf8201c30be1814a7f7f6aac89c09e752e129a92ba1f5117f9049559d835846a3e49abfc1d83c906a59c362b8fd05e2c31fbf6
7
+ data.tar.gz: 2870c75eef04c8798e3699c17a4e88296bfe144400b81c7bf4463c0d3bcface04ef151cae4a0b0349266890d16485a4257d5aa4756d4985684dceb789021b0eb
data/README.md CHANGED
@@ -37,6 +37,9 @@ gem 'square.rb'
37
37
  * [Disputes]
38
38
  * [Checkout]
39
39
  * [Apple Pay]
40
+ * [Cards]
41
+
42
+ ### Terminal
40
43
  * [Terminal]
41
44
 
42
45
  ### Orders
@@ -60,6 +63,10 @@ gem 'square.rb'
60
63
  ### Loyalty
61
64
  * [Loyalty]
62
65
 
66
+ ### Gift Cards
67
+ * [Gift Cards]
68
+ * [Gift Card Activities]
69
+
63
70
  ### Bookings
64
71
  * [Bookings]
65
72
 
@@ -67,12 +74,11 @@ gem 'square.rb'
67
74
  * [Merchants]
68
75
  * [Locations]
69
76
  * [Devices]
77
+ * [Cash Drawers]
70
78
 
71
79
  ### Team
72
80
  * [Team]
73
- * [Employees]
74
81
  * [Labor]
75
- * [Cash Drawers]
76
82
 
77
83
  ### Financials
78
84
  * [Bank Accounts]
@@ -86,6 +92,7 @@ gem 'square.rb'
86
92
  * [OAuth]
87
93
 
88
94
  ### Deprecated APIs
95
+ * [Employees]
89
96
  * [V1 Employees]
90
97
  * [V1 Transactions]
91
98
  * [V1 Items]
@@ -337,3 +344,6 @@ You can also use the Square API to create applications or services that work wit
337
344
  [Transactions]: doc/api/transactions.md
338
345
  [Sites]: doc/api/sites.md
339
346
  [Snippets]: doc/api/snippets.md
347
+ [Cards]: doc/api/cards.md
348
+ [Gift Cards]: doc/api/gift-cards.md
349
+ [Gift Card Activities]: doc/api/gift-card-activities.md
@@ -8,7 +8,7 @@ module Square
8
8
  @http_call_back = http_call_back
9
9
 
10
10
  @global_headers = {
11
- 'user-agent' => 'Square-Ruby-SDK/13.1.0.20210818',
11
+ 'user-agent' => 'Square-Ruby-SDK/14.1.0.20210915',
12
12
  'Square-Version' => config.square_version
13
13
  }
14
14
  end
@@ -435,7 +435,7 @@ module Square
435
435
  # Searches for [CatalogObject]($m/CatalogObject) of any type by matching
436
436
  # supported search attribute values,
437
437
  # excluding custom attribute values on items or item variations, against one
438
- # or more of the specified query expressions.
438
+ # or more of the specified query filters.
439
439
  # This (`SearchCatalogObjects`) endpoint differs from the
440
440
  # [SearchCatalogItems]($e/Catalog/SearchCatalogItems)
441
441
  # endpoint in the following aspects:
@@ -485,7 +485,7 @@ module Square
485
485
  # Searches for catalog items or item variations by matching supported search
486
486
  # attribute values, including
487
487
  # custom attribute values, against one or more of the specified query
488
- # expressions.
488
+ # filters.
489
489
  # This (`SearchCatalogItems`) endpoint differs from the
490
490
  # [SearchCatalogObjects]($e/Catalog/SearchCatalogObjects)
491
491
  # endpoint in the following aspects:
@@ -27,8 +27,8 @@ module Square
27
27
  # Credentials
28
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 [developer
31
- # dashboard](https://developer.squareup.com/apps).
30
+ # available from the OAuth page for your application on the Developer
31
+ # Dashboard.
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.
@@ -84,7 +84,7 @@ module Square
84
84
  # Authorization: Client APPLICATION_SECRET
85
85
  # ```
86
86
  # Replace `APPLICATION_SECRET` with the application secret on the OAuth
87
- # page in the [developer dashboard](https://developer.squareup.com/apps).
87
+ # page for your application on the Developer Dashboard.
88
88
  # @param [RevokeTokenRequest] body Required parameter: An object containing
89
89
  # the fields to POST for the request. See the corresponding object
90
90
  # definition for field details.
@@ -121,15 +121,22 @@ module Square
121
121
  )
122
122
  end
123
123
 
124
- # Returns an OAuth access token.
125
- # The endpoint supports distinct methods of obtaining OAuth access tokens.
126
- # Applications specify a method by adding the `grant_type` parameter
127
- # in the request and also provide relevant information.
128
- # __Note:__ Regardless of the method application specified,
129
- # the endpoint always returns two items; an OAuth access token and
130
- # a refresh token in the response.
131
- # __OAuth tokens should only live on secure servers. Application clients
132
- # 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.
133
140
  # @param [ObtainTokenRequest] body Required parameter: An object containing
134
141
  # the fields to POST for the request. See the corresponding object
135
142
  # definition for field details.
@@ -116,6 +116,43 @@ module Square
116
116
  )
117
117
  end
118
118
 
119
+ # Creates a new order, in the `DRAFT` state, by duplicating an existing
120
+ # order. The newly created order has
121
+ # only the core fields (such as line items, taxes, and discounts) copied
122
+ # from the original order.
123
+ # @param [CloneOrderRequest] body Required parameter: An object containing
124
+ # the fields to POST for the request. See the corresponding object
125
+ # definition for field details.
126
+ # @return [CloneOrderResponse Hash] response from the API call
127
+ def clone_order(body:)
128
+ # Prepare query url.
129
+ _query_builder = config.get_base_uri
130
+ _query_builder << '/v2/orders/clone'
131
+ _query_url = APIHelper.clean_url _query_builder
132
+
133
+ # Prepare headers.
134
+ _headers = {
135
+ 'accept' => 'application/json',
136
+ 'content-type' => 'application/json; charset=utf-8'
137
+ }
138
+
139
+ # Prepare and execute HttpRequest.
140
+ _request = config.http_client.post(
141
+ _query_url,
142
+ headers: _headers,
143
+ parameters: body.to_json
144
+ )
145
+ OAuth2.apply(config, _request)
146
+ _response = execute_request(_request)
147
+
148
+ # Return appropriate response type.
149
+ decoded = APIHelper.json_deserialize(_response.raw_body)
150
+ _errors = APIHelper.map_response(decoded, ['errors'])
151
+ ApiResponse.new(
152
+ _response, data: decoded, errors: _errors
153
+ )
154
+ end
155
+
119
156
  # Search all orders for one or more locations. Orders include all sales,
120
157
  # returns, and exchanges regardless of how or when they entered the Square
121
158
  # ecosystem (such as Point of Sale, Invoices, and Connect APIs).
@@ -168,6 +168,7 @@ module Square
168
168
  a.each do |key, value_a|
169
169
  b.each do |k, value_b|
170
170
  next unless key == k
171
+
171
172
  x[k] = []
172
173
  if value_a.instance_of? Array
173
174
  value_a.each do |v|
data/lib/square/client.rb CHANGED
@@ -4,7 +4,7 @@ module Square
4
4
  attr_reader :config
5
5
 
6
6
  def sdk_version
7
- '13.1.0.20210818'
7
+ '14.1.0.20210915'
8
8
  end
9
9
 
10
10
  def square_version
@@ -23,12 +23,6 @@ module Square
23
23
  @o_auth ||= OAuthApi.new config
24
24
  end
25
25
 
26
- # Access to v1_employees controller.
27
- # @return [V1EmployeesApi] Returns the controller instance.
28
- def v1_employees
29
- @v1_employees ||= V1EmployeesApi.new config
30
- end
31
-
32
26
  # Access to v1_transactions controller.
33
27
  # @return [V1TransactionsApi] Returns the controller instance.
34
28
  def v1_transactions
@@ -220,7 +214,7 @@ module Square
220
214
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
221
215
  retry_methods: %i[get put], environment: 'production',
222
216
  custom_url: 'https://connect.squareup.com',
223
- square_version: '2021-08-18', access_token: 'TODO: Replace',
217
+ square_version: '2021-09-15', access_token: 'TODO: Replace',
224
218
  additional_headers: {}, config: nil)
225
219
  @config = if config.nil?
226
220
  Configuration.new(timeout: timeout, max_retries: max_retries,
@@ -3,22 +3,15 @@ module Square
3
3
  # are configured in this class.
4
4
  class Configuration
5
5
  # The attribute readers for properties.
6
- attr_reader :http_client
7
- attr_reader :timeout
8
- attr_reader :max_retries
9
- attr_reader :retry_interval
10
- attr_reader :backoff_factor
11
- attr_reader :retry_statuses
12
- attr_reader :retry_methods
13
- attr_reader :environment
14
- attr_reader :custom_url
15
- attr_reader :square_version
16
- attr_reader :access_token
17
-
6
+ attr_reader :http_client, :timeout, :max_retries, :retry_interval, :backoff_factor,
7
+ :retry_statuses, :retry_methods, :environment, :custom_url, :square_version,
8
+ :access_token,
9
+
18
10
  def additional_headers
19
11
  @additional_headers.clone
20
12
  end
21
13
 
14
+
22
15
  class << self
23
16
  attr_reader :environments
24
17
  end
@@ -28,7 +21,7 @@ module Square
28
21
  retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
29
22
  retry_methods: %i[get put], environment: 'production',
30
23
  custom_url: 'https://connect.squareup.com',
31
- square_version: '2021-08-18', access_token: 'TODO: Replace',
24
+ square_version: '2021-09-15', access_token: 'TODO: Replace',
32
25
  additional_headers: {})
33
26
  # The value to use for connection timeout
34
27
  @timeout = timeout
@@ -1,8 +1,7 @@
1
1
  module Square
2
2
  # A utility to allow users to set the content-type for files
3
3
  class FileWrapper
4
- attr_reader :content_type
5
- attr_reader :file
4
+ attr_reader :content_type, :file
6
5
 
7
6
  def initialize(file, content_type: 'application/octet-stream')
8
7
  @file = file
data/lib/square.rb CHANGED
@@ -4,63 +4,62 @@ require 'faraday'
4
4
  require 'certifi'
5
5
  require 'logging'
6
6
 
7
- require_relative 'square/api_helper.rb'
8
- require_relative 'square/client.rb'
7
+ require_relative 'square/api_helper'
8
+ require_relative 'square/client'
9
9
 
10
10
  # Utilities
11
- require_relative 'square/utilities/file_wrapper.rb'
12
- require_relative 'square/utilities/date_time_helper.rb'
11
+ require_relative 'square/utilities/file_wrapper'
12
+ require_relative 'square/utilities/date_time_helper'
13
13
 
14
14
  # Http
15
- require_relative 'square/http/api_response.rb'
16
- require_relative 'square/http/http_call_back.rb'
17
- require_relative 'square/http/http_client.rb'
18
- require_relative 'square/http/faraday_client.rb'
19
- require_relative 'square/http/http_method_enum.rb'
20
- require_relative 'square/http/http_request.rb'
21
- require_relative 'square/http/http_response.rb'
22
- require_relative 'square/http/auth/o_auth2.rb'
15
+ require_relative 'square/http/api_response'
16
+ require_relative 'square/http/http_call_back'
17
+ require_relative 'square/http/http_client'
18
+ require_relative 'square/http/faraday_client'
19
+ require_relative 'square/http/http_method_enum'
20
+ require_relative 'square/http/http_request'
21
+ require_relative 'square/http/http_response'
22
+ require_relative 'square/http/auth/o_auth2'
23
23
 
24
24
  # Models
25
25
 
26
26
  # Exceptions
27
- require_relative 'square/exceptions/api_exception.rb'
27
+ require_relative 'square/exceptions/api_exception'
28
28
 
29
- require_relative 'square/configuration.rb'
29
+ require_relative 'square/configuration'
30
30
 
31
31
  # Controllers
32
- require_relative 'square/api/base_api.rb'
33
- require_relative 'square/api/mobile_authorization_api.rb'
34
- require_relative 'square/api/o_auth_api.rb'
35
- require_relative 'square/api/v1_employees_api.rb'
36
- require_relative 'square/api/v1_transactions_api.rb'
37
- require_relative 'square/api/apple_pay_api.rb'
38
- require_relative 'square/api/bank_accounts_api.rb'
39
- require_relative 'square/api/bookings_api.rb'
40
- require_relative 'square/api/cards_api.rb'
41
- require_relative 'square/api/cash_drawers_api.rb'
42
- require_relative 'square/api/catalog_api.rb'
43
- require_relative 'square/api/customers_api.rb'
44
- require_relative 'square/api/customer_groups_api.rb'
45
- require_relative 'square/api/customer_segments_api.rb'
46
- require_relative 'square/api/devices_api.rb'
47
- require_relative 'square/api/disputes_api.rb'
48
- require_relative 'square/api/employees_api.rb'
49
- require_relative 'square/api/gift_cards_api.rb'
50
- require_relative 'square/api/gift_card_activities_api.rb'
51
- require_relative 'square/api/inventory_api.rb'
52
- require_relative 'square/api/invoices_api.rb'
53
- require_relative 'square/api/labor_api.rb'
54
- require_relative 'square/api/locations_api.rb'
55
- require_relative 'square/api/checkout_api.rb'
56
- require_relative 'square/api/transactions_api.rb'
57
- require_relative 'square/api/loyalty_api.rb'
58
- require_relative 'square/api/merchants_api.rb'
59
- require_relative 'square/api/orders_api.rb'
60
- require_relative 'square/api/payments_api.rb'
61
- require_relative 'square/api/refunds_api.rb'
62
- require_relative 'square/api/sites_api.rb'
63
- require_relative 'square/api/snippets_api.rb'
64
- require_relative 'square/api/subscriptions_api.rb'
65
- require_relative 'square/api/team_api.rb'
66
- require_relative 'square/api/terminal_api.rb'
32
+ require_relative 'square/api/base_api'
33
+ require_relative 'square/api/mobile_authorization_api'
34
+ require_relative 'square/api/o_auth_api'
35
+ require_relative 'square/api/v1_transactions_api'
36
+ require_relative 'square/api/apple_pay_api'
37
+ require_relative 'square/api/bank_accounts_api'
38
+ require_relative 'square/api/bookings_api'
39
+ require_relative 'square/api/cards_api'
40
+ require_relative 'square/api/cash_drawers_api'
41
+ require_relative 'square/api/catalog_api'
42
+ require_relative 'square/api/customers_api'
43
+ require_relative 'square/api/customer_groups_api'
44
+ require_relative 'square/api/customer_segments_api'
45
+ require_relative 'square/api/devices_api'
46
+ require_relative 'square/api/disputes_api'
47
+ require_relative 'square/api/employees_api'
48
+ require_relative 'square/api/gift_cards_api'
49
+ require_relative 'square/api/gift_card_activities_api'
50
+ require_relative 'square/api/inventory_api'
51
+ require_relative 'square/api/invoices_api'
52
+ require_relative 'square/api/labor_api'
53
+ require_relative 'square/api/locations_api'
54
+ require_relative 'square/api/checkout_api'
55
+ require_relative 'square/api/transactions_api'
56
+ require_relative 'square/api/loyalty_api'
57
+ require_relative 'square/api/merchants_api'
58
+ require_relative 'square/api/orders_api'
59
+ require_relative 'square/api/payments_api'
60
+ require_relative 'square/api/refunds_api'
61
+ require_relative 'square/api/sites_api'
62
+ require_relative 'square/api/snippets_api'
63
+ require_relative 'square/api/subscriptions_api'
64
+ require_relative 'square/api/team_api'
65
+ require_relative 'square/api/terminal_api'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: square.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.1.0.20210818
4
+ version: 14.1.0.20210915
5
5
  platform: ruby
6
6
  authors:
7
7
  - Square Developer Platform
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-18 00:00:00.000000000 Z
11
+ date: 2021-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logging
@@ -31,9 +31,9 @@ dependencies:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.0'
34
- - - "<="
34
+ - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 1.3.0
36
+ version: 1.0.1
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -41,9 +41,9 @@ dependencies:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
43
  version: '1.0'
44
- - - "<="
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 1.3.0
46
+ version: 1.0.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: faraday_middleware
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -169,7 +169,6 @@ files:
169
169
  - lib/square/api/team_api.rb
170
170
  - lib/square/api/terminal_api.rb
171
171
  - lib/square/api/transactions_api.rb
172
- - lib/square/api/v1_employees_api.rb
173
172
  - lib/square/api/v1_transactions_api.rb
174
173
  - lib/square/api_helper.rb
175
174
  - lib/square/client.rb
@@ -219,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
218
  - !ruby/object:Gem::Version
220
219
  version: '0'
221
220
  requirements: []
222
- rubygems_version: 3.1.4
221
+ rubygems_version: 3.1.6
223
222
  signing_key:
224
223
  specification_version: 4
225
224
  summary: square
@@ -1,362 +0,0 @@
1
- module Square
2
- # V1EmployeesApi
3
- class V1EmployeesApi < BaseApi
4
- def initialize(config, http_call_back: nil)
5
- super(config, http_call_back: http_call_back)
6
- end
7
-
8
- # Provides summary information for all of a business's employees.
9
- # @param [SortOrder] order Optional parameter: The order in which employees
10
- # are listed in the response, based on their created_at field. Default
11
- # value: ASC
12
- # @param [String] begin_updated_at Optional parameter: If filtering results
13
- # by their updated_at field, the beginning of the requested reporting
14
- # period, in ISO 8601 format
15
- # @param [String] end_updated_at Optional parameter: If filtering results by
16
- # there updated_at field, the end of the requested reporting period, in ISO
17
- # 8601 format.
18
- # @param [String] begin_created_at Optional parameter: If filtering results
19
- # by their created_at field, the beginning of the requested reporting
20
- # period, in ISO 8601 format.
21
- # @param [String] end_created_at Optional parameter: If filtering results by
22
- # their created_at field, the end of the requested reporting period, in ISO
23
- # 8601 format.
24
- # @param [V1ListEmployeesRequestStatus] status Optional parameter: If
25
- # provided, the endpoint returns only employee entities with the specified
26
- # status (ACTIVE or INACTIVE).
27
- # @param [String] external_id Optional parameter: If provided, the endpoint
28
- # returns only employee entities with the specified external_id.
29
- # @param [Integer] limit Optional parameter: The maximum integer number of
30
- # employee entities to return in a single response. Default 100, maximum
31
- # 200.
32
- # @param [String] batch_token Optional parameter: A pagination cursor to
33
- # retrieve the next set of results for your original query to the
34
- # endpoint.
35
- # @return [List of V1Employee Hash] response from the API call
36
- def list_employees(order: nil,
37
- begin_updated_at: nil,
38
- end_updated_at: nil,
39
- begin_created_at: nil,
40
- end_created_at: nil,
41
- status: nil,
42
- external_id: nil,
43
- limit: nil,
44
- batch_token: nil)
45
- # Prepare query url.
46
- _query_builder = config.get_base_uri
47
- _query_builder << '/v1/me/employees'
48
- _query_builder = APIHelper.append_url_with_query_parameters(
49
- _query_builder,
50
- 'order' => order,
51
- 'begin_updated_at' => begin_updated_at,
52
- 'end_updated_at' => end_updated_at,
53
- 'begin_created_at' => begin_created_at,
54
- 'end_created_at' => end_created_at,
55
- 'status' => status,
56
- 'external_id' => external_id,
57
- 'limit' => limit,
58
- 'batch_token' => batch_token
59
- )
60
- _query_url = APIHelper.clean_url _query_builder
61
-
62
- # Prepare headers.
63
- _headers = {
64
- 'accept' => 'application/json'
65
- }
66
-
67
- # Prepare and execute HttpRequest.
68
- _request = config.http_client.get(
69
- _query_url,
70
- headers: _headers
71
- )
72
- OAuth2.apply(config, _request)
73
- _response = execute_request(_request)
74
-
75
- # Return appropriate response type.
76
- decoded = APIHelper.json_deserialize(_response.raw_body)
77
- _errors = APIHelper.map_response(decoded, ['errors'])
78
- ApiResponse.new(
79
- _response, data: decoded, errors: _errors
80
- )
81
- end
82
-
83
- # Use the CreateEmployee endpoint to add an employee to a Square
84
- # account. Employees created with the Connect API have an initial status
85
- # of `INACTIVE`. Inactive employees cannot sign in to Square Point of Sale
86
- # until they are activated from the Square Dashboard. Employee status
87
- # cannot be changed with the Connect API.
88
- # Employee entities cannot be deleted. To disable employee profiles,
89
- # set the employee's status to <code>INACTIVE</code>
90
- # @param [V1Employee] body Required parameter: An object containing the
91
- # fields to POST for the request. See the corresponding object definition
92
- # for field details.
93
- # @return [V1Employee Hash] response from the API call
94
- def create_employee(body:)
95
- # Prepare query url.
96
- _query_builder = config.get_base_uri
97
- _query_builder << '/v1/me/employees'
98
- _query_url = APIHelper.clean_url _query_builder
99
-
100
- # Prepare headers.
101
- _headers = {
102
- 'accept' => 'application/json',
103
- 'content-type' => 'application/json; charset=utf-8'
104
- }
105
-
106
- # Prepare and execute HttpRequest.
107
- _request = config.http_client.post(
108
- _query_url,
109
- headers: _headers,
110
- parameters: body.to_json
111
- )
112
- OAuth2.apply(config, _request)
113
- _response = execute_request(_request)
114
-
115
- # Return appropriate response type.
116
- decoded = APIHelper.json_deserialize(_response.raw_body)
117
- _errors = APIHelper.map_response(decoded, ['errors'])
118
- ApiResponse.new(
119
- _response, data: decoded, errors: _errors
120
- )
121
- end
122
-
123
- # Provides the details for a single employee.
124
- # @param [String] employee_id Required parameter: The employee's ID.
125
- # @return [V1Employee Hash] response from the API call
126
- def retrieve_employee(employee_id:)
127
- # Prepare query url.
128
- _query_builder = config.get_base_uri
129
- _query_builder << '/v1/me/employees/{employee_id}'
130
- _query_builder = APIHelper.append_url_with_template_parameters(
131
- _query_builder,
132
- 'employee_id' => { 'value' => employee_id, 'encode' => true }
133
- )
134
- _query_url = APIHelper.clean_url _query_builder
135
-
136
- # Prepare headers.
137
- _headers = {
138
- 'accept' => 'application/json'
139
- }
140
-
141
- # Prepare and execute HttpRequest.
142
- _request = config.http_client.get(
143
- _query_url,
144
- headers: _headers
145
- )
146
- OAuth2.apply(config, _request)
147
- _response = execute_request(_request)
148
-
149
- # Return appropriate response type.
150
- decoded = APIHelper.json_deserialize(_response.raw_body)
151
- _errors = APIHelper.map_response(decoded, ['errors'])
152
- ApiResponse.new(
153
- _response, data: decoded, errors: _errors
154
- )
155
- end
156
-
157
- # UpdateEmployee
158
- # @param [String] employee_id Required parameter: The ID of the role to
159
- # modify.
160
- # @param [V1Employee] body Required parameter: An object containing the
161
- # fields to POST for the request. See the corresponding object definition
162
- # for field details.
163
- # @return [V1Employee Hash] response from the API call
164
- def update_employee(employee_id:,
165
- body:)
166
- # Prepare query url.
167
- _query_builder = config.get_base_uri
168
- _query_builder << '/v1/me/employees/{employee_id}'
169
- _query_builder = APIHelper.append_url_with_template_parameters(
170
- _query_builder,
171
- 'employee_id' => { 'value' => employee_id, 'encode' => true }
172
- )
173
- _query_url = APIHelper.clean_url _query_builder
174
-
175
- # Prepare headers.
176
- _headers = {
177
- 'accept' => 'application/json',
178
- 'content-type' => 'application/json; charset=utf-8'
179
- }
180
-
181
- # Prepare and execute HttpRequest.
182
- _request = config.http_client.put(
183
- _query_url,
184
- headers: _headers,
185
- parameters: body.to_json
186
- )
187
- OAuth2.apply(config, _request)
188
- _response = execute_request(_request)
189
-
190
- # Return appropriate response type.
191
- decoded = APIHelper.json_deserialize(_response.raw_body)
192
- _errors = APIHelper.map_response(decoded, ['errors'])
193
- ApiResponse.new(
194
- _response, data: decoded, errors: _errors
195
- )
196
- end
197
-
198
- # Provides summary information for all of a business's employee roles.
199
- # @param [SortOrder] order Optional parameter: The order in which employees
200
- # are listed in the response, based on their created_at field.Default value:
201
- # ASC
202
- # @param [Integer] limit Optional parameter: The maximum integer number of
203
- # employee entities to return in a single response. Default 100, maximum
204
- # 200.
205
- # @param [String] batch_token Optional parameter: A pagination cursor to
206
- # retrieve the next set of results for your original query to the
207
- # endpoint.
208
- # @return [List of V1EmployeeRole Hash] response from the API call
209
- def list_employee_roles(order: nil,
210
- limit: nil,
211
- batch_token: nil)
212
- # Prepare query url.
213
- _query_builder = config.get_base_uri
214
- _query_builder << '/v1/me/roles'
215
- _query_builder = APIHelper.append_url_with_query_parameters(
216
- _query_builder,
217
- 'order' => order,
218
- 'limit' => limit,
219
- 'batch_token' => batch_token
220
- )
221
- _query_url = APIHelper.clean_url _query_builder
222
-
223
- # Prepare headers.
224
- _headers = {
225
- 'accept' => 'application/json'
226
- }
227
-
228
- # Prepare and execute HttpRequest.
229
- _request = config.http_client.get(
230
- _query_url,
231
- headers: _headers
232
- )
233
- OAuth2.apply(config, _request)
234
- _response = execute_request(_request)
235
-
236
- # Return appropriate response type.
237
- decoded = APIHelper.json_deserialize(_response.raw_body)
238
- _errors = APIHelper.map_response(decoded, ['errors'])
239
- ApiResponse.new(
240
- _response, data: decoded, errors: _errors
241
- )
242
- end
243
-
244
- # Creates an employee role you can then assign to employees.
245
- # Square accounts can include any number of roles that can be assigned to
246
- # employees. These roles define the actions and permissions granted to an
247
- # employee with that role. For example, an employee with a "Shift Manager"
248
- # role might be able to issue refunds in Square Point of Sale, whereas an
249
- # employee with a "Clerk" role might not.
250
- # Roles are assigned with the
251
- # [V1UpdateEmployee]($e/V1Employees/UpdateEmployeeRole)
252
- # endpoint. An employee can have only one role at a time.
253
- # If an employee has no role, they have none of the permissions associated
254
- # with roles. All employees can accept payments with Square Point of Sale.
255
- # @param [V1EmployeeRole] body Required parameter: An EmployeeRole object
256
- # with a name and permissions, and an optional owner flag.
257
- # @return [V1EmployeeRole Hash] response from the API call
258
- def create_employee_role(body:)
259
- # Prepare query url.
260
- _query_builder = config.get_base_uri
261
- _query_builder << '/v1/me/roles'
262
- _query_url = APIHelper.clean_url _query_builder
263
-
264
- # Prepare headers.
265
- _headers = {
266
- 'accept' => 'application/json',
267
- 'content-type' => 'application/json; charset=utf-8'
268
- }
269
-
270
- # Prepare and execute HttpRequest.
271
- _request = config.http_client.post(
272
- _query_url,
273
- headers: _headers,
274
- parameters: body.to_json
275
- )
276
- OAuth2.apply(config, _request)
277
- _response = execute_request(_request)
278
-
279
- # Return appropriate response type.
280
- decoded = APIHelper.json_deserialize(_response.raw_body)
281
- _errors = APIHelper.map_response(decoded, ['errors'])
282
- ApiResponse.new(
283
- _response, data: decoded, errors: _errors
284
- )
285
- end
286
-
287
- # Provides the details for a single employee role.
288
- # @param [String] role_id Required parameter: The role's ID.
289
- # @return [V1EmployeeRole Hash] response from the API call
290
- def retrieve_employee_role(role_id:)
291
- # Prepare query url.
292
- _query_builder = config.get_base_uri
293
- _query_builder << '/v1/me/roles/{role_id}'
294
- _query_builder = APIHelper.append_url_with_template_parameters(
295
- _query_builder,
296
- 'role_id' => { 'value' => role_id, 'encode' => true }
297
- )
298
- _query_url = APIHelper.clean_url _query_builder
299
-
300
- # Prepare headers.
301
- _headers = {
302
- 'accept' => 'application/json'
303
- }
304
-
305
- # Prepare and execute HttpRequest.
306
- _request = config.http_client.get(
307
- _query_url,
308
- headers: _headers
309
- )
310
- OAuth2.apply(config, _request)
311
- _response = execute_request(_request)
312
-
313
- # Return appropriate response type.
314
- decoded = APIHelper.json_deserialize(_response.raw_body)
315
- _errors = APIHelper.map_response(decoded, ['errors'])
316
- ApiResponse.new(
317
- _response, data: decoded, errors: _errors
318
- )
319
- end
320
-
321
- # Modifies the details of an employee role.
322
- # @param [String] role_id Required parameter: The ID of the role to
323
- # modify.
324
- # @param [V1EmployeeRole] body Required parameter: An object containing the
325
- # fields to POST for the request. See the corresponding object definition
326
- # for field details.
327
- # @return [V1EmployeeRole Hash] response from the API call
328
- def update_employee_role(role_id:,
329
- body:)
330
- # Prepare query url.
331
- _query_builder = config.get_base_uri
332
- _query_builder << '/v1/me/roles/{role_id}'
333
- _query_builder = APIHelper.append_url_with_template_parameters(
334
- _query_builder,
335
- 'role_id' => { 'value' => role_id, 'encode' => true }
336
- )
337
- _query_url = APIHelper.clean_url _query_builder
338
-
339
- # Prepare headers.
340
- _headers = {
341
- 'accept' => 'application/json',
342
- 'content-type' => 'application/json; charset=utf-8'
343
- }
344
-
345
- # Prepare and execute HttpRequest.
346
- _request = config.http_client.put(
347
- _query_url,
348
- headers: _headers,
349
- parameters: body.to_json
350
- )
351
- OAuth2.apply(config, _request)
352
- _response = execute_request(_request)
353
-
354
- # Return appropriate response type.
355
- decoded = APIHelper.json_deserialize(_response.raw_body)
356
- _errors = APIHelper.map_response(decoded, ['errors'])
357
- ApiResponse.new(
358
- _response, data: decoded, errors: _errors
359
- )
360
- end
361
- end
362
- end