Method: Pebbles::API#initialize
- Defined in:
- lib/pebbles/api.rb
#initialize(options = {}) ⇒ API
Returns a new instance of API.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pebbles/api.rb', line 35 def initialize(={}) = OPTIONS.merge() [:headers] = HEADERS.merge([:headers]) @api_key = .delete(:api_key) || ENV['PEBBLES_API_KEY'] if !@api_key && .has_key?(:username) && .has_key?(:password) username = .delete(:username) password = .delete(:password) @connection = Excon.new("#{[:scheme]}://#{[:host]}", ) @api_key = self.post_login(username, password).body["api_key"] end @connection = Excon.new("#{[:scheme]}://#{[:host]}", ) end |