Class: Particle::Client
- Inherits:
-
Object
- Object
- Particle::Client
- Includes:
- BuildTargets, Devices, Firmware, 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/publish.rb,
lib/particle/client/firmware.rb,
lib/particle/client/webhooks.rb,
lib/particle/client/platforms.rb,
lib/particle/client/build_targets.rb
Overview
Client for the Particle API
Defined Under Namespace
Modules: BuildTargets, Devices, Firmware, Platforms, Publish, Tokens, Webhooks
Constant Summary
Constants included from BuildTargets
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 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, #change_device_product, #claim_device, #device, #device_attributes, #devices, #get_variable, #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.
26 27 28 29 30 31 |
# File 'lib/particle/client.rb', line 26 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
50 51 52 53 54 55 56 57 58 |
# File 'lib/particle/client.rb', line 50 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
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/particle/client.rb', line 36 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 |