correios_sigep 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: fec627da594dd4e6b1e000fdd9e78a2a52636483
4
- data.tar.gz: 6f4cabc32b5258354255a6ae0082a8feafe16fab
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ N2E3ZDYxYTU0NGM0NjEzYmQzYjg5YzhhNDYzMGZmNTQzYjQzMjVhMg==
5
+ data.tar.gz: !binary |-
6
+ ZDdmMmQ3MDNmOTg0ZmY4MjY0YmZkN2EyYTMwODY3MGIwODYxNjMzNQ==
5
7
  SHA512:
6
- metadata.gz: 61544b05b1a115ca38ab87f172ecde8366b1b968425f9d35f334bdb6ce342a580afa3314d88a6d5ffa9ffedf78fbbdcddc612d6e6a6310564ec3a59ed4da2e84
7
- data.tar.gz: b05dfa0826155699f49638ecf4de325dec78256ca1a4c6660dc9d27a83d960b714c9b7b711ea0b82ae402c86930216138dd373d66be68cbc877d443fd7710e7f
8
+ metadata.gz: !binary |-
9
+ OTUzMzMyMjJhZTk5ZmEyY2RlMWU0NDk4NjVjYTNhYjA5MTg4N2VkZjZhYjRk
10
+ MmExYmM3ODM2MzM4ZWMzOGE4MGJhODg5ODZmN2U0Zjk4MTc0MDMwZWMxMzli
11
+ Yzc3ZGU0NTg3ZTE3ZTc3ZjliMTc3MmU3ZTljNDY3OWYyY2M0YmI=
12
+ data.tar.gz: !binary |-
13
+ YzlmYzgzZjA4MmE5M2EwZDY5OTM1ZjUwNDNiMDk0OTkwYjNjY2I4NGQzNDBj
14
+ YTljNzNhZjYyNDRkMGM0OWQ4OWQ1YWYwNWM3NmMxMjJmMTEwNmYxNjg1MmZm
15
+ MTQzNGZkZTZlZDExNzI0MDIxNWQ3NzBiY2Q2ODFjNzI3ZTBmN2I=
@@ -6,6 +6,7 @@ require 'correios_sigep/builders/xml/product'
6
6
  require 'correios_sigep/builders/xml/collect_objects'
7
7
  require 'correios_sigep/builders/xml/collect'
8
8
  require 'correios_sigep/builders/xml/authentication'
9
+ require 'correios_sigep/builders/xml/request'
9
10
  require 'correios_sigep/builders/xml/request_collect_number'
10
11
  require 'correios_sigep/builders/xml/request_sro'
11
12
  require 'correios_sigep/models/recipient'
@@ -0,0 +1,18 @@
1
+ module CorreiosSigep
2
+ module Builders
3
+ module XML
4
+ class Request
5
+
6
+ def self.build_xml(request)
7
+ document = Nokogiri::XML(request.to_xml)
8
+ XML::Authentication.new(document).build_xml!
9
+
10
+ document
11
+ .to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
12
+ .gsub(/<(\/)?root>/, '')
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,17 +1,7 @@
1
1
  module CorreiosSigep
2
2
  module Builders
3
3
  module XML
4
- class RequestCollectNumber
5
-
6
- def self.build_xml(logistic_reverse)
7
- document = Nokogiri::XML(logistic_reverse.to_xml)
8
- XML::Authentication.new(document).build_xml!
9
-
10
- document
11
- .to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
12
- .gsub(/<(\/)?root>/, '')
13
- end
14
-
4
+ class RequestCollectNumber < Request
15
5
  end
16
6
  end
17
7
  end
@@ -1,17 +1,7 @@
1
1
  module CorreiosSigep
2
2
  module Builders
3
3
  module XML
4
- class RequestSRO
5
-
6
- def self.build_xml(sro)
7
- document = Nokogiri::XML(sro.to_xml)
8
- XML::Authentication.new(document).build_xml!
9
-
10
- document
11
- .to_xml(save_with: Nokogiri::XML::Node::SaveOptions::NO_DECLARATION)
12
- .gsub(/<(\/)?root>/, '')
13
- end
14
-
4
+ class RequestSRO < Request
15
5
  end
16
6
  end
17
7
  end
@@ -1,3 +1,3 @@
1
1
  module CorreiosSigep
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -5,11 +5,11 @@ module CorreiosSigep
5
5
  module XML
6
6
  describe RequestCollectNumber do
7
7
  describe '.build_xml' do
8
- let(:logistic_reverse) { CorreiosSigep::Models::LogisticReverse.new }
9
- let(:expected_xml) do
10
- "<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&#xC3;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"
11
- end
12
8
  subject { described_class.build_xml(logistic_reverse) }
9
+
10
+ let(:logistic_reverse) { CorreiosSigep::Models::LogisticReverse.new }
11
+ let(:expected_xml) { builders_fixture('request_collect_number.xml') }
12
+
13
13
  before :each do
14
14
  seed_logistic_reverse(logistic_reverse)
15
15
  end
@@ -2,16 +2,14 @@ module CorreiosSigep
2
2
  module Builders
3
3
  module XML
4
4
  describe RequestSRO do
5
- let(:sro_params) { { collect_number: '1234', type: 'A' } }
6
- let(:sro) { CorreiosSigep::Models::SRO.new(sro_params) }
7
- let(:xml) do
8
- "<cartao>0057018901</cartao><codigo_servico>41076</codigo_servico><contrato>9912208555</contrato><codAdministrativo>08082650</codAdministrativo><senha>8o8otn</senha><usuario>60618043</usuario>\n <tipoBusca>H</tipoBusca>\n <tipoSolicitacao>A</tipoSolicitacao>\n <numeroPedido>1234</numeroPedido>\n\n"
9
- end
5
+ describe '.build_xml' do
6
+ subject { described_class.build_xml(sro) }
10
7
 
11
- subject { described_class.build_xml(sro) }
8
+ let(:sro_params) { { collect_number: '1234', type: 'A' } }
9
+ let(:sro) { CorreiosSigep::Models::SRO.new(sro_params) }
10
+ let(:expected_xml) { builders_fixture('request_sro.xml') }
12
11
 
13
- it 'builds a xml without root but with authentication' do
14
- expect(subject).to eq xml
12
+ it { should eq expected_xml }
15
13
  end
16
14
  end
17
15
  end
@@ -0,0 +1,67 @@
1
+ <cartao>0057018901</cartao><codigo_servico>41076</codigo_servico><contrato>9912208555</contrato><codAdministrativo>08082650</codAdministrativo><senha>8o8otn</senha><usuario>60618043</usuario>
2
+ <destinatario>
3
+ <nome>ESTABELECIMENT W*M</nome>
4
+ <logradouro>ESTRADA DE ACESSO A JANDIRA</logradouro>
5
+ <numero>1400</numero>
6
+ <complemento>G4</complemento>
7
+ <bairro>FAZENDA ITAQUI</bairro>
8
+ <referencia>REFERENCE</referencia>
9
+ <cidade>BARUERI</cidade>
10
+ <uf>SP</uf>
11
+ <cep>06442130</cep>
12
+ <ddd>11</ddd>
13
+ <telefone>21683228</telefone>
14
+ <email>teste@example.com</email>
15
+ </destinatario>
16
+ <coletas_solicitadas>
17
+ <tipo>CA</tipo>
18
+ <id_cliente>1405670</id_cliente>
19
+ <valor_declarado>100.5</valor_declarado>
20
+ <descricao>teste</descricao>
21
+ <cklist>cklist</cklist>
22
+ <numero>1</numero>
23
+ <ag>1</ag>
24
+ <cartao>1234</cartao>
25
+ <servico_adicional>20.5</servico_adicional>
26
+ <ar>2</ar>
27
+ <remetente>
28
+ <nome>JEFERSON VAZ DOS SANTOS</nome>
29
+ <logradouro>RUA BLA BLA BLA</logradouro>
30
+ <numero>666</numero>
31
+ <complemento>APT 100</complemento>
32
+ <bairro>PINHEIROS</bairro>
33
+ <reference>REFERENCE</reference>
34
+ <cidade>S&#xC3;O PAULO</cidade>
35
+ <uf>SP</uf>
36
+ <cep>05427020</cep>
37
+ <ddd>16</ddd>
38
+ <telefone>41606809</telefone>
39
+ <email>jeff@example.com</email>
40
+ <identificacao/>
41
+ <ddd_celular/>
42
+ <celular/>
43
+ <sms/>
44
+ </remetente>
45
+ <produto>
46
+ <codigo>code</codigo>
47
+ <tipo>type</tipo>
48
+ <qtd>3</qtd>
49
+ </produto>
50
+ <obj_col>
51
+ <obj>
52
+ <item>127078</item>
53
+ <id>1405670</id>
54
+ <desc>Pen Drive SAndisk 16GB SDCZ50-016G-A95</desc>
55
+ <ship>ship</ship>
56
+ <num>1</num>
57
+ </obj>
58
+ <obj>
59
+ <item>277574</item>
60
+ <id>1405670</id>
61
+ <desc>Chip unico claro Pre pago</desc>
62
+ <ship>ship</ship>
63
+ <num>2</num>
64
+ </obj>
65
+ </obj_col>
66
+ </coletas_solicitadas>
67
+
@@ -0,0 +1,5 @@
1
+ <cartao>0057018901</cartao><codigo_servico>41076</codigo_servico><contrato>9912208555</contrato><codAdministrativo>08082650</codAdministrativo><senha>8o8otn</senha><usuario>60618043</usuario>
2
+ <tipoBusca>H</tipoBusca>
3
+ <tipoSolicitacao>A</tipoSolicitacao>
4
+ <numeroPedido>1234</numeroPedido>
5
+
@@ -2,4 +2,8 @@ module FixtureHelper
2
2
  def correios_fixture(filename)
3
3
  File.open("./spec/fixtures/correios/#{filename}")
4
4
  end
5
+
6
+ def builders_fixture(filename)
7
+ File.read("./spec/fixtures/builders/#{filename}")
8
+ end
5
9
  end
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.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Ribeiro
@@ -9,90 +9,90 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-09 00:00:00.000000000 Z
12
+ date: 2015-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '2.0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ~>
33
33
  - !ruby/object:Gem::Version
34
34
  version: '1.7'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ~>
40
40
  - !ruby/object:Gem::Version
41
41
  version: '1.7'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rake
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '10.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '10.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3.0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: simplecov
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0.9'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0.9'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: webmock
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: '1.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ~>
96
96
  - !ruby/object:Gem::Version
97
97
  version: '1.0'
98
98
  description: An integration with Correios SIGEP WEB system (http://www.correios.com.br/para-sua-empresa/encomendas/sigep-web)
@@ -105,12 +105,12 @@ executables:
105
105
  extensions: []
106
106
  extra_rdoc_files: []
107
107
  files:
108
- - ".gitignore"
109
- - ".rspec"
110
- - ".rubocop.yml"
111
- - ".ruby-gemset"
112
- - ".ruby-version"
113
- - ".travis.yml"
108
+ - .gitignore
109
+ - .rspec
110
+ - .rubocop.yml
111
+ - .ruby-gemset
112
+ - .ruby-version
113
+ - .travis.yml
114
114
  - Gemfile
115
115
  - LICENSE.txt
116
116
  - README.md
@@ -123,6 +123,7 @@ files:
123
123
  - lib/correios_sigep/builders/xml/collect_objects.rb
124
124
  - lib/correios_sigep/builders/xml/product.rb
125
125
  - lib/correios_sigep/builders/xml/recipient.rb
126
+ - lib/correios_sigep/builders/xml/request.rb
126
127
  - lib/correios_sigep/builders/xml/request_collect_number.rb
127
128
  - lib/correios_sigep/builders/xml/request_sro.rb
128
129
  - lib/correios_sigep/builders/xml/sender.rb
@@ -160,6 +161,8 @@ files:
160
161
  - spec/correios_sigep/models/sender_spec.rb
161
162
  - spec/correios_sigep/models/sro_spec.rb
162
163
  - spec/correios_sigep_spec.rb
164
+ - spec/fixtures/builders/request_collect_number.xml
165
+ - spec/fixtures/builders/request_sro.xml
163
166
  - spec/fixtures/correios/response_already_in_use.xml
164
167
  - spec/fixtures/correios/response_inexistent_zipcode.xml
165
168
  - spec/fixtures/correios/response_not_answered_for_zipcode.xml
@@ -181,17 +184,17 @@ require_paths:
181
184
  - lib
182
185
  required_ruby_version: !ruby/object:Gem::Requirement
183
186
  requirements:
184
- - - ">="
187
+ - - ! '>='
185
188
  - !ruby/object:Gem::Version
186
189
  version: '0'
187
190
  required_rubygems_version: !ruby/object:Gem::Requirement
188
191
  requirements:
189
- - - ">="
192
+ - - ! '>='
190
193
  - !ruby/object:Gem::Version
191
194
  version: '0'
192
195
  requirements: []
193
196
  rubyforge_project:
194
- rubygems_version: 2.4.3
197
+ rubygems_version: 2.4.5
195
198
  signing_key:
196
199
  specification_version: 4
197
200
  summary: A gem that integrates with Correios SIGEP WEB.
@@ -210,6 +213,8 @@ test_files:
210
213
  - spec/correios_sigep/models/sender_spec.rb
211
214
  - spec/correios_sigep/models/sro_spec.rb
212
215
  - spec/correios_sigep_spec.rb
216
+ - spec/fixtures/builders/request_collect_number.xml
217
+ - spec/fixtures/builders/request_sro.xml
213
218
  - spec/fixtures/correios/response_already_in_use.xml
214
219
  - spec/fixtures/correios/response_inexistent_zipcode.xml
215
220
  - spec/fixtures/correios/response_not_answered_for_zipcode.xml