Class: AgileZen::Client
- Inherits:
-
Object
- Object
- AgileZen::Client
- Defined in:
- lib/agilezen/client.rb
Overview
AgileZen::Client class.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#connection ⇒ Object
Builds and returns the Faraday::Connection based on set options.
-
#connection=(conn) ⇒ Object
Set the Faraday::Connection.
-
#connection_headers ⇒ Object
Helper method for defining globally required headers.
-
#connection_url ⇒ Object
Helper method for determining the correct URL.
-
#has_required_authentication? ⇒ Boolean
Whether the client has the require auth to make API requests.
-
#initialize(options = {}) ⇒ Client
constructor
Initializer for client.
Methods included from Stories
#project_stories, #project_story
Methods included from Projects
Constructor Details
#initialize(options = {}) ⇒ Client
Initializer for client.
11 12 13 |
# File 'lib/agilezen/client.rb', line 11 def initialize( ={}) @api_key = [:api_key] end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/agilezen/client.rb', line 8 def api_key @api_key end |
Instance Method Details
#connection ⇒ Object
Builds and returns the Faraday::Connection based on set options.
26 27 28 29 30 31 32 33 |
# File 'lib/agilezen/client.rb', line 26 def connection @connection ||= Faraday::Connection.new(:url => connection_url, :headers => connection_headers) do |builder| builder.adapter Faraday.default_adapter #builder.use Faraday::Response::Yajl builder.use Faraday::Response::ParseJson builder.use Faraday::Response::Mashify end end |
#connection=(conn) ⇒ Object
Set the Faraday::Connection
21 22 23 |
# File 'lib/agilezen/client.rb', line 21 def connection=(conn) @connection = conn end |
#connection_headers ⇒ Object
Helper method for defining globally required headers.
41 42 43 44 45 46 |
# File 'lib/agilezen/client.rb', line 41 def connection_headers headers = { :accept => 'application/json', 'X-Zen-ApiKey' => @api_key } end |
#connection_url ⇒ Object
Helper method for determining the correct URL.
36 37 38 |
# File 'lib/agilezen/client.rb', line 36 def connection_url 'https://agilezen.com' end |
#has_required_authentication? ⇒ Boolean
Whether the client has the require auth to make API requests.
16 17 18 |
# File 'lib/agilezen/client.rb', line 16 def has_required_authentication? !@api_key.nil? end |