class Io::Flow::V0::Clients::Tokens
Public Class Methods
# File lib/flow_commerce/flow_api_v0_client.rb, line 8915 def initialize(client) @client = HttpClient::Preconditions.assert_class('client', client, ::Io::Flow::V0::Client) end
Public Instance Methods
# File lib/flow_commerce/flow_api_v0_client.rb, line 8963 def delete_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/tokens/#{CGI.escape(id)}").delete nil end
Get all tokens that you are authorized to view. Note that the cleartext token value is never sent. To view the API token itself, see the resource path /tokens/:id/cleartext
# File lib/flow_commerce/flow_api_v0_client.rb, line 8922 def get(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) query = { :id => (x = opts.delete(:id); x.nil? ? nil : HttpClient::Preconditions.assert_class('id', x, Array).map { |v| HttpClient::Preconditions.assert_class('id', v, String) }), :organization => (x = opts.delete(:organization); x.nil? ? nil : HttpClient::Preconditions.assert_class('organization', x, String)), :partner => (x = opts.delete(:partner); x.nil? ? nil : HttpClient::Preconditions.assert_class('partner', x, String)), :mine => (x = opts.delete(:mine); x.nil? ? nil : HttpClient::Preconditions.assert_boolean('mine', x)), :limit => HttpClient::Preconditions.assert_class('limit', (x = opts.delete(:limit); x.nil? ? 25 : x), Integer), :offset => HttpClient::Preconditions.assert_class('offset', (x = opts.delete(:offset); x.nil? ? 0 : x), Integer), :sort => HttpClient::Preconditions.assert_class('sort', (x = opts.delete(:sort); x.nil? ? "-created_at" : x), String) }.delete_if { |k, v| v.nil? } r = @client.request("/tokens").with_query(query).get r.map { |x| ::Io::Flow::V0::Models::Token.from_json(x) } end
Get metadata for the token with this ID
# File lib/flow_commerce/flow_api_v0_client.rb, line 8957 def get_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/tokens/#{CGI.escape(id)}").get ::Io::Flow::V0::Models::Token.from_json(r) end
Retrieves the token with the actual string token in cleartext
# File lib/flow_commerce/flow_api_v0_client.rb, line 8970 def get_cleartext_by_id(id) HttpClient::Preconditions.assert_class('id', id, String) r = @client.request("/tokens/#{CGI.escape(id)}/cleartext").get ::Io::Flow::V0::Models::Cleartext.new(r) end
Old method to validate a token, obtaining specific information if the token is valid (or a 404 if the token does not exist). We use an HTTP POST with a form body to ensure that the token itself is not logged in the request logs.
# File lib/flow_commerce/flow_api_v0_client.rb, line 8940 def post_authentications(token_authentication_form) (x = token_authentication_form; x.is_a?(::Io::Flow::V0::Models::TokenAuthenticationForm) ? x : ::Io::Flow::V0::Models::TokenAuthenticationForm.new(x)) r = @client.request("/tokens/authentications").with_json(token_authentication_form.to_json).post ::Io::Flow::V0::Models::TokenReference.from_json(r) end
Preferred method to validate a token (including RBAC checks), obtaining specific information if the token is valid (or a 404 if the token does not exist). We use an HTTP POST with a form body to ensure that the token itself is not logged in the request logs.
# File lib/flow_commerce/flow_api_v0_client.rb, line 8950 def post_authentications_and_v2(token_rbac_authentication_form) (x = token_rbac_authentication_form; x.is_a?(::Io::Flow::V0::Models::TokenRbacAuthenticationForm) ? x : ::Io::Flow::V0::Models::TokenRbacAuthenticationForm.new(x)) r = @client.request("/tokens/authentications/v2").with_json(token_rbac_authentication_form.to_json).post ::Io::Flow::V0::Models::TokenReference.from_json(r) end