shapeshift_io 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/lib/shapeshift/client.rb +2 -1
- data/lib/shapeshift/connections.rb +26 -1
- data/lib/shapeshift/errors.rb +3 -2
- data/lib/shapeshift/version.rb +1 -1
- 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: 59b0220eae2890ec3bd65ff8a19e7bd56f1923bd
|
4
|
+
data.tar.gz: 932b12f9fd38d5308d82ff9d4fdb2acc30193453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 940895ad92a7e99a2d70f289b2c2913d90a26c290959d843af5e1954f62272f3dcf13401629bb8a7523fdcf00bbda4646923d1c81b78af332b2c0c7d5e577bdc
|
7
|
+
data.tar.gz: 528aa0565733b74bd0ae58e69c855f3ecd48645d6db8d2712a110a55a54c0c90867b09d66d4a0136de3f6f9d88a1cb82f2100a3d6a84c7c00005f425a8c27328
|
data/lib/shapeshift/client.rb
CHANGED
@@ -14,14 +14,39 @@ module Shapeshift
|
|
14
14
|
def get( url, options = {} )
|
15
15
|
headers = merge_headers( options[:headers] || {} )
|
16
16
|
resp = self.class.get( url, { headers: headers } )
|
17
|
+
return parse( resp )
|
18
|
+
rescue ShapeshiftError => e
|
19
|
+
puts e.message
|
17
20
|
end
|
18
21
|
|
19
22
|
# Make an HTTP POST request
|
20
23
|
def post( url, options = {} )
|
21
24
|
headers = merge_headers( options[:headers] || {} )
|
22
25
|
body = options[:body]
|
23
|
-
resp = self.class.
|
26
|
+
resp = self.class.post( url, { body: body.to_json, headers: headers } )
|
27
|
+
return parse( resp )
|
28
|
+
rescue ShapeshiftError => e
|
29
|
+
puts e.message
|
24
30
|
end
|
25
31
|
|
32
|
+
private
|
33
|
+
|
34
|
+
def parse( resp )
|
35
|
+
if resp.code == 200
|
36
|
+
body = resp.parsed_response
|
37
|
+
|
38
|
+
# Received marketplace error from Shapeshift
|
39
|
+
if body.is_a?(Hash) && body.has_key?("error")
|
40
|
+
raise ShapeshiftError.new( body["error"] )
|
41
|
+
elsif body.is_a?(Hash) && body.has_key?("success")
|
42
|
+
return body["success"]
|
43
|
+
else
|
44
|
+
return body
|
45
|
+
end
|
46
|
+
else
|
47
|
+
raise HTTPError
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
26
51
|
end
|
27
52
|
end
|
data/lib/shapeshift/errors.rb
CHANGED
data/lib/shapeshift/version.rb
CHANGED