solidus_bling 3.0.0 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +18 -19
  3. data/Rakefile +2 -2
  4. data/app/controllers/spree/admin/solidus_bling/accounts_controller.rb +5 -2
  5. data/app/jobs/solidus_bling/order_job.rb +0 -1
  6. data/app/models/solidus_bling/account.rb +0 -1
  7. data/app/models/solidus_bling/order.rb +25 -27
  8. data/app/models/solidus_bling/token.rb +5 -9
  9. data/app/subscribers/solidus_bling/subscriber.rb +1 -1
  10. data/app/views/spree/admin/solidus_bling/accounts/_form.html.erb +132 -67
  11. data/app/views/spree/admin/solidus_bling/accounts/_link_auth.html.erb +10 -0
  12. data/app/views/spree/admin/solidus_bling/accounts/edit.html.erb +2 -0
  13. data/app/views/spree/admin/solidus_bling/accounts/index.html.erb +69 -8
  14. data/app/views/spree/admin/solidus_bling/accounts/new.html.erb +1 -0
  15. data/bin/meu_sandbox +0 -0
  16. data/db/migrate/20231110113221_create_solidus_bling_shipping_methods.rb +2 -2
  17. data/lib/generators/solidus_bling/install/install_generator.rb +6 -6
  18. data/lib/solidus_bling/configuration.rb +1 -1
  19. data/lib/solidus_bling/engine.rb +5 -5
  20. data/lib/solidus_bling/version.rb +1 -1
  21. data/lib/solidus_bling.rb +5 -5
  22. data/solidus_bling.gemspec +16 -17
  23. metadata +9 -22
  24. data/spec/jobs/solidus_bling/order_job_spec.rb +0 -7
  25. data/spec/models/solidus_bling/account_spec.rb +0 -7
  26. data/spec/models/solidus_bling/event_spec.rb +0 -7
  27. data/spec/models/solidus_bling/payment_method_spec.rb +0 -7
  28. data/spec/models/solidus_bling/seller_spec.rb +0 -7
  29. data/spec/models/solidus_bling/shipping_method_spec.rb +0 -7
  30. data/spec/spec_helper.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6db82bc3c77223d35418dc4778dea214887526407f73b566a1e3e36929d9349a
4
- data.tar.gz: fb46fb95a4787468f045fb0b3e4b28c5e9d51fe20b6cad8d2292f9c222f11bac
3
+ metadata.gz: fe9686f547075a1388e93b0d93ef24e9be44988cce5deb8f7a122ab0ff80ac15
4
+ data.tar.gz: 8d06bef816cc6d034daa37e0c54088e5724ca1098b471d266f88e9684810c0a8
5
5
  SHA512:
6
- metadata.gz: 5191696fc43ae7a0e9174bb03eb47464c21eab8f0e181533e4d4c1433e55dde194637af73e8a8363336929cc8e8b7eab28a4de810d102232e5d090488c5eb20f
7
- data.tar.gz: d278d7f74dcfe34ddf36833fed252e9149011b7ad43131a034a0ab41854711938917fb3d255760734ff243f21a7b7cc9d2807ecb6a3dce7ca549394d9f923fc5
6
+ metadata.gz: bfd59588eea2c8b706ca6dd40f51eaafd56a60f87ca4bf39d05641395437262fbf878731b5e0a0acf142ce1a5b1b646dd0ef70e7f79dbd0f085d389b8dfd47eb
7
+ data.tar.gz: 8c4d46c87072916920882e754055889b54bd78a141b72f55fe9c7896a8c700fe74b289337b3fe4d168d70bb84283ab35553372baa13dfa6fd26d5a9939bb08d8
data/Gemfile CHANGED
@@ -1,42 +1,41 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
- branch = ENV.fetch('SOLIDUS_BRANCH', 'main')
7
- gem 'solidus', github: 'solidusio/solidus', branch: branch
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 >= 'v3.2'
11
- gem 'solidus_frontend'
12
- elsif branch == 'main'
13
- gem 'solidus_frontend', github: 'solidusio/solidus_frontend'
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 'solidus_frontend', github: 'solidusio/solidus', branch: branch
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 'rails', '>0.a'
22
-
21
+ gem "rails", ">0.a"
23
22
 
24
23
  # Provides basic authentication functionality for testing parts of your engine
25
- gem 'solidus_auth_devise'
24
+ gem "solidus_auth_devise"
26
25
 
27
- case ENV.fetch('DB', nil)
28
- when 'mysql'
29
- gem 'mysql2'
30
- when 'postgresql'
31
- gem 'pg'
26
+ case ENV.fetch("DB", nil)
27
+ when "mysql"
28
+ gem "mysql2"
29
+ when "postgresql"
30
+ gem "pg"
32
31
  else
33
- gem 'sqlite3'
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 'async', '< 3' if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('3')
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, 'Gemfile-local') if File.exist? 'Gemfile-local'
47
+ send(:eval_gemfile, "Gemfile-local") if File.exist? "Gemfile-local"
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'
4
+ require "solidus_dev_support/rake_tasks"
5
5
  SolidusDevSupport::RakeTasks.install
6
6
 
7
- task default: 'extension:specs'
7
+ task default: "extension:specs"
@@ -1,7 +1,6 @@
1
1
  module Spree
2
2
  module Admin
3
3
  module SolidusBling
4
-
5
4
  class AccountsController < BaseController
6
5
  before_action :set_account, only: [:show, :edit, :update, :destroy]
7
6
 
@@ -13,6 +12,10 @@ module Spree
13
12
  end
14
13
 
15
14
  def new
15
+ if ::SolidusBling::Account.any?
16
+ flash[:error] = "Você só pode ter uma conta Bling cadastrada"
17
+ redirect_to admin_solidus_bling_accounts_path
18
+ end
16
19
  @bling_account = ::SolidusBling::Account.new
17
20
  @payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
18
21
  @shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
@@ -62,7 +65,7 @@ module Spree
62
65
  def set_account
63
66
  @bling_account = ::SolidusBling::Account.find(params[:id])
64
67
  end
65
-
68
+
66
69
  def account_params
67
70
  params.require(:account).permit(
68
71
  :client_id, :client_secret, :refresh_token, :redirect_url, :state, :access_token, :api_key, :external_store_id, :incoming_category_id,
@@ -15,6 +15,5 @@ module SolidusBling
15
15
  bling_event.save!
16
16
  end
17
17
  end
18
-
19
18
  end
20
19
  end
@@ -10,6 +10,5 @@ module SolidusBling
10
10
  return if (token_expires_in - 1.day) > DateTime.now
11
11
  Token.new.refresh self
12
12
  end
13
-
14
13
  end
15
14
  end
@@ -1,6 +1,5 @@
1
1
  module SolidusBling
2
2
  class Order
3
-
4
3
  def initialize spree_order
5
4
  @order = spree_order
6
5
  end
@@ -8,7 +7,7 @@ module SolidusBling
8
7
  def send
9
8
  @account = SolidusBling::Account.first
10
9
  @account.check_token
11
- BlingApi.access_token = @account.access_token
10
+ BlingApi.configuration.access_token = @account.access_token
12
11
 
13
12
  contato = costumer
14
13
  items = products
@@ -16,7 +15,7 @@ module SolidusBling
16
15
  observacoes_internas = internal_observations
17
16
  transporte = shipment
18
17
 
19
- bling_order = BlingApi::Order.new(
18
+ BlingApi::Order.new(
20
19
  id_contato: contato.id,
21
20
  items: items,
22
21
  parcelas: parcelas,
@@ -38,13 +37,13 @@ module SolidusBling
38
37
  contato = BlingApi::Customer.find_by_tax_id(@order.tax_id)
39
38
  if contato
40
39
  contato.update(
41
- pessoa_juridica: @order.tax_id.length > 14 ? true : false,
40
+ pessoa_juridica: @order.tax_id.length > 14,
42
41
  numero_documento: @order.tax_id,
43
42
  **build_customer
44
43
  )
45
44
  else
46
45
  contato = BlingApi::Customer.new(
47
- pessoa_juridica: @order.tax_id.length > 14 ? true : false,
46
+ pessoa_juridica: @order.tax_id.length > 14,
48
47
  numero_documento: @order.tax_id,
49
48
  **build_customer
50
49
  ).create
@@ -56,13 +55,13 @@ module SolidusBling
56
55
  @order.line_items.map do |item|
57
56
  product = BlingApi::Product.find_by_sku(item.sku)
58
57
  {
59
- "id": product.id,
60
- "quantidade": item.quantity,
61
- "valor": item.price.to_f,
62
- "produto": {
63
- "id": product.id
58
+ id: product.id,
59
+ quantidade: item.quantity,
60
+ valor: item.price.to_f,
61
+ produto: {
62
+ id: product.id
64
63
  }
65
- }
64
+ }
66
65
  end.compact
67
66
  end
68
67
 
@@ -81,13 +80,13 @@ module SolidusBling
81
80
  end
82
81
 
83
82
  def internal_observations
84
- "Pagamento: #{@parcelas}x R$ #{(@order.total.to_f / @parcelas).round(2)}" +
85
- "\n" +
86
- "Forma de envio: #{@order.shipments.last.selected_shipping_rate.name}" +
87
- "\n" +
88
- "#{build_cupons(@order.promotions)}" +
89
- "\n" +
90
- "#{build_order_url}"
83
+ "Pagamento: #{@parcelas}x R$ #{(@order.total.to_f / @parcelas).round(2)}" \
84
+ "\n" \
85
+ "Forma de envio: #{@order.shipments.last.selected_shipping_rate.name}" \
86
+ "\n" +
87
+ build_cupons(@order.promotions).to_s +
88
+ "\n" +
89
+ build_order_url.to_s
91
90
  end
92
91
 
93
92
  def shipment
@@ -123,9 +122,9 @@ module SolidusBling
123
122
 
124
123
  def build_customer
125
124
  {
126
- nome: @order.bill_address.name,
127
- telefone: @order.bill_address.phone,
128
- email: @order.email,
125
+ nome: @order.bill_address.name,
126
+ telefone: @order.bill_address.phone,
127
+ email: @order.email,
129
128
  endereco: {
130
129
  "endereco" => @order.bill_address.address1,
131
130
  "cep" => @order.bill_address.zipcode,
@@ -133,8 +132,8 @@ module SolidusBling
133
132
  "municipio" => @order.bill_address.city,
134
133
  "uf" => @order.bill_address.state.abbr,
135
134
  "numero" => @order.bill_address.number,
136
- "complemento" => @order.bill_address.address2,
137
- },
135
+ "complemento" => @order.bill_address.address2
136
+ },
138
137
  endereco_cobranca: {
139
138
  "endereco" => @order.bill_address.address1,
140
139
  "cep" => @order.bill_address.zipcode,
@@ -142,7 +141,7 @@ module SolidusBling
142
141
  "municipio" => @order.bill_address.city,
143
142
  "uf" => @order.bill_address.state.abbr,
144
143
  "numero" => @order.bill_address.number,
145
- "complemento" => @order.bill_address.address2,
144
+ "complemento" => @order.bill_address.address2
146
145
  }
147
146
  }
148
147
  end
@@ -150,7 +149,7 @@ module SolidusBling
150
149
  def build_cupons cupons
151
150
  string_cupons = ""
152
151
  if !cupons.empty?
153
- string_cupons = "Cupons utilizados: #{cupons.pluck(:name).join(", ")}"
152
+ string_cupons = "Cupons utilizados: #{cupons.pluck(:name).join(", ")}"
154
153
  end
155
154
  string_cupons
156
155
  end
@@ -158,6 +157,5 @@ module SolidusBling
158
157
  def build_order_url
159
158
  "Link para o pedido: #{@order.store.url}/orders/#{@order.number}/token/#{@order.guest_token}"
160
159
  end
161
-
162
160
  end
163
- end
161
+ end
@@ -2,10 +2,6 @@ module SolidusBling
2
2
  class Token < ::Ac::Base
3
3
  BASE_URL = "https://www.bling.com.br/Api/v3"
4
4
 
5
- def initialize
6
- super
7
- end
8
-
9
5
  def authorize bling_account, code
10
6
  basic_encoded = Base64.strict_encode64("#{bling_account.client_id}:#{bling_account.client_secret}")
11
7
  headers = {
@@ -22,8 +18,8 @@ module SolidusBling
22
18
  token_expires_in: DateTime.now.utc + response_json["expires_in"].seconds,
23
19
  refresh_token: response_json["refresh_token"]
24
20
  )
25
- rescue
26
- false
21
+ rescue
22
+ false
27
23
  end
28
24
 
29
25
  def refresh bling_account
@@ -37,8 +33,8 @@ module SolidusBling
37
33
  token_expires_in: DateTime.now.utc + response_json["expires_in"].seconds,
38
34
  refresh_token: response_json["refresh_token"]
39
35
  )
40
- rescue
41
- false
36
+ rescue
37
+ false
42
38
  end
43
39
  end
44
- end
40
+ end
@@ -3,7 +3,7 @@ module SolidusBling
3
3
  include Omnes::Subscriber
4
4
 
5
5
  handle :order_finalized,
6
- with: :send_order_to_bling
6
+ with: :send_order_to_bling
7
7
 
8
8
  def send_order_to_bling event, debug_info = {}
9
9
  SolidusBling::OrderJob.perform_later(event: event.payload)
@@ -1,89 +1,154 @@
1
+ <%= render "link_auth", bling_account: bling_account %>
2
+
1
3
  <%= form_with model: bling_account, url: form_url do |form| %>
2
- <h6>Dados da conta</h6>
3
- <div>
4
- <%= form.label :client_id, "Client ID: " %>
5
- <%= form.text_field :client_id %>
6
- </div>
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">
7
10
 
8
- <div>
9
- <%= form.label :client_secret, "Client Secret: " %>
10
- <%= form.text_field :client_secret %>
11
- </div>
11
+ <%= form.field_container :client_id do %>
12
+ <%= form.label :client_id, "Client ID", class: 'required' %>
13
+ <%= form.text_field :client_id, required: true, class: 'fullwidth' %>
14
+ <%= form.error_message_on :client_id %>
15
+ <% end %>
12
16
 
13
- <div>
14
- <%= form.label :refresh_token, "Refresh Token: " %>
15
- <%= form.text_field :refresh_token %>
16
- </div>
17
+ <%= form.field_container :client_secret do %>
18
+ <%= form.label :client_secret, "Client Secret", class: 'required' %>
19
+ <%= form.text_field :client_secret, required: true, class: 'fullwidth' %>
20
+ <%= form.error_message_on :client_secret %>
21
+ <% end %>
17
22
 
18
- <div>
19
- <%= form.label :redirect_url, "Redirect URL: " %>
20
- <%= form.text_field :redirect_url %>
21
- </div>
23
+ <%= form.field_container :external_store_id do %>
24
+ <%= form.label :external_store_id, "ID Loja", class: 'required' %>
25
+ <%= form.text_field :external_store_id, required: true, class: 'fullwidth' %>
26
+ <%= form.error_message_on :external_store_id %>
27
+ <% end %>
22
28
 
23
- <div>
24
- <%= form.label :state, "State: " %>
25
- <%= form.text_field :state %>
26
- </div>
29
+ <%= form.field_container :incoming_category_id do %>
30
+ <%= form.label :incoming_category_id, "ID Categoria Receita", class: 'required' %>
31
+ <%= form.text_field :incoming_category_id, required: true, class: 'fullwidth' %>
32
+ <%= form.error_message_on :incoming_category_id %>
33
+ <% end %>
27
34
 
28
- <div>
29
- <%= form.label :access_token, "Access Token: " %>
30
- <%= form.text_field :access_token %>
31
- </div>
35
+ </div>
32
36
 
33
- <div>
34
- <%= form.label :external_store_id, "ID da Loja no Bling: " %>
35
- <%= form.text_field :external_store_id %>
36
- </div>
37
+ <div class="col-12 col-md-6">
37
38
 
38
- <div>
39
- <%= form.label :incoming_category_id, "ID da Categoria de Receita: " %>
40
- <%= form.text_field :incoming_category_id %>
41
- </div>
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 %>
44
+
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 %>
42
50
 
43
- <div style="margin: 10px 0">
44
- <h6>Métodos de Pagamento</h6>
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 class="field">
64
+ <%= label_tag :token_expires_in, "Token Expiration" %>
65
+ <div class="fullwidth" id="token_expires_in" name="token_expires_in">
66
+ <%= bling_account.token_expires_in %>
67
+ </div>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ </fieldset>
72
+
73
+ <fieldset class="no-border-top">
74
+ <legend>
75
+ Métodos de Pagamento
76
+ </legend>
45
77
  <%= form.fields_for :payment_methods do |payment_form| %>
46
- <div>
47
- <%= payment_form.select :spree_payment_method_id, @payment_methods %>
48
- <%= payment_form.label :external_id, "ID Forma de Pagamento: " %>
49
- <%= payment_form.text_field :external_id %>
78
+ <div class="row">
79
+ <div class="col-12 col-md-6">
80
+ <div class="field">
81
+ <%= payment_form.label :spree_payment_method_id, "Método de Pagamento", class: 'required' %>
82
+ <%= payment_form.select :spree_payment_method_id, @payment_methods, {}, { class: "custom-select fullwidth" } %>
83
+ </div>
84
+ </div>
85
+ <div class="col-12 col-md-6">
86
+ <div class="field">
87
+ <%= payment_form.label :external_id, "ID Forma de Pagamento", class: 'required' %>
88
+ <%= payment_form.text_field :external_id, required: true, class:"fullwidth" %>
89
+ </div>
90
+ </div>
50
91
  </div>
51
92
  <% end %>
52
- </div>
93
+ </fieldset>
53
94
 
54
- <div style="margin: 10px 0">
55
- <h6>Métodos de Envio</h6>
56
- <%= form.fields_for :shipping_methods do |shipping_form| %>
57
- <div>
58
- <%= shipping_form.select :spree_shipping_method_id, @shipping_methods %>
59
- <%= shipping_form.label :alias, "Alias: " %>
60
- <%= shipping_form.text_field :alias %>
61
- <%= shipping_form.label :company, "Nome Transportadora: " %>
62
- <%= shipping_form.text_field :company %>
95
+ <fieldset class="no-border-top">
96
+ <legend>
97
+ Métodos de Envio
98
+ </legend>
99
+ <%= form.fields_for :shipping_methods do |ship_form| %>
100
+ <div class="row">
101
+ <div class="col-12 col-md-4">
102
+ <div class="field">
103
+ <%= ship_form.label :spree_shipping_method_id, "Método de Envio", class: 'required' %>
104
+ <%= ship_form.select :spree_shipping_method_id, @shipping_methods, {}, { class: "custom-select fullwidth" } %>
105
+ </div>
106
+ </div>
107
+ <div class="col-12 col-md-4">
108
+ <div class="field">
109
+ <%= ship_form.label :alias, "Alias", class: 'required' %>
110
+ <%= ship_form.text_field :alias, required: true, class:"fullwidth" %>
111
+ </div>
112
+ </div>
113
+ <div class="col-12 col-md-4">
114
+ <div class="field">
115
+ <%= ship_form.label :company, "Nome Transportadora", class: 'required' %>
116
+ <%= ship_form.text_field :company, required: true, class:"fullwidth" %>
117
+ </div>
118
+ </div>
63
119
  </div>
64
120
  <% end %>
65
- </div>
121
+ </fieldset>
66
122
 
67
- <div style="margin: 10px 0">
68
- <h6>Vendedores</h6>
123
+ <fieldset class="no-border-top">
124
+ <legend>
125
+ Vendedores
126
+ </legend>
69
127
  <% bling_account.sellers.each do |seller| %>
70
128
  <%= form.fields_for :sellers do |seller_form| %>
71
- <%= seller_form.label :name, "Nome do Vendedor: " %>
72
- <%= seller_form.text_field :name %>
73
-
74
- <%= seller_form.label :external_id, "ID do Vendedor: " %>
75
- <%= seller_form.text_field :external_id %>
129
+ <div class="row">
130
+ <div class="col-12 col-md-6">
131
+ <div class="field">
132
+ <%= seller_form.label :name, "Nome do Vendedor", class: 'required' %>
133
+ <%= seller_form.text_field :name, required: true, class:"fullwidth" %>
134
+ </div>
135
+ </div>
136
+ <div class="col-12 col-md-6">
137
+ <div class="field">
138
+ <%= seller_form.label :external_id, "ID Vendedor", class: 'required' %>
139
+ <%= seller_form.text_field :external_id, required: true, class:"fullwidth" %>
140
+ </div>
141
+ </div>
142
+ </div>
76
143
  <% end %>
77
144
  <% end %>
78
- </div>
145
+ </fieldset>
79
146
 
80
- <%= form.submit "Salvar" %>
81
- <% end %>
82
147
 
83
- <div>
84
- <input value="https://www.bling.com.br/Api/v3/oauth/authorize?response_type=code&client_id=<%= bling_account.client_id %>&state=<%= bling_account.state %>&scopes=98308+98309+98310+98313+98314+507943+5990556+6631498+106168710+182224097+199272829+200802821+220621674+318257556+318257565+318257568+318257570+318257583+333936575+363921589+363921590+363921591+363921592+363953167+363953556+791588404+875116881+1869535257+5862218180+13645012997+13645013013">
85
- <a target="_blank" class="" href="https://www.bling.com.br/Api/v3/oauth/authorize?response_type=code&client_id=<%= bling_account.client_id %>&state=<%= bling_account.state %>&scopes=98308+98309+98310+98313+98314+507943+5990556+6631498+106168710+182224097+199272829+200802821+220621674+318257556+318257565+318257568+318257570+318257583+333936575+363921589+363921590+363921591+363921592+363953167+363953556+791588404+875116881+1869535257+5862218180+13645012997+13645013013">
86
- <svg style="width: 24px; height: 24px;" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
87
- <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>
88
- </a>
89
- </div>
148
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
149
+ <%= form.submit "Salvar", class: 'btn btn-primary' %>
150
+ <% if params["action"] == 'edit' %>
151
+ <%= link_to "Excluir", admin_solidus_bling_account_path(bling_account.id), method: :delete, data: { confirm: "Tem certeza que deseja excluir a conta?"}, class: 'button' %>
152
+ <% end %>
153
+ </div>
154
+ <% end %>
@@ -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="bling_url">URL de autorização</label>
4
+ <a target="_blank" href="https://www.bling.com.br/Api/v3/oauth/authorize?response_type=code&client_id=<%= bling_account.client_id %>&state=<%= bling_account.state %>&scopes=98308+98309+98310+98313+98314+507943+5990556+6631498+106168710+182224097+199272829+200802821+220621674+318257556+318257565+318257568+318257570+318257583+333936575+363921589+363921590+363921591+363921592+363953167+363953556+791588404+875116881+1869535257+5862218180+13645012997+13645013013">
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="bling_url" class="fullwidth" value="https://www.bling.com.br/Api/v3/oauth/authorize?response_type=code&client_id=<%= bling_account.client_id %>&state=<%= bling_account.state %>&scopes=98308+98309+98310+98313+98314+507943+5990556+6631498+106168710+182224097+199272829+200802821+220621674+318257556+318257565+318257568+318257570+318257583+333936575+363921589+363921590+363921591+363921592+363953167+363953556+791588404+875116881+1869535257+5862218180+13645012997+13645013013">
10
+ </div>
@@ -1 +1,3 @@
1
+ <% admin_breadcrumb("Bling") %>
2
+
1
3
  <%= render "form", bling_account: @bling_account, form_url: admin_solidus_bling_account_path(@bling_account.id) %>
@@ -1,13 +1,74 @@
1
- <%= link_to "Criar", new_admin_solidus_bling_account_path %>
2
- <div>
1
+
2
+ <% admin_layout "full-width" %>
3
+
4
+ <% admin_breadcrumb("Bling") %>
5
+
6
+ <% content_for :page_actions do %>
7
+ <% if SolidusBling::Account.count < 1 %>
8
+ <li>
9
+ <%= link_to "Nova Conta", new_admin_solidus_bling_account_path, class: 'btn btn-primary' %>
10
+ </li>
11
+ <% end %>
12
+ <% end %>
13
+
14
+ <div class="content-wrapper">
3
15
  <% @accounts.each do |account| %>
4
- <div>
5
- <div>
6
- Nome do aplicativo:
7
- <span>ID - <%= account.id %></span>
16
+ <%= render "link_auth", bling_account: account %>
17
+
18
+ <fieldset class="no-border-top">
19
+ <legend>
20
+ Dados da Conta
21
+ </legend>
22
+ <div class="row">
23
+ <div class="col-12 col-md-6">
24
+
25
+ <div class="field">
26
+ <%= label_tag :client_id, "Client ID" %>
27
+ <%= text_field_tag :client_id, account.client_id, class:"fullwidth", disabled: true %>
28
+ </div>
29
+
30
+ <div class="field">
31
+ <%= label_tag :client_secret, "Client Secret" %>
32
+ <%= text_field_tag :client_secret, account.client_secret, class:"fullwidth", disabled: true %>
33
+ </div>
34
+
35
+ <div class="field">
36
+ <%= label_tag :refresh_token, "Refresh Token" %>
37
+ <%= text_field_tag :refresh_token, account.refresh_token, class:"fullwidth", disabled: true %>
38
+ </div>
39
+ </div>
40
+
41
+ <div class="col-12 col-md-6">
42
+
43
+ <div class="field">
44
+ <%= label_tag :redirect_url, "Redirect URL" %>
45
+ <%= text_field_tag :redirect_url, account.redirect_url, class:"fullwidth", disabled: true %>
46
+ </div>
47
+
48
+ <div class="field">
49
+ <%= label_tag :state, "State" %>
50
+ <%= text_field_tag :state, account.state, class:"fullwidth", disabled: true %>
51
+ </div>
52
+
53
+ <div class="field">
54
+ <%= label_tag :access_token, "Access Token" %>
55
+ <%= text_field_tag :access_token, account.access_token, class:"fullwidth", disabled: true %>
56
+ </div>
57
+
58
+ <div class="field">
59
+ <%= label_tag :token_expires_in, "Token Expiration" %>
60
+ <div class="fullwidth" id="token_expires_in" name="token_expires_in">
61
+ <%= account.token_expires_in %>
62
+ </div>
63
+ </div>
8
64
  </div>
9
- <%= link_to "Editar", edit_admin_solidus_bling_account_path(account.id) %>
10
- <%= link_to "Excluir", admin_solidus_bling_account_path(account.id), method: :delete %>
11
65
  </div>
66
+ </fieldset>
67
+
68
+ <div class="form-buttons filter-actions actions" data-hook="buttons">
69
+ <%= link_to "Editar", edit_admin_solidus_bling_account_path(account.id), class: 'btn btn-primary' %>
70
+ <%= link_to "Excluir", admin_solidus_bling_account_path(account.id), method: :delete, data: { confirm: "Tem certeza que deseja excluir a conta?"}, class: 'button' %>
71
+ </div>
12
72
  <% end %>
13
73
  </div>
74
+
@@ -1,2 +1,3 @@
1
+ <% admin_breadcrumb("Conta Bling") %>
1
2
 
2
3
  <%= render "form", bling_account: @bling_account, form_url: admin_solidus_bling_accounts_path %>
data/bin/meu_sandbox CHANGED
File without changes
@@ -3,8 +3,8 @@ class CreateSolidusBlingShippingMethods < ActiveRecord::Migration[7.0]
3
3
  create_table :solidus_bling_shipping_methods do |t|
4
4
  t.string :alias
5
5
  t.string :company
6
- t.integer :account_id, null: false, index: true, index: { name: "solidus_bling_shipping_account_index" }
7
- t.integer :spree_shipping_method_id, null: false, index: true, index: { name: "solidus_bling_spree_shipping_index" }
6
+ t.integer :account_id, null: false, index: {name: "solidus_bling_shipping_account_index"}
7
+ t.integer :spree_shipping_method_id, null: false, index: {name: "solidus_bling_spree_shipping_index"}
8
8
 
9
9
  t.timestamps
10
10
 
@@ -4,26 +4,26 @@ module SolidusBling
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('templates', __dir__)
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 'initializer.rb', 'config/initializers/solidus_bling.rb'
14
+ template "initializer.rb", "config/initializers/solidus_bling.rb"
15
15
  end
16
16
 
17
17
  def add_migrations
18
- run 'bin/rails railties:install:migrations FROM=solidus_bling'
18
+ run "bin/rails railties:install:migrations FROM=solidus_bling"
19
19
  end
20
20
 
21
21
  def 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
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 'bin/rails db:migrate'
24
+ run "bin/rails db:migrate"
25
25
  else
26
- puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
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
 
@@ -12,7 +12,7 @@ module SolidusBling
12
12
  @configuration ||= Configuration.new
13
13
  end
14
14
 
15
- alias config configuration
15
+ alias_method :config, :configuration
16
16
 
17
17
  def configure
18
18
  yield configuration
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'solidus_core'
4
- require 'solidus_support'
3
+ require "solidus_core"
4
+ require "solidus_support"
5
5
 
6
6
  module SolidusBling
7
7
  class Engine < Rails::Engine
@@ -9,15 +9,15 @@ module SolidusBling
9
9
 
10
10
  isolate_namespace ::SolidusBling
11
11
 
12
- engine_name 'solidus_bling'
12
+ engine_name "solidus_bling"
13
13
 
14
- initializer 'solidus_bling.configure_backend' do
14
+ initializer "solidus_bling.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: "bling_account",
20
- icon: 'exclamation',
20
+ icon: "exclamation",
21
21
  url: "/admin/solidus_bling/accounts",
22
22
  condition: -> { can?(:manage, ::Spree::Store) }
23
23
  )
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBling
4
- VERSION = '3.0.0'
4
+ VERSION = "3.0.3"
5
5
  end
data/lib/solidus_bling.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'solidus_brazilian_adaptations'
4
- require 'bling_api'
5
- require 'solidus_bling/configuration'
6
- require 'solidus_bling/version'
7
- require 'solidus_bling/engine'
3
+ require "solidus_brazilian_adaptations"
4
+ require "bling_api"
5
+ require "solidus_bling/configuration"
6
+ require "solidus_bling/version"
7
+ require "solidus_bling/engine"
@@ -1,37 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'lib/solidus_bling/version'
3
+ require_relative "lib/solidus_bling/version"
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = 'solidus_bling'
6
+ spec.name = "solidus_bling"
7
7
  spec.version = SolidusBling::VERSION
8
- spec.authors = ['Hamilton Tumenas Borges']
9
- spec.email = 'hamiltontubo@gmail.com'
8
+ spec.authors = ["Hamilton Tumenas Borges"]
9
+ spec.email = "hamiltontubo@gmail.com"
10
10
 
11
- spec.summary = 'Solidus extension to integrate with the Bling'
12
- spec.homepage = 'https://github.com/hamiltontborges/solidus_bling#readme'
13
- spec.license = 'BSD-3-Clause'
11
+ spec.summary = "Solidus extension to integrate with the Bling"
12
+ spec.homepage = "https://github.com/hamiltontborges/solidus_bling#readme"
13
+ spec.license = "BSD-3-Clause"
14
14
 
15
- spec.metadata['homepage_uri'] = spec.homepage
16
- spec.metadata['source_code_uri'] = 'https://github.com/hamiltontborges/solidus_bling'
17
- spec.metadata['changelog_uri'] = 'https://github.com/hamiltontborges/solidus_bling/blob/master/CHANGELOG.md'
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/hamiltontborges/solidus_bling"
17
+ spec.metadata["changelog_uri"] = "https://github.com/hamiltontborges/solidus_bling/blob/master/CHANGELOG.md"
18
18
 
19
- spec.required_ruby_version = Gem::Requirement.new('>= 2.5', '< 4')
19
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.5", "< 4")
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
23
  files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
24
24
 
25
25
  spec.files = files.grep_v(%r{^(test|spec|features)/})
26
- spec.test_files = files.grep(%r{^(test|spec|features)/})
27
26
  spec.bindir = "exe"
28
27
  spec.executables = files.grep(%r{^exe/}) { |f| File.basename(f) }
29
28
  spec.require_paths = ["lib"]
30
29
 
31
- spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 5']
32
- spec.add_dependency 'solidus_support', '~> 0.5'
33
- spec.add_dependency 'solidus_brazilian_adaptations'
34
- spec.add_dependency 'bling_api'
30
+ spec.add_dependency "solidus_core", [">= 2.0.0", "< 5"]
31
+ spec.add_dependency "solidus_support", "~> 0.5"
32
+ spec.add_dependency "solidus_brazilian_adaptations"
33
+ spec.add_dependency "bling_api"
35
34
 
36
- spec.add_development_dependency 'solidus_dev_support', '~> 2.7'
35
+ spec.add_development_dependency "solidus_dev_support", "~> 2.7"
37
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_bling
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.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-13 00:00:00.000000000 Z
11
+ date: 2023-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: solidus_core
@@ -86,7 +86,7 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '2.7'
89
- description:
89
+ description:
90
90
  email: hamiltontubo@gmail.com
91
91
  executables: []
92
92
  extensions: []
@@ -117,6 +117,7 @@ files:
117
117
  - app/models/solidus_bling/token.rb
118
118
  - app/subscribers/solidus_bling/subscriber.rb
119
119
  - app/views/spree/admin/solidus_bling/accounts/_form.html.erb
120
+ - app/views/spree/admin/solidus_bling/accounts/_link_auth.html.erb
120
121
  - app/views/spree/admin/solidus_bling/accounts/edit.html.erb
121
122
  - app/views/spree/admin/solidus_bling/accounts/index.html.erb
122
123
  - app/views/spree/admin/solidus_bling/accounts/new.html.erb
@@ -146,13 +147,6 @@ files:
146
147
  - lib/solidus_bling/testing_support/factories.rb
147
148
  - lib/solidus_bling/version.rb
148
149
  - solidus_bling.gemspec
149
- - spec/jobs/solidus_bling/order_job_spec.rb
150
- - spec/models/solidus_bling/account_spec.rb
151
- - spec/models/solidus_bling/event_spec.rb
152
- - spec/models/solidus_bling/payment_method_spec.rb
153
- - spec/models/solidus_bling/seller_spec.rb
154
- - spec/models/solidus_bling/shipping_method_spec.rb
155
- - spec/spec_helper.rb
156
150
  homepage: https://github.com/hamiltontborges/solidus_bling#readme
157
151
  licenses:
158
152
  - BSD-3-Clause
@@ -160,7 +154,7 @@ metadata:
160
154
  homepage_uri: https://github.com/hamiltontborges/solidus_bling#readme
161
155
  source_code_uri: https://github.com/hamiltontborges/solidus_bling
162
156
  changelog_uri: https://github.com/hamiltontborges/solidus_bling/blob/master/CHANGELOG.md
163
- post_install_message:
157
+ post_install_message:
164
158
  rdoc_options: []
165
159
  require_paths:
166
160
  - lib
@@ -178,15 +172,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
178
172
  - !ruby/object:Gem::Version
179
173
  version: '0'
180
174
  requirements: []
181
- rubygems_version: 3.4.19
182
- signing_key:
175
+ rubygems_version: 3.4.20
176
+ signing_key:
183
177
  specification_version: 4
184
178
  summary: Solidus extension to integrate with the Bling
185
- test_files:
186
- - spec/jobs/solidus_bling/order_job_spec.rb
187
- - spec/models/solidus_bling/account_spec.rb
188
- - spec/models/solidus_bling/event_spec.rb
189
- - spec/models/solidus_bling/payment_method_spec.rb
190
- - spec/models/solidus_bling/seller_spec.rb
191
- - spec/models/solidus_bling/shipping_method_spec.rb
192
- - spec/spec_helper.rb
179
+ test_files: []
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module SolidusBling
4
- RSpec.describe OrderJob, type: :job do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module SolidusBling
4
- RSpec.describe Account, type: :model do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module SolidusBling
4
- RSpec.describe Event, type: :model do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module SolidusBling
4
- RSpec.describe PaymentMethod, type: :model do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module SolidusBling
4
- RSpec.describe Seller, type: :model do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- require 'rails_helper'
2
-
3
- module SolidusBling
4
- RSpec.describe ShippingMethod, type: :model do
5
- pending "add some examples to (or delete) #{__FILE__}"
6
- end
7
- end
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_bling/testing_support/factories.rb
23
- SolidusDevSupport::TestingSupport::Factories.load_for(SolidusBling::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