correios_sigep 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/correios_sigep.rb +1 -0
- data/lib/correios_sigep/logistic_reverse/request_collect_number.rb +8 -3
- data/lib/correios_sigep/models/correios_response_codes.rb +1 -0
- data/lib/correios_sigep/models/errors/not_configured_client.rb +8 -0
- data/lib/correios_sigep/version.rb +1 -1
- data/spec/correios_sigep/logistic_reverse/request_collect_number_spec.rb +11 -0
- data/spec/fixtures/correios/response_not_configured_client.xml +14 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWM2MTI5Yzk4NjdhOTNiMjVjMDg2YTM5ZDgxNDZkY2E2Y2Q3MTY4OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NGViYTA4NjY1MzdiMGJjOTBjMWJiNjA1ZjMwNzk4ZmI3YTZmZTllOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NjU5YjUzZTVjY2Q0ZDg3OWMwNDRkNDFkOGM5MjE0YmM5MDE4NDU5MmI2YjY1
|
10
|
+
N2UxMGEzZjgzZTVlZWUyMzgwYzJhNjFkMWNlYThkZjEzMTk5ZWVmOTQ3ZjFm
|
11
|
+
NWZlMTQ3ZTJjZWFkNzg0YjhiZDFlNTY1NDVjNjI0YzE5NzJiZDU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NmRhMGJjNjY0N2QxYmI5YWUyYzIxYmYzYWY5OTQ3MDQ2MmIxNmU3N2FlZDlj
|
14
|
+
ZDdkYzBjMDMyZWUyMDIyMThkN2RkYTQ5MzViY2Q1ODFkNjgyNjU5MmYxN2Jh
|
15
|
+
ZWNiZGFkOTg4NzFlYjMxMmI5NmNjNTA5YTk2ZGIzMmFmNGIyMWI=
|
data/lib/correios_sigep.rb
CHANGED
@@ -24,6 +24,7 @@ require 'correios_sigep/models/errors/unavailable_service'
|
|
24
24
|
require 'correios_sigep/models/errors/inexistent_zipcode'
|
25
25
|
require 'correios_sigep/models/errors/unavailable_house_collect'
|
26
26
|
require 'correios_sigep/models/errors/collect_not_answered_for_the_zipcode'
|
27
|
+
require 'correios_sigep/models/errors/not_configured_client'
|
27
28
|
require 'correios_sigep/models/errors/unknown_error'
|
28
29
|
require 'correios_sigep/models/errors/sro_not_ready'
|
29
30
|
require 'correios_sigep/logistic_reverse/base_client'
|
@@ -24,6 +24,7 @@ module CorreiosSigep
|
|
24
24
|
def handle_errors code, response_doc
|
25
25
|
result_string = '//resultado-solicitacao | //resultado_solicitacao'
|
26
26
|
result_node = response_doc.search(result_string)
|
27
|
+
error_message = response_doc.search('//msg-erro | //msg_erro').text rescue ''
|
27
28
|
|
28
29
|
case code
|
29
30
|
when Models::CorreiosResponseCodes::SUCCESS
|
@@ -31,7 +32,6 @@ module CorreiosSigep
|
|
31
32
|
result.first.text rescue nil
|
32
33
|
|
33
34
|
when Models::CorreiosResponseCodes::TICKET_ALREADY_USED
|
34
|
-
error_message = result_node.search('//msg_erro | //msg_erro').text
|
35
35
|
raise Models::Errors::TicketAlreadyUsed.new error_message
|
36
36
|
|
37
37
|
when Models::CorreiosResponseCodes::UNAVAILABLE_SERVICE
|
@@ -46,9 +46,14 @@ module CorreiosSigep
|
|
46
46
|
when Models::CorreiosResponseCodes::COLLECT_NOT_ANSWERED_FOR_THE_ZIPCODE
|
47
47
|
raise Models::Errors::CollectNotAnsweredForTheZipcode
|
48
48
|
|
49
|
+
when Models::CorreiosResponseCodes::NOT_CONFIGURED_CLIENT
|
50
|
+
raise Models::Errors::NotConfiguredClient.new error_message
|
51
|
+
|
49
52
|
else
|
50
|
-
error_message = result_node.search('//
|
51
|
-
|
53
|
+
error_message = result_node.search('//msg-erro | //msg_erro').text
|
54
|
+
invalid_xml_message = response_doc.search("//return").text
|
55
|
+
|
56
|
+
raise Models::Errors::UnknownError.new [error_message, invalid_xml_message].join(', ')
|
52
57
|
end
|
53
58
|
end
|
54
59
|
end
|
@@ -83,6 +83,17 @@ module CorreiosSigep
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
+
context 'when user is not configured to use sigepweb' do
|
87
|
+
it 'should raise NotConfiguredClient error' do
|
88
|
+
stub_request(:post, "http://webservicescolhomologacao.correios.com.br/ScolWeb/WebServiceScol").
|
89
|
+
with(:body => "<?xml version=\"1.0\" encoding=\"UTF-8\"?><env:Envelope xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:tns=\"http://webservice.scol.correios.com.br/\" xmlns:env=\"http://schemas.xmlsoap.org/soap/envelope/\"><env:Body><tns:solicitarPostagemReversa><cartao>0057018901</cartao><codigo_servico>41076</codigo_servico><contrato>9912208555</contrato><codAdministrativo>08082650</codAdministrativo><senha>8o8otn</senha><usuario>60618043</usuario>\n <destinatario>\n <nome>ESTABELECIMENT W*M</nome>\n <logradouro>ESTRADA DE ACESSO A JANDIRA</logradouro>\n <numero>1400</numero>\n <complemento>G4</complemento>\n <bairro>FAZENDA ITAQUI</bairro>\n <referencia>REFERENCE</referencia>\n <cidade>BARUERI</cidade>\n <uf>SP</uf>\n <cep>06442130</cep>\n <ddd>11</ddd>\n <telefone>21683228</telefone>\n <email>teste@example.com</email>\n </destinatario>\n <coletas_solicitadas>\n <tipo>CA</tipo>\n <id_cliente>1405670</id_cliente>\n <valor_declarado>100.5</valor_declarado>\n <descricao>teste</descricao>\n <cklist>cklist</cklist>\n <numero>1</numero>\n <ag>1</ag>\n <cartao>1234</cartao>\n <servico_adicional>20.5</servico_adicional>\n <ar>2</ar>\n <remetente>\n <nome>JEFERSON VAZ DOS SANTOS</nome>\n <logradouro>RUA BLA BLA BLA</logradouro>\n <numero>666</numero>\n <complemento>APT 100</complemento>\n <bairro>PINHEIROS</bairro>\n <reference>REFERENCE</reference>\n <cidade>SÃO PAULO</cidade>\n <uf>SP</uf>\n <cep>05427020</cep>\n <ddd>16</ddd>\n <telefone>41606809</telefone>\n <email>jeff@example.com</email>\n <identificacao/>\n <ddd_celular/>\n <celular/>\n <sms/>\n </remetente>\n <produto>\n <codigo>code</codigo>\n <tipo>type</tipo>\n <qtd>3</qtd>\n </produto>\n <obj_col>\n <obj>\n <item>127078</item>\n <id>1405670</id>\n <desc>Pen Drive SAndisk 16GB SDCZ50-016G-A95</desc>\n <ship>ship</ship>\n <num>1</num>\n </obj>\n <obj>\n <item>277574</item>\n <id>1405670</id>\n <desc>Chip unico claro Pre pago</desc>\n <ship>ship</ship>\n <num>2</num>\n </obj>\n </obj_col>\n </coletas_solicitadas>\n\n</tns:solicitarPostagemReversa></env:Body></env:Envelope>",
|
90
|
+
:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'2306', 'Content-Type'=>'text/xml;charset=UTF-8', 'Soapaction'=>'"solicitarPostagemReversa"', 'User-Agent'=>'Ruby'}).
|
91
|
+
to_return(:status => 200, :body => correios_fixture('response_not_configured_client.xml'), :headers => {})
|
92
|
+
|
93
|
+
expect{subject}.to raise_error(Models::Errors::NotConfiguredClient)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
86
97
|
|
87
98
|
context 'when correios answer with another code' do
|
88
99
|
it 'should raise UnknownError error' do
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<ns2:solicitarPostagemReversaResponse xmlns:ns2="http://webservice.scol.correios.com.br/">
|
5
|
+
<return>
|
6
|
+
<status_processamento>00</status_processamento>
|
7
|
+
<data_processamento>02/06/2015</data_processamento>
|
8
|
+
<hora_processamento>12:07</hora_processamento>
|
9
|
+
<cod_erro>105</cod_erro>
|
10
|
+
<msg_erro>CLIENTE NÃO CONFIGURADO PARA USAR O SISTEMA (Dados de login inválidos (Código administrativo, usuário ou senha)</msg_erro>
|
11
|
+
</return>
|
12
|
+
</ns2:solicitarPostagemReversaResponse>
|
13
|
+
</S:Body>
|
14
|
+
</S:Envelope>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: correios_sigep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Ribeiro
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-06-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- lib/correios_sigep/models/correios_response_codes.rb
|
136
136
|
- lib/correios_sigep/models/errors/collect_not_answered_for_the_zipcode.rb
|
137
137
|
- lib/correios_sigep/models/errors/inexistent_zipcode.rb
|
138
|
+
- lib/correios_sigep/models/errors/not_configured_client.rb
|
138
139
|
- lib/correios_sigep/models/errors/sro_not_ready.rb
|
139
140
|
- lib/correios_sigep/models/errors/ticket_already_used.rb
|
140
141
|
- lib/correios_sigep/models/errors/unavailable_house_collect.rb
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- spec/fixtures/correios/response_already_in_use.xml
|
167
168
|
- spec/fixtures/correios/response_inexistent_zipcode.xml
|
168
169
|
- spec/fixtures/correios/response_not_answered_for_zipcode.xml
|
170
|
+
- spec/fixtures/correios/response_not_configured_client.xml
|
169
171
|
- spec/fixtures/correios/response_success.xml
|
170
172
|
- spec/fixtures/correios/response_unavailable_house_collect.xml
|
171
173
|
- spec/fixtures/correios/response_unavailable_service.xml
|
@@ -218,6 +220,7 @@ test_files:
|
|
218
220
|
- spec/fixtures/correios/response_already_in_use.xml
|
219
221
|
- spec/fixtures/correios/response_inexistent_zipcode.xml
|
220
222
|
- spec/fixtures/correios/response_not_answered_for_zipcode.xml
|
223
|
+
- spec/fixtures/correios/response_not_configured_client.xml
|
221
224
|
- spec/fixtures/correios/response_success.xml
|
222
225
|
- spec/fixtures/correios/response_unavailable_house_collect.xml
|
223
226
|
- spec/fixtures/correios/response_unavailable_service.xml
|