class Particle::Token
Domain model for one Particle
token
Public Class Methods
create_path()
click to toggle source
# File lib/particle/token.rb, line 68 def self.create_path "/oauth/token" end
list_path()
click to toggle source
# File lib/particle/token.rb, line 64 def self.list_path "v1/access_tokens" end
new(client, attributes)
click to toggle source
# File lib/particle/token.rb, line 5 def initialize(client, attributes) @client = client @attributes = if attributes.is_a? String { token: attributes } else # Consider attributes loaded when passed in through constructor @loaded = true attributes end end
Public Instance Methods
create(username, password)
click to toggle source
Create a Particle
token @param username [String] The username (email) used to log in to
the Particle Cloud API
@param password [String] The password used to log in to
the Particle Cloud API
# File lib/particle/token.rb, line 51 def create(username, password) @client.create_token(username, password) end
get_attributes()
click to toggle source
Tokens can't be loaded. What you see is what you get…
# File lib/particle/token.rb, line 27 def get_attributes @loaded = true @attributes end
inspect()
click to toggle source
Text representation of the token, masking the secret part
@return [String]
Calls superclass method
Particle::Model#inspect
# File lib/particle/token.rb, line 35 def inspect inspected = super # Only show last 4 of token, secret if id inspected = inspected.gsub! id, "#{'*'*36}#{id[36..-1]}" end inspected end
path()
click to toggle source
# File lib/particle/token.rb, line 72 def path "/v1/access_tokens/#{access_token}" end
remove(username, password)
click to toggle source
Remove a Particle
token @param username [String] The username (email) used to log in to
the Particle Cloud API
@param password [String] The password used to log in to
the Particle Cloud API
# File lib/particle/token.rb, line 60 def remove(username, password) @client.remove_token(username, password, self) end
token()
click to toggle source
The id of the token
# File lib/particle/token.rb, line 18 def token @attributes[:token] end
Also aliased as: id, access_token