Class: Smartsheet::Token
- Inherits:
-
Object
- Object
- Smartsheet::Token
- Defined in:
- lib/smartsheet/endpoints/token/token.rb
Overview
Instance Method Summary collapse
- #build_authorization_url(client_id:, scopes:) ⇒ Object
- #get(client_id:, hash:, code:, params: {}, header_overrides: {}) ⇒ Object
-
#initialize(client) ⇒ Token
constructor
A new instance of Token.
- #refresh(client_id:, hash:, refresh_token:, params: {}, header_overrides: {}) ⇒ Object
- #revoke(params: {}, header_overrides: {}) ⇒ Object
Constructor Details
#initialize(client) ⇒ Token
Returns a new instance of Token.
12 13 14 |
# File 'lib/smartsheet/endpoints/token/token.rb', line 12 def initialize(client) @client = client end |
Instance Method Details
#build_authorization_url(client_id:, scopes:) ⇒ Object
16 17 18 19 |
# File 'lib/smartsheet/endpoints/token/token.rb', line 16 def (client_id:, scopes:) scopes_string = scopes.join('%20') "https://app.smartsheet.com/b/authorize?response_type=code&client_id=#{client_id}&scope=#{scopes_string}" end |
#get(client_id:, hash:, code:, params: {}, header_overrides: {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/smartsheet/endpoints/token/token.rb', line 21 def get(client_id:, hash:, code:, params: {}, header_overrides: {}) endpoint_spec = Smartsheet::API::EndpointSpec.new( :post, ['token'], no_auth: true ) request_spec = Smartsheet::API::RequestSpec.new( header_overrides: header_overrides, params: params.merge({ client_id: client_id, code: code, hash: hash, grant_type: 'authorization_code' }) ) client.make_request(endpoint_spec, request_spec) end |
#refresh(client_id:, hash:, refresh_token:, params: {}, header_overrides: {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/smartsheet/endpoints/token/token.rb', line 39 def refresh(client_id:, hash:, refresh_token:, params: {}, header_overrides: {}) endpoint_spec = Smartsheet::API::EndpointSpec.new( :post, ['token'], no_auth: true ) request_spec = Smartsheet::API::RequestSpec.new( header_overrides: header_overrides, params: params.merge({ client_id: client_id, refresh_token: refresh_token, hash: hash, grant_type: 'refresh_token' }) ) client.make_request(endpoint_spec, request_spec) end |
#revoke(params: {}, header_overrides: {}) ⇒ Object
57 58 59 60 61 62 63 64 |
# File 'lib/smartsheet/endpoints/token/token.rb', line 57 def revoke(params: {}, header_overrides: {}) endpoint_spec = Smartsheet::API::EndpointSpec.new(:delete, ['token']) request_spec = Smartsheet::API::RequestSpec.new( header_overrides: header_overrides, params: params ) client.make_request(endpoint_spec, request_spec) end |