liftapp-client 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Liftapp::Client
2
2
 
3
- TODO: Write a gem description
3
+ Ruby library to access the Lift.do API. Since there is not yet an official API, this library uses the undocumented mobile app API.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,28 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ##### Request your profile_hash
22
+ ```ruby
23
+ client = Liftapp::Client.new(email: 'neo@matrix.com', password: 'whiterabbit')
24
+ data = client.login()
25
+ puts data['profile_hash']
26
+ ```
27
+
28
+ ##### Request your subscribed habits
29
+ ```ruby
30
+ client = Liftapp::Client.new(email: 'neo@matrix.com', password: 'whiterabbit')
31
+ data = client.dashboard
32
+ puts data['subscriptions'].inspect
33
+ ```
34
+
35
+ ##### Request checkin data for your habit
36
+ ```ruby
37
+ client = Liftapp::Client.new(profile_hash: 'e7fcd2db926273e895ef')
38
+ data = client.checkin_data('3280')
39
+ puts data[:checkins].inspect
40
+ puts data[:'habit-name']
41
+ ```
42
+
22
43
 
23
44
  ## Contributing
24
45
 
@@ -1,6 +1,6 @@
1
1
  require 'sinatra'
2
2
  require 'coffee-script'
3
- require_relative '../../lib/lift'
3
+ require 'liftapp-client'
4
4
 
5
5
  configure do
6
6
  mime_type :plain, 'text/plain'
@@ -11,14 +11,14 @@ get '/' do
11
11
  end
12
12
 
13
13
  post '/dashboard.json' do
14
- client = LiftAPI::Client.new(email: params[:email], password: params[:password])
14
+ client = Liftapp::Client.new(email: params[:email], password: params[:password])
15
15
  content_type :json
16
16
  client.dashboard.to_json
17
17
  end
18
18
 
19
19
  get '/checkins/:user/:habit' do
20
20
  content_type :plain
21
- client = LiftAPI::Client.new(profile_hash: params[:user])
21
+ client = Liftapp::Client.new(profile_hash: params[:user])
22
22
  data = client.checkin_data(params[:habit])
23
23
  output = data[:checkins].map { |d| d.strftime('%Y-%m-%d') }
24
24
  output.unshift data[:'habit-name']
@@ -1,5 +1,5 @@
1
1
  module Liftapp
2
2
  class Client
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -18,22 +18,19 @@ module Liftapp
18
18
  end
19
19
 
20
20
  def login
21
- response = HTTParty.get('https://lift.do/i/0/users/current', @auth_options)
21
+ response = HTTParty.get('https://www.lift.do/i/0/users/current', @auth_options)
22
22
  @profile_hash = response['profile_hash']
23
23
  response
24
24
  end
25
25
 
26
26
  def dashboard
27
- HTTParty.get('https://lift.do/api/v2/dashboard', @auth_options)
27
+ HTTParty.get('https://www.lift.do/api/v2/dashboard', @auth_options)
28
28
  end
29
29
 
30
30
  def habit_activity(habit_id)
31
31
  HTTParty.get('https://www.lift.do/api/v2/habits/' + habit_id + '/activity', @auth_options)
32
32
  end
33
33
 
34
- def checkin(habit)
35
- end
36
-
37
34
  def checkin_data(habit_id)
38
35
  response = HTTParty.get('https://www.lift.do/users/' + @profile_hash + '/' + habit_id)
39
36
 
@@ -15,6 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Liftapp::Client::VERSION
17
17
 
18
- gem.add_development_dependency 'httparty'
19
- gem.add_development_dependency 'nokogiri'
18
+ gem.add_dependency 'httparty'
19
+ gem.add_dependency 'nokogiri'
20
+ gem.add_dependency 'webmock'
20
21
  end