correios_api 0.5.0 → 1.0.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 +7 -3
- data/lib/correios_api/pre_shipping.rb +0 -1
- data/lib/correios_api/rate.rb +1 -1
- data/lib/correios_api/shipping_quotes.rb +2 -3
- data/lib/correios_api/tracking.rb +0 -1
- data/lib/correios_api/version.rb +1 -1
- data/lib/correios_api.rb +1 -0
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1b4f48a2104d6ac49417b563e78fee09c9a9380f60e7caa96a6581cd3302124
|
4
|
+
data.tar.gz: 9e807f3939fc92c0e0735da58c50448703608572dfddf3e26dca92e84e94d98f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e8ace9e32df4e85270152bce9c6fa9082b8356f94b817f77ecdccc30d6b7d3e5d58db92d3a6c78c608d2d5dd39b9a3f19d52feb107b06eedcd9452c0e2cb8b2
|
7
|
+
data.tar.gz: 36a13664dd9abba3339cd2a9fa3032ecc43e942f83fa88fa167bf74cf2701f35d06686a8b75f7e7e54ba7aa7f20617a99c68ccf4719773f5bc3c94d569e0af1a
|
data/lib/correios_api/client.rb
CHANGED
@@ -159,9 +159,11 @@ module CorreiosApi
|
|
159
159
|
end
|
160
160
|
|
161
161
|
def delivery_time zipcode_from, zipcode_to
|
162
|
+
zipcode_from_digits = CodigoPostal.new(zipcode_from).cep_digits
|
163
|
+
zipcode_to_digits = CodigoPostal.new(zipcode_to).cep_digits
|
162
164
|
body = {
|
163
165
|
idLote: "1",
|
164
|
-
parametrosPrazo: SERVICES.map { |service| {coProduto: service[:code], nuRequisicao: 1, cepOrigem:
|
166
|
+
parametrosPrazo: SERVICES.map { |service| {coProduto: service[:code], nuRequisicao: 1, cepOrigem: zipcode_from_digits, cepDestino: zipcode_to_digits} }
|
165
167
|
}
|
166
168
|
response = post(
|
167
169
|
"/prazo/v1/nacional",
|
@@ -172,12 +174,14 @@ module CorreiosApi
|
|
172
174
|
end
|
173
175
|
|
174
176
|
def delivery_cost zipcode_from, zipcode_to, weight_g, height_cm, width_cm, length_cm
|
177
|
+
zipcode_from_digits = CodigoPostal.new(zipcode_from).cep_digits
|
178
|
+
zipcode_to_digits = CodigoPostal.new(zipcode_to).cep_digits
|
175
179
|
params_produto = SERVICES.map do |service|
|
176
180
|
{
|
177
181
|
coProduto: service[:code],
|
178
182
|
nuRequisicao: "1",
|
179
|
-
cepOrigem:
|
180
|
-
cepDestino:
|
183
|
+
cepOrigem: zipcode_from_digits,
|
184
|
+
cepDestino: zipcode_to_digits,
|
181
185
|
psObjeto: weight_g,
|
182
186
|
altura: height_cm,
|
183
187
|
largura: width_cm,
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module CorreiosApi
|
2
2
|
class PreShipping
|
3
|
-
|
4
3
|
attr_reader :response, :external_id, :tracking_code, :service_code, :payment_method_id, :price, :items, :post_prevision, :posting_deadline, :status, :status_detail, :label_type, :package_type
|
5
4
|
def initialize response
|
6
5
|
@response = response
|
data/lib/correios_api/rate.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
module CorreiosApi
|
2
2
|
class ShippingQuotes
|
3
|
-
|
4
3
|
attr_reader :rates
|
5
4
|
def initialize rates
|
6
5
|
@rates = rates
|
7
6
|
end
|
8
7
|
|
9
8
|
def cheaper_rate
|
10
|
-
valid_rates.
|
9
|
+
valid_rates.min_by(&:price)
|
11
10
|
end
|
12
11
|
|
13
12
|
def faster_rate
|
14
|
-
valid_rates.
|
13
|
+
valid_rates.min_by(&:delivery_time_in_days)
|
15
14
|
end
|
16
15
|
|
17
16
|
def valid_rates
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module CorreiosApi
|
2
2
|
class Tracking
|
3
|
-
|
4
3
|
attr_reader :response, :tracking_code, :sigla, :descricao, :categoria, :data_prevista, :weight_g, :height_cm, :width_cm, :length_cm, :formato, :modalidade, :eventos
|
5
4
|
def initialize response
|
6
5
|
@tracking_code = response.dig("objetos", 0, "codObjeto")
|
data/lib/correios_api/version.rb
CHANGED
data/lib/correios_api.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: correios_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.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-10-
|
11
|
+
date: 2024-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: codigo_postal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: base64
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,7 +81,7 @@ metadata:
|
|
67
81
|
homepage_uri: https://github.com/todasessascoisas/correios_api
|
68
82
|
source_code_uri: https://github.com/todasessascoisas/correios_api
|
69
83
|
changelog_uri: https://github.com/todasessascoisas/correios_api
|
70
|
-
post_install_message:
|
84
|
+
post_install_message:
|
71
85
|
rdoc_options: []
|
72
86
|
require_paths:
|
73
87
|
- lib
|
@@ -82,8 +96,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
96
|
- !ruby/object:Gem::Version
|
83
97
|
version: '0'
|
84
98
|
requirements: []
|
85
|
-
rubygems_version: 3.5.
|
86
|
-
signing_key:
|
99
|
+
rubygems_version: 3.5.11
|
100
|
+
signing_key:
|
87
101
|
specification_version: 4
|
88
102
|
summary: ''
|
89
103
|
test_files: []
|