Class: Particle::Client
- Inherits:
-
Object
- Object
- Particle::Client
- Includes:
- BuildTargets, Devices, Firmware, OAuthClients, Platforms, Publish, Tokens, Webhooks, Configurable, Connection
- Defined in:
- lib/particle/client.rb,
lib/particle/client/tokens.rb,
lib/particle/client/devices.rb,
lib/particle/client/library.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/client/oauth_clients.rb
Overview
Client for the Particle API
Defined Under Namespace
Modules: BuildTargets, Devices, Firmware, Libraries, OAuthClients, Platforms, Publish, Tokens, Webhooks
Constant Summary
Constants included from Firmware
Firmware::COMPILE_PATH, Firmware::PLATFORMS
Constants included from Publish
Constants included from Connection
Particle::Connection::MIDDLEWARE
Instance Attribute Summary
Attributes included from Connection
Attributes included from Configurable
#access_token, #api_endpoint, #connection_options, #user_agent
Instance Method Summary collapse
-
#access_token=(value) ⇒ Object
Set OAuth2 access token for authentication.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#inspect ⇒ String
Text representation of the client, masking tokens.
Methods included from OAuthClients
#create_oauth_client, #oauth_client, #oauth_clients, #remove_oauth_client
Methods included from Platforms
Methods included from BuildTargets
Methods included from Firmware
#compile, #download_binary, #flash_device
Methods included from Tokens
#create_token, #login, #remove_token, #token, #tokens
Methods included from Webhooks
#create_webhook, #remove_webhook, #webhook, #webhook_attributes, #webhooks
Methods included from Publish
Methods included from Devices
#call_function, #claim_device, #device, #device_attributes, #devices, #get_variable, #ping_device, #provision_device, #remove_device, #rename_device, #signal_device, #update_device_public_key
Methods included from Connection
#connection, #delete, #get, #patch, #post, #put
Methods included from Configurable
#configure, keys, #reset!, #same_options?
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 |
# File 'lib/particle/client.rb', line 28 def initialize( = {}) # Use options passed in, but fall back to module defaults Particle::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", [key] || Particle.instance_variable_get(:"@#{key}")) end end |
Instance Method Details
#access_token=(value) ⇒ Object
Set OAuth2 access token for authentication
52 53 54 55 56 57 58 59 60 |
# File 'lib/particle/client.rb', line 52 def access_token=(value) reset_connection @access_token = if value.respond_to? :access_token value.access_token else value end end |
#inspect ⇒ String
Text representation of the client, masking tokens
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/particle/client.rb', line 38 def inspect inspected = super # Only show last 4 of token, secret if @access_token inspected = inspected.gsub! @access_token, "#{'*'*36}#{@access_token[36..-1]}" end inspected end |