shapeshift_io 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 354fe2260b9451312bb0359b9307ba905e964532
4
- data.tar.gz: eb0b1ece969e49d46034512b7992342968bc9fb4
3
+ metadata.gz: 59b0220eae2890ec3bd65ff8a19e7bd56f1923bd
4
+ data.tar.gz: 932b12f9fd38d5308d82ff9d4fdb2acc30193453
5
5
  SHA512:
6
- metadata.gz: b2dcf911084b41d4a34a459298d61c3c9949eb0b4754cab7a4fec2ae7ad5ab3e5042cc9e4b03afed5c9efc302f0e90e9569929ce9a5d94f3e851f5ed8c933f69
7
- data.tar.gz: c0a7695205588f20c743f70201b783b8bc8c96f6ebb2ba69efff0eb5e552ddc868b91e68a1329931af5a60c17ec786afb4c2bd0afea1f6c21da919dc6a44cd2c
6
+ metadata.gz: 940895ad92a7e99a2d70f289b2c2913d90a26c290959d843af5e1954f62272f3dcf13401629bb8a7523fdcf00bbda4646923d1c81b78af332b2c0c7d5e577bdc
7
+ data.tar.gz: 528aa0565733b74bd0ae58e69c855f3ecd48645d6db8d2712a110a55a54c0c90867b09d66d4a0136de3f6f9d88a1cb82f2100a3d6a84c7c00005f425a8c27328
@@ -5,7 +5,8 @@ module Shapeshift
5
5
 
6
6
  include Shapeshift::Connection
7
7
  include Shapeshift::MarketClient
8
-
8
+ include Shapeshift::TransactionClient
9
+
9
10
  def initialize( headers = {} )
10
11
  @headers = {}
11
12
  end
@@ -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.get( url, { body: body.to_json, headers: headers } )
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
@@ -1,6 +1,7 @@
1
1
  module Shapeshift
2
2
 
3
- class HTTPError < StandardError; end
4
- class NoDemandError < StandardError; end
3
+ class ShapeshiftError < StandardError; end
4
+ class HTTPError < ShapeshiftError; end
5
+ class NoDemandError < ShapeshiftError; end
5
6
 
6
7
  end
@@ -1,3 +1,3 @@
1
1
  module Shapeshift
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shapeshift_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romanos Fessas