Class: TryTerra::Client
- Inherits:
-
Object
- Object
- TryTerra::Client
- Defined in:
- lib/try_terra/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.tryterra.co/v2/"
Instance Attribute Summary collapse
-
#dev_id ⇒ Object
readonly
Returns the value of attribute dev_id.
-
#stubs ⇒ Object
readonly
Returns the value of attribute stubs.
-
#x_api_key ⇒ Object
readonly
Returns the value of attribute x_api_key.
Instance Method Summary collapse
- #activity(**params) ⇒ Object
- #athlete(**params) ⇒ Object
- #auth ⇒ Object
- #body(**params) ⇒ Object
- #connection ⇒ Object
- #daily(**params) ⇒ Object
-
#initialize(dev_id:, x_api_key:, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #menstruation(**params) ⇒ Object
- #sleep(**params) ⇒ Object
- #subscriptions(**params) ⇒ Object
- #user_info(**params) ⇒ Object
Constructor Details
#initialize(dev_id:, x_api_key:, stubs: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/try_terra/client.rb', line 7 def initialize(dev_id:, x_api_key:, stubs: nil) @dev_id = dev_id @x_api_key = x_api_key @stubs = stubs end |
Instance Attribute Details
#dev_id ⇒ Object (readonly)
Returns the value of attribute dev_id.
5 6 7 |
# File 'lib/try_terra/client.rb', line 5 def dev_id @dev_id end |
#stubs ⇒ Object (readonly)
Returns the value of attribute stubs.
5 6 7 |
# File 'lib/try_terra/client.rb', line 5 def stubs @stubs end |
#x_api_key ⇒ Object (readonly)
Returns the value of attribute x_api_key.
5 6 7 |
# File 'lib/try_terra/client.rb', line 5 def x_api_key @x_api_key end |
Instance Method Details
#activity(**params) ⇒ Object
29 30 31 |
# File 'lib/try_terra/client.rb', line 29 def activity(**params) ActivityResource.new(self).get(params) end |
#athlete(**params) ⇒ Object
25 26 27 |
# File 'lib/try_terra/client.rb', line 25 def athlete(**params) AthleteResource.new(self).get(params) end |
#auth ⇒ Object
13 14 15 |
# File 'lib/try_terra/client.rb', line 13 def auth AuthResource.new(self) end |
#body(**params) ⇒ Object
33 34 35 |
# File 'lib/try_terra/client.rb', line 33 def body(**params) BodyResource.new(self).get(params) end |
#connection ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/try_terra/client.rb', line 49 def connection @connection ||= Faraday.new(BASE_URL) do |conn| conn.headers["dev-id"] = dev_id conn.headers["x-api-key"] = x_api_key conn.response :json, content_type: "application/json" # for testing if @stubs conn.adapter :test, @stubs end end end |
#daily(**params) ⇒ Object
37 38 39 |
# File 'lib/try_terra/client.rb', line 37 def daily(**params) DailyResource.new(self).get(params) end |
#menstruation(**params) ⇒ Object
45 46 47 |
# File 'lib/try_terra/client.rb', line 45 def menstruation(**params) MenstruationResource.new(self).get(params) end |
#sleep(**params) ⇒ Object
41 42 43 |
# File 'lib/try_terra/client.rb', line 41 def sleep(**params) SleepResource.new(self).get(params) end |
#subscriptions(**params) ⇒ Object
17 18 19 |
# File 'lib/try_terra/client.rb', line 17 def subscriptions(**params) SubscriptionsResource.new(self).get(params) end |
#user_info(**params) ⇒ Object
21 22 23 |
# File 'lib/try_terra/client.rb', line 21 def user_info(**params) UserInfoResource.new(self).get(params) end |