corraios 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/corraios/containers/base.rb +6 -0
- data/lib/corraios/containers/envelope.rb +5 -5
- data/lib/corraios/containers/package.rb +0 -4
- data/lib/corraios/containers/roll.rb +6 -5
- data/lib/corraios/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a2f2d9a0311b5312ffe6009212d28b7ddc5051e
|
4
|
+
data.tar.gz: d79b490315100b343cfb07ab616eaeb57db57095
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0eea7dda003360aab2b0d3816838b8f130d1d23f885d16a0ca1b4f5df15449a0ca9b205cab90b6b555867a66246d72cd26337a7dd370c4a431bac6aedf4254b
|
7
|
+
data.tar.gz: f5dfdb36865948edc5617980377009641c541d41dde0308a9a25ee6c07ad0f700d074c103b55dce084bfa1836d1b5f58708ecf921fcdf66072939ae961ab8d65
|
data/README.md
CHANGED
@@ -123,9 +123,14 @@ end
|
|
123
123
|
|
124
124
|
## TODO
|
125
125
|
|
126
|
+
- Unificar requisições para diferentes serviços (Hoje a chamada `calculator.perform :pac, :sedex` realiza duas requisiçoes ao servidor do Correios. Pode ser feita em uma)
|
127
|
+
- Unificar respostas quando mais de uma requisição é feita ao mesmo serviço (isso acontece quando o peso excede o limite de 30kg)
|
128
|
+
- Utilizar webmock nos testes
|
126
129
|
- adicionar opção mão própria
|
127
130
|
- adicionar opção aviso recebimento
|
128
131
|
- adicionar opção valor declarado
|
132
|
+
- Opção para configurar o timeout
|
133
|
+
- Opção de tentativas
|
129
134
|
|
130
135
|
|
131
136
|
## Contributing
|
@@ -32,6 +32,12 @@ module Corraios
|
|
32
32
|
self.class.instance_variable_get('@attributes_restrictions').keys
|
33
33
|
end
|
34
34
|
|
35
|
+
def valid?
|
36
|
+
attributes_names.all? do |attr|
|
37
|
+
self.class.valid_field?(attr, send(attr))
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
35
41
|
class << self
|
36
42
|
|
37
43
|
def add_attribute name, restrictions, query_attribute_name = nil, round_value = true
|
@@ -8,10 +8,6 @@ module Corraios
|
|
8
8
|
add_attribute :width, 11..60, 'nVlLargura'
|
9
9
|
add_attribute :length, 16..60, 'nVlComprimento'
|
10
10
|
|
11
|
-
def valid?
|
12
|
-
self.class.valid_fields? @attributes
|
13
|
-
end
|
14
|
-
|
15
11
|
def can_merge?(envelope)
|
16
12
|
new_weight = self.weight + envelope.weight
|
17
13
|
|
@@ -24,7 +20,11 @@ module Corraios
|
|
24
20
|
end
|
25
21
|
|
26
22
|
def to_package
|
27
|
-
Package.new
|
23
|
+
Package.new(weight: self.weight,
|
24
|
+
height: 2,
|
25
|
+
width: Package::floor_for(:width, self.width),
|
26
|
+
length: Package::floor_for(:length, self.length)
|
27
|
+
)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
@@ -9,10 +9,6 @@ module Corraios
|
|
9
9
|
add_attribute :length, 16..105, 'nVlComprimento'
|
10
10
|
add_attribute :height, 2..105, 'nVlAltura'
|
11
11
|
|
12
|
-
def valid?
|
13
|
-
self.class.valid_fields? @attributes
|
14
|
-
end
|
15
|
-
|
16
12
|
def can_merge?(other)
|
17
13
|
new_volume = self.volume + other.volume
|
18
14
|
new_sides_size = (new_volume ** (1.0/3))
|
@@ -8,10 +8,6 @@ module Corraios
|
|
8
8
|
add_attribute :length, 18..105, 'nVlComprimento'
|
9
9
|
add_attribute :diameter, 5..91, 'nVlDiametro'
|
10
10
|
|
11
|
-
def valid?
|
12
|
-
self.class.valid_fields? @attributes
|
13
|
-
end
|
14
|
-
|
15
11
|
def can_merge?(other)
|
16
12
|
false
|
17
13
|
end
|
@@ -25,7 +21,12 @@ module Corraios
|
|
25
21
|
end
|
26
22
|
|
27
23
|
def to_package
|
28
|
-
Package.new
|
24
|
+
Package.new(
|
25
|
+
weight: self.weight,
|
26
|
+
height: Package::floor_for(:height, self.diameter),
|
27
|
+
width: Package::floor_for(:width, self.diameter),
|
28
|
+
length: Package::floor_for(:length, self.length)
|
29
|
+
)
|
29
30
|
end
|
30
31
|
|
31
32
|
class << self
|
data/lib/corraios/version.rb
CHANGED