square_connect 2.20180712.1.234 → 2.20180712.2.237

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: ae35dcc77ca9d4c9237ef793c0705e35e339e6e405e4a23f9ec1499f5aa8b5cb
4
- data.tar.gz: 48c4190f9e040ed33bd69a4c6ae8faeec3148f4be1de0258e0617c744a3083a9
3
+ metadata.gz: 7fd9e4618a2eb573bc5a2f90c06484f712edff424d0d4e0db65b5ad202bba934
4
+ data.tar.gz: 1957542f6fd3e07d4ad97eb8a527a64e85dd5b8f71724045bfb88de2a0a96d9c
5
5
  SHA512:
6
- metadata.gz: 6dc88b69ea94b19cffff9aacf123c1ab6893be3d21232d3270e2af37adee835c7ceb4bdc511f9e056bc2adb1099149556c78446ba795fb5b09c4e588797ae420
7
- data.tar.gz: 1b0964fe2038553a3966ef475769ae749b6e26b20694f16724715fa91f2d7e2c18071baba0ead0833d7fb1b1ed8b29ce4f07a46ed32480551342fb03de272c60
6
+ metadata.gz: b1b67173dda7bb4078c465c81eec01a7c9a5b1755ffc328065d9eaa83bc267cc118ce7091583549b2d93ceee0a1b80e894531fcf3f292bc8c11659c8c9263110
7
+ data.tar.gz: c8c6ba9110f351a1665c4b3d4cf269f6559ca99a47cf9553f9a6661cb5506c9cbd5ad231c305deca8ef490854a677886aa57749cded1e2dd841088ef8c9d004f
data/CHANGES.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## Version 2.20180712.2 (2018-08-21)
4
+
5
+ The Connect SDK now includes functionality for the OAuth API. The Square OAuth API lets applications request and obtain permission from a Square account to make API calls on behalf of that account. Applications can request individual permissions so that users do not need to grant full access to their Square accounts.
6
+
7
+ ### OAuth API
8
+
9
+ * `ObtainToken` endpoint — Exchanges the authorization code for an access token. After a merchant authorizes your application with the permissions form, an authorization code is sent to the application's redirect URL (See [Implementing OAuth](https://docs.connect.squareup.com/api/oauth#implementingoauth) for information about how to set up the redirect URL).
10
+
11
+ * `RenewToken` endpoint — Renews an OAuth access token before it expires. OAuth access tokens besides your application's personal access token expire after __30 days__. You can also renew expired tokens within __15 days__ of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated merchant must complete the [OAuth flow](https://docs.connect.squareup.com/api/oauth#implementingoauth) from the beginning. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
12
+ * `RevokeToken` endpoint — Revokes an access token generated with the OAuth flow. If a merchant has more than one access token for your application, this endpoint revokes all of them, regardless of which token you specify. If you revoke a merchant's access token, all of the merchant's active subscriptions associated with your application are canceled immediately. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
13
+
3
14
  ## Version 2.20180712.1 (2018-08-02)
4
15
 
5
16
  We have added MobileAuthorization API.
data/README.md CHANGED
@@ -10,7 +10,7 @@ for the specification and template files we used to generate this.
10
10
  This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
11
11
 
12
12
  - API version: 2.0
13
- - Package version: 2.20180712.1
13
+ - Package version: 2.20180712.2
14
14
  - Build package: io.swagger.codegen.languages.RubyClientCodegen
15
15
 
16
16
  For more information, please visit [https://squareup.com/developers](https://squareup.com/developers)
@@ -96,6 +96,9 @@ Class | Method | HTTP request | Description
96
96
  *SquareConnect::CustomersApi* | [**update_customer**](docs/CustomersApi.md#update_customer) | **PUT** /v2/customers/{customer_id} | UpdateCustomer
97
97
  *SquareConnect::LocationsApi* | [**list_locations**](docs/LocationsApi.md#list_locations) | **GET** /v2/locations | ListLocations
98
98
  *SquareConnect::MobileAuthorizationApi* | [**create_mobile_authorization_code**](docs/MobileAuthorizationApi.md#create_mobile_authorization_code) | **POST** /mobile/authorization-code | CreateMobileAuthorizationCode
99
+ *SquareConnect::OAuthApi* | [**obtain_token**](docs/OAuthApi.md#obtain_token) | **POST** /oauth2/token | ObtainToken
100
+ *SquareConnect::OAuthApi* | [**renew_token**](docs/OAuthApi.md#renew_token) | **POST** /oauth2/clients/{client_id}/access-token/renew | RenewToken
101
+ *SquareConnect::OAuthApi* | [**revoke_token**](docs/OAuthApi.md#revoke_token) | **POST** /oauth2/revoke | RevokeToken
99
102
  *SquareConnect::OrdersApi* | [**batch_retrieve_orders**](docs/OrdersApi.md#batch_retrieve_orders) | **POST** /v2/locations/{location_id}/orders/batch-retrieve | BatchRetrieveOrders
100
103
  *SquareConnect::OrdersApi* | [**create_order**](docs/OrdersApi.md#create_order) | **POST** /v2/locations/{location_id}/orders | CreateOrder
101
104
  *SquareConnect::ReportingApi* | [**list_additional_recipient_receivable_refunds**](docs/ReportingApi.md#list_additional_recipient_receivable_refunds) | **GET** /v2/locations/{location_id}/additional-recipient-receivable-refunds | ListAdditionalRecipientReceivableRefunds
@@ -288,6 +291,8 @@ Class | Method | HTTP request | Description
288
291
  - [SquareConnect::LocationStatus](docs/LocationStatus.md)
289
292
  - [SquareConnect::LocationType](docs/LocationType.md)
290
293
  - [SquareConnect::Money](docs/Money.md)
294
+ - [SquareConnect::ObtainTokenRequest](docs/ObtainTokenRequest.md)
295
+ - [SquareConnect::ObtainTokenResponse](docs/ObtainTokenResponse.md)
291
296
  - [SquareConnect::Order](docs/Order.md)
292
297
  - [SquareConnect::OrderLineItem](docs/OrderLineItem.md)
293
298
  - [SquareConnect::OrderLineItemDiscount](docs/OrderLineItemDiscount.md)
@@ -301,12 +306,16 @@ Class | Method | HTTP request | Description
301
306
  - [SquareConnect::RegisterDomainRequest](docs/RegisterDomainRequest.md)
302
307
  - [SquareConnect::RegisterDomainResponse](docs/RegisterDomainResponse.md)
303
308
  - [SquareConnect::RegisterDomainResponseStatus](docs/RegisterDomainResponseStatus.md)
309
+ - [SquareConnect::RenewTokenRequest](docs/RenewTokenRequest.md)
310
+ - [SquareConnect::RenewTokenResponse](docs/RenewTokenResponse.md)
304
311
  - [SquareConnect::RetrieveCatalogObjectRequest](docs/RetrieveCatalogObjectRequest.md)
305
312
  - [SquareConnect::RetrieveCatalogObjectResponse](docs/RetrieveCatalogObjectResponse.md)
306
313
  - [SquareConnect::RetrieveCustomerRequest](docs/RetrieveCustomerRequest.md)
307
314
  - [SquareConnect::RetrieveCustomerResponse](docs/RetrieveCustomerResponse.md)
308
315
  - [SquareConnect::RetrieveTransactionRequest](docs/RetrieveTransactionRequest.md)
309
316
  - [SquareConnect::RetrieveTransactionResponse](docs/RetrieveTransactionResponse.md)
317
+ - [SquareConnect::RevokeTokenRequest](docs/RevokeTokenRequest.md)
318
+ - [SquareConnect::RevokeTokenResponse](docs/RevokeTokenResponse.md)
310
319
  - [SquareConnect::SearchCatalogObjectsRequest](docs/SearchCatalogObjectsRequest.md)
311
320
  - [SquareConnect::SearchCatalogObjectsResponse](docs/SearchCatalogObjectsResponse.md)
312
321
  - [SquareConnect::SearchCustomersRequest](docs/SearchCustomersRequest.md)
data/docs/OAuthApi.md ADDED
@@ -0,0 +1,169 @@
1
+ # SquareConnect::OAuthApi
2
+
3
+ All URIs are relative to *https://connect.squareup.com*
4
+
5
+ Method | HTTP request | Description
6
+ ------------- | ------------- | -------------
7
+ [**obtain_token**](OAuthApi.md#obtain_token) | **POST** /oauth2/token | ObtainToken
8
+ [**renew_token**](OAuthApi.md#renew_token) | **POST** /oauth2/clients/{client_id}/access-token/renew | RenewToken
9
+ [**revoke_token**](OAuthApi.md#revoke_token) | **POST** /oauth2/revoke | RevokeToken
10
+
11
+
12
+ # **obtain_token**
13
+ > ObtainTokenResponse obtain_token(body)
14
+
15
+ ObtainToken
16
+
17
+ Exchanges the authorization code for an access token. After a merchant authorizes your application with the permissions form, an authorization code is sent to the application's redirect URL (See [Implementing OAuth](https://docs.connect.squareup.com/api/oauth#implementingoauth) for information about how to set up the redirect URL).
18
+
19
+ ### Example
20
+ ```ruby
21
+ # load the gem
22
+ require 'square_connect'
23
+
24
+ api_instance = SquareConnect::OAuthApi.new
25
+
26
+ body = SquareConnect::ObtainTokenRequest.new # ObtainTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
27
+
28
+
29
+ begin
30
+ #ObtainToken
31
+ result = api_instance.obtain_token(body)
32
+ p result
33
+ rescue SquareConnect::ApiError => e
34
+ puts "Exception when calling OAuthApi->obtain_token: #{e}"
35
+ end
36
+ ```
37
+
38
+ ### Parameters
39
+
40
+ Name | Type | Description | Notes
41
+ ------------- | ------------- | ------------- | -------------
42
+ **body** | [**ObtainTokenRequest**](ObtainTokenRequest.md)| An object containing the fields to POST for the request. See the corresponding object definition for field details. |
43
+
44
+ ### Return type
45
+
46
+ [**ObtainTokenResponse**](ObtainTokenResponse.md)
47
+
48
+ ### Authorization
49
+
50
+ No authorization required
51
+
52
+ ### HTTP request headers
53
+
54
+ - **Content-Type**: application/json
55
+ - **Accept**: application/json
56
+
57
+
58
+
59
+ # **renew_token**
60
+ > RenewTokenResponse renew_token(client_id, body)
61
+
62
+ RenewToken
63
+
64
+ Renews an OAuth access token before it expires. OAuth access tokens besides your application's personal access token expire after __30 days__. You can also renew expired tokens within __15 days__ of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated merchant must complete the [OAuth flow](https://docs.connect.squareup.com/api/oauth#implementingoauth) from the beginning. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
65
+
66
+ ### Example
67
+ ```ruby
68
+ # load the gem
69
+ require 'square_connect'
70
+ # setup authorization
71
+ SquareConnect.configure do |config|
72
+ # Configure API key authorization: oauth2ClientSecret
73
+ config.api_key['Authorization'] = 'YOUR API KEY'
74
+ # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
75
+ #config.api_key_prefix['Authorization'] = 'Bearer'
76
+ end
77
+
78
+ api_instance = SquareConnect::OAuthApi.new
79
+
80
+ client_id = "client_id_example" # String | Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps).
81
+
82
+ body = SquareConnect::RenewTokenRequest.new # RenewTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
83
+
84
+
85
+ begin
86
+ #RenewToken
87
+ result = api_instance.renew_token(client_id, body)
88
+ p result
89
+ rescue SquareConnect::ApiError => e
90
+ puts "Exception when calling OAuthApi->renew_token: #{e}"
91
+ end
92
+ ```
93
+
94
+ ### Parameters
95
+
96
+ Name | Type | Description | Notes
97
+ ------------- | ------------- | ------------- | -------------
98
+ **client_id** | **String**| Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps). |
99
+ **body** | [**RenewTokenRequest**](RenewTokenRequest.md)| An object containing the fields to POST for the request. See the corresponding object definition for field details. |
100
+
101
+ ### Return type
102
+
103
+ [**RenewTokenResponse**](RenewTokenResponse.md)
104
+
105
+ ### Authorization
106
+
107
+ [oauth2ClientSecret](../README.md#oauth2ClientSecret)
108
+
109
+ ### HTTP request headers
110
+
111
+ - **Content-Type**: application/json
112
+ - **Accept**: application/json
113
+
114
+
115
+
116
+ # **revoke_token**
117
+ > RevokeTokenResponse revoke_token(body)
118
+
119
+ RevokeToken
120
+
121
+ Revokes an access token generated with the OAuth flow. If a merchant has more than one access token for your application, this endpoint revokes all of them, regardless of which token you specify. If you revoke a merchant's access token, all of the merchant's active subscriptions associated with your application are canceled immediately. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
122
+
123
+ ### Example
124
+ ```ruby
125
+ # load the gem
126
+ require 'square_connect'
127
+ # setup authorization
128
+ SquareConnect.configure do |config|
129
+ # Configure API key authorization: oauth2ClientSecret
130
+ config.api_key['Authorization'] = 'YOUR API KEY'
131
+ # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
132
+ #config.api_key_prefix['Authorization'] = 'Bearer'
133
+ end
134
+
135
+ api_instance = SquareConnect::OAuthApi.new
136
+
137
+ body = SquareConnect::RevokeTokenRequest.new # RevokeTokenRequest | An object containing the fields to POST for the request. See the corresponding object definition for field details.
138
+
139
+
140
+ begin
141
+ #RevokeToken
142
+ result = api_instance.revoke_token(body)
143
+ p result
144
+ rescue SquareConnect::ApiError => e
145
+ puts "Exception when calling OAuthApi->revoke_token: #{e}"
146
+ end
147
+ ```
148
+
149
+ ### Parameters
150
+
151
+ Name | Type | Description | Notes
152
+ ------------- | ------------- | ------------- | -------------
153
+ **body** | [**RevokeTokenRequest**](RevokeTokenRequest.md)| An object containing the fields to POST for the request. See the corresponding object definition for field details. |
154
+
155
+ ### Return type
156
+
157
+ [**RevokeTokenResponse**](RevokeTokenResponse.md)
158
+
159
+ ### Authorization
160
+
161
+ [oauth2ClientSecret](../README.md#oauth2ClientSecret)
162
+
163
+ ### HTTP request headers
164
+
165
+ - **Content-Type**: application/json
166
+ - **Accept**: application/json
167
+
168
+
169
+
@@ -0,0 +1,15 @@
1
+ # SquareConnect::ObtainTokenRequest
2
+
3
+ ### Description
4
+
5
+
6
+
7
+ ## Properties
8
+ Name | Type | Description | Notes
9
+ ------------ | ------------- | ------------- | -------------
10
+ **client_id** | **String** | Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps). | [optional]
11
+ **client_secret** | **String** | Your application's secret, available from the [application dashboard](https://connect.squareup.com/apps). | [optional]
12
+ **code** | **String** | The authorization code to exchange. | [optional]
13
+ **redirect_uri** | **String** | The redirect URL assigned in the [application dashboard](https://connect.squareup.com/apps). | [optional]
14
+
15
+
@@ -0,0 +1,18 @@
1
+ # SquareConnect::ObtainTokenResponse
2
+
3
+ ### Description
4
+
5
+
6
+
7
+ ## Properties
8
+ Name | Type | Description | Notes
9
+ ------------ | ------------- | ------------- | -------------
10
+ **access_token** | **String** | Your application's access token. You provide this token in a header with every request to Connect API endpoints. See [Request and response headers](https://docs.connect.squareup.com/api/connect/v2/#requestandresponseheaders) for the format of this header. | [optional]
11
+ **token_type** | **String** | This value is always _bearer_. | [optional]
12
+ **expires_at** | **String** | The date when access_token expires, in [ISO 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format. | [optional]
13
+ **merchant_id** | **String** | The ID of the authorizing merchant's business. | [optional]
14
+ **subscription_id** | **String** | The ID of the merchant [subscription](https://docs.connect.squareup.com/api/connect/v1/#navsection-subscriptionmanagement) associated with the authorization. Only present if the merchant signed up for a subscription during authorization. | [optional]
15
+ **plan_id** | **String** | The ID of the [subscription](https://docs.connect.squareup.com/api/connect/v1/#navsection-subscriptionmanagement) plan the merchant signed up for. Only present if the merchant signed up for a subscription during authorization. | [optional]
16
+ **id_token** | **String** | Then OpenID token belonging to this this person. Only present if the OPENID scope is included in the authorize request. | [optional]
17
+
18
+
@@ -0,0 +1,12 @@
1
+ # SquareConnect::RenewTokenRequest
2
+
3
+ ### Description
4
+
5
+
6
+
7
+ ## Properties
8
+ Name | Type | Description | Notes
9
+ ------------ | ------------- | ------------- | -------------
10
+ **access_token** | **String** | The token you want to renew. | [optional]
11
+
12
+
@@ -0,0 +1,17 @@
1
+ # SquareConnect::RenewTokenResponse
2
+
3
+ ### Description
4
+
5
+
6
+
7
+ ## Properties
8
+ Name | Type | Description | Notes
9
+ ------------ | ------------- | ------------- | -------------
10
+ **access_token** | **String** | The renewed access token. This value might be different from the `access_token` you provided in your request. You provide this token in a header with every request to Connect API endpoints. See [Request and response headers](https://docs.connect.squareup.com/api/connect/v2/#requestandresponseheaders) for the format of this header. | [optional]
11
+ **token_type** | **String** | This value is always _bearer_. | [optional]
12
+ **expires_at** | **String** | The date when access_token expires, in [ISO 8601](http://www.iso.org/iso/home/standards/iso8601.htm) format. | [optional]
13
+ **merchant_id** | **String** | The ID of the authorizing merchant's business. | [optional]
14
+ **subscription_id** | **String** | The ID of the merchant [subscription](https://docs.connect.squareup.com/api/connect/v1/#navsection-subscriptionmanagement) associated with the authorization. Only present if the merchant signed up for a subscription during authorization. | [optional]
15
+ **plan_id** | **String** | The ID of the [subscription](https://docs.connect.squareup.com/api/connect/v1/#navsection-subscriptionmanagement) plan the merchant signed up for. Only present if the merchant signed up for a subscription during authorization. | [optional]
16
+
17
+
@@ -0,0 +1,14 @@
1
+ # SquareConnect::RevokeTokenRequest
2
+
3
+ ### Description
4
+
5
+
6
+
7
+ ## Properties
8
+ Name | Type | Description | Notes
9
+ ------------ | ------------- | ------------- | -------------
10
+ **client_id** | **String** | Your application's ID, available from the [application dashboard](https://connect.squareup.com/apps). | [optional]
11
+ **access_token** | **String** | The access token of the merchant whose token you want to revoke. Do not provide a value for merchant_id if you provide this parameter. | [optional]
12
+ **merchant_id** | **String** | The ID of the merchant whose token you want to revoke. Do not provide a value for access_token if you provide this parameter. | [optional]
13
+
14
+
@@ -0,0 +1,12 @@
1
+ # SquareConnect::RevokeTokenResponse
2
+
3
+ ### Description
4
+
5
+
6
+
7
+ ## Properties
8
+ Name | Type | Description | Notes
9
+ ------------ | ------------- | ------------- | -------------
10
+ **success** | **BOOLEAN** | If the request is successful, this is true. | [optional]
11
+
12
+
@@ -0,0 +1,189 @@
1
+ =begin
2
+ #Square Connect API
3
+
4
+ OpenAPI spec version: 2.0
5
+ Contact: developers@squareup.com
6
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
7
+
8
+ =end
9
+
10
+ require "uri"
11
+
12
+ module SquareConnect
13
+ class OAuthApi
14
+ attr_accessor :api_client
15
+
16
+ def initialize(api_client = ApiClient.default)
17
+ @api_client = api_client
18
+ end
19
+
20
+ # ObtainToken
21
+ # Exchanges the authorization code for an access token. After a merchant authorizes your application with the permissions form, an authorization code is sent to the application's redirect URL (See [Implementing OAuth](https://docs.connect.squareup.com/api/oauth#implementingoauth) for information about how to set up the redirect URL).
22
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
23
+ # @param [Hash] opts the optional parameters
24
+ # @return [ObtainTokenResponse]
25
+ def obtain_token(body, opts = {})
26
+ data, _status_code, _headers = obtain_token_with_http_info(body, opts)
27
+ return data
28
+ end
29
+
30
+ # ObtainToken
31
+ # Exchanges the authorization code for an access token. After a merchant authorizes your application with the permissions form, an authorization code is sent to the application's redirect URL (See [Implementing OAuth](https://docs.connect.squareup.com/api/oauth#implementingoauth) for information about how to set up the redirect URL).
32
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
33
+ # @param [Hash] opts the optional parameters
34
+ # @return [Array<(ObtainTokenResponse, Fixnum, Hash)>] ObtainTokenResponse data, response status code and response headers
35
+ def obtain_token_with_http_info(body, opts = {})
36
+ if @api_client.config.debugging
37
+ @api_client.config.logger.debug "Calling API: OAuthApi.obtain_token ..."
38
+ end
39
+ # verify the required parameter 'body' is set
40
+ fail ArgumentError, "Missing the required parameter 'body' when calling OAuthApi.obtain_token" if body.nil?
41
+ # resource path
42
+ local_var_path = "/oauth2/token".sub('{format}','json')
43
+
44
+ # query parameters
45
+ query_params = {}
46
+
47
+ # header parameters
48
+ header_params = {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
+ # HTTP header 'Content-Type'
52
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
53
+
54
+ header_params['Square-Version'] = "2018-07-12"
55
+
56
+ # form parameters
57
+ form_params = {}
58
+
59
+ # http body (model)
60
+ post_body = @api_client.object_to_http_body(body)
61
+ auth_names = []
62
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
63
+ :header_params => header_params,
64
+ :query_params => query_params,
65
+ :form_params => form_params,
66
+ :body => post_body,
67
+ :auth_names => auth_names,
68
+ :return_type => 'ObtainTokenResponse')
69
+ if @api_client.config.debugging
70
+ @api_client.config.logger.debug "API called: OAuthApi#obtain_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
71
+ end
72
+ return data, status_code, headers
73
+ end
74
+
75
+ # RenewToken
76
+ # Renews an OAuth access token before it expires. OAuth access tokens besides your application's personal access token expire after __30 days__. You can also renew expired tokens within __15 days__ of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated merchant must complete the [OAuth flow](https://docs.connect.squareup.com/api/oauth#implementingoauth) from the beginning. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
77
+ # @param client_id Your application&#39;s ID, available from the [application dashboard](https://connect.squareup.com/apps).
78
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
79
+ # @param [Hash] opts the optional parameters
80
+ # @return [RenewTokenResponse]
81
+ def renew_token(client_id, body, opts = {})
82
+ data, _status_code, _headers = renew_token_with_http_info(client_id, body, opts)
83
+ return data
84
+ end
85
+
86
+ # RenewToken
87
+ # Renews an OAuth access token before it expires. OAuth access tokens besides your application&#39;s personal access token expire after __30 days__. You can also renew expired tokens within __15 days__ of their expiration. You cannot renew an access token that has been expired for more than 15 days. Instead, the associated merchant must complete the [OAuth flow](https://docs.connect.squareup.com/api/oauth#implementingoauth) from the beginning. __Important:__ The &#x60;Authorization&#x60; header you provide to this endpoint must have the following format: &#x60;&#x60;&#x60; Authorization: Client APPLICATION_SECRET &#x60;&#x60;&#x60; Replace &#x60;APPLICATION_SECRET&#x60; with your application&#39;s secret, available from the [application dashboard](https://connect.squareup.com/apps).
88
+ # @param client_id Your application&#39;s ID, available from the [application dashboard](https://connect.squareup.com/apps).
89
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
90
+ # @param [Hash] opts the optional parameters
91
+ # @return [Array<(RenewTokenResponse, Fixnum, Hash)>] RenewTokenResponse data, response status code and response headers
92
+ def renew_token_with_http_info(client_id, body, opts = {})
93
+ if @api_client.config.debugging
94
+ @api_client.config.logger.debug "Calling API: OAuthApi.renew_token ..."
95
+ end
96
+ # verify the required parameter 'client_id' is set
97
+ fail ArgumentError, "Missing the required parameter 'client_id' when calling OAuthApi.renew_token" if client_id.nil?
98
+ # verify the required parameter 'body' is set
99
+ fail ArgumentError, "Missing the required parameter 'body' when calling OAuthApi.renew_token" if body.nil?
100
+ # resource path
101
+ local_var_path = "/oauth2/clients/{client_id}/access-token/renew".sub('{format}','json').sub('{' + 'client_id' + '}', client_id.to_s)
102
+
103
+ # query parameters
104
+ query_params = {}
105
+
106
+ # header parameters
107
+ header_params = {}
108
+ # HTTP header 'Accept' (if needed)
109
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
110
+ # HTTP header 'Content-Type'
111
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
112
+
113
+ header_params['Square-Version'] = "2018-07-12"
114
+
115
+ # form parameters
116
+ form_params = {}
117
+
118
+ # http body (model)
119
+ post_body = @api_client.object_to_http_body(body)
120
+ auth_names = ['oauth2ClientSecret']
121
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
122
+ :header_params => header_params,
123
+ :query_params => query_params,
124
+ :form_params => form_params,
125
+ :body => post_body,
126
+ :auth_names => auth_names,
127
+ :return_type => 'RenewTokenResponse')
128
+ if @api_client.config.debugging
129
+ @api_client.config.logger.debug "API called: OAuthApi#renew_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
130
+ end
131
+ return data, status_code, headers
132
+ end
133
+
134
+ # RevokeToken
135
+ # Revokes an access token generated with the OAuth flow. If a merchant has more than one access token for your application, this endpoint revokes all of them, regardless of which token you specify. If you revoke a merchant's access token, all of the merchant's active subscriptions associated with your application are canceled immediately. __Important:__ The `Authorization` header you provide to this endpoint must have the following format: ``` Authorization: Client APPLICATION_SECRET ``` Replace `APPLICATION_SECRET` with your application's secret, available from the [application dashboard](https://connect.squareup.com/apps).
136
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
137
+ # @param [Hash] opts the optional parameters
138
+ # @return [RevokeTokenResponse]
139
+ def revoke_token(body, opts = {})
140
+ data, _status_code, _headers = revoke_token_with_http_info(body, opts)
141
+ return data
142
+ end
143
+
144
+ # RevokeToken
145
+ # Revokes an access token generated with the OAuth flow. If a merchant has more than one access token for your application, this endpoint revokes all of them, regardless of which token you specify. If you revoke a merchant&#39;s access token, all of the merchant&#39;s active subscriptions associated with your application are canceled immediately. __Important:__ The &#x60;Authorization&#x60; header you provide to this endpoint must have the following format: &#x60;&#x60;&#x60; Authorization: Client APPLICATION_SECRET &#x60;&#x60;&#x60; Replace &#x60;APPLICATION_SECRET&#x60; with your application&#39;s secret, available from the [application dashboard](https://connect.squareup.com/apps).
146
+ # @param body An object containing the fields to POST for the request. See the corresponding object definition for field details.
147
+ # @param [Hash] opts the optional parameters
148
+ # @return [Array<(RevokeTokenResponse, Fixnum, Hash)>] RevokeTokenResponse data, response status code and response headers
149
+ def revoke_token_with_http_info(body, opts = {})
150
+ if @api_client.config.debugging
151
+ @api_client.config.logger.debug "Calling API: OAuthApi.revoke_token ..."
152
+ end
153
+ # verify the required parameter 'body' is set
154
+ fail ArgumentError, "Missing the required parameter 'body' when calling OAuthApi.revoke_token" if body.nil?
155
+ # resource path
156
+ local_var_path = "/oauth2/revoke".sub('{format}','json')
157
+
158
+ # query parameters
159
+ query_params = {}
160
+
161
+ # header parameters
162
+ header_params = {}
163
+ # HTTP header 'Accept' (if needed)
164
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
165
+ # HTTP header 'Content-Type'
166
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
167
+
168
+ header_params['Square-Version'] = "2018-07-12"
169
+
170
+ # form parameters
171
+ form_params = {}
172
+
173
+ # http body (model)
174
+ post_body = @api_client.object_to_http_body(body)
175
+ auth_names = ['oauth2ClientSecret']
176
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path,
177
+ :header_params => header_params,
178
+ :query_params => query_params,
179
+ :form_params => form_params,
180
+ :body => post_body,
181
+ :auth_names => auth_names,
182
+ :return_type => 'RevokeTokenResponse')
183
+ if @api_client.config.debugging
184
+ @api_client.config.logger.debug "API called: OAuthApi#revoke_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
185
+ end
186
+ return data, status_code, headers
187
+ end
188
+ end
189
+ end