Class: V2Intuity::Endpoints::Endpoint
- Inherits:
-
Object
- Object
- V2Intuity::Endpoints::Endpoint
- Defined in:
- lib/v2_intuity/endpoints/endpoint.rb
Direct Known Subclasses
Marketplace, Measurement, Nutrition, Sleep, Stream, Summary, User, Workout
Constant Summary collapse
- ENDPOINTS =
{ measurements: 'measurements', sleeps: 'sleeps', nutrition: 'nutrition', summaries: 'summaries', workouts: 'workouts', users: 'users', marketplace: 'marketplace', streams: 'streams' }.freeze
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
Returns the value of attribute base_uri.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#id ⇒ Object
Returns the value of attribute id.
-
#org_id ⇒ Object
Returns the value of attribute org_id.
-
#path ⇒ Object
Returns the value of attribute path.
-
#token ⇒ Object
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #sign_with ⇒ Object
- #uri(options = {}) ⇒ Object
- #uri_options(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Endpoint
Returns a new instance of Endpoint.
11 12 13 14 15 16 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 11 def initialize( = {}) @endpoint = [:endpoint] @path = .fetch(:path, 'organizations') @id = [:id] add_constants() end |
Instance Attribute Details
#base_uri ⇒ Object
Returns the value of attribute base_uri.
4 5 6 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 4 def base_uri @base_uri end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
4 5 6 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 4 def endpoint @endpoint end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 4 def id @id end |
#org_id ⇒ Object
Returns the value of attribute org_id.
4 5 6 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 4 def org_id @org_id end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 4 def path @path end |
#token ⇒ Object
Returns the value of attribute token.
4 5 6 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 4 def token @token end |
Instance Method Details
#sign_with ⇒ Object
36 37 38 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 36 def sign_with [:access_token] end |
#uri(options = {}) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 18 def uri( = {}) () if @id.nil? "#{@base_uri}/#{@path}/#{@org_id}/#{@endpoint}" else "#{@base_uri}/#{@path}/#{@org_id}/users/#{@id}/#{@endpoint}" end end |
#uri_options(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/v2_intuity/endpoints/endpoint.rb', line 27 def ( = {}) @base_uri ||= [:base_uri] @org_id ||= [:org_id] @id ||= [:id] raise 'org_id is needed' unless @org_id raise 'base_uri is needed' unless @base_uri end |