Module: WhenIWork
- Defined in:
- lib/when-i-work.rb,
lib/when-i-work/user.rb,
lib/when-i-work/error.rb,
lib/when-i-work/shift.rb,
lib/when-i-work/resource.rb,
lib/when-i-work/authentication.rb
Defined Under Namespace
Modules: Error Classes: Authentication, Resource, Shift, User
Class Attribute Summary collapse
-
.api_key ⇒ Object
Returns the value of attribute api_key.
-
.password ⇒ Object
Returns the value of attribute password.
-
.token ⇒ Object
Returns the value of attribute token.
-
.username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Class Attribute Details
.api_key ⇒ Object
Returns the value of attribute api_key.
12 13 14 |
# File 'lib/when-i-work.rb', line 12 def api_key @api_key end |
.password ⇒ Object
Returns the value of attribute password.
12 13 14 |
# File 'lib/when-i-work.rb', line 12 def password @password end |
.token ⇒ Object
Returns the value of attribute token.
12 13 14 |
# File 'lib/when-i-work.rb', line 12 def token @token end |
.username ⇒ Object
Returns the value of attribute username.
12 13 14 |
# File 'lib/when-i-work.rb', line 12 def username @username end |
Class Method Details
.api_url ⇒ Object
14 15 16 |
# File 'lib/when-i-work.rb', line 14 def api_url "https://api.wheniwork.com/2/" end |
.client(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/when-i-work.rb', line 24 def client( = {}) unless [:skip_authentication] self.token ||= Authentication.login(username, password, api_key) end Faraday.new(url: api_url) do |faraday| #faraday.response :detailed_logger faraday.request :json faraday.response :json, :content_type => /\bjson$/ faraday.adapter Faraday.default_adapter faraday.headers = { 'W-Token' => self.token } if self.token end end |
.configure(username, password, api_key) ⇒ Object
18 19 20 21 22 |
# File 'lib/when-i-work.rb', line 18 def configure(username, password, api_key) self.username = username self.password = password self.api_key = api_key end |