solidus_me 1.0.1 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -2
- data/app/controller/spree/admin/melhor_envio_controller.rb +7 -5
- data/app/overrides/store_preferences.rb +2 -0
- data/app/views/spree/admin/melhor_envio/index.html.erb +15 -3
- data/lib/solidus_me/version.rb +1 -1
- metadata +2 -3
- data/db/migrate/20231103175330_add_delivery_time_to_spree_shipping_rate.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99922e6f7427808c33c7d153ac2003bd4542bbbdaceecfd35d18098894459258
|
4
|
+
data.tar.gz: 645f6bcb96aa4c92d31ce87d96e37ed84395c2f9657415b2c874ca338ec7f2d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87cffabde251c0cfc6319853b72e089bb98dd31e242506c14e9f6be41d95bff55bed304724ef03ae7d58ce8267faa4eff24c6c5f756d1192b8088397931bc31
|
7
|
+
data.tar.gz: 05ae50b4f505c42bd35c75bdd86a53be276eba2fb385abc8f71a488ea4c8ea4363abb4053a976f9286ca2abb2789cb066410779e3a92a13ff8aed935d9f4646b
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[![CircleCI](https://circleci.com/gh/solidusio-contrib/solidus_me.svg?style=shield)](https://circleci.com/gh/solidusio-contrib/solidus_me)
|
4
4
|
[![codecov](https://codecov.io/gh/solidusio-contrib/solidus_me/branch/master/graph/badge.svg)](https://codecov.io/gh/solidusio-contrib/solidus_me)
|
5
5
|
|
6
|
-
|
6
|
+
Gem para cotar empresas e valores de entrega junto à Api do Melhor Envio.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -18,10 +18,35 @@ Bundle your dependencies and run the installation generator:
|
|
18
18
|
```shell
|
19
19
|
bin/rails generate solidus_me:install
|
20
20
|
```
|
21
|
+
Adicionar no arquivo `/config/initilizers/spree.rb`
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
Spree.config do |config|
|
25
|
+
---
|
26
|
+
config.stock.estimator_class = "SolidusMe::ShippingEstimator"
|
27
|
+
---
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
No painel do admin será adiconado o item do `Melhor Envio` no menu lateral. Nesta página deverão ser preenchidos os seguintes campos para autenticação do aplicativo:
|
32
|
+
|
33
|
+
```text
|
34
|
+
CEP de origem:
|
35
|
+
Client ID:
|
36
|
+
Client Secret:
|
37
|
+
```
|
38
|
+
Após salvar, o link completo para autenticação do aplicativo ficará disponível abaixo. Uma vez autorizado, são gerados os `refresh_token` e `access_token`, e o sistema estará pronto para cotação dos fretes junto ao Melhor Envio.
|
39
|
+
|
40
|
+
Por padrão, os serviços de entrega são os `SEDEX`, `PAC` e `MiniEnvios` dos CORREIOS. Porém, os serviços podem ser customizados de acordo com a necessidade. Basta adicioná-los aos `preferences` da `Spree::Store`:
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
# Por exemplo
|
44
|
+
Spree::Store.first.update(preferences: { melhor_envio: { services: ["SEDEX", "PAC", "Mini Envios", ".Com", ".Package"] } })
|
45
|
+
```
|
21
46
|
|
22
47
|
## Usage
|
23
48
|
|
24
|
-
|
49
|
+
|
25
50
|
|
26
51
|
## Development
|
27
52
|
|
@@ -7,10 +7,7 @@ module Spree
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def update
|
10
|
-
@me_preferences
|
11
|
-
@me_preferences[:client_id] = params[:client_id]
|
12
|
-
@me_preferences[:client_secret] = params[:client_secret]
|
13
|
-
@me_preferences[:refresh_token] = params[:refresh_token]
|
10
|
+
@me_preferences = preferences_params
|
14
11
|
Spree::Store.first.update(preferences: { melhor_envio: @me_preferences })
|
15
12
|
redirect_to admin_melhor_envio_index_path
|
16
13
|
end
|
@@ -21,7 +18,7 @@ module Spree
|
|
21
18
|
client_id: @me_preferences[:client_id],
|
22
19
|
client_secret: @me_preferences[:client_secret],
|
23
20
|
code: code,
|
24
|
-
redirect_url:
|
21
|
+
redirect_url: @me_preferences[:redirect_url]
|
25
22
|
).json
|
26
23
|
@me_preferences[:access_token] = authorize_json["access_token"]
|
27
24
|
@me_preferences[:refresh_token] = authorize_json["refresh_token"]
|
@@ -36,6 +33,11 @@ module Spree
|
|
36
33
|
@me_preferences = Spree::Store.first.preferences[:melhor_envio]
|
37
34
|
end
|
38
35
|
|
36
|
+
def preferences_params
|
37
|
+
hash_preferences = params.permit(:postal_code_from, :services, :client_id, :client_secret, :redirect_url, :state, :access_token, :refresh_token, :token_expires_in)
|
38
|
+
hash_preferences[:services] = hash_preferences[:services].split(" ")
|
39
|
+
hash_preferences.to_h
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
43
|
end
|
@@ -7,8 +7,9 @@
|
|
7
7
|
</div>
|
8
8
|
|
9
9
|
<div style="margin-top: 10px;">
|
10
|
+
<%= form.hidden_field :services, value: @me_preferences[:services] %>
|
10
11
|
<span>Serviços Disponíveis: <%= @me_preferences[:services]&.join(", ") %></span>
|
11
|
-
</div>
|
12
|
+
</div>
|
12
13
|
|
13
14
|
<div style="margin-top: 10px;">
|
14
15
|
<%= form.label :client_id, "Client ID: " %>
|
@@ -20,6 +21,16 @@
|
|
20
21
|
<%= form.text_field :client_secret, value: @me_preferences[:client_secret] %>
|
21
22
|
</div>
|
22
23
|
|
24
|
+
<div style="margin-top: 10px;">
|
25
|
+
<%= form.label :redirect_url, "Redirect URL: " %>
|
26
|
+
<%= form.text_field :redirect_url, value: @me_preferences[:redirect_url] %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div style="margin-top: 10px;">
|
30
|
+
<%= form.label :state, "State: " %>
|
31
|
+
<%= form.text_field :state, value: @me_preferences[:state] %>
|
32
|
+
</div>
|
33
|
+
|
23
34
|
<div style="margin-top: 10px;">
|
24
35
|
<%= form.label :access_token, "Access Token: " %>
|
25
36
|
<%= form.text_field :access_token, value: @me_preferences[:access_token] %>
|
@@ -31,6 +42,7 @@
|
|
31
42
|
</div>
|
32
43
|
|
33
44
|
<div style="margin-top: 10px;">
|
45
|
+
<%= form.hidden_field :token_expires_in, value: @me_preferences[:token_expires_in] %>
|
34
46
|
<span>Expiração do token: <%= @me_preferences[:token_expires_in] %></span>
|
35
47
|
</div>
|
36
48
|
|
@@ -38,8 +50,8 @@
|
|
38
50
|
<% end %>
|
39
51
|
|
40
52
|
<div>
|
41
|
-
<input value="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= @me_preferences[:client_id] %>&redirect_uri=<%=
|
42
|
-
<a target="_blank" class="" href="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= @me_preferences[:client_id] %>&redirect_uri=<%=
|
53
|
+
<input value="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= @me_preferences[:client_id] %>&redirect_uri=<%= @me_preferences[:redirect_url] %>&response_type=code&state=<%= @me_preferences[:state] %>&scope=shipping-calculate">
|
54
|
+
<a target="_blank" class="" href="https://www.melhorenvio.com.br/oauth/authorize?client_id=<%= @me_preferences[:client_id] %>&redirect_uri=<%= @me_preferences[:redirect_url] %>&response_type=code&state=<%= @me_preferences[:state] %>&scope=shipping-calculate">
|
43
55
|
<svg style="width: 24px; height: 24px;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
44
56
|
<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>
|
45
57
|
</a>
|
data/lib/solidus_me/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.3
|
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-11-
|
11
|
+
date: 2023-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -106,7 +106,6 @@ files:
|
|
106
106
|
- config/locales/pt-BR.yml
|
107
107
|
- config/routes.rb
|
108
108
|
- db/migrate/20231103133348_add_preferences_to_spree_store.rb
|
109
|
-
- db/migrate/20231103175330_add_delivery_time_to_spree_shipping_rate.rb
|
110
109
|
- lib/generators/solidus_me/install/install_generator.rb
|
111
110
|
- lib/generators/solidus_me/install/templates/initializer.rb
|
112
111
|
- lib/solidus_me.rb
|