Class: ZenApi::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/zenapi/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Client

Returns a new instance of Client.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/zenapi/client.rb', line 5

def initialize(args = {})
  raise ArgumentError, 'api_key have to be String' unless args[:api_key].is_a?(String)

  options = { :headers => {}}
  options[:url] ||= "https://agilezen.com/api/v1/"
  options[:headers]['X-Zen-ApiKey'] = args[:api_key]

  self.conn ||= Faraday.new(options) do |builder|
    builder.use Faraday::Request::UrlEncoded
    builder.use Faraday::Response::Logger
    builder.use Faraday::Adapter::NetHttp
  end
end

Instance Attribute Details

#connObject

Returns the value of attribute conn.



3
4
5
# File 'lib/zenapi/client.rb', line 3

def conn
  @conn
end