Class: LosantRest::AccessToken
- Inherits:
-
Object
- Object
- LosantRest::AccessToken
- Defined in:
- lib/losant_rest/access_token.rb
Overview
Class containing all the actions for the Access Token Resource
Instance Method Summary collapse
-
#delete(params = {}) ⇒ Object
Deletes an accessToken.
-
#get(params = {}) ⇒ Object
Retrieves information on an accessToken.
-
#initialize(client) ⇒ AccessToken
constructor
A new instance of AccessToken.
-
#patch(params = {}) ⇒ Object
Updates information about an accessToken.
Constructor Details
#initialize(client) ⇒ AccessToken
Returns a new instance of AccessToken.
6 7 8 |
# File 'lib/losant_rest/access_token.rb', line 6 def initialize(client) @client = client end |
Instance Method Details
#delete(params = {}) ⇒ Object
Deletes an accessToken
Parameters:
-
string accessTokenId - ID associated with the accessToken
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - If accessToken was successfully deleted (api.losant.com/#/definitions/success)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if accessToken was not found (api.losant.com/#/definitions/error)
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/losant_rest/access_token.rb', line 25 def delete(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("accessTokenId is required") unless params.has_key?(:accessTokenId) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/access-tokens/#{params[:accessTokenId]}" @client.request( method: :delete, path: path, query: query_params, headers: headers, body: body) end |
#get(params = {}) ⇒ Object
Retrieves information on an accessToken
Parameters:
-
string accessTokenId - ID associated with the accessToken
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Access token information (api.losant.com/#/definitions/accessToken)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if accessToken was not found (api.losant.com/#/definitions/error)
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/losant_rest/access_token.rb', line 63 def get(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("accessTokenId is required") unless params.has_key?(:accessTokenId) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/access-tokens/#{params[:accessTokenId]}" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end |
#patch(params = {}) ⇒ Object
Updates information about an accessToken
Parameters:
-
string accessTokenId - ID associated with the accessToken
-
hash accessToken - Object containing new properties of the accessToken (api.losant.com/#/definitions/accessTokenPatch)
-
string losantdomain - Domain scope of request (rarely needed)
-
boolean _actions - Return resource actions in response
-
boolean _links - Return resource link in response
-
boolean _embedded - Return embedded resources in response
Responses:
-
200 - Updated accessToken information (api.losant.com/#/definitions/accessToken)
Errors:
-
400 - Error if malformed request (api.losant.com/#/definitions/error)
-
404 - Error if accessToken was not found (api.losant.com/#/definitions/error)
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/losant_rest/access_token.rb', line 102 def patch(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("accessTokenId is required") unless params.has_key?(:accessTokenId) raise ArgumentError.new("accessToken is required") unless params.has_key?(:accessToken) body = params[:accessToken] if params.has_key?(:accessToken) headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain) query_params[:_actions] = params[:_actions] if params.has_key?(:_actions) query_params[:_links] = params[:_links] if params.has_key?(:_links) query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded) path = "/access-tokens/#{params[:accessTokenId]}" @client.request( method: :patch, path: path, query: query_params, headers: headers, body: body) end |