correios_sigep 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGUyY2U0NTg5N2FmZmRjNDk4NzcyZTRlYzIxYTM1ZjY4OTI1ZTY0Ng==
4
+ NGI0YjllYmVmNWNmMjI5MmEzYjdkOWQ3MDc4Yzc0ZmEwY2QzNzZlNA==
5
5
  data.tar.gz: !binary |-
6
- NGE1NDdjNGUzM2VjZDExYmI1ZDMwNDUzNzBjN2VhYzNjNGU5ZDg1Mw==
6
+ NmRkZDgxODAyYzYxMzY5MTMzMDVlZDNhMzk2ZDYxYjhmNzgxMjMzMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZTUwNmQyZWYwNDEzYThiMDI2MGVkZTg5Nzc3NWRiYjdmYmRkMjdjNWEzNTk2
10
- ZGQ1ZDgwZDE3M2U2OTIyZjlhZTY1OGIyMWM4ZjQ0OWFiNDZjMWQxYTk0NTE4
11
- OGNmMDM5MzYxNDgyY2ExZjA3YjFkMjRjYjNmNzZhZThhMzNjNTY=
9
+ ZGFiOTMwMDRmMmJkNzE2MDMxNjg5OGM5YzQ1NmE0NDUzZDc5ZGY2ZDY2ZDg3
10
+ ZGYyOTM2YjY3YWZlODViNjRkYWZlMGY0MWJkOTc0ZmYwNDA1OTI1NjNlMzUw
11
+ YzQwOTEyZDE2ODk5YmQ5OGU3MDZjYjVmZWY5NTM4MWYwZjE1Yzg=
12
12
  data.tar.gz: !binary |-
13
- ZjEyOTFmNjc3NDZkNzk0NzljMTViMzA5NjFhNzYwZDI2MzI4ZjNmZDViN2Iz
14
- MjcyOWQyZmNjN2FmMWE3MDRkY2QyMWM1YzAzN2E5MTI1NjljZGEzYjUwZmNh
15
- ZjZmNGM4ODFkMjNkNjUyNjAyYTI5OGM1Y2U0MTVmNGEwMTk1ZDA=
13
+ OWY2ZTFhNDBhZTJjOTdiODUyM2NhYzNkMTU4MWQ4ZGVmMTQzZTBkYzg1ZmIy
14
+ YjFhY2VjMTkyZDc4NWRhOTViNTc3NWE4MjM2NGM2NjBmYTUxZjQ5YTgwZDIy
15
+ Y2E5NGM1YTczMjI2ZTA0NmZiMTk0YmJjZTAyMzYxY2FkODEwODM=
data/README.md CHANGED
@@ -26,9 +26,114 @@ Ou instale manualmente com:
26
26
 
27
27
  $ gem install correios_sigep
28
28
 
29
+ ## Utilizando
30
+
31
+ ### Configurando
32
+ Para utilizar a gem, é necessário configurar os campos necessários com base nos dados contrato com os Correios.
33
+
34
+ ```ruby
35
+ CorreiosSigep.configure do |config|
36
+ config.user = '60618043'
37
+ config.password = '8o8otn'
38
+ config.administrative_code = '08082650'
39
+ config.card = '0057018901'
40
+ config.contract = '9912208555'
41
+ config.service_code = '41076'
42
+ end
43
+ ```
44
+
45
+ Se for necessário, é possível adicionar também um proxy.
46
+
47
+ ```ruby
48
+ config.proxy = 'http://px.myproxy.com'
49
+ ```
50
+
51
+ ### Logistica Reversa
52
+
53
+ #### Solicitar Postagem Reversa
54
+ (pg. 36 da documentação)
55
+
56
+ ```ruby
57
+ recipient = CorreiosSigep::Models::Recipient.new({
58
+ address: 'Endereco',
59
+ area_code: 'DDD',
60
+ city: 'Cidade',
61
+ complement: 'Complemento',
62
+ email: 'Email',
63
+ name: 'Nome',
64
+ neighborhood: 'Bairro',
65
+ number: 'Numero',
66
+ phone: 'Telefone',
67
+ postal_code: 'CEP',
68
+ reference: 'Referencia',
69
+ state: 'Estado'
70
+ })
71
+ sender = CorreiosSigep::Models::Sender.new({
72
+ address: 'Endereco',
73
+ area_code: 'DDD',
74
+ city: 'Cidade',
75
+ complement: 'Complemento',
76
+ email: 'Email',
77
+ name: 'Nome',
78
+ neighborhood: 'Bairro',
79
+ number: 'Numero',
80
+ phone: 'Telefone',
81
+ postal_code: 'CEP',
82
+ reference: 'Referencia',
83
+ state: 'Estado'
84
+ })
85
+ objects = [
86
+ {
87
+ item: 'Item',
88
+ id: '1',
89
+ description: 'Descricao',
90
+ num: '',
91
+ },
92
+ {
93
+ item: 'Item',
94
+ id: '2',
95
+ description: 'Descricao',
96
+ num: '',
97
+ }
98
+ ]
99
+
100
+ # Produto: pag 67 da documentação oficial dos correios
101
+ product = CorreiosSigep::Models::Product.new({
102
+ code: '116600403',
103
+ type: '0',
104
+ quantity: 1
105
+ })
106
+ collect = CorreiosSigep::Models::Collect.new({
107
+ aditional_service: '10.00',
108
+ ag: '5',
109
+ ar: '1',
110
+ card: '',
111
+ checklist: '2',
112
+ client_id: '102030',
113
+ declared_value: '1000.00',
114
+ description: 'Descricao',
115
+ number: '',
116
+ type: 'A'
117
+ }.merge(sender: sender, objects: objects, product: product))
118
+
119
+ logistic_reverse = CorreiosSigep::Models::LogisticReverse.new(recipient: recipient, collect: collect)
120
+ collect_number = CorreiosSigep::LogisticReverse::RequestCollectNumber.new(logistic_reverse).process
121
+
122
+ ```
123
+
124
+ #### Possíveis erros mapeados
125
+ ```ruby
126
+ TICKET_ALREADY_USED = 195 # NÚMERO DE E-TICKET JÁ UTILIZA
127
+ UNAVAILABLE_SERVICE = 210 # SERVIÇO INDISPONÍVEL NO MOMENTO
128
+ INEXISTENT_ZIPCODE = 113 # CEP DO DESTINATÁRIO INEXISTENTE
129
+ UNAVAILABLE_HOUSE_COLLECT = 111 # COLETA DOMICILIAR NÃO DISPONÍVEL PARA O SERVIÇO SEDEX 10
130
+ COLLECT_NOT_ANSWERED_FOR_THE_ZIPCODE = 117 # CEP DO REMETENTE INEXISTENTE
131
+ NOT_CONFIGURED_CLIENT = 105 # CLIENTE NÃO CONFIGURADO PARA USAR O SISTEMA
132
+ ```
133
+
29
134
  ## Contributing
30
135
 
31
- 1. Fork it ( https://github.com/[my-github-username]/correios_sigep/fork )
136
+ 1. Fork it ( https://github.com/duduribeiro/correios_sigep/fork )
32
137
  2. Create your feature branch (`git checkout -b my-new-feature`)
33
138
  3. Commit your changes (`git commit -am 'Add some feature'`)
34
139
  4. Push to the branch (`git push origin my-new-feature`)
@@ -51,8 +51,8 @@ module CorreiosSigep
51
51
  raise Models::Errors::NotConfiguredClient.new error_message
52
52
 
53
53
  else
54
- error_message = result_node.search('//msg-erro | //msg_erro').text
55
- invalid_xml_message = response_doc.search("//return").text
54
+ error_message = result_node.search('//msg-erro | //msg_erro').text rescue ''
55
+ invalid_xml_message = response_doc.search("//return").text rescue ''
56
56
 
57
57
  raise Models::Errors::UnknownError.new [error_message, invalid_xml_message].join(', ')
58
58
  end
@@ -1,3 +1,3 @@
1
1
  module CorreiosSigep
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  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.2.4
4
+ version: 0.2.5
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-07-17 00:00:00.000000000 Z
12
+ date: 2015-08-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon