luna_api 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/luna_api/todo.rb +13 -2
- data/lib/luna_api/version.rb +1 -1
- metadata +2 -2
data/lib/luna_api/todo.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
module LunaApi
|
2
|
+
class TodoError < StandardError; end
|
2
3
|
class Todo
|
3
4
|
def self.get
|
4
5
|
response = Typhoeus::Request.get("http://todo.lunasandals.com/")
|
@@ -7,17 +8,27 @@ module LunaApi
|
|
7
8
|
|
8
9
|
def self.create(attrs)
|
9
10
|
response = Typhoeus::Request.post("http://todo.lunasandals.com/todo", :params => {:todo => attrs})
|
10
|
-
response
|
11
|
+
handle_response(response)
|
11
12
|
end
|
12
13
|
|
13
14
|
def self.complete(id)
|
14
15
|
response = Typhoeus::Request.put("http://todo.lunasandals.com/todo/#{id}/complete")
|
15
|
-
response
|
16
|
+
handle_response(response)
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.tags
|
19
20
|
response = Typhoeus::Request.get("http://todo.lunasandals.com/tags")
|
20
21
|
response.body
|
21
22
|
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def self.handle_response(response)
|
27
|
+
if response.success?
|
28
|
+
response.body
|
29
|
+
else
|
30
|
+
raise TodoError, response.body
|
31
|
+
end
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
data/lib/luna_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luna_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-10-
|
12
|
+
date: 2012-10-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|