Class: Dailymile::Client
- Inherits:
-
Object
- Object
- Dailymile::Client
- Extended by:
- Forwardable
- Defined in:
- lib/dailymile/client.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Class Method Summary collapse
Instance Method Summary collapse
-
#entries(*args) ⇒ Object
EXAMPLES: everyone stream: client.entries nearby stream: client.entries :nearby, 37.77916, -122.420049, :page => 2 ben’s stream: client.entries :ben, :page => 2.
-
#initialize(token = nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
11 12 13 |
# File 'lib/dailymile/client.rb', line 11 def access_token @access_token end |
Class Method Details
.set_client_credentials(client_id, client_secret) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/dailymile/client.rb', line 14 def self.set_client_credentials(client_id, client_secret) @@client = OAuth2::Client.new(client_id, client_secret, :site => BASE_URI, :access_token_path => OAUTH_TOKEN_PATH, :authorize_path => OAUTH_AUTHORIZE_PATH ) end |
Instance Method Details
#entries(*args) ⇒ Object
EXAMPLES:
everyone stream: client.entries
nearby stream: client.entries :nearby, 37.77916, -122.420049, :page => 2
ben's stream: client.entries :ben, :page => 2
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dailymile/client.rb', line 32 def entries(*args) params = (args) filter = args.shift entries_path = case filter when String, Symbol filter = filter.to_s.strip if STREAM_FILTERS.include?(filter) if filter == 'nearby' lat, lon = args "/entries/nearby/#{lat},#{lon}" else "/entries/#{filter}" end else "/people/#{filter}/entries" end else '/entries' end data = get entries_path, params data["entries"] end |