Class: Carriots::Client

Inherits:
Object
  • Object
show all
Includes:
ApiMethods, Configurable, Connection
Defined in:
lib/carriots/client.rb

Overview

Client for the Carriot API

Instance Attribute Summary

Attributes included from Configurable

#api_endpoint, #connection_options, #default_media_type, #login, #user_agent, #web_endpoint, #write_api_key

Instance Method Summary collapse

Methods included from ApiMethods

#stream, #streams

Methods included from Connection

#connection, #get

Methods included from Configurable

#configure, keys, #reset!, #same_options?

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
21
# File 'lib/carriots/client.rb', line 15

def initialize(options = {})
  # Use options passed in, but fall back to module defaults
  Carriots::Configurable.keys.each do |key|
    instance_variable_set(:"@#{key}", options[key] ||
      Carriots.instance_variable_get(:"@#{key}"))
  end
end

Instance Method Details

#default_deviceObject



39
40
41
# File 'lib/carriots/client.rb', line 39

def default_device
  "defaultDevice@#{}.#{}"
end

#inspectString

Text representation of the client, masking api_keys

Returns:

  • (String)


26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/carriots/client.rb', line 26

def inspect
  inspected = super

  # mask api_keys
  # inspected = inspected.gsub! @write_api_key, "*******" if @write_api_key
  # Only show last 4 of token, secret
  if @write_api_key
    inspected = inspected.gsub! @write_api_key, revele_last_n_digit(@write_api_key)
  end

  inspected
end