stp_client 0.3.0 → 0.4.0
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/Gemfile.lock +2 -2
- data/lib/stp/account.rb +5 -2
- data/lib/stp/errors/account_already_exists.rb +6 -0
- data/lib/stp/errors/stp_error.rb +18 -0
- data/lib/stp/version.rb +1 -1
- data/lib/stp.rb +10 -1
- data/spec/stp/account_create_spec.rb +1 -1
- data/spec/stp/account_delete_spec.rb +1 -1
- metadata +3 -2
- data/lib/stp/stp_error.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5daa60f12ce66c0757768630a8851208f4e16a6f57b769c75da532820c5daff8
|
4
|
+
data.tar.gz: 8af7bade911342be87701c0eefd401858663631f1c1a90287e6ec0f6f22c310b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b65070385c57e1258d2b8df82704d12e9f9b616e3db201f81410431eb51c7a27ca436c4856138de2e64bcea22827811cadae64e4d5f24bb8d4d7eddc4db7e64
|
7
|
+
data.tar.gz: d4edc29c1ddb34da6db3d22ee91183753547e84aef5df64e2077aa5ee465ea4031b76d2f828e6e8bf49415207cb152ec39d93b5899f6df8c61b4ed9568401f74
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stp_client (0.
|
4
|
+
stp_client (0.3.0)
|
5
5
|
crypto_yellowme (~> 0.4)
|
6
6
|
faraday (~> 1.0)
|
7
7
|
|
@@ -35,7 +35,7 @@ GEM
|
|
35
35
|
i18n (1.7.0)
|
36
36
|
concurrent-ruby (~> 1.0)
|
37
37
|
json (2.3.0)
|
38
|
-
minitest (5.
|
38
|
+
minitest (5.14.0)
|
39
39
|
multipart-post (2.1.1)
|
40
40
|
public_suffix (4.0.3)
|
41
41
|
rspec (3.9.0)
|
data/lib/stp/account.rb
CHANGED
@@ -8,8 +8,10 @@ module STP
|
|
8
8
|
req.headers['Content-Type'] = 'application/json'
|
9
9
|
req.body = account.to_json
|
10
10
|
end
|
11
|
+
puts response.body if STP.verbose
|
11
12
|
hash = JSON.parse(response.body)
|
12
|
-
raise STP::
|
13
|
+
raise STP::Errors::AccountAlreadyExists.new(hash['id'], hash['message']) if hash['id'] == 1 && hash['message'] == "Cuenta Duplicada"
|
14
|
+
raise STP::Errors::STPError.new(hash['id'], hash['message']) unless hash['id'] == 0
|
13
15
|
end
|
14
16
|
|
15
17
|
def self.delete(account)
|
@@ -20,8 +22,9 @@ module STP
|
|
20
22
|
req.headers['Content-Type'] = 'application/json'
|
21
23
|
req.body = account.to_json
|
22
24
|
end
|
25
|
+
puts response.body if STP.verbose
|
23
26
|
hash = JSON.parse(response.body)
|
24
|
-
raise STP::STPError.new(hash['message']) unless hash['id'] == 0
|
27
|
+
raise STP::Errors::STPError.new(hash['id'], hash['message']) unless hash['id'] == 0
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module STP
|
2
|
+
module Errors
|
3
|
+
class STPError < StandardError
|
4
|
+
def initialize(code = nil, message = nil)
|
5
|
+
@code = code
|
6
|
+
@message = message
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_h
|
10
|
+
{ code: @code, message: @message }
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
to_h.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/stp/version.rb
CHANGED
data/lib/stp.rb
CHANGED
@@ -5,7 +5,8 @@ require 'stp/structs/account'
|
|
5
5
|
require 'stp/structs/payment_order'
|
6
6
|
require 'stp/account'
|
7
7
|
require 'stp/payment_order'
|
8
|
-
require 'stp/stp_error'
|
8
|
+
require 'stp/errors/stp_error'
|
9
|
+
require 'stp/errors/account_already_exists'
|
9
10
|
|
10
11
|
module STP
|
11
12
|
def self.config
|
@@ -43,4 +44,12 @@ module STP
|
|
43
44
|
def self.company
|
44
45
|
@company
|
45
46
|
end
|
47
|
+
|
48
|
+
def self.verbose
|
49
|
+
@verbose
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.verbose=(verbose)
|
53
|
+
@verbose = verbose
|
54
|
+
end
|
46
55
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stp_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yellowme
|
@@ -109,8 +109,9 @@ files:
|
|
109
109
|
- Rakefile
|
110
110
|
- lib/stp.rb
|
111
111
|
- lib/stp/account.rb
|
112
|
+
- lib/stp/errors/account_already_exists.rb
|
113
|
+
- lib/stp/errors/stp_error.rb
|
112
114
|
- lib/stp/payment_order.rb
|
113
|
-
- lib/stp/stp_error.rb
|
114
115
|
- lib/stp/structs/account.rb
|
115
116
|
- lib/stp/structs/payment_order.rb
|
116
117
|
- lib/stp/version.rb
|
data/lib/stp/stp_error.rb
DELETED