myrando 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/myrando/version.rb +1 -1
- data/lib/myrando.rb +28 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 342b4b10703690ed8fef14bfa4cacbde22fc63b5
|
4
|
+
data.tar.gz: b0ba567316d220050090178010398c4e91732e86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28aaa1a0a44fa80c34ed17d8882fafa85465de1e6e16c6a9744bd3eda9ff9d8d32c1e19c9b6e9a51e477cd33a56e5f9cab49e7e1adfffd4afe28c06aee540750
|
7
|
+
data.tar.gz: 337a3e1e2e201f34c6985586b1181511bb9559539115392c78751d1dbcf716121b7d17a4f6922a26850c191fe65385f6825250b5d80a07fcad2ed4dae3cf063e
|
data/README.md
CHANGED
@@ -26,6 +26,14 @@ rando = Myrando::MyRando.new(:username => "your email", :password => "your passw
|
|
26
26
|
rando.get_photos()
|
27
27
|
```
|
28
28
|
|
29
|
+
### Get your account status
|
30
|
+
|
31
|
+
``` ruby
|
32
|
+
require 'myrando'
|
33
|
+
rando = Myrando::MyRando.new(:username => "your email", :password => "your password")
|
34
|
+
rando.get_account_status()
|
35
|
+
```
|
36
|
+
|
29
37
|
## Contributing
|
30
38
|
|
31
39
|
1. Fork it
|
data/lib/myrando/version.rb
CHANGED
data/lib/myrando.rb
CHANGED
@@ -23,12 +23,34 @@ module Myrando
|
|
23
23
|
def get_photos(page=1)
|
24
24
|
resp = self.class.get("#{RANDO_API_URL}/users/#{@user_info[:user_id]}/deliveries/received.json?page=#{page}&auth_token=#{@user_info[:token]}")
|
25
25
|
if resp.code == 200
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
randos
|
26
|
+
begin
|
27
|
+
json = MultiJson.decode(resp.body)
|
28
|
+
raise ApiError, "Rando returned an error: #{json['error']}" if not json.kind_of?(Array) and json.has_key?('error')
|
29
|
+
randos = []
|
30
|
+
json.each do |r|
|
31
|
+
randos << r
|
32
|
+
end
|
33
|
+
randos
|
34
|
+
rescue MultiJson::DecodeError
|
35
|
+
raise ApiError, "Rando returned an error:\nStatus: #{resp.code}\nBody: #{resp.body}"
|
36
|
+
end
|
37
|
+
else
|
38
|
+
raise ApiError, "Rando returned an error:\nStatus: #{resp.code}\nBody: #{resp.body}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_account_status()
|
43
|
+
resp = self.class.get("#{RANDO_API_URL}/account.json?auth_token=#{@user_info[:token]}")
|
44
|
+
if resp.code == 200
|
45
|
+
begin
|
46
|
+
json = MultiJson.decode(resp.body)
|
47
|
+
raise ApiError, "Rando returned an error: #{json['error']}" if json.has_key?('error')
|
48
|
+
return json
|
49
|
+
rescue MultiJson::DecodeError
|
50
|
+
raise ApiError, "Rando returned an error:\nStatus: #{resp.code}\nBody: #{resp.body}"
|
30
51
|
end
|
31
|
-
|
52
|
+
else
|
53
|
+
raise ApiError, "Rando returned an error:\nStatus: #{resp.code}\nBody: #{resp.body}"
|
32
54
|
end
|
33
55
|
end
|
34
56
|
|
@@ -39,7 +61,7 @@ module Myrando
|
|
39
61
|
if resp.code == 200
|
40
62
|
begin
|
41
63
|
json = MultiJson.decode(resp.body)
|
42
|
-
raise ApiError, "Rando returned an error: #{json['error']}" if json
|
64
|
+
raise ApiError, "Rando returned an error: #{json['error']}" if json.has_key?('error')
|
43
65
|
{:token => json['authentication_token'], :user_id => json['id']}
|
44
66
|
rescue MultiJson::DecodeError
|
45
67
|
raise ApiError, "Rando returned an error:\nStatus: #{resp.code}\nBody: #{resp.body}"
|