solidus_me 3.1.0 → 3.2.0

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: 9db290c638a2d01484e2fa15aab8c66e9aa5aa9d655360b2aa59a290654c9131
4
- data.tar.gz: c6f27dc5ad820d3b778805e138b566de84733caa75a1ec0f49d0bbcb21580ecd
3
+ metadata.gz: 7038411a1992fbe76be03e3ea54363e0a9a53bb813377951dad557aa718f3e09
4
+ data.tar.gz: 710ff6fccbe6dd9c9419fae66cd9ae77e14acb44f7a6a559f5b046d2651e670a
5
5
  SHA512:
6
- metadata.gz: 69fbcd15348fe78ff501e5245558da1be4156a298889a4afb347f70350d99cd4d857f5ae3445de1d5d02e4e4bbfd3f945b56cd62bb328776fd344cd98d3f1569
7
- data.tar.gz: 229e6ce800fb87c1330033303358ac7ae6f5ca41eb934e5da7dbdeb60c6a913d968dcc2047696da70a6b094f47c9870c0b69f6d9f936ac6dd299b4bc0d0d267e
6
+ metadata.gz: 3d1d04d17d6f872b078bcd1a038bd048ad766bc8294a5ed075bf08e5f3b60af050234e15be9b92dd8b4040288591b54b04d7fd2406f0e8886f210392744f197c
7
+ data.tar.gz: bdb62ee68a0920a1cae31658760649bb4c5f6148f09afaa1a4d0920afc77323de282eea87d8ce97b2ffc387ad0cd5f09c06a1b8c65c1c51f0a0d029ef7b34142
@@ -32,7 +32,8 @@ module SolidusMe
32
32
  length_cm = length(variants)
33
33
 
34
34
  zipcode = package.order.ship_address.zipcode
35
- services = @me_account.services.blank? ? ["SEDEX", "PAC", "Mini Envios", ".Package", ".Com"] : @me_account.services
35
+ services = @me_account.services.presence || ["SEDEX", "PAC", "Mini Envios", ".Package",
36
+ ".Com"]
36
37
 
37
38
  rates = @me_client.rates(
38
39
  from: @me_account.postal_code_from,
@@ -41,7 +42,7 @@ module SolidusMe
41
42
  contents_value_brl: price
42
43
  )
43
44
  rates.select { |rate| rate.price > 0 && services.include?(rate.service_name) }
44
- rescue
45
+ rescue StandardError
45
46
  [default_rate]
46
47
  end
47
48
 
@@ -55,35 +56,40 @@ module SolidusMe
55
56
  shipping_method.shipping_categories = Spree::ShippingCategory.all
56
57
  shipping_method.available_to_users = true
57
58
  end
59
+ estimate_prose = "Chegará em até #{ActionController::Base.helpers.pluralize(melhor_envio_rate.max_delivery_time,
60
+ 'dia', plural: 'dias')} úteis"
58
61
 
59
62
  Spree::ShippingRate.new(
60
63
  shipment: package.shipment,
61
64
  shipping_method: shipping_method,
62
65
  cost: melhor_envio_rate.price,
63
- min_delivery_time: (Time.now + melhor_envio_rate.delivery_range["min"].days),
64
- max_delivery_time: (Time.now + melhor_envio_rate.delivery_range["max"].days)
66
+ min_delivery_time: melhor_envio_rate.min_delivery_time.business_days.from_now,
67
+ max_delivery_time: melhor_envio_rate.max_delivery_time.business_days.from_now,
68
+ estimate_prose: estimate_prose,
69
+ expires_in: Time.now + 2.hours
65
70
  )
66
71
  end
67
72
 
68
73
  def default_rate
69
- default_rate = Data.define(:price, :service_name, :carrier_name, :delivery_range)
74
+ default_rate = Data.define(:price, :service_name, :carrier_name, :min_delivery_time, :max_delivery_time)
70
75
  default_rate.new(
71
76
  price: 15.00,
72
77
  service_name: "",
73
78
  carrier_name: "Frete padrão",
74
- delivery_range: {"min" => 5, "max" => 5}
79
+ min_delivery_time: 5,
80
+ max_delivery_time: 7,
75
81
  )
76
82
  end
77
83
 
78
- def height variants
84
+ def height(variants)
79
85
  variants.pluck(:height, :width, :depth).map(&:max).compact.max
80
86
  end
81
87
 
82
- def width variants
88
+ def width(variants)
83
89
  variants.pluck(:height, :width, :depth).map { |dimensions| dimensions.sort[1] }.compact.max
84
90
  end
85
91
 
86
- def length variants
92
+ def length(variants)
87
93
  variants.pluck(:height, :width, :depth).map(&:min).compact.sum
88
94
  end
89
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusMe
4
- VERSION = "3.1.0"
4
+ VERSION = "3.2.0"
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: 3.1.0
4
+ version: 3.2.0
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: 2024-10-11 00:00:00.000000000 Z
11
+ date: 2024-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core