Class: Fleetly::Client

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Activity, Logitem, Request, User
Defined in:
lib/fleetly/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logitem

#get_logitem_details, #get_logitems

Methods included from Activity

#get_activities, #get_activity

Methods included from User

#me, #user_search

Methods included from Request

#get, #post, #request

Constructor Details

#initialize(options = {}) ⇒ Client

Create a new Fleetly::Client object



23
24
25
26
# File 'lib/fleetly/client.rb', line 23

def initialize(options={})
  @api_url = options[:api_url] || Fleetly.api_url
  @token = options[:token] || Fleetly.token
end

Instance Attribute Details

#api_urlObject (readonly)

Returns the value of attribute api_url.



17
18
19
# File 'lib/fleetly/client.rb', line 17

def api_url
  @api_url
end

#tokenObject (readonly)

Returns the value of attribute token.



17
18
19
# File 'lib/fleetly/client.rb', line 17

def token
  @token
end

Instance Method Details

#connectionFaraday::Connection

Create a Faraday::Connection object

Returns:

  • (Faraday::Connection)


32
33
34
35
36
37
38
39
40
# File 'lib/fleetly/client.rb', line 32

def connection
  params = {}
  @connection = Faraday.new(url: api_url, params: params, headers: default_headers) do |faraday|
    faraday.use FaradayMiddleware::Mashify
    faraday.use FaradayMiddleware::ParseJson, content_type: /\bjson$/
    faraday.use FaradayMiddleware::FollowRedirects
    faraday.adapter Faraday.default_adapter
  end
end