ully 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ully.rb +27 -25
  3. data/lib/ully/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 814210f81a154678ba28247936979ad8ba7fc567
4
- data.tar.gz: 00780b266bf4a4af59dd853f5e3713c128c7d830
3
+ metadata.gz: 4a97f89996532048cfd94def85912a5e2878a9b6
4
+ data.tar.gz: ae90535729cb2e4b8a24cc60e78aae9ccdf5d9a7
5
5
  SHA512:
6
- metadata.gz: ff5809d5cb24cbeaf531dba9a65c73f7999201adc163daa047687ac980e503bdc5249e662cda7f5de3cc034c832cab4c044895d79c9470f6e598191d79758516
7
- data.tar.gz: 2ea02eebca63348e9fa7a8dbfa55f7f35879cd73e9995e276af6ce26c8dd7f86e9fe43a75383a15a24247c6fd761a27695d9012f4bfc1d6f6d483d033284db64
6
+ metadata.gz: c54759bf64ca0756b4a705117ff94d48d82df0e82fb26e68a9e4aace10780814f62de0275492c1a9ae95a98c906703824309ea2498a168569cfde2c2ed0d8a65
7
+ data.tar.gz: b352ef1956b07dd81b1d81a3f3a7819711d4fb79a94ee290b2354452a9896c55db00ec9c4d437cb6337d576f983c4c16f1b5b4496d626dd3d4ec77a5e25ee941
data/lib/ully.rb CHANGED
@@ -13,7 +13,7 @@ require "yaml"
13
13
  module Ully
14
14
  class Client
15
15
  include HTTParty
16
- base_uri "https://ully.herokuapp.com"
16
+ base_uri ENV["ULLY_URI"] || "https://ully.in/api"
17
17
 
18
18
  def initialize(access_token)
19
19
  self.class.default_params :access_token => access_token
@@ -22,20 +22,22 @@ module Ully
22
22
  # Pretty responses in terminal
23
23
  def self.pretty_response(response, format)
24
24
  json = JSON.parse(response.body)
25
+ json_response = json["response"]
25
26
  if format == "json"
26
- JSON.pretty_generate(json)
27
+ JSON.pretty_generate(json_response)
27
28
  elsif format == "yaml"
28
- json.to_yaml
29
+ json_response.to_yaml
29
30
  else
30
- json
31
+ json_response
31
32
  end
32
33
  end
33
34
 
34
35
  # Login in user account
35
36
  def login(email, password)
36
- response = self.class.post('/forgot/token', :body => {:email => email, :password => password})
37
- config = JSON.parse(response.body)
38
- if config.has_key?("token") && config.has_key?("role")
37
+ response = self.class.post("/forgot/access_token", :body => {:email => email, :password => password})
38
+ json_response = JSON.parse(response.body)
39
+ config = json_response["response"]
40
+ if config.has_key?("access_token") && config.has_key?("permissions")
39
41
  File.open("ullyConfig.yml", "w"){ |f| f << config.to_yaml }
40
42
  puts "Logged successfully!"
41
43
  else
@@ -46,8 +48,8 @@ module Ully
46
48
  # Check if user is logged
47
49
  def logged_in?
48
50
  if File.exist?("ullyConfig.yml")
49
- config = YAML.load_file('ullyConfig.yml')
50
- if config.has_key?("token") && config.has_key?("role")
51
+ config = YAML.load_file("ullyConfig.yml")
52
+ if config.has_key?("access_token") && config.has_key?("permissions")
51
53
  true
52
54
  else
53
55
  false
@@ -59,97 +61,97 @@ module Ully
59
61
 
60
62
  # Create accounts
61
63
  def signup(name, email, username, password, format=false)
62
- response = self.class.post('/signup', :body => {:name => name, :email => email, :username => username, :password => password})
64
+ response = self.class.post("/signup", :body => {:name => name, :email => email, :username => username, :password => password})
63
65
  self.class.pretty_response(response, format)
64
66
  end
65
67
 
66
68
  # Forgot password
67
69
  def forgot(email, username, format=false)
68
- response = self.class.post('/forgot', :body => {:email => email, :username => username})
70
+ response = self.class.post("/forgot", :body => {:email => email, :username => username})
69
71
  self.class.pretty_response(response, format)
70
72
  end
71
73
 
72
74
  # Stats of Ully
73
75
  def stats(format=false)
74
- response = self.class.get('/stats')
76
+ response = self.class.get("/stats")
75
77
  self.class.pretty_response(response, format)
76
78
  end
77
79
 
78
80
  # Stats of Ully
79
81
  def stats_by_username(username, format=false)
80
- response = self.class.get('/stats/'+username)
82
+ response = self.class.get("/stats/"+username)
81
83
  self.class.pretty_response(response, format)
82
84
  end
83
85
 
84
86
  # Status of Ully API
85
87
  def status(format=false)
86
- response = self.class.get('/status')
88
+ response = self.class.get("/status")
87
89
  self.class.pretty_response(response, format)
88
90
  end
89
91
 
90
92
  # Show profile info
91
93
  def me(format=false)
92
- response = self.class.get('/me')
94
+ response = self.class.get("/me")
93
95
  self.class.pretty_response(response, format)
94
96
  end
95
97
 
96
98
  # Update profile info
97
99
  def update_me(current_password, name="", email="", username="", password="", format=false)
98
- response = self.class.put('/me', :body => {:name => name, :email => email, :username => username, :currentpassword => current_password, :password => password})
100
+ response = self.class.put("/me", :body => {:name => name, :email => email, :username => username, :currentpassword => current_password, :password => password})
99
101
  self.class.pretty_response(response, format)
100
102
  end
101
103
 
102
104
  # Delete profile info
103
105
  def delete_me(format=false)
104
- response = self.class.delete('/me')
106
+ response = self.class.delete("/me")
105
107
  self.class.pretty_response(response, format)
106
108
  end
107
109
 
108
110
  # Show collections
109
111
  def collections(format=false)
110
- response = self.class.get('/collections', :query => {:fields => "name,slug,urls,public"})
112
+ response = self.class.get("/collections", :query => {:fields => "name,slug,urls,public"})
111
113
  self.class.pretty_response(response, format)
112
114
  end
113
115
 
114
116
  # Show collections by username
115
117
  def collections_by_username(username, format=false)
116
- response = self.class.get('/collections/of/'+username, :query => {:fields => "name,slug,urls,public"})
118
+ response = self.class.get("/collections/of/"+username, :query => {:fields => "name,slug,urls,public"})
117
119
  self.class.pretty_response(response, format)
118
120
  end
119
121
 
120
122
  # Create collections
121
123
  def create_collections(name, slug, public_collection=true, format=false)
122
- response = self.class.post('/collections', :body => {:name => name, :slug => slug, :public => public_collection})
124
+ response = self.class.post("/collections", :body => {:name => name, :slug => slug, :public => public_collection})
123
125
  self.class.pretty_response(response, format)
124
126
  end
125
127
 
126
128
  # Update collections
127
129
  def update_collections(collection_slug, name="", slug="", public_collection=true, format=false)
128
- response = self.class.put('/collections/'+collection_slug, :body => {:name => name, :slug => slug, :public => public_collection})
130
+ response = self.class.put("/collections/"+collection_slug, :body => {:name => name, :slug => slug, :public => public_collection})
129
131
  self.class.pretty_response(response, format)
130
132
  end
131
133
 
132
134
  # Delete collections
133
135
  def delete_collections(collection_slug, format=false)
134
- response = self.class.delete('/collections/'+collection_slug)
136
+ response = self.class.delete("/collections/"+collection_slug)
135
137
  self.class.pretty_response(response, format)
136
138
  end
137
139
 
138
140
  # Create urls
139
141
  def create_urls(collection_slug, url, title="", description="", format=false)
140
- response = self.class.post('/collections/'+collection_slug+'/urls', :body => {:title => title, :url => url, :description => description})
142
+ response = self.class.post("/collections/"+collection_slug+"/urls", :body => {:title => title, :url => url, :description => description})
141
143
  self.class.pretty_response(response, format)
142
144
  end
143
145
 
144
146
  # Update urls
145
147
  def update_urls(collection_slug, url_id, url, title="", description="", format=false)
146
- response = self.class.put('/collections/'+collection_slug+'/urls/'+url_id, :body => {:title => title, :url => url, :description => description})
148
+ response = self.class.put("/collections/"+collection_slug+"/urls/"+url_id, :body => {:title => title, :url => url, :description => description})
147
149
  self.class.pretty_response(response, format)
148
150
  end
149
151
 
150
152
  # Delete urls
151
153
  def delete_urls(collection_slug, url_id, format=false)
152
- response = self.class.delete('/collections/'+collection_slug+'/urls/'+url_id)
154
+ response = self.class.delete("/collections/"+collection_slug+"/urls/"+url_id)
153
155
  self.class.pretty_response(response, format)
154
156
  end
155
157
  end
data/lib/ully/version.rb CHANGED
@@ -5,5 +5,5 @@
5
5
  # Licensed under the BSD license.
6
6
 
7
7
  module Ully
8
- VERSION = "0.1.0"
8
+ VERSION = "0.1.1"
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ully
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher EnyTC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-02 00:00:00.000000000 Z
11
+ date: 2014-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty