luna_api 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/luna_api/request.rb +25 -0
- data/lib/luna_api/sale.rb +2 -2
- data/lib/luna_api/store.rb +1 -1
- data/lib/luna_api/todo.rb +4 -4
- data/lib/luna_api/version.rb +1 -1
- data/lib/luna_api.rb +1 -0
- metadata +3 -2
@@ -0,0 +1,25 @@
|
|
1
|
+
module LunaApi
|
2
|
+
class Request
|
3
|
+
class << self
|
4
|
+
def get(url, *args)
|
5
|
+
request("get", url, *args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def post(url, *args)
|
9
|
+
request("post", url, *args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def put(url, *args)
|
13
|
+
request("put", url, *args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def request(method, url, *args)
|
17
|
+
Typhoeus::Request.send(method,
|
18
|
+
url,
|
19
|
+
*args,
|
20
|
+
userpwd: "#{ENV["LUNA_API_USERNAME"]}:#{ENV["LUNA_API_PASSWORD"]}"
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/luna_api/sale.rb
CHANGED
@@ -2,12 +2,12 @@ module LunaApi
|
|
2
2
|
class Sale < OpenStruct
|
3
3
|
URL = "http://luna-data.herokuapp.com/transactions"
|
4
4
|
def self.all
|
5
|
-
response =
|
5
|
+
response = LunaApi::Request.get(URL)
|
6
6
|
sales = JSON.parse(response.body)
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.create(attrs)
|
10
|
-
response =
|
10
|
+
response = LunaApi::Request.post(URL, params: attrs)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/lib/luna_api/store.rb
CHANGED
@@ -2,7 +2,7 @@ module LunaApi
|
|
2
2
|
class Store < OpenStruct
|
3
3
|
|
4
4
|
def self.all
|
5
|
-
response =
|
5
|
+
response = LunaApi::Request.get("http://wholesale.lunasandals.com/api/stores")
|
6
6
|
s = JSON.parse(response.body)
|
7
7
|
s.each do |country, list|
|
8
8
|
list.each do |state, stores|
|
data/lib/luna_api/todo.rb
CHANGED
@@ -2,22 +2,22 @@ module LunaApi
|
|
2
2
|
class TodoError < StandardError; end
|
3
3
|
class Todo
|
4
4
|
def self.get
|
5
|
-
response =
|
5
|
+
response = LunaApi::Request.get("http://todo.lunasandals.com/")
|
6
6
|
response.body
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.create(attrs)
|
10
|
-
response =
|
10
|
+
response = LunaApi::Request.post("http://todo.lunasandals.com/todo", :params => {:todo => attrs})
|
11
11
|
handle_response(response)
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.complete(id)
|
15
|
-
response =
|
15
|
+
response = LunaApi::Request.put("http://todo.lunasandals.com/todo/#{id}/complete")
|
16
16
|
handle_response(response)
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.tags
|
20
|
-
response =
|
20
|
+
response = LunaApi::Request.get("http://todo.lunasandals.com/tags")
|
21
21
|
response.body
|
22
22
|
end
|
23
23
|
|
data/lib/luna_api/version.rb
CHANGED
data/lib/luna_api.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.1.
|
4
|
+
version: 0.1.3
|
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: 2013-
|
12
|
+
date: 2013-02-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- README.md
|
41
41
|
- Rakefile
|
42
42
|
- lib/luna_api.rb
|
43
|
+
- lib/luna_api/request.rb
|
43
44
|
- lib/luna_api/sale.rb
|
44
45
|
- lib/luna_api/store.rb
|
45
46
|
- lib/luna_api/todo.rb
|