processout 1.0.12 → 1.1.0

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: 02def77f76870ac790824f7c1f3e0404e7d8fc6d
4
- data.tar.gz: e25b8ad6a9a481d3a4486a58ed38f74db5cb59ec
3
+ metadata.gz: cb8788229d045a0326bb2f36bc0200f4b6329ce5
4
+ data.tar.gz: 04abbbf094057f2842683186332887b43a8d61c5
5
5
  SHA512:
6
- metadata.gz: a01767334b858ecc948d01889a6277e6395f4834d445f93d873ec17920d3bbdf4e418ab0e7511830e09c948ddaabbec3ee18c5027e4a95fb19f2d0acc55af935
7
- data.tar.gz: 2b97554ee1f08698ecfbb752498b0d503d36625fd77866502c7d5f2b207f01894ae72a2a359425c637eb962f4ae673aaea0fcf364f3b43945a9f5633172f8ec4
6
+ metadata.gz: 95264089be96d313114a0f363e1c5e3341e9032288a051e4178e95beb56f1b5020333ecebd4544ba9ad4b11343246145e8ede1bcbb7d22bb5b9e39ca0d3b76e4
7
+ data.tar.gz: 5b83f080072da078affccd9dcc26f59b82e906b95e111adf32a98575566fe1464072cc415631c2298d69b520266172d4469339a2f2307d25723c3d4de33e3f01
@@ -1,7 +1,9 @@
1
1
  module ProcessOut
2
2
  class AuthenticationError < StandardError
3
- def initialize(msg)
4
- super
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
1
  module ProcessOut
2
2
  class GenericError < StandardError
3
- def initialize(msg)
4
- super
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
1
  module ProcessOut
2
2
  class InternalError < StandardError
3
- def initialize(msg)
4
- super
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
1
  module ProcessOut
2
2
  class NotFoundError < StandardError
3
- def initialize(msg)
4
- super
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
5
7
  end
6
8
  end
7
9
  end
@@ -1,7 +1,9 @@
1
1
  module ProcessOut
2
2
  class ValidationError < StandardError
3
- def initialize(msg)
4
- super
3
+ attr_accessor :code
4
+ def initialize(code, msg)
5
+ self.code = code
6
+ super(msg)
5
7
  end
6
8
  end
7
9
  end
@@ -26,6 +26,14 @@ module ProcessOut
26
26
  false
27
27
  end
28
28
 
29
+ # Code returns the error code contained in the response, if any
30
+ def code
31
+ if @body.include? "error_type"
32
+ return @body["error_type"]
33
+ end
34
+ ""
35
+ end
36
+
29
37
  # Message returns the error message contained in the response, if any
30
38
  def message
31
39
  if @body.include? "message"
@@ -39,21 +47,19 @@ module ProcessOut
39
47
  def check
40
48
  unless self.success
41
49
  if @status == 404
42
- raise NotFoundError, self.message
50
+ raise NotFoundError.new(self.code, self.message)
43
51
  end
44
52
  if @status == 401
45
- raise AuthenticationError, self.message
53
+ raise AuthenticationError.new(self.code, self.message)
46
54
  end
47
55
  if @status == 400
48
- raise ValidationError, self.message
56
+ raise ValidationError.new(self.code, self.message)
49
57
  end
50
58
  if @status >= 500
51
- raise InternalError, "ProcessOut returned an internal error (" +
52
- @status.to_s + "): " + self.message
59
+ raise InternalError.new(self.code, self.message)
53
60
  end
54
61
 
55
- raise GenericError, "ProcessOut returned an error (" +
56
- @status.to_s + "): " + self.message
62
+ raise GenericError.new(self.code, self.message)
57
63
  end
58
64
  end
59
65
  protected :check
@@ -1,3 +1,3 @@
1
1
  module ProcessOut
2
- VERSION = "1.0.12"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: processout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manuel HUEZ
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-09 00:00:00.000000000 Z
11
+ date: 2016-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler