synapse_pay_rest 0.0.14 → 0.0.15

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: 9eb067fcbf87836159c1afdfeb9fdf13a0b64c6a
4
- data.tar.gz: 8e41c3f89e3de30798a252645ec77310d4cc39e3
3
+ metadata.gz: 47dd33491a54e460f6d819149c967607c7a93aaa
4
+ data.tar.gz: 409fe90ce07bb9eb0c99546cdb5d7c5d48c0e5e1
5
5
  SHA512:
6
- metadata.gz: 1b981fbc586dec4a9cfe4f08e973f8a333d7993a7aa5520124e330020cf0be64e8f421d9caa0b0b3f8e6e38288729edcc7209ebbca94eb8a171cf8c8e046d20a
7
- data.tar.gz: 249ed0c41fad41c2ec69703df4eb17d5370981bd0fa8fb51f713436ffe958543cb2a54cff29383476e71e32711b8a7d05d8aac3897e5306486d3d592a8c8303d
6
+ metadata.gz: 5b63b1214ab80b3e6647e4d9dab8c83c8dfde99f4902532f556a84538842b8643ddc3cf511c58d22946fb9c1b10d31abbb8ec454908519c6b8f8656db0718fa3
7
+ data.tar.gz: a08d5a5e82b14cbd9bd3cfb6116284e04833a2d8a33025c7fd077367ee1f938376817f1cc3388069cf1209776148a46d736f8eeeabd50e9bbb34c8d9df6fbad1
@@ -87,7 +87,7 @@ module SynapsePayRest
87
87
  klass.new(message: message, code: error_code, response: body)
88
88
  end
89
89
 
90
- private
90
+ private
91
91
 
92
92
  def parse_error(body)
93
93
  if body.nil? || body.empty?
@@ -96,7 +96,6 @@ module SynapsePayRest
96
96
  [body['error']['en'], body['error_code']]
97
97
  end
98
98
  end
99
-
100
99
  end
101
100
 
102
101
  # Initializes a new Error object
@@ -64,50 +64,9 @@ module SynapsePayRest
64
64
 
65
65
  def with_error_handling
66
66
  yield
67
- rescue => e
68
- # By the way, this is a really bad idea.
69
- # See: https://www.relishapp.com/womply/ruby-style-guide/docs/exceptions
70
- # The exceptions should be enumerated. Not all exceptions are going
71
- # to be parsable by JSON. The only one that should be captured are the
72
- # are the HTTP Client responses.
73
- case e.response.code
74
- when 400
75
- return e.response
76
- when 401
77
- return e.response
78
- when 409
79
- return e.response
80
- when 500
81
- return e.response
82
- when 405
83
- return handle_method_not_allowed
84
- when 502
85
- #Raise a gateway error
86
- return handle_gateway_error
87
- when 504
88
- #Raise a timeout error
89
- return handle_timeout_error
90
- else
91
- #Raise a generic error
92
- return handle_unknown_error
93
- end
94
- end
95
-
96
- def handle_method_not_allowed
97
- return {'success' => false, 'reason' => 'The method is not allowed. Check your id parameters.'}.to_json
98
- end
99
-
100
- def handle_gateway_error
101
- return {'success' => false, 'reason' => 'The gateway appears to be down. Check synapsepay.com or try again later.'}.to_json
102
- end
103
-
104
- def handle_timeout_error
105
- return {'success' => false, 'reason' => 'A timeout has occurred.'}.to_json
106
- end
107
-
108
-
109
- def handle_unknown_error
110
- return {'success' => false, 'reason' => 'Unknown error in library. Contact synapsepay.'}.to_json
67
+ rescue RestClient::Exception => e
68
+ body = JSON.parse(e.response.body)
69
+ raise Error.error_from_response(body, e.response.code)
111
70
  end
112
71
  end
113
72
  end
@@ -1,3 +1,3 @@
1
1
  module SynapsePayRest
2
- VERSION = '0.0.14'
2
+ VERSION = '0.0.15'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synapse_pay_rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Hipps
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-09-26 00:00:00.000000000 Z
12
+ date: 2016-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler