stp_client 0.4.0 → 0.4.1

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
  SHA256:
3
- metadata.gz: 5daa60f12ce66c0757768630a8851208f4e16a6f57b769c75da532820c5daff8
4
- data.tar.gz: 8af7bade911342be87701c0eefd401858663631f1c1a90287e6ec0f6f22c310b
3
+ metadata.gz: '05976db95cd7be28ef2d13164508e7d5c745c4e2ca3b8f35b1f9241948410e22'
4
+ data.tar.gz: 927bea6de224a93188c78ccdd7cacd477fbe58fe17a3cdfc8dfba18119387b8c
5
5
  SHA512:
6
- metadata.gz: 2b65070385c57e1258d2b8df82704d12e9f9b616e3db201f81410431eb51c7a27ca436c4856138de2e64bcea22827811cadae64e4d5f24bb8d4d7eddc4db7e64
7
- data.tar.gz: d4edc29c1ddb34da6db3d22ee91183753547e84aef5df64e2077aa5ee465ea4031b76d2f828e6e8bf49415207cb152ec39d93b5899f6df8c61b4ed9568401f74
6
+ metadata.gz: d35b0e8528f1534f3c903097c06b3442f93f4d0ae4836605a8e7f66fe5a4e3ed77c8d9a662fbf86bab5eb758539de30381d58852c737e81784cd59495692110f
7
+ data.tar.gz: e16c3fb810252149388304a5cabe36b2e48314c49646a3245094bc78c57e36ad7ce4b6fef345bd9778ab3414ba25ef29111b9f92d76e897f0ae5c056f9534deb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stp_client (0.3.0)
4
+ stp_client (0.4.0)
5
5
  crypto_yellowme (~> 0.4)
6
6
  faraday (~> 1.0)
7
7
 
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['message']) if hash['id'] == 1 && hash['message'] == "Cuenta Duplicada"
14
- raise STP::Errors::STPError.new(hash['id'], hash['message']) unless hash['id'] == 0
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['message']) unless hash['id'] == 0
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/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module STP
2
- VERSION = '0.4.0'
2
+ VERSION = '0.4.1'
3
3
  end
@@ -61,7 +61,7 @@ RSpec.describe STP::Account do
61
61
  end
62
62
 
63
63
  context 'fails when' do
64
- context 'repeating account and rfcCurp' do
64
+ context 'random error' do
65
65
  let(:account_obj) do
66
66
  account = STP::Structs::Account.new
67
67
  account.account = '01010101'
@@ -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_nunmber = 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
@@ -96,7 +96,7 @@ RSpec.describe STP::PaymentOrder do
96
96
  end
97
97
 
98
98
  it { expect(subject['id']).to eq -2 }
99
- it { expect(subject['descripcionError']).not_to be_nil }
99
+ it { expect(subject['descripcion']).not_to be_nil }
100
100
  end
101
101
  end
102
102
  end
@@ -1,7 +1,7 @@
1
1
  module STPTestHelpers
2
2
  def self.PAYMENT_ORDER_MOCK_ERROR(error_code)
3
3
  {
4
- 'descripcionError' => 'regular error msg',
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
- 'descripcionError' => 'regular error msg',
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
- 'descripcionError' => 'regular error msg',
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.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yellowme