correios_api 0.3.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/correios_api/client.rb +10 -10
- data/lib/correios_api/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf169db04d4e23814996679218d7a62c3ee448cc1476750bafeae980a594d1a2
|
4
|
+
data.tar.gz: c31ddcde2e7119e13ae706b05750c86442bde3eb58bf8947fee00d25ca493721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e580eb615143becb078949ef5b8b83397ab36e1640c5444f6da2794a3399c1806c012b83a369be5458d568d238ea4aca8fccea57b69734df80bc2106e1d9f41
|
7
|
+
data.tar.gz: 5cd2059ff69c566df95037cb6b3f7f4c9c03d72804b5295849d63ff3b5b1615b9408df14889e93a9cc34ea7915c7ee6ed90ae737bda640e7bb3c7fb8d6e6106a
|
data/lib/correios_api/client.rb
CHANGED
@@ -23,15 +23,16 @@ module CorreiosApi
|
|
23
23
|
"04227" => "CORREIOS MINI ENVIOS CTR AG"
|
24
24
|
}
|
25
25
|
|
26
|
-
attr_reader :username, :password, :post_card, :contract_number, :
|
27
|
-
def initialize username:, password:, post_card:, contract_number: nil,
|
26
|
+
attr_reader :username, :password, :post_card, :contract_number, :token, :expires_in
|
27
|
+
def initialize username:, password:, post_card:, contract_number: nil, token: nil, expires_in: nil
|
28
28
|
@username = username
|
29
29
|
@password = password
|
30
30
|
@post_card = post_card
|
31
31
|
@contract_number = contract_number
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
@token = token
|
33
|
+
# if @token.nil? || @expires_in < Time.now
|
34
|
+
# authenticate
|
35
|
+
# end
|
35
36
|
end
|
36
37
|
|
37
38
|
def authenticate
|
@@ -46,8 +47,7 @@ module CorreiosApi
|
|
46
47
|
},
|
47
48
|
body: JSON.dump(body)
|
48
49
|
) { |response| validate_response(response, "token") }
|
49
|
-
|
50
|
-
@access_token = response.json.dig("token")
|
50
|
+
@token = response.json.dig("token")
|
51
51
|
@expires_in = Time.new(response.json.dig("expiraEm"))
|
52
52
|
end
|
53
53
|
|
@@ -93,7 +93,7 @@ module CorreiosApi
|
|
93
93
|
larguraInformada: width_cm,
|
94
94
|
comprimentoInformado: length_cm,
|
95
95
|
cienteObjetoNaoProibido: "1",
|
96
|
-
modalidadePagamento: "2"
|
96
|
+
modalidadePagamento: "2" # 1-à vista, 2-à faturar, 3- à avista e à afaturar e 4- Prestação de contas recebimento ou pagamento
|
97
97
|
# solicitarColeta: "N",
|
98
98
|
# dataPrevistaPostagem: "29/09/2024"
|
99
99
|
}
|
@@ -161,7 +161,7 @@ module CorreiosApi
|
|
161
161
|
def delivery_time zipcode_from, zipcode_to
|
162
162
|
body = {
|
163
163
|
idLote: "1",
|
164
|
-
parametrosPrazo: SERVICES.map { |service| {
|
164
|
+
parametrosPrazo: SERVICES.map { |service| {coProduto: service[:code], nuRequisicao: 1, cepOrigem: zipcode_from, cepDestino: zipcode_to} }
|
165
165
|
}
|
166
166
|
response = post(
|
167
167
|
"/prazo/v1/nacional",
|
@@ -201,7 +201,7 @@ module CorreiosApi
|
|
201
201
|
|
202
202
|
def headers
|
203
203
|
{
|
204
|
-
"Authorization" => "Bearer #{@
|
204
|
+
"Authorization" => "Bearer #{@token}",
|
205
205
|
"Content-Type" => "application/json"
|
206
206
|
}
|
207
207
|
end
|
data/lib/correios_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: correios_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todas Essas Coisas
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base64
|
@@ -67,7 +67,7 @@ metadata:
|
|
67
67
|
homepage_uri: https://github.com/todasessascoisas/correios_api
|
68
68
|
source_code_uri: https://github.com/todasessascoisas/correios_api
|
69
69
|
changelog_uri: https://github.com/todasessascoisas/correios_api
|
70
|
-
post_install_message:
|
70
|
+
post_install_message:
|
71
71
|
rdoc_options: []
|
72
72
|
require_paths:
|
73
73
|
- lib
|
@@ -82,8 +82,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
|
-
rubygems_version: 3.5.
|
86
|
-
signing_key:
|
85
|
+
rubygems_version: 3.5.10
|
86
|
+
signing_key:
|
87
87
|
specification_version: 4
|
88
88
|
summary: ''
|
89
89
|
test_files: []
|