Module: Particle

Extended by:
Configurable
Defined in:
lib/particle.rb,
lib/particle/error.rb,
lib/particle/model.rb,
lib/particle/token.rb,
lib/particle/client.rb,
lib/particle/device.rb,
lib/particle/default.rb,
lib/particle/version.rb,
lib/particle/webhook.rb,
lib/particle/platform.rb,
lib/particle/connection.rb,
lib/particle/build_target.rb,
lib/particle/configurable.rb,
lib/particle/client/tokens.rb,
lib/particle/client/devices.rb,
lib/particle/client/publish.rb,
lib/particle/client/firmware.rb,
lib/particle/client/webhooks.rb,
lib/particle/client/platforms.rb,
lib/particle/client/build_targets.rb,
lib/particle/response/raise_error.rb,
lib/particle/response/parse_json_symbols.rb

Defined Under Namespace

Modules: Configurable, Connection, Default, Response Classes: BadRequest, BuildTarget, Client, ClientError, Device, Error, Forbidden, MissingTokenError, Model, NotFound, Platform, ServerError, TimedOut, Token, Unauthorized, Webhook

Constant Summary collapse

VERSION =
"1.2.0".freeze

Instance Attribute Summary

Attributes included from Configurable

#access_token, #api_endpoint, #connection_options, #user_agent

Class Method Summary collapse

Methods included from Configurable

configure, keys, reset!, same_options?

Class Method Details

.clientObject



9
10
11
12
# File 'lib/particle.rb', line 9

def client
  return @client if @client && @client.same_options?(options)
  @client = Particle::Client.new(options)
end

.login(username, password, options = {}) ⇒ Token

Authenticate with Particle and start using the new token as the global token

Delegates actual functionality to the client.

Parameters:

  • username (String)

    The username (email) used to log in to the Particle Cloud API

  • password (String)

    The password used to log in to the Particle Cloud API

  • options (Hash) (defaults to: {})

    Additional Particle Cloud API options to create the token.

Returns:

  • (Token)

    The token object

See Also:

  • {Particle{Particle::Client{Particle::Client::Tokens{Particle::Client::Tokens#login}


27
28
29
30
31
# File 'lib/particle.rb', line 27

def (username, password, options = {})
  token = client.(username, password, options)
  self.access_token = token.access_token
  token
end