solidus_me 3.3.1 → 3.4.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac3b73ea48e4461bf029a3882594562aaeffd9e1ac0617b92642f1c32bb731e5
|
4
|
+
data.tar.gz: 8570fb55a1623c0c13e721b7b7a5fb7085a6fb42a2411b5266549e032478966e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d71249d412670d8d4a2af11164a9ab2180abcd8022a88b77ebd925c53557ccd54c71f8b5ff12a2b684c7df8b11d0b2f8f49fdda145bed1b48582b4974e01df3c
|
7
|
+
data.tar.gz: 0ac0090dd26a8002a7f2c57a19a6685779caaf0b65133f6c9893de6ac44e3b760fdd311eba90219316a4ffef6b77431a3cb2aef4e7d421ac30096942e2bbb719
|
@@ -48,8 +48,76 @@ module SolidusMe
|
|
48
48
|
shipping_rates
|
49
49
|
end
|
50
50
|
|
51
|
+
def insert_package_into_cart from
|
52
|
+
me_client = set_me_client
|
53
|
+
order = package.order
|
54
|
+
variants = order.variants
|
55
|
+
line_items = order.line_items
|
56
|
+
address = order.ship_address
|
57
|
+
weight = package.weight
|
58
|
+
dimensions = estimate_dimensions_from_package(package)
|
59
|
+
|
60
|
+
shipping_method_name = @shipping_methods.sole.name
|
61
|
+
service_id = SHIPPING_METHODS.filter { _1[:name] == shipping_method_name }.sole[:external_id]
|
62
|
+
|
63
|
+
to = {
|
64
|
+
name: address.name,
|
65
|
+
phone: address.phone,
|
66
|
+
email: order.email,
|
67
|
+
document: order.tax_id,
|
68
|
+
address: address.address1,
|
69
|
+
complement: address.address2,
|
70
|
+
number: address.number,
|
71
|
+
district: address.district,
|
72
|
+
city: address.city,
|
73
|
+
postal_code: address.zipcode,
|
74
|
+
state_abbr: address.state.abbr
|
75
|
+
}
|
76
|
+
|
77
|
+
products = []
|
78
|
+
line_items.each do |line_item|
|
79
|
+
products << {
|
80
|
+
name: line_item.name,
|
81
|
+
quantity: line_item.quantity,
|
82
|
+
unitary_value: line_item.price
|
83
|
+
}
|
84
|
+
end
|
85
|
+
|
86
|
+
volumes = [{
|
87
|
+
width: dimensions[0].to_i.round(2),
|
88
|
+
height: dimensions[1].to_i.round(2),
|
89
|
+
length: dimensions[2].to_i.round(2),
|
90
|
+
weight: weight
|
91
|
+
}]
|
92
|
+
|
93
|
+
me_client.insert_package_into_cart(service_id:, from:, to:, products:, volumes:)
|
94
|
+
end
|
95
|
+
|
96
|
+
def payment_ticket(ticket_id)
|
97
|
+
me_client = set_me_client
|
98
|
+
me_client.payment_ticket ticket_id
|
99
|
+
end
|
100
|
+
|
101
|
+
def generate_ticket(ticket_id)
|
102
|
+
me_client = set_me_client
|
103
|
+
me_client.generate_ticket ticket_id
|
104
|
+
end
|
105
|
+
|
106
|
+
def print_ticket(ticket_id)
|
107
|
+
me_client = set_me_client
|
108
|
+
me_client.print_ticket ticket_id
|
109
|
+
end
|
110
|
+
|
51
111
|
private
|
52
112
|
|
113
|
+
def set_me_client
|
114
|
+
me_account = Account.first
|
115
|
+
return if me_account.blank?
|
116
|
+
|
117
|
+
me_account.check_token
|
118
|
+
MeApi::Client.new(me_account.access_token)
|
119
|
+
end
|
120
|
+
|
53
121
|
def get_rates_from_melhor_envio(package)
|
54
122
|
price = package.contents.map { |content| content.price }.sum
|
55
123
|
weight = package.weight
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<div class="field">
|
2
2
|
<div style="display: flex; align-items: center; margin-bottom: 6px">
|
3
3
|
<label style="margin-right: 5px; margin-bottom: 0" for="me_url">URL de autorização</label>
|
4
|
-
<a target="_blank" href="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= me_account.client_id %>&redirect_uri=<%= me_account.redirect_url %>&response_type=code&state=<%= me_account.state %>&scope=shipping-calculate">
|
4
|
+
<a target="_blank" href="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= me_account.client_id %>&redirect_uri=<%= me_account.redirect_url %>&response_type=code&state=<%= me_account.state %>&scope=shipping-calculate cart-read cart-write companies-read companies-write coupons-read coupons-write notifications-read orders-read products-read products-write purchases-read shipping-calculate shipping-cancel shipping-checkout shipping-companies shipping-generate shipping-preview shipping-print shipping-share shipping-tracking ecommerce-shipping transactions-read users-read users-write">
|
5
5
|
<svg style="width: 18px; height: 18px; color: black" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
6
6
|
<path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25"></path></svg>
|
7
7
|
</a>
|
8
8
|
</div>
|
9
9
|
<input id="me_url" class="fullwidth" value="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= me_account.client_id %>&redirect_uri=<%= me_account.redirect_url %>&response_type=code&state=<%= me_account.state %>&scope=shipping-calculate">
|
10
|
-
</div>
|
10
|
+
</div>
|
data/lib/solidus_me/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamilton Tumenas Borges
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: me_api
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
|
-
rubygems_version: 3.6.
|
97
|
+
rubygems_version: 3.6.9
|
98
98
|
specification_version: 4
|
99
99
|
summary: Gem para integração com a API do Melhor Envio
|
100
100
|
test_files: []
|