solidus_me 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7484e033983b5cb4df982a16bf4170f371d85ee52147b7430837f86928870556
4
- data.tar.gz: e636ef95f9df52b4859096b15281bd79b9e9bfe6d2c96f22052f8fe37a696ab6
3
+ metadata.gz: 62dc6eb4a3e71567bda2d582a32a291159d9b89c76fed8719aec035d4668f3f3
4
+ data.tar.gz: c82e7fd2763ce627db6cba278036fa3b1f864363d89cab1a83720c7c8913382a
5
5
  SHA512:
6
- metadata.gz: 84723d7436b065f29f403b3b3fd54a00d7b5d7a9ba2de8c9eb8110006d413536ceee1dc59c16a8f1edb63bbfda5d3765bc82f595b70a3ced74bce4409b69c713
7
- data.tar.gz: 2129ee7f79aef74cbe78f341458bd798b6f06aab88b7e5b48e1e35598e2dc2a443e04c5dff856e39a99a481cfb941c24c65a1da6f0a91b68f4bb61ab9dfa644f
6
+ metadata.gz: 455417c56401f745ac3c946531f7597930998808edefe1d9666c78decbe058ba1fa2d79b5dc4b28f348f57f9dcd046cee01447c30174b75c0067092b3aa4c81b
7
+ data.tar.gz: a7d939b072ad093ee5c59eb0760ceb2c6b2d1fcc357899d5ab0aa875ff4bfd2501bb723c2ddc26cbb44af540494c225be624ad4b87afa0a0925cbdb848820e43
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
- require "solidus_dev_support/rake_tasks"
5
- SolidusDevSupport::RakeTasks.install
4
+ # require "solidus_dev_support/rake_tasks"
5
+ # SolidusDevSupport::RakeTasks.install
6
6
 
7
7
  task default: "extension:specs"
@@ -2,7 +2,7 @@ module SolidusMe
2
2
  class ShippingEstimator
3
3
  def shipping_rates(package, _frontend_only = true)
4
4
  @me_account = Account.first
5
- return [] if @me_account.blank?
5
+ return [build_shipping_rate(default_rate, package)] if @me_account.blank?
6
6
 
7
7
  @me_account.check_token
8
8
  @me_client = MeApi::Client.new(@me_account.access_token)
@@ -23,15 +23,24 @@ module SolidusMe
23
23
  private
24
24
 
25
25
  def get_rates_from_melhor_envio(package)
26
- weight = package.contents.map { |content| content.weight }.sum
27
26
  price = package.contents.map { |content| content.price }.sum
27
+ weight = package.weight
28
+
29
+ variants = package.contents.map { |content| content.variant }
30
+ height_cm = height(variants)
31
+ width_cm = width(variants)
32
+ length_cm = length(variants)
33
+
28
34
  zipcode = package.order.ship_address.zipcode
29
35
  services = @me_account.services.blank? ? ["SEDEX", "PAC", "Mini Envios", ".Package", ".Com"] : @me_account.services
30
36
 
31
37
  rates = @me_client.rates(
32
38
  from: @me_account.postal_code_from,
33
39
  to: zipcode,
34
- weight_kg: (weight / 1000),
40
+ weight_kg: (weight / 1000.00),
41
+ height_cm: height_cm,
42
+ width_cm: width_cm,
43
+ length_cm: length_cm,
35
44
  contents_value_brl: price
36
45
  )
37
46
  rates.select { |rate| rate.price > 0 && services.include?(rate.service_name) }
@@ -67,5 +76,17 @@ module SolidusMe
67
76
  delivery_range: {"min" => 5, "max" => 5}
68
77
  )
69
78
  end
79
+
80
+ def height variants
81
+ variants.pluck(:height, :width, :depth).map(&:max).compact.max
82
+ end
83
+
84
+ def width variants
85
+ variants.pluck(:height, :width, :depth).map { |dimensions| dimensions.sort[1] }.compact.max
86
+ end
87
+
88
+ def length variants
89
+ variants.pluck(:height, :width, :depth).map(&:min).compact.sum
90
+ end
70
91
  end
71
92
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusMe
4
- VERSION = "2.1.1"
4
+ VERSION = "2.2.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_me
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hamilton Tumenas Borges
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-06 00:00:00.000000000 Z
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
157
  - !ruby/object:Gem::Version
158
158
  version: '0'
159
159
  requirements: []
160
- rubygems_version: 3.4.19
160
+ rubygems_version: 3.5.10
161
161
  signing_key:
162
162
  specification_version: 4
163
163
  summary: Gem para integração com a API do Melhor Envio