solidus_me 2.0.0 → 2.0.3
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 +4 -4
- data/Gemfile +18 -19
- data/Rakefile +2 -2
- data/app/controller/spree/admin/solidus_me/accounts_controller.rb +57 -51
- data/app/models/solidus_me/account.rb +1 -3
- data/app/models/solidus_me/shipping_estimator.rb +18 -21
- data/app/views/spree/admin/solidus_me/accounts/_form.html.erb +73 -45
- data/app/views/spree/admin/solidus_me/accounts/_link_auth.html.erb +10 -0
- data/app/views/spree/admin/solidus_me/accounts/edit.html.erb +2 -0
- data/app/views/spree/admin/solidus_me/accounts/index.html.erb +65 -8
- data/lib/generators/solidus_me/install/install_generator.rb +6 -6
- data/lib/solidus_me/configuration.rb +1 -1
- data/lib/solidus_me/engine.rb +5 -5
- data/lib/solidus_me/version.rb +1 -1
- data/lib/solidus_me.rb +5 -5
- data/solidus_me.gemspec +17 -18
- metadata +8 -11
- data/spec/models/solidus_me/account_spec.rb +0 -7
- data/spec/spec_helper.rb +0 -32
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce8c0bd086328dcd248ff193c74ccb79d5419e2daac7c197229e82bdaedfd372
|
4
|
+
data.tar.gz: 74b2947d34605aa4f8413ecbba6de5acbb9390e4e92d2e9f2653d242e6c1880b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06d48ad883be1578b1e1bb2fa5da5ab6e9a051a23f8bee29b42dcb0d299e10cac7b31dcf67bfff52ae90caa54e5df3529a100e91918488f7c78af66d36ea1d21
|
7
|
+
data.tar.gz: 6b85dc08b68564f879b08fa12c60ea17f9961af09f538a4cc68d45957b0efdf1d8ab3e4dc62326642235d25799ed94bde898d5b9a5fa4f8891c59d510245261b
|
data/Gemfile
CHANGED
@@ -1,42 +1,41 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source "https://rubygems.org"
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
5
|
|
6
|
-
branch = ENV.fetch(
|
7
|
-
gem
|
6
|
+
branch = ENV.fetch("SOLIDUS_BRANCH", "main")
|
7
|
+
gem "solidus", github: "solidusio/solidus", branch: branch
|
8
8
|
|
9
9
|
# The solidus_frontend gem has been pulled out since v3.2
|
10
|
-
if branch >=
|
11
|
-
gem
|
12
|
-
elsif branch ==
|
13
|
-
gem
|
10
|
+
if branch >= "v3.2"
|
11
|
+
gem "solidus_frontend"
|
12
|
+
elsif branch == "main"
|
13
|
+
gem "solidus_frontend", github: "solidusio/solidus_frontend"
|
14
14
|
else
|
15
|
-
gem
|
15
|
+
gem "solidus_frontend", github: "solidusio/solidus", branch: branch
|
16
16
|
end
|
17
17
|
|
18
18
|
# Needed to help Bundler figure out how to resolve dependencies,
|
19
19
|
# otherwise it takes forever to resolve them.
|
20
20
|
# See https://github.com/bundler/bundler/issues/6677
|
21
|
-
gem
|
22
|
-
|
21
|
+
gem "rails", ">0.a"
|
23
22
|
|
24
23
|
# Provides basic authentication functionality for testing parts of your engine
|
25
|
-
gem
|
24
|
+
gem "solidus_auth_devise"
|
26
25
|
|
27
|
-
case ENV.fetch(
|
28
|
-
when
|
29
|
-
gem
|
30
|
-
when
|
31
|
-
gem
|
26
|
+
case ENV.fetch("DB", nil)
|
27
|
+
when "mysql"
|
28
|
+
gem "mysql2"
|
29
|
+
when "postgresql"
|
30
|
+
gem "pg"
|
32
31
|
else
|
33
|
-
gem
|
32
|
+
gem "sqlite3"
|
34
33
|
end
|
35
34
|
|
36
35
|
# While we still support Ruby < 3 we need to workaround a limitation in
|
37
36
|
# the 'async' gem that relies on the latest ruby, since RubyGems doesn't
|
38
37
|
# resolve gems based on the required ruby version.
|
39
|
-
gem
|
38
|
+
gem "async", "< 3" if Gem::Version.new(RUBY_VERSION) < Gem::Version.new("3")
|
40
39
|
|
41
40
|
gemspec
|
42
41
|
|
@@ -45,4 +44,4 @@ gemspec
|
|
45
44
|
#
|
46
45
|
# We use `send` instead of calling `eval_gemfile` to work around an issue with
|
47
46
|
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
|
48
|
-
send(:eval_gemfile,
|
47
|
+
send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
|
data/Rakefile
CHANGED
@@ -1,69 +1,75 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
module SolidusMe
|
4
|
+
class AccountsController < BaseController
|
5
|
+
before_action :set_account, only: [:edit, :update, :destroy]
|
4
6
|
|
5
|
-
|
7
|
+
def index
|
8
|
+
@accounts = ::SolidusMe::Account.all
|
9
|
+
end
|
6
10
|
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
def new
|
12
|
+
if ::SolidusMe::Account.any?
|
13
|
+
flash[:error] = "Você só pode ter uma conta Melhor Envio cadastrada"
|
14
|
+
redirect_to admin_solidus_me_accounts_path
|
15
|
+
end
|
16
|
+
@me_account = ::SolidusMe::Account.new
|
17
|
+
end
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
|
19
|
+
def create
|
20
|
+
me_account = ::SolidusMe::Account.new account_params
|
21
|
+
if me_account.save
|
22
|
+
flash[:success] = "Conta criada com sucesso"
|
23
|
+
redirect_to admin_solidus_me_accounts_path
|
24
|
+
else
|
25
|
+
flash[:error] = me_account.errors.full_messages.join("\n")
|
26
|
+
redirect_to new_admin_solidus_me_account_path
|
27
|
+
end
|
28
|
+
end
|
14
29
|
|
15
|
-
|
16
|
-
me_account = ::SolidusMe::Account.new account_params
|
17
|
-
if me_account.save
|
18
|
-
flash[:success] = "Conta criada com sucesso"
|
19
|
-
redirect_to admin_solidus_me_accounts_path
|
20
|
-
else
|
21
|
-
flash[:error] = me_account.errors.full_messages.join("\n")
|
22
|
-
redirect_to new_admin_solidus_me_account_path
|
30
|
+
def edit
|
23
31
|
end
|
24
|
-
end
|
25
32
|
|
26
|
-
|
27
|
-
|
28
|
-
|
33
|
+
def update
|
34
|
+
@me_account.update account_params
|
35
|
+
flash[:success] = "Conta atualizada com sucesso"
|
36
|
+
redirect_to edit_admin_solidus_me_account_path(@me_account.id)
|
37
|
+
end
|
29
38
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
39
|
+
def destroy
|
40
|
+
@me_account.delete
|
41
|
+
redirect_to admin_solidus_me_accounts_path
|
42
|
+
end
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
44
|
+
def authorize
|
45
|
+
code = params[:code]
|
46
|
+
me_account = ::SolidusMe::Account.first
|
47
|
+
authorize_json = MeApi::Client.new.authorize(
|
48
|
+
client_id: me_account.client_id,
|
49
|
+
client_secret: me_account.client_secret,
|
50
|
+
code: code,
|
51
|
+
redirect_url: me_account.redirect_url
|
52
|
+
).json
|
53
|
+
me_account.update(
|
54
|
+
access_token: authorize_json["access_token"],
|
55
|
+
refresh_token: authorize_json["refresh_token"],
|
56
|
+
token_expires_in: (DateTime.now + authorize_json["expires_in"].seconds).to_s
|
57
|
+
)
|
58
|
+
redirect_to edit_admin_solidus_me_account_path me_account
|
59
|
+
end
|
41
60
|
|
42
|
-
|
43
|
-
code = params[:code]
|
44
|
-
me_account = ::SolidusMe::Account.first
|
45
|
-
authorize_json = MeApi::Client.new.authorize(
|
46
|
-
client_id: me_account.client_id,
|
47
|
-
client_secret: me_account.client_secret,
|
48
|
-
code: code,
|
49
|
-
redirect_url: me_account.redirect_url
|
50
|
-
).json
|
51
|
-
me_account.update(
|
52
|
-
access_token: authorize_json["access_token"],
|
53
|
-
refresh_token: authorize_json["refresh_token"],
|
54
|
-
token_expires_in: (DateTime.now + authorize_json["expires_in"].seconds).to_s
|
55
|
-
)
|
56
|
-
redirect_to edit_admin_solidus_me_account_path me_account
|
57
|
-
end
|
61
|
+
private
|
58
62
|
|
59
|
-
|
63
|
+
def account_params
|
64
|
+
params.require(:account).permit(
|
65
|
+
:client_id, :client_secret, :access_token, :refresh_token, :redirect_url, :state, :token_expires_in, :services, :postal_code_from
|
66
|
+
)
|
67
|
+
end
|
60
68
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
)
|
69
|
+
def set_account
|
70
|
+
@me_account = ::SolidusMe::Account.find(params[:id])
|
71
|
+
end
|
65
72
|
end
|
66
73
|
end
|
67
74
|
end
|
68
75
|
end
|
69
|
-
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module SolidusMe
|
2
2
|
class Account < ApplicationRecord
|
3
|
-
|
4
3
|
def check_token
|
5
4
|
return if client_id.blank? || client_secret.blank? || refresh_token.blank?
|
6
5
|
return if (token_expires_in - 1.day) > DateTime.now
|
@@ -16,8 +15,7 @@ module SolidusMe
|
|
16
15
|
access_token = refresh_json["access_token"]
|
17
16
|
refresh_token = refresh_json["refresh_token"]
|
18
17
|
token_expires_in = DateTime.now.utc + refresh_json["expires_in"].seconds
|
19
|
-
|
18
|
+
update(access_token: access_token, refresh_token: refresh_token, token_expires_in: token_expires_in)
|
20
19
|
end
|
21
|
-
|
22
20
|
end
|
23
21
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module SolidusMe
|
2
2
|
class ShippingEstimator
|
3
|
-
|
4
3
|
def shipping_rates(package, _frontend_only = true)
|
5
4
|
@me_account = Account.first
|
6
5
|
return [] if @me_account.blank?
|
7
|
-
|
6
|
+
|
8
7
|
@me_account.check_token
|
9
8
|
@me_client = MeApi::Client.new(@me_account.access_token)
|
10
9
|
|
@@ -24,35 +23,33 @@ module SolidusMe
|
|
24
23
|
private
|
25
24
|
|
26
25
|
def get_rates_from_melhor_envio(package)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
services = @me_account.services.blank? ? ["SEDEX", "PAC", "Mini Envios", ".Package", ".Com"] : @me_account.services
|
26
|
+
weight = package.contents.map { |content| content.weight }.sum
|
27
|
+
price = package.contents.map { |content| content.price }.sum
|
28
|
+
zipcode = package.order.ship_address.zipcode
|
29
|
+
services = @me_account.services.blank? ? ["SEDEX", "PAC", "Mini Envios", ".Package", ".Com"] : @me_account.services
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end
|
31
|
+
rates = @me_client.rates(
|
32
|
+
from: @me_account.postal_code_from,
|
33
|
+
to: zipcode,
|
34
|
+
weight_kg: (weight / 1000),
|
35
|
+
contents_value_brl: price
|
36
|
+
)
|
37
|
+
rates.select { |rate| rate.price > 0 && services.include?(rate.service_name) }
|
38
|
+
rescue
|
39
|
+
[default_rate]
|
43
40
|
end
|
44
41
|
|
45
42
|
def build_shipping_rate(melhor_envio_rate, package)
|
46
43
|
shipping_method = Spree::ShippingMethod.find_or_create_by(
|
47
44
|
carrier: melhor_envio_rate.carrier_name,
|
48
|
-
service_level: melhor_envio_rate.service_name
|
45
|
+
service_level: melhor_envio_rate.service_name
|
49
46
|
) do |shipping_method|
|
50
47
|
shipping_method.name = "#{melhor_envio_rate.carrier_name} #{melhor_envio_rate.service_name}"
|
51
48
|
shipping_method.calculator = Spree::Calculator::Shipping::FlatRate.create
|
52
49
|
shipping_method.shipping_categories = Spree::ShippingCategory.all
|
53
50
|
shipping_method.available_to_users = true
|
54
51
|
end
|
55
|
-
|
52
|
+
|
56
53
|
Spree::ShippingRate.new(
|
57
54
|
shipping_method: shipping_method,
|
58
55
|
cost: melhor_envio_rate.price,
|
@@ -67,8 +64,8 @@ module SolidusMe
|
|
67
64
|
price: 15.00,
|
68
65
|
service_name: "",
|
69
66
|
carrier_name: "Frete padrão",
|
70
|
-
delivery_range: {
|
67
|
+
delivery_range: {"min" => 5, "max" => 5}
|
71
68
|
)
|
72
69
|
end
|
73
70
|
end
|
74
|
-
end
|
71
|
+
end
|
@@ -1,58 +1,86 @@
|
|
1
|
+
<%= render "link_auth", me_account: me_account %>
|
2
|
+
|
1
3
|
<%= form_with model: me_account, url: form_url do |form| %>
|
2
|
-
<
|
4
|
+
<fieldset class="no-border-top">
|
5
|
+
<legend>
|
6
|
+
Dados da Conta
|
7
|
+
</legend>
|
8
|
+
<div class="row">
|
9
|
+
<div class="col-12 col-md-6">
|
3
10
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
11
|
+
<%= form.field_container :postal_code_from do %>
|
12
|
+
<%= form.label :postal_code_from, "CEP de Origem", class: 'required' %>
|
13
|
+
<%= form.text_field :postal_code_from, required: true, class: 'fullwidth' %>
|
14
|
+
<%= form.error_message_on :postal_code_from %>
|
15
|
+
<% end %>
|
8
16
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
17
|
+
<%= form.field_container :services do %>
|
18
|
+
<%= form.label :services, "Serviços" %>
|
19
|
+
<%= form.text_field :services, class: 'fullwidth', disabled: true %>
|
20
|
+
<%= form.error_message_on :services %>
|
21
|
+
<% end %>
|
13
22
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
23
|
+
<%= form.field_container :client_id do %>
|
24
|
+
<%= form.label :client_id, "Client ID", class: 'required' %>
|
25
|
+
<%= form.text_field :client_id, required: true, class: 'fullwidth' %>
|
26
|
+
<%= form.error_message_on :client_id %>
|
27
|
+
<% end %>
|
18
28
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
29
|
+
<%= form.field_container :client_secret do %>
|
30
|
+
<%= form.label :client_secret, "Client Secret", class: 'required' %>
|
31
|
+
<%= form.text_field :client_secret, required: true, class: 'fullwidth' %>
|
32
|
+
<%= form.error_message_on :client_secret %>
|
33
|
+
<% end %>
|
23
34
|
|
24
|
-
|
25
|
-
<%= form.label :redirect_url, "Redirect URL: " %>
|
26
|
-
<%= form.text_field :redirect_url, value: me_account.redirect_url %>
|
27
|
-
</div>
|
35
|
+
</div>
|
28
36
|
|
29
|
-
|
30
|
-
<%= form.label :state, "State: " %>
|
31
|
-
<%= form.text_field :state, value: me_account.state %>
|
32
|
-
</div>
|
37
|
+
<div class="col-12 col-md-6">
|
33
38
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
39
|
+
<%= form.field_container :redirect_url do %>
|
40
|
+
<%= form.label :redirect_url, "Redirect URL", class: 'required' %>
|
41
|
+
<%= form.text_field :redirect_url, required: true, class: 'fullwidth' %>
|
42
|
+
<%= form.error_message_on :redirect_url %>
|
43
|
+
<% end %>
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
45
|
+
<%= form.field_container :state do %>
|
46
|
+
<%= form.label :state, "State", class: 'required' %>
|
47
|
+
<%= form.text_field :state, required: true, class: 'fullwidth' %>
|
48
|
+
<%= form.error_message_on :state %>
|
49
|
+
<% end %>
|
43
50
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
<%= form.field_container :refresh_token do %>
|
52
|
+
<%= form.label :refresh_token, "Refresh Token" %>
|
53
|
+
<%= form.text_field :refresh_token, class: 'fullwidth' %>
|
54
|
+
<%= form.error_message_on :refresh_token %>
|
55
|
+
<% end %>
|
56
|
+
|
57
|
+
<%= form.field_container :access_token do %>
|
58
|
+
<%= form.label :access_token, "Access Token" %>
|
59
|
+
<%= form.text_field :access_token, class: 'fullwidth' %>
|
60
|
+
<%= form.error_message_on :access_token %>
|
61
|
+
<% end %>
|
62
|
+
|
63
|
+
<div style="margin-top: 10px;">
|
64
|
+
<%= form.hidden_field :token_expires_in %>
|
65
|
+
<% if params["action"] != 'new' %>
|
66
|
+
<div class="field">
|
67
|
+
<%= label_tag :token_expires_in, "Token Expiration" %>
|
68
|
+
<div class="fullwidth" id="token_expires_in" name="token_expires_in"><%= me_account.token_expires_in %> </div>
|
69
|
+
</div>
|
70
|
+
<% end %>
|
71
|
+
</div>
|
72
|
+
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
</fieldset>
|
48
76
|
|
49
|
-
|
77
|
+
|
78
|
+
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
79
|
+
<%= form.submit "Salvar", class: 'btn btn-primary' %>
|
80
|
+
<% if params["action"] == 'edit' %>
|
81
|
+
<%= link_to "Excluir", admin_solidus_me_account_path(me_account.id), method: :delete, data: { confirm: "Tem certeza que deseja excluir a conta?"}, class: 'button' %>
|
82
|
+
<% end %>
|
83
|
+
</div>
|
50
84
|
<% end %>
|
51
85
|
|
52
|
-
|
53
|
-
<input 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">
|
54
|
-
<a target="_blank" class="" 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">
|
55
|
-
<svg style="width: 24px; height: 24px;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
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>
|
57
|
-
</a>
|
58
|
-
</div>
|
86
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div class="field">
|
2
|
+
<div style="display: flex; align-items: center; margin-bottom: 6px">
|
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">
|
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
|
+
<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
|
+
</a>
|
8
|
+
</div>
|
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>
|
@@ -1,12 +1,69 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% admin_layout "full-width" %>
|
2
|
+
|
3
|
+
<% admin_breadcrumb("Melhor Envio") %>
|
4
|
+
|
5
|
+
<% content_for :page_actions do %>
|
6
|
+
<% if SolidusMe::Account.count < 1 %>
|
7
|
+
<li>
|
8
|
+
<%= link_to "Nova Conta", new_admin_solidus_me_account_path, class: 'btn btn-primary' %>
|
9
|
+
</li>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<div class="content-wrapper">
|
3
14
|
<% @accounts.each do |account| %>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
15
|
+
<%= render "link_auth", me_account: account %>
|
16
|
+
|
17
|
+
<fieldset class="no-border-top">
|
18
|
+
<legend>
|
19
|
+
Dados da Conta
|
20
|
+
</legend>
|
21
|
+
<div class="row">
|
22
|
+
<div class="col-12 col-md-6">
|
23
|
+
<div class="field">
|
24
|
+
<%= label_tag :client_id, "Client ID" %>
|
25
|
+
<%= text_field_tag :client_id, account.client_id, class:"fullwidth", disabled: true %>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="field">
|
29
|
+
<%= label_tag :client_secret, "Client Secret" %>
|
30
|
+
<%= text_field_tag :client_secret, account.client_secret, class:"fullwidth", disabled: true %>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<div class="field">
|
34
|
+
<%= label_tag :refresh_token, "Refresh Token" %>
|
35
|
+
<%= text_field_tag :refresh_token, account.refresh_token, class:"fullwidth", disabled: true %>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div class="field">
|
39
|
+
<%= label_tag :token_expires_in, "Token Expiration" %>
|
40
|
+
<div class="fullwidth" id="token_expires_in" name="token_expires_in">
|
41
|
+
<%= account.token_expires_in %>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div class="col-12 col-md-6">
|
47
|
+
|
48
|
+
<div class="field">
|
49
|
+
<%= label_tag :redirect_url, "Redirect URL" %>
|
50
|
+
<%= text_field_tag :redirect_url, account.redirect_url, class:"fullwidth", disabled: true %>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
<div class="field">
|
54
|
+
<%= label_tag :state, "State" %>
|
55
|
+
<%= text_field_tag :state, account.state, class:"fullwidth", disabled: true %>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<div class="field">
|
59
|
+
<%= label_tag :access_token, "Access Token" %>
|
60
|
+
<%= text_field_tag :access_token, account.access_token, class:"fullwidth", disabled: true %>
|
61
|
+
</div>
|
62
|
+
</div>
|
63
|
+
</fieldset>
|
64
|
+
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
65
|
+
<%= link_to "Editar", edit_admin_solidus_me_account_path(account.id), class: 'btn btn-primary' %>
|
66
|
+
<%= link_to "Excluir", admin_solidus_me_account_path(account.id), method: :delete, data: { confirm: "Tem certeza que deseja excluir a conta?"}, class: 'button' %>
|
10
67
|
</div>
|
11
68
|
<% end %>
|
12
69
|
</div>
|
@@ -4,26 +4,26 @@ module SolidusMe
|
|
4
4
|
module Generators
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
6
6
|
class_option :auto_run_migrations, type: :boolean, default: false
|
7
|
-
source_root File.expand_path(
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
8
|
|
9
9
|
def self.exit_on_failure?
|
10
10
|
true
|
11
11
|
end
|
12
12
|
|
13
13
|
def copy_initializer
|
14
|
-
template
|
14
|
+
template "initializer.rb", "config/initializers/solidus_me.rb"
|
15
15
|
end
|
16
16
|
|
17
17
|
def add_migrations
|
18
|
-
run
|
18
|
+
run "bin/rails railties:install:migrations FROM=solidus_me"
|
19
19
|
end
|
20
20
|
|
21
21
|
def run_migrations
|
22
|
-
run_migrations = options[:auto_run_migrations] || [
|
22
|
+
run_migrations = options[:auto_run_migrations] || ["", "y", "Y"].include?(ask("Would you like to run the migrations now? [Y/n]")) # rubocop:disable Layout/LineLength
|
23
23
|
if run_migrations
|
24
|
-
run
|
24
|
+
run "bin/rails db:migrate"
|
25
25
|
else
|
26
|
-
puts
|
26
|
+
puts "Skipping bin/rails db:migrate, don't forget to run it!" # rubocop:disable Rails/Output
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
data/lib/solidus_me/engine.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "solidus_core"
|
4
|
+
require "solidus_support"
|
5
5
|
|
6
6
|
module SolidusMe
|
7
7
|
class Engine < Rails::Engine
|
@@ -9,15 +9,15 @@ module SolidusMe
|
|
9
9
|
|
10
10
|
isolate_namespace SolidusMe
|
11
11
|
|
12
|
-
engine_name
|
12
|
+
engine_name "solidus_me"
|
13
13
|
|
14
|
-
initializer
|
14
|
+
initializer "solidus_me.configure_backend" do
|
15
15
|
next unless ::Spree::Backend::Config.respond_to?(:menu_items)
|
16
16
|
|
17
17
|
::Spree::Backend::Config.configure do |config|
|
18
18
|
config.menu_items << config.class::MenuItem.new(
|
19
19
|
label: "melhor_envio",
|
20
|
-
icon:
|
20
|
+
icon: "truck",
|
21
21
|
url: "/admin/solidus_me/accounts",
|
22
22
|
condition: -> { can?(:manage, ::Spree::Store) }
|
23
23
|
)
|
data/lib/solidus_me/version.rb
CHANGED
data/lib/solidus_me.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
3
|
+
require "me_api"
|
4
|
+
require "solidus_brazilian_adaptations"
|
5
|
+
require "solidus_me/configuration"
|
6
|
+
require "solidus_me/version"
|
7
|
+
require "solidus_me/engine"
|
data/solidus_me.gemspec
CHANGED
@@ -1,38 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative "lib/solidus_me/version"
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = "solidus_me"
|
7
7
|
spec.version = SolidusMe::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email =
|
8
|
+
spec.authors = ["Hamilton Tumenas Borges"]
|
9
|
+
spec.email = "hamiltontubo@gmail.com"
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
11
|
+
spec.summary = "Gem para integração com a API do Melhor Envio"
|
12
|
+
spec.description = "Gem para integração com a API do Melhor Envio"
|
13
|
+
spec.homepage = "https://github.com/solidusio-contrib/solidus_me#readme"
|
14
|
+
spec.license = "BSD-3-Clause"
|
15
15
|
|
16
|
-
spec.metadata[
|
17
|
-
spec.metadata[
|
18
|
-
spec.metadata[
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/solidusio-contrib/solidus_me"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/solidusio-contrib/solidus_me/blob/master/CHANGELOG.md"
|
19
19
|
|
20
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
20
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5", "< 4")
|
21
21
|
|
22
22
|
# Specify which files should be added to the gem when it is released.
|
23
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
24
|
files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
|
25
25
|
|
26
26
|
spec.files = files.grep_v(%r{^(test|spec|features)/})
|
27
|
-
spec.test_files = files.grep(%r{^(test|spec|features)/})
|
28
27
|
spec.bindir = "exe"
|
29
28
|
spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
|
30
29
|
spec.require_paths = ["lib"]
|
31
30
|
|
32
|
-
spec.add_dependency
|
33
|
-
spec.add_dependency
|
34
|
-
spec.add_dependency
|
35
|
-
spec.add_dependency
|
31
|
+
spec.add_dependency "solidus_core", [">= 2.0.0", "< 5"]
|
32
|
+
spec.add_dependency "solidus_support", "~> 0.5"
|
33
|
+
spec.add_dependency "me_api"
|
34
|
+
spec.add_dependency "solidus_brazilian_adaptations"
|
36
35
|
|
37
|
-
spec.add_development_dependency
|
36
|
+
spec.add_development_dependency "solidus_dev_support", "~> 2.7"
|
38
37
|
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.0.
|
4
|
+
version: 2.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hamilton Tumenas Borges
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_core
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- app/models/solidus_me/account.rb
|
109
109
|
- app/models/solidus_me/shipping_estimator.rb
|
110
110
|
- app/views/spree/admin/solidus_me/accounts/_form.html.erb
|
111
|
+
- app/views/spree/admin/solidus_me/accounts/_link_auth.html.erb
|
111
112
|
- app/views/spree/admin/solidus_me/accounts/edit.html.erb
|
112
113
|
- app/views/spree/admin/solidus_me/accounts/index.html.erb
|
113
114
|
- app/views/spree/admin/solidus_me/accounts/new.html.erb
|
@@ -131,8 +132,6 @@ files:
|
|
131
132
|
- lib/solidus_me/testing_support/factories.rb
|
132
133
|
- lib/solidus_me/version.rb
|
133
134
|
- solidus_me.gemspec
|
134
|
-
- spec/models/solidus_me/account_spec.rb
|
135
|
-
- spec/spec_helper.rb
|
136
135
|
homepage: https://github.com/solidusio-contrib/solidus_me#readme
|
137
136
|
licenses:
|
138
137
|
- BSD-3-Clause
|
@@ -140,7 +139,7 @@ metadata:
|
|
140
139
|
homepage_uri: https://github.com/solidusio-contrib/solidus_me#readme
|
141
140
|
source_code_uri: https://github.com/solidusio-contrib/solidus_me
|
142
141
|
changelog_uri: https://github.com/solidusio-contrib/solidus_me/blob/master/CHANGELOG.md
|
143
|
-
post_install_message:
|
142
|
+
post_install_message:
|
144
143
|
rdoc_options: []
|
145
144
|
require_paths:
|
146
145
|
- lib
|
@@ -158,10 +157,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
158
157
|
- !ruby/object:Gem::Version
|
159
158
|
version: '0'
|
160
159
|
requirements: []
|
161
|
-
rubygems_version: 3.4.
|
162
|
-
signing_key:
|
160
|
+
rubygems_version: 3.4.20
|
161
|
+
signing_key:
|
163
162
|
specification_version: 4
|
164
163
|
summary: Gem para integração com a API do Melhor Envio
|
165
|
-
test_files:
|
166
|
-
- spec/models/solidus_me/account_spec.rb
|
167
|
-
- spec/spec_helper.rb
|
164
|
+
test_files: []
|
data/spec/spec_helper.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Configure Rails Environment
|
4
|
-
ENV['RAILS_ENV'] = 'test'
|
5
|
-
|
6
|
-
# Run Coverage report
|
7
|
-
require 'solidus_dev_support/rspec/coverage'
|
8
|
-
|
9
|
-
# Create the dummy app if it's still missing.
|
10
|
-
dummy_env = "#{__dir__}/dummy/config/environment.rb"
|
11
|
-
system 'bin/rake extension:test_app' unless File.exist? dummy_env
|
12
|
-
require dummy_env
|
13
|
-
|
14
|
-
# Requires factories and other useful helpers defined in spree_core.
|
15
|
-
require 'solidus_dev_support/rspec/feature_helper'
|
16
|
-
|
17
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
18
|
-
# in spec/support/ and its subdirectories.
|
19
|
-
Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
|
20
|
-
|
21
|
-
# Requires factories defined in Solidus core and this extension.
|
22
|
-
# See: lib/solidus_me/testing_support/factories.rb
|
23
|
-
SolidusDevSupport::TestingSupport::Factories.load_for(SolidusMe::Engine)
|
24
|
-
|
25
|
-
RSpec.configure do |config|
|
26
|
-
config.infer_spec_type_from_file_location!
|
27
|
-
config.use_transactional_fixtures = false
|
28
|
-
|
29
|
-
if Spree.solidus_gem_version < Gem::Version.new('2.11')
|
30
|
-
config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
|
31
|
-
end
|
32
|
-
end
|