square.rb 3.20190814.0 → 3.20190925.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/square.rb +53 -52
- data/lib/square/api/apple_pay_api.rb +55 -55
- data/lib/square/api/base_api.rb +48 -45
- data/lib/square/api/catalog_api.rb +461 -461
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -335
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -300
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +117 -45
- data/lib/square/api/merchants_api.rb +46 -0
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -168
- data/lib/square/api/orders_api.rb +271 -269
- data/lib/square/api/payments_api.rb +282 -282
- data/lib/square/api/refunds_api.rb +149 -149
- data/lib/square/api/reporting_api.rb +145 -143
- data/lib/square/api/transactions_api.rb +379 -379
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -281
- data/lib/square/client.rb +155 -139
- data/lib/square/configuration.rb +98 -88
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/test/api/test_labor_api.rb +74 -0
- metadata +4 -3
- data/lib/square/api/v1_locations_api.rbe +0 -67
@@ -1,45 +1,117 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# LocationsApi
|
8
|
-
class LocationsApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Provides the details for all of a business's locations.
|
14
|
-
# Most other Connect API endpoints have a required `location_id` path
|
15
|
-
# parameter.
|
16
|
-
# The `id` field of the [`Location`](#type-location) objects returned by
|
17
|
-
# this
|
18
|
-
# endpoint correspond to that `location_id` parameter.
|
19
|
-
# @return [ListLocationsResponse Hash] response from the API call
|
20
|
-
def list_locations
|
21
|
-
# Prepare query url.
|
22
|
-
_query_builder = config.get_base_uri
|
23
|
-
_query_builder << '/v2/locations'
|
24
|
-
_query_url = APIHelper.clean_url _query_builder
|
25
|
-
|
26
|
-
# Prepare headers.
|
27
|
-
_headers = {
|
28
|
-
'accept' => 'application/json'
|
29
|
-
}
|
30
|
-
|
31
|
-
# Prepare and execute HttpRequest.
|
32
|
-
_request = config.http_client.get(
|
33
|
-
_query_url,
|
34
|
-
headers: _headers
|
35
|
-
)
|
36
|
-
OAuth2.apply(config, _request)
|
37
|
-
_response = execute_request(_request)
|
38
|
-
|
39
|
-
# Return appropriate response type.
|
40
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
41
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
42
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
43
|
-
end
|
44
|
-
|
45
|
-
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# LocationsApi
|
8
|
+
class LocationsApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Provides the details for all of a business's locations.
|
14
|
+
# Most other Connect API endpoints have a required `location_id` path
|
15
|
+
# parameter.
|
16
|
+
# The `id` field of the [`Location`](#type-location) objects returned by
|
17
|
+
# this
|
18
|
+
# endpoint correspond to that `location_id` parameter.
|
19
|
+
# @return [ListLocationsResponse Hash] response from the API call
|
20
|
+
def list_locations
|
21
|
+
# Prepare query url.
|
22
|
+
_query_builder = config.get_base_uri
|
23
|
+
_query_builder << '/v2/locations'
|
24
|
+
_query_url = APIHelper.clean_url _query_builder
|
25
|
+
|
26
|
+
# Prepare headers.
|
27
|
+
_headers = {
|
28
|
+
'accept' => 'application/json'
|
29
|
+
}
|
30
|
+
|
31
|
+
# Prepare and execute HttpRequest.
|
32
|
+
_request = config.http_client.get(
|
33
|
+
_query_url,
|
34
|
+
headers: _headers
|
35
|
+
)
|
36
|
+
OAuth2.apply(config, _request)
|
37
|
+
_response = execute_request(_request)
|
38
|
+
|
39
|
+
# Return appropriate response type.
|
40
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
41
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
42
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Retrieves details of a location.
|
46
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
47
|
+
# retrieve.
|
48
|
+
# @return [RetrieveLocationResponse Hash] response from the API call
|
49
|
+
def retrieve_location(location_id:)
|
50
|
+
# Prepare query url.
|
51
|
+
_query_builder = config.get_base_uri
|
52
|
+
_query_builder << '/v2/locations/{location_id}'
|
53
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
54
|
+
_query_builder,
|
55
|
+
'location_id' => location_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
|
+
|
78
|
+
# Updates the `Location` specified by the given ID.
|
79
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
80
|
+
# update.
|
81
|
+
# @param [UpdateLocationRequest] body Required parameter: An object
|
82
|
+
# containing the fields to POST for the request. See the corresponding
|
83
|
+
# object definition for field details.
|
84
|
+
# @return [UpdateLocationResponse Hash] response from the API call
|
85
|
+
def update_location(location_id:,
|
86
|
+
body:)
|
87
|
+
# Prepare query url.
|
88
|
+
_query_builder = config.get_base_uri
|
89
|
+
_query_builder << '/v2/locations/{location_id}'
|
90
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
91
|
+
_query_builder,
|
92
|
+
'location_id' => location_id
|
93
|
+
)
|
94
|
+
_query_url = APIHelper.clean_url _query_builder
|
95
|
+
|
96
|
+
# Prepare headers.
|
97
|
+
_headers = {
|
98
|
+
'accept' => 'application/json',
|
99
|
+
'content-type' => 'application/json; charset=utf-8'
|
100
|
+
}
|
101
|
+
|
102
|
+
# Prepare and execute HttpRequest.
|
103
|
+
_request = config.http_client.put(
|
104
|
+
_query_url,
|
105
|
+
headers: _headers,
|
106
|
+
parameters: body.to_json
|
107
|
+
)
|
108
|
+
OAuth2.apply(config, _request)
|
109
|
+
_response = execute_request(_request)
|
110
|
+
|
111
|
+
# Return appropriate response type.
|
112
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
113
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
114
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# MerchantsApi
|
8
|
+
class MerchantsApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Retrieve a `Merchant` object for the given `merchant_id`.
|
14
|
+
# @param [String] merchant_id Required parameter: The ID of the merchant to
|
15
|
+
# retrieve
|
16
|
+
# @return [RetrieveMerchantResponse Hash] response from the API call
|
17
|
+
def retrieve_merchant(merchant_id:)
|
18
|
+
# Prepare query url.
|
19
|
+
_query_builder = config.get_base_uri
|
20
|
+
_query_builder << '/v2/merchants/{merchant_id}'
|
21
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
22
|
+
_query_builder,
|
23
|
+
'merchant_id' => merchant_id
|
24
|
+
)
|
25
|
+
_query_url = APIHelper.clean_url _query_builder
|
26
|
+
|
27
|
+
# Prepare headers.
|
28
|
+
_headers = {
|
29
|
+
'accept' => 'application/json'
|
30
|
+
}
|
31
|
+
|
32
|
+
# Prepare and execute HttpRequest.
|
33
|
+
_request = config.http_client.get(
|
34
|
+
_query_url,
|
35
|
+
headers: _headers
|
36
|
+
)
|
37
|
+
OAuth2.apply(config, _request)
|
38
|
+
_response = execute_request(_request)
|
39
|
+
|
40
|
+
# Return appropriate response type.
|
41
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
42
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
43
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -1,56 +1,56 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# MobileAuthorizationApi
|
8
|
-
class MobileAuthorizationApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Generates code to authorize a mobile application to connect to a Square
|
14
|
-
# card reader
|
15
|
-
# Authorization codes are one-time-use and expire __60 minutes__ after being
|
16
|
-
# issued.
|
17
|
-
# __Important:__ The `Authorization` header you provide to this endpoint
|
18
|
-
# must have the following format:
|
19
|
-
# ```
|
20
|
-
# Authorization: Bearer ACCESS_TOKEN
|
21
|
-
# ```
|
22
|
-
# Replace `ACCESS_TOKEN` with a [valid production authorization
|
23
|
-
# credential](https://
|
24
|
-
#
|
25
|
-
# @param [CreateMobileAuthorizationCodeRequest] body Required parameter: An
|
26
|
-
# object containing the fields to POST for the request. See the
|
27
|
-
# corresponding object definition for field details.
|
28
|
-
# @return [CreateMobileAuthorizationCodeResponse Hash] response from the API call
|
29
|
-
def create_mobile_authorization_code(body:)
|
30
|
-
# Prepare query url.
|
31
|
-
_query_builder = config.get_base_uri
|
32
|
-
_query_builder << '/mobile/authorization-code'
|
33
|
-
_query_url = APIHelper.clean_url _query_builder
|
34
|
-
|
35
|
-
# Prepare headers.
|
36
|
-
_headers = {
|
37
|
-
'accept' => 'application/json',
|
38
|
-
'content-type' => 'application/json; charset=utf-8'
|
39
|
-
}
|
40
|
-
|
41
|
-
# Prepare and execute HttpRequest.
|
42
|
-
_request = config.http_client.post(
|
43
|
-
_query_url,
|
44
|
-
headers: _headers,
|
45
|
-
parameters: body.to_json
|
46
|
-
)
|
47
|
-
OAuth2.apply(config, _request)
|
48
|
-
_response = execute_request(_request)
|
49
|
-
|
50
|
-
# Return appropriate response type.
|
51
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
52
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
53
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# MobileAuthorizationApi
|
8
|
+
class MobileAuthorizationApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Generates code to authorize a mobile application to connect to a Square
|
14
|
+
# card reader
|
15
|
+
# Authorization codes are one-time-use and expire __60 minutes__ after being
|
16
|
+
# issued.
|
17
|
+
# __Important:__ The `Authorization` header you provide to this endpoint
|
18
|
+
# must have the following format:
|
19
|
+
# ```
|
20
|
+
# Authorization: Bearer ACCESS_TOKEN
|
21
|
+
# ```
|
22
|
+
# Replace `ACCESS_TOKEN` with a [valid production authorization
|
23
|
+
# credential](https://developer.squareup.com/docs/get-started#step-4-underst
|
24
|
+
# and-the-different-application-credentials).
|
25
|
+
# @param [CreateMobileAuthorizationCodeRequest] body Required parameter: An
|
26
|
+
# object containing the fields to POST for the request. See the
|
27
|
+
# corresponding object definition for field details.
|
28
|
+
# @return [CreateMobileAuthorizationCodeResponse Hash] response from the API call
|
29
|
+
def create_mobile_authorization_code(body:)
|
30
|
+
# Prepare query url.
|
31
|
+
_query_builder = config.get_base_uri
|
32
|
+
_query_builder << '/mobile/authorization-code'
|
33
|
+
_query_url = APIHelper.clean_url _query_builder
|
34
|
+
|
35
|
+
# Prepare headers.
|
36
|
+
_headers = {
|
37
|
+
'accept' => 'application/json',
|
38
|
+
'content-type' => 'application/json; charset=utf-8'
|
39
|
+
}
|
40
|
+
|
41
|
+
# Prepare and execute HttpRequest.
|
42
|
+
_request = config.http_client.post(
|
43
|
+
_query_url,
|
44
|
+
headers: _headers,
|
45
|
+
parameters: body.to_json
|
46
|
+
)
|
47
|
+
OAuth2.apply(config, _request)
|
48
|
+
_response = execute_request(_request)
|
49
|
+
|
50
|
+
# Return appropriate response type.
|
51
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
52
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
53
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,168 +1,168 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# OAuthApi
|
8
|
-
class OAuthApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# `RenewToken` is deprecated. For information about refreshing OAuth access
|
14
|
-
# tokens, see
|
15
|
-
# [Renew OAuth
|
16
|
-
# Token](https://developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-
|
17
|
-
# tokens).
|
18
|
-
# Renews an OAuth access token before it expires.
|
19
|
-
# OAuth access tokens besides your application's personal access token
|
20
|
-
# expire after __30 days__.
|
21
|
-
# You can also renew expired tokens within __15 days__ of their expiration.
|
22
|
-
# You cannot renew an access token that has been expired for more than 15
|
23
|
-
# days.
|
24
|
-
# Instead, the associated user must re-complete the OAuth flow from the
|
25
|
-
# beginning.
|
26
|
-
# __Important:__ The `Authorization` header for this endpoint must have the
|
27
|
-
# following format:
|
28
|
-
# ```
|
29
|
-
# Authorization: Client APPLICATION_SECRET
|
30
|
-
# ```
|
31
|
-
# Replace `APPLICATION_SECRET` with the application secret on the
|
32
|
-
# Credentials
|
33
|
-
# page in the [application dashboard](https://connect.squareup.com/apps).
|
34
|
-
# @param [String] client_id Required parameter: Your application's ID,
|
35
|
-
# available from the [application
|
36
|
-
# dashboard](https://connect.squareup.com/apps).
|
37
|
-
# @param [RenewTokenRequest] body Required parameter: An object containing
|
38
|
-
# the fields to POST for the request. See the corresponding object
|
39
|
-
# definition for field details.
|
40
|
-
# @param [String] authorization Required parameter: Client
|
41
|
-
# APPLICATION_SECRET
|
42
|
-
# @return [RenewTokenResponse Hash] response from the API call
|
43
|
-
def renew_token(client_id:,
|
44
|
-
body:,
|
45
|
-
authorization:)
|
46
|
-
warn 'Endpoint renew_token in OAuthApi is deprecated'
|
47
|
-
# Prepare query url.
|
48
|
-
_query_builder = config.get_base_uri
|
49
|
-
_query_builder << '/oauth2/clients/{client_id}/access-token/renew'
|
50
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
51
|
-
_query_builder,
|
52
|
-
'client_id' => client_id
|
53
|
-
)
|
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
|
-
'Authorization' => authorization
|
61
|
-
}
|
62
|
-
|
63
|
-
# Prepare and execute HttpRequest.
|
64
|
-
_request = config.http_client.post(
|
65
|
-
_query_url,
|
66
|
-
headers: _headers,
|
67
|
-
parameters: body.to_json
|
68
|
-
)
|
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
|
-
# Revokes an access token generated with the OAuth flow.
|
78
|
-
# If an account has more than one OAuth access token for your application,
|
79
|
-
# this
|
80
|
-
# endpoint revokes all of them, regardless of which token you specify. When
|
81
|
-
# an
|
82
|
-
# OAuth access token is revoked, all of the active subscriptions associated
|
83
|
-
# with that OAuth token are canceled immediately.
|
84
|
-
# __Important:__ The `Authorization` header for this endpoint must have the
|
85
|
-
# following format:
|
86
|
-
# ```
|
87
|
-
# Authorization: Client APPLICATION_SECRET
|
88
|
-
# ```
|
89
|
-
# Replace `APPLICATION_SECRET` with the application secret on the
|
90
|
-
# Credentials
|
91
|
-
# page in the [application dashboard](https://connect.squareup.com/apps).
|
92
|
-
# @param [RevokeTokenRequest] body Required parameter: An object containing
|
93
|
-
# the fields to POST for the request. See the corresponding object
|
94
|
-
# definition for field details.
|
95
|
-
# @param [String] authorization Required parameter: Client
|
96
|
-
# APPLICATION_SECRET
|
97
|
-
# @return [RevokeTokenResponse Hash] response from the API call
|
98
|
-
def revoke_token(body:,
|
99
|
-
authorization:)
|
100
|
-
# Prepare query url.
|
101
|
-
_query_builder = config.get_base_uri
|
102
|
-
_query_builder << '/oauth2/revoke'
|
103
|
-
_query_url = APIHelper.clean_url _query_builder
|
104
|
-
|
105
|
-
# Prepare headers.
|
106
|
-
_headers = {
|
107
|
-
'accept' => 'application/json',
|
108
|
-
'content-type' => 'application/json; charset=utf-8',
|
109
|
-
'Authorization' => authorization
|
110
|
-
}
|
111
|
-
|
112
|
-
# Prepare and execute HttpRequest.
|
113
|
-
_request = config.http_client.post(
|
114
|
-
_query_url,
|
115
|
-
headers: _headers,
|
116
|
-
parameters: body.to_json
|
117
|
-
)
|
118
|
-
_response = execute_request(_request)
|
119
|
-
|
120
|
-
# Return appropriate response type.
|
121
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
122
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
123
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
124
|
-
end
|
125
|
-
|
126
|
-
# Returns an OAuth access token.
|
127
|
-
# The endpoint supports distinct methods of obtaining OAuth access tokens.
|
128
|
-
# Applications specify a method by adding the `grant_type` parameter
|
129
|
-
# in the request and also provide relevant information.
|
130
|
-
# For more information, see [OAuth access token
|
131
|
-
# management](https://developer.squareup.com/docs/authz/oauth/how-it-works#o
|
132
|
-
# auth-access-token-management).
|
133
|
-
# __Note:__ Regardless of the method application specified,
|
134
|
-
# the endpoint always returns two items; an OAuth access token and
|
135
|
-
# a refresh token in the response.
|
136
|
-
# __OAuth tokens should only live on secure servers. Application clients
|
137
|
-
# should never interact directly with OAuth tokens__.
|
138
|
-
# @param [ObtainTokenRequest] body Required parameter: An object containing
|
139
|
-
# the fields to POST for the request. See the corresponding object
|
140
|
-
# definition for field details.
|
141
|
-
# @return [ObtainTokenResponse Hash] response from the API call
|
142
|
-
def obtain_token(body:)
|
143
|
-
# Prepare query url.
|
144
|
-
_query_builder = config.get_base_uri
|
145
|
-
_query_builder << '/oauth2/token'
|
146
|
-
_query_url = APIHelper.clean_url _query_builder
|
147
|
-
|
148
|
-
# Prepare headers.
|
149
|
-
_headers = {
|
150
|
-
'accept' => 'application/json',
|
151
|
-
'content-type' => 'application/json; charset=utf-8'
|
152
|
-
}
|
153
|
-
|
154
|
-
# Prepare and execute HttpRequest.
|
155
|
-
_request = config.http_client.post(
|
156
|
-
_query_url,
|
157
|
-
headers: _headers,
|
158
|
-
parameters: body.to_json
|
159
|
-
)
|
160
|
-
_response = execute_request(_request)
|
161
|
-
|
162
|
-
# Return appropriate response type.
|
163
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
164
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
165
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
166
|
-
end
|
167
|
-
end
|
168
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# OAuthApi
|
8
|
+
class OAuthApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# `RenewToken` is deprecated. For information about refreshing OAuth access
|
14
|
+
# tokens, see
|
15
|
+
# [Renew OAuth
|
16
|
+
# Token](https://developer.squareup.com/docs/oauth-api/cookbook/renew-oauth-
|
17
|
+
# tokens).
|
18
|
+
# Renews an OAuth access token before it expires.
|
19
|
+
# OAuth access tokens besides your application's personal access token
|
20
|
+
# expire after __30 days__.
|
21
|
+
# You can also renew expired tokens within __15 days__ of their expiration.
|
22
|
+
# You cannot renew an access token that has been expired for more than 15
|
23
|
+
# days.
|
24
|
+
# Instead, the associated user must re-complete the OAuth flow from the
|
25
|
+
# beginning.
|
26
|
+
# __Important:__ The `Authorization` header for this endpoint must have the
|
27
|
+
# following format:
|
28
|
+
# ```
|
29
|
+
# Authorization: Client APPLICATION_SECRET
|
30
|
+
# ```
|
31
|
+
# Replace `APPLICATION_SECRET` with the application secret on the
|
32
|
+
# Credentials
|
33
|
+
# page in the [application dashboard](https://connect.squareup.com/apps).
|
34
|
+
# @param [String] client_id Required parameter: Your application's ID,
|
35
|
+
# available from the [application
|
36
|
+
# dashboard](https://connect.squareup.com/apps).
|
37
|
+
# @param [RenewTokenRequest] body Required parameter: An object containing
|
38
|
+
# the fields to POST for the request. See the corresponding object
|
39
|
+
# definition for field details.
|
40
|
+
# @param [String] authorization Required parameter: Client
|
41
|
+
# APPLICATION_SECRET
|
42
|
+
# @return [RenewTokenResponse Hash] response from the API call
|
43
|
+
def renew_token(client_id:,
|
44
|
+
body:,
|
45
|
+
authorization:)
|
46
|
+
warn 'Endpoint renew_token in OAuthApi is deprecated'
|
47
|
+
# Prepare query url.
|
48
|
+
_query_builder = config.get_base_uri
|
49
|
+
_query_builder << '/oauth2/clients/{client_id}/access-token/renew'
|
50
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
51
|
+
_query_builder,
|
52
|
+
'client_id' => client_id
|
53
|
+
)
|
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
|
+
'Authorization' => authorization
|
61
|
+
}
|
62
|
+
|
63
|
+
# Prepare and execute HttpRequest.
|
64
|
+
_request = config.http_client.post(
|
65
|
+
_query_url,
|
66
|
+
headers: _headers,
|
67
|
+
parameters: body.to_json
|
68
|
+
)
|
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
|
+
# Revokes an access token generated with the OAuth flow.
|
78
|
+
# If an account has more than one OAuth access token for your application,
|
79
|
+
# this
|
80
|
+
# endpoint revokes all of them, regardless of which token you specify. When
|
81
|
+
# an
|
82
|
+
# OAuth access token is revoked, all of the active subscriptions associated
|
83
|
+
# with that OAuth token are canceled immediately.
|
84
|
+
# __Important:__ The `Authorization` header for this endpoint must have the
|
85
|
+
# following format:
|
86
|
+
# ```
|
87
|
+
# Authorization: Client APPLICATION_SECRET
|
88
|
+
# ```
|
89
|
+
# Replace `APPLICATION_SECRET` with the application secret on the
|
90
|
+
# Credentials
|
91
|
+
# page in the [application dashboard](https://connect.squareup.com/apps).
|
92
|
+
# @param [RevokeTokenRequest] body Required parameter: An object containing
|
93
|
+
# the fields to POST for the request. See the corresponding object
|
94
|
+
# definition for field details.
|
95
|
+
# @param [String] authorization Required parameter: Client
|
96
|
+
# APPLICATION_SECRET
|
97
|
+
# @return [RevokeTokenResponse Hash] response from the API call
|
98
|
+
def revoke_token(body:,
|
99
|
+
authorization:)
|
100
|
+
# Prepare query url.
|
101
|
+
_query_builder = config.get_base_uri
|
102
|
+
_query_builder << '/oauth2/revoke'
|
103
|
+
_query_url = APIHelper.clean_url _query_builder
|
104
|
+
|
105
|
+
# Prepare headers.
|
106
|
+
_headers = {
|
107
|
+
'accept' => 'application/json',
|
108
|
+
'content-type' => 'application/json; charset=utf-8',
|
109
|
+
'Authorization' => authorization
|
110
|
+
}
|
111
|
+
|
112
|
+
# Prepare and execute HttpRequest.
|
113
|
+
_request = config.http_client.post(
|
114
|
+
_query_url,
|
115
|
+
headers: _headers,
|
116
|
+
parameters: body.to_json
|
117
|
+
)
|
118
|
+
_response = execute_request(_request)
|
119
|
+
|
120
|
+
# Return appropriate response type.
|
121
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
122
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
123
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
124
|
+
end
|
125
|
+
|
126
|
+
# Returns an OAuth access token.
|
127
|
+
# The endpoint supports distinct methods of obtaining OAuth access tokens.
|
128
|
+
# Applications specify a method by adding the `grant_type` parameter
|
129
|
+
# in the request and also provide relevant information.
|
130
|
+
# For more information, see [OAuth access token
|
131
|
+
# management](https://developer.squareup.com/docs/authz/oauth/how-it-works#o
|
132
|
+
# auth-access-token-management).
|
133
|
+
# __Note:__ Regardless of the method application specified,
|
134
|
+
# the endpoint always returns two items; an OAuth access token and
|
135
|
+
# a refresh token in the response.
|
136
|
+
# __OAuth tokens should only live on secure servers. Application clients
|
137
|
+
# should never interact directly with OAuth tokens__.
|
138
|
+
# @param [ObtainTokenRequest] body Required parameter: An object containing
|
139
|
+
# the fields to POST for the request. See the corresponding object
|
140
|
+
# definition for field details.
|
141
|
+
# @return [ObtainTokenResponse Hash] response from the API call
|
142
|
+
def obtain_token(body:)
|
143
|
+
# Prepare query url.
|
144
|
+
_query_builder = config.get_base_uri
|
145
|
+
_query_builder << '/oauth2/token'
|
146
|
+
_query_url = APIHelper.clean_url _query_builder
|
147
|
+
|
148
|
+
# Prepare headers.
|
149
|
+
_headers = {
|
150
|
+
'accept' => 'application/json',
|
151
|
+
'content-type' => 'application/json; charset=utf-8'
|
152
|
+
}
|
153
|
+
|
154
|
+
# Prepare and execute HttpRequest.
|
155
|
+
_request = config.http_client.post(
|
156
|
+
_query_url,
|
157
|
+
headers: _headers,
|
158
|
+
parameters: body.to_json
|
159
|
+
)
|
160
|
+
_response = execute_request(_request)
|
161
|
+
|
162
|
+
# Return appropriate response type.
|
163
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
164
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
165
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|