stp_client 0.4.0 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/lib/stp/account.rb +3 -3
- data/lib/stp/structs/account.rb +8 -5
- data/lib/stp/version.rb +1 -1
- data/spec/stp/account_create_spec.rb +37 -3
- data/spec/stp/account_delete_spec.rb +5 -5
- data/spec/stp/payment_order_spec.rb +1 -1
- data/spec/support/stp_test_helpers.rb +4 -4
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6b8ee11ef13c3ad87564a457471e65eec86c5f139f734416bbb5923dbfe0a50
|
4
|
+
data.tar.gz: cd9d980754eb8d4b820e63f88bf03278d3ee4b670242d14b11a813a6b5716068
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85e591aaee0f159c472cd7f5cccba6463c16756215137730d2ed3656364715ef6d049681ee32ed428f7e498f5f014f7a8b9e78cb0d3cb6ca6fdb4b196a4fcab0
|
7
|
+
data.tar.gz: 5d18948844c674333ac6cc896d15bac7fef9e81ff24917a23c2d0a9d9f39e661bba263eb7613369a063bf7ed6c03da023eedbf9bc0cfc0f2c67b28a23903725c
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
stp_client (0.3
|
4
|
+
stp_client (0.4.3)
|
5
5
|
crypto_yellowme (~> 0.4)
|
6
6
|
faraday (~> 1.0)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activemodel (5.2.4.
|
12
|
-
activesupport (= 5.2.4.
|
13
|
-
activesupport (5.2.4.
|
11
|
+
activemodel (5.2.4.3)
|
12
|
+
activesupport (= 5.2.4.3)
|
13
|
+
activesupport (5.2.4.3)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
@@ -18,7 +18,7 @@ GEM
|
|
18
18
|
addressable (2.7.0)
|
19
19
|
public_suffix (>= 2.0.2, < 5.0)
|
20
20
|
bcrypt (3.1.13)
|
21
|
-
concurrent-ruby (1.1.
|
21
|
+
concurrent-ruby (1.1.6)
|
22
22
|
crack (0.4.3)
|
23
23
|
safe_yaml (~> 1.0.0)
|
24
24
|
crypto_yellowme (0.4.0)
|
@@ -29,13 +29,13 @@ GEM
|
|
29
29
|
docile (1.3.2)
|
30
30
|
faker (2.10.0)
|
31
31
|
i18n (>= 1.6, < 1.8)
|
32
|
-
faraday (1.0.
|
32
|
+
faraday (1.0.1)
|
33
33
|
multipart-post (>= 1.2, < 3)
|
34
34
|
hashdiff (1.0.1)
|
35
|
-
i18n (1.7.
|
35
|
+
i18n (1.7.1)
|
36
36
|
concurrent-ruby (~> 1.0)
|
37
37
|
json (2.3.0)
|
38
|
-
minitest (5.14.
|
38
|
+
minitest (5.14.1)
|
39
39
|
multipart-post (2.1.1)
|
40
40
|
public_suffix (4.0.3)
|
41
41
|
rspec (3.9.0)
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
simplecov-html (~> 0.10.0)
|
59
59
|
simplecov-html (0.10.2)
|
60
60
|
thread_safe (0.3.6)
|
61
|
-
tzinfo (1.2.
|
61
|
+
tzinfo (1.2.7)
|
62
62
|
thread_safe (~> 0.1)
|
63
63
|
webmock (3.4.2)
|
64
64
|
addressable (>= 2.3.6)
|
@@ -76,4 +76,4 @@ DEPENDENCIES
|
|
76
76
|
webmock (~> 3.4.2)
|
77
77
|
|
78
78
|
BUNDLED WITH
|
79
|
-
2.
|
79
|
+
2.1.2
|
data/lib/stp/account.rb
CHANGED
@@ -10,8 +10,8 @@ module STP
|
|
10
10
|
end
|
11
11
|
puts response.body if STP.verbose
|
12
12
|
hash = JSON.parse(response.body)
|
13
|
-
raise STP::Errors::AccountAlreadyExists.new(hash['id'], hash['
|
14
|
-
raise STP::Errors::STPError.new(hash['id'], hash['
|
13
|
+
raise STP::Errors::AccountAlreadyExists.new(hash['id'], hash['descripcion']) if hash['id'] == 1 && hash['descripcion'] == 'Cuenta Duplicada'
|
14
|
+
raise STP::Errors::STPError.new(hash['id'], hash['descripcion']) unless hash['id'] == 0
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.delete(account)
|
@@ -24,7 +24,7 @@ module STP
|
|
24
24
|
end
|
25
25
|
puts response.body if STP.verbose
|
26
26
|
hash = JSON.parse(response.body)
|
27
|
-
raise STP::Errors::STPError.new(hash['id'], hash['
|
27
|
+
raise STP::Errors::STPError.new(hash['id'], hash['descripcion']) unless hash['id'] == 0
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/lib/stp/structs/account.rb
CHANGED
@@ -13,7 +13,7 @@ module STP
|
|
13
13
|
:economic_activity, # actividadEconomica
|
14
14
|
:street, # calle
|
15
15
|
:exterior_number, # numeroExterior
|
16
|
-
:
|
16
|
+
:interior_number, # numeroInterior
|
17
17
|
:neighborhood, # colonia
|
18
18
|
:municipality, # alcaldiaMunicipio
|
19
19
|
:zip_code, # cp
|
@@ -34,12 +34,15 @@ module STP
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def as_json(_options = {})
|
37
|
+
name = @name.present? ? I18n.transliterate(@name) : nil
|
38
|
+
paternal_surname = @paternal_surname.present? ? I18n.transliterate(@paternal_surname) : nil
|
39
|
+
maternal_surname = @maternal_surname.present? ? I18n.transliterate(@maternal_surname) : nil
|
37
40
|
{
|
38
41
|
cuenta: @account,
|
39
42
|
empresa: @company,
|
40
|
-
nombre:
|
41
|
-
apellidoPaterno:
|
42
|
-
apellidoMaterno:
|
43
|
+
nombre: name,
|
44
|
+
apellidoPaterno: paternal_surname,
|
45
|
+
apellidoMaterno: maternal_surname,
|
43
46
|
rfcCurp: @rfc,
|
44
47
|
fechaNacimiento: @birthdate,
|
45
48
|
genero: @sex,
|
@@ -47,7 +50,7 @@ module STP
|
|
47
50
|
actividadEconomica: @economic_activity,
|
48
51
|
calle: @street,
|
49
52
|
numeroExterior: @exterior_number,
|
50
|
-
numeroInterior: @
|
53
|
+
numeroInterior: @interior_number,
|
51
54
|
colonia: @neighborhood,
|
52
55
|
alcaldiaMunicipio: @municipality,
|
53
56
|
cp: @zip_code,
|
data/lib/stp/version.rb
CHANGED
@@ -21,7 +21,7 @@ RSpec.describe STP::Account do
|
|
21
21
|
account.economic_activity = 'programador'
|
22
22
|
account.street = Faker::Address.street_name
|
23
23
|
account.exterior_number = Faker::Address.building_number
|
24
|
-
account.
|
24
|
+
account.interior_number = Faker::Address.building_number
|
25
25
|
account.neighborhood = Faker::Address.community
|
26
26
|
account.municipality = Faker::Address.community
|
27
27
|
account.zip_code = Faker::Number.number(digits: 5)
|
@@ -61,7 +61,7 @@ RSpec.describe STP::Account do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
context 'fails when' do
|
64
|
-
context '
|
64
|
+
context 'random error' do
|
65
65
|
let(:account_obj) do
|
66
66
|
account = STP::Structs::Account.new
|
67
67
|
account.account = '01010101'
|
@@ -75,7 +75,7 @@ RSpec.describe STP::Account do
|
|
75
75
|
account.economic_activity = 'programador'
|
76
76
|
account.street = Faker::Address.street_name
|
77
77
|
account.exterior_number = Faker::Address.building_number
|
78
|
-
account.
|
78
|
+
account.interior_number = Faker::Address.building_number
|
79
79
|
account.neighborhood = Faker::Address.community
|
80
80
|
account.municipality = Faker::Address.community
|
81
81
|
account.zip_code = Faker::Number.number(digits: 5)
|
@@ -94,6 +94,40 @@ RSpec.describe STP::Account do
|
|
94
94
|
|
95
95
|
it { expect {subject}.to raise_error(STP::Errors::STPError) }
|
96
96
|
end
|
97
|
+
|
98
|
+
context 'repeating account and rfcCurp' do
|
99
|
+
let(:account_obj) do
|
100
|
+
account = STP::Structs::Account.new
|
101
|
+
account.account = '01010101'
|
102
|
+
account.name = Faker::Name.first_name
|
103
|
+
account.paternal_surname = Faker::Name.last_name
|
104
|
+
account.maternal_surname = Faker::Name.last_name
|
105
|
+
account.rfc = 'RFC'
|
106
|
+
account.birthdate = Faker::Date.birthday(min_age: 6, max_age: 65)
|
107
|
+
account.sex = 'male'
|
108
|
+
account.state = 'Mérida'
|
109
|
+
account.economic_activity = 'programador'
|
110
|
+
account.street = Faker::Address.street_name
|
111
|
+
account.exterior_number = Faker::Address.building_number
|
112
|
+
account.interior_number = Faker::Address.building_number
|
113
|
+
account.neighborhood = Faker::Address.community
|
114
|
+
account.municipality = Faker::Address.community
|
115
|
+
account.zip_code = Faker::Number.number(digits: 5)
|
116
|
+
account.country = 'México'
|
117
|
+
account.email = Faker::Internet.email
|
118
|
+
account.identification_id = 'id'
|
119
|
+
account.phone = Faker::PhoneNumber.phone_number
|
120
|
+
account
|
121
|
+
end
|
122
|
+
|
123
|
+
before do
|
124
|
+
stub_request(:put, "#{STP.api_uri}/cuentaModule/fisica").to_return(
|
125
|
+
body: JSON.dump(STPTestHelpers::ACCOUNT_CREATE_MOCK_ERROR(1, 'Cuenta Duplicada')), status: 200
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
it { expect {subject}.to raise_error(STP::Errors::AccountAlreadyExists) }
|
130
|
+
end
|
97
131
|
end
|
98
132
|
end
|
99
133
|
end
|
@@ -21,7 +21,7 @@ RSpec.describe STP::Account do
|
|
21
21
|
account.economic_activity = 'programador'
|
22
22
|
account.street = Faker::Address.street_name
|
23
23
|
account.exterior_number = Faker::Address.building_number
|
24
|
-
account.
|
24
|
+
account.interior_number = Faker::Address.building_number
|
25
25
|
account.neighborhood = Faker::Address.community
|
26
26
|
account.municipality = Faker::Address.community
|
27
27
|
account.zip_code = Faker::Number.number(digits: 5)
|
@@ -41,7 +41,7 @@ RSpec.describe STP::Account do
|
|
41
41
|
allow(STP::Account).to receive(:create).
|
42
42
|
and_return(STPTestHelpers::ACCOUNT_DELETE_MOCK_SUCCESS())
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
before do
|
46
46
|
stub_request(:delete, "#{STP.api_uri}/cuentaModule/fisica").to_return(
|
47
47
|
body: JSON.dump(STPTestHelpers::ACCOUNT_DELETE_MOCK_SUCCESS()), status: 200
|
@@ -59,7 +59,7 @@ RSpec.describe STP::Account do
|
|
59
59
|
account.rfc = 'RFCURP'
|
60
60
|
account
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
before do
|
64
64
|
stub_request(:delete, "#{STP.api_uri}/cuentaModule/fisica").to_return(
|
65
65
|
body: JSON.dump(STPTestHelpers::ACCOUNT_DELETE_MOCK_SUCCESS()), status: 200
|
@@ -85,7 +85,7 @@ RSpec.describe STP::Account do
|
|
85
85
|
account.economic_activity = 'programador'
|
86
86
|
account.street = Faker::Address.street_name
|
87
87
|
account.exterior_number = Faker::Address.building_number
|
88
|
-
account.
|
88
|
+
account.interior_number = Faker::Address.building_number
|
89
89
|
account.neighborhood = Faker::Address.community
|
90
90
|
account.municipality = Faker::Address.community
|
91
91
|
account.zip_code = Faker::Number.number(digits: 5)
|
@@ -95,7 +95,7 @@ RSpec.describe STP::Account do
|
|
95
95
|
account.phone = Faker::PhoneNumber.phone_number
|
96
96
|
account
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
before do
|
100
100
|
stub_request(:delete, "#{STP.api_uri}/cuentaModule/fisica").to_return(
|
101
101
|
body: JSON.dump(STPTestHelpers::ACCOUNT_DELETE_MOCK_ERROR(-2)), status: 200
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module STPTestHelpers
|
2
2
|
def self.PAYMENT_ORDER_MOCK_ERROR(error_code)
|
3
3
|
{
|
4
|
-
'
|
4
|
+
'descripcion' => 'regular error msg',
|
5
5
|
'id' => error_code,
|
6
6
|
}
|
7
7
|
end
|
@@ -16,9 +16,9 @@ module STPTestHelpers
|
|
16
16
|
}
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.ACCOUNT_CREATE_MOCK_ERROR(error_code)
|
19
|
+
def self.ACCOUNT_CREATE_MOCK_ERROR(error_code, message='regular error msg')
|
20
20
|
{
|
21
|
-
'
|
21
|
+
'descripcion' => message,
|
22
22
|
'id' => error_code,
|
23
23
|
}
|
24
24
|
end
|
@@ -32,7 +32,7 @@ module STPTestHelpers
|
|
32
32
|
|
33
33
|
def self.ACCOUNT_DELETE_MOCK_ERROR(error_code)
|
34
34
|
{
|
35
|
-
'
|
35
|
+
'descripcion' => 'regular error msg',
|
36
36
|
'id' => error_code,
|
37
37
|
}
|
38
38
|
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.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yellowme
|
@@ -142,8 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: '0'
|
144
144
|
requirements: []
|
145
|
-
|
146
|
-
rubygems_version: 2.7.6
|
145
|
+
rubygems_version: 3.1.2
|
147
146
|
signing_key:
|
148
147
|
specification_version: 4
|
149
148
|
summary: STP Client is a ruby integration to STP services
|