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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 299c3d587a192c84759b86cb6275e108955dc028
4
- data.tar.gz: 967b3d702ec45de6ca21845a2a57f70ddc2dbef1
3
+ metadata.gz: 8a2f2d9a0311b5312ffe6009212d28b7ddc5051e
4
+ data.tar.gz: d79b490315100b343cfb07ab616eaeb57db57095
5
5
  SHA512:
6
- metadata.gz: de4a3fed92a452896a6c89942a0ba092cb23c79876d70fdb128662ecbbcfeecaec5917a91d76d4d2c98dd6a09d9cbbfb0c1bb9c649f33862acabe7b7c801d7b8
7
- data.tar.gz: 97b2b19f272dc9dcb132f935e64e52b0c9a059a386ba19eb8911aa0338ce7c4867244e99a99ac2e13f26a17bcaef49e0166a9326bd8b2e15f569e74361165f4a
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 weight: self.weight, height: 2, width: self.width, length: self.length
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 weight: self.weight, length: self.length, width: self.diameter, height: self.diameter
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
@@ -1,3 +1,3 @@
1
1
  module Corraios
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: corraios
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
  - Rodrigo Ra