solidus_bling 2.0.6 → 3.0.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 +4 -4
- data/.gitattributes +2 -0
- data/.gitignore +0 -1
- data/CHANGELOG.md +1 -3
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/app/controllers/spree/admin/solidus_bling/accounts_controller.rb +77 -0
- data/app/jobs/solidus_bling/order_job.rb +5 -7
- data/app/models/solidus_bling/account.rb +7 -1
- data/app/models/solidus_bling/order.rb +122 -95
- data/app/models/solidus_bling/token.rb +44 -0
- data/app/subscribers/solidus_bling/subscriber.rb +2 -22
- data/app/views/spree/admin/{accounts → solidus_bling/accounts}/_form.html.erb +21 -8
- data/app/views/spree/admin/solidus_bling/accounts/edit.html.erb +1 -0
- data/app/views/spree/admin/solidus_bling/accounts/index.html.erb +13 -0
- data/app/views/spree/admin/{accounts → solidus_bling/accounts}/new.html.erb +1 -1
- data/bin/meu_sandbox +67 -0
- data/config/locales/pt-BR.yml +1 -1
- data/config/routes.rb +6 -2
- data/db/migrate/{20230918141419_create_solidus_bling_accounts.rb → 20231109210635_create_solidus_bling_accounts.rb} +4 -5
- data/db/migrate/{20230918142547_create_solidus_bling_events.rb → 20231110112819_create_solidus_bling_events.rb} +1 -2
- data/db/migrate/{20230918143057_create_solidus_bling_shipping_methods.rb → 20231110113221_create_solidus_bling_shipping_methods.rb} +1 -0
- data/lib/generators/solidus_bling/install/install_generator.rb +0 -10
- data/lib/solidus_bling/engine.rb +8 -11
- data/lib/solidus_bling/version.rb +1 -1
- data/lib/solidus_bling.rb +1 -1
- data/solidus_bling.gemspec +6 -7
- metadata +25 -55
- data/app/assets/javascripts/spree/backend/solidus_bling.js +0 -2
- data/app/assets/javascripts/spree/frontend/solidus_bling.js +0 -2
- data/app/assets/stylesheets/spree/backend/solidus_bling.css +0 -4
- data/app/assets/stylesheets/spree/frontend/solidus_bling.css +0 -4
- data/app/controllers/spree/admin/accounts_controller.rb +0 -67
- data/app/controllers/spree/admin/bling_products_controller.rb +0 -20
- data/app/decorators/models/solidus_bling/spree/payment_method_decorator.rb +0 -13
- data/app/decorators/models/solidus_bling/spree/shipping_method_decorator.rb +0 -13
- data/app/helpers/solidus_bling/accounts_helper.rb +0 -4
- data/app/helpers/solidus_bling/bling_products_helper.rb +0 -4
- data/app/jobs/solidus_bling/contact_job.rb +0 -22
- data/app/jobs/solidus_bling/product_job.rb +0 -13
- data/app/jobs/solidus_bling/update_product_job.rb +0 -9
- data/app/models/solidus_bling/api.rb +0 -57
- data/app/models/solidus_bling/contact.rb +0 -83
- data/app/models/solidus_bling/product.rb +0 -36
- data/app/views/spree/admin/accounts/edit.html.erb +0 -11
- data/app/views/spree/admin/accounts/index.html.erb +0 -13
- data/db/migrate/20230918141700_create_solidus_bling_products.rb +0 -12
- data/db/migrate/20231018141940_add_company_to_solidus_bling_shipping_methods.rb +0 -5
- data/spec/helpers/solidus_bling/accounts_helper_spec.rb +0 -17
- data/spec/helpers/solidus_bling/bling_products_helper_spec.rb +0 -17
- data/spec/jobs/solidus_bling/contact_job_spec.rb +0 -7
- data/spec/jobs/solidus_bling/product_job_spec.rb +0 -7
- data/spec/jobs/solidus_bling/update_product_job_spec.rb +0 -7
- data/spec/models/solidus_bling/product_spec.rb +0 -7
- data/spec/requests/solidus_bling/accounts_spec.rb +0 -7
- data/spec/requests/solidus_bling/bling_products_spec.rb +0 -7
- /data/app/views/spree/admin/{accounts → solidus_bling/accounts}/show.html.erb +0 -0
- /data/db/migrate/{20230918141505_add_bling_order_id_to_spree_orders.rb → 20231110112528_add_bling_order_id_to_spree_orders.rb} +0 -0
- /data/db/migrate/{20230918142742_create_solidus_bling_payment_methods.rb → 20231110112958_create_solidus_bling_payment_methods.rb} +0 -0
- /data/db/migrate/{20230918142953_create_solidus_bling_sellers.rb → 20231110113122_create_solidus_bling_sellers.rb} +0 -0
@@ -1,36 +0,0 @@
|
|
1
|
-
module SolidusBling
|
2
|
-
class Product < ApplicationRecord
|
3
|
-
belongs_to :account
|
4
|
-
|
5
|
-
def self.update bling_account
|
6
|
-
bling_api = SolidusBling::Api.new(bling_account)
|
7
|
-
skus = ::Spree::Variant.pluck(:sku)
|
8
|
-
hash_products = {}
|
9
|
-
products = skus.map do |sku|
|
10
|
-
begin
|
11
|
-
attempts ||= 1
|
12
|
-
req = Typhoeus.get("#{bling_api.account.api_base_url}/produtos?codigo=#{sku}", headers: bling_api.headers)
|
13
|
-
res_json = JSON.parse(req.body)
|
14
|
-
# p "#{sku} => #{res_json}"
|
15
|
-
next if res_json["data"] == []
|
16
|
-
product = res_json["data"].first
|
17
|
-
hash_products[sku] = product["id"]
|
18
|
-
{
|
19
|
-
account_id: bling_api.account.id,
|
20
|
-
sku: sku,
|
21
|
-
external_id: product["id"].to_s,
|
22
|
-
name: product["nome"]
|
23
|
-
}
|
24
|
-
rescue => e
|
25
|
-
hash_products[sku] = res_json
|
26
|
-
# p "#{sku} => #{res_json} => #{e}"
|
27
|
-
sleep 1
|
28
|
-
retry if (attempts += 1) < 5
|
29
|
-
end
|
30
|
-
end.compact.uniq
|
31
|
-
SolidusBling::Product.upsert_all(products, unique_by: :sku)
|
32
|
-
::Spree::Bus.publish :bling_products_updated, products: hash_products
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
<div style="margin: 10px 0px">
|
2
|
-
<%= button_to "Baixar produtos", admin_bling_product_path(@bling_account.id), method: :put, data:
|
3
|
-
{confirm: "Deseja baixar os produtos?" } %>
|
4
|
-
<span>Produtos baixados: <%= @products_count %></span>
|
5
|
-
<br>
|
6
|
-
<% if @last_update.present? %>
|
7
|
-
<span>Ultima atualização: <%= @last_update.strftime("%d/%m/%Y %H:%M") %> </span>
|
8
|
-
<% end %>
|
9
|
-
</div>
|
10
|
-
|
11
|
-
<%= render "form", bling_account: @bling_account, form_url: admin_account_path(@bling_account.id) %>
|
@@ -1,13 +0,0 @@
|
|
1
|
-
<%= link_to "Criar", new_admin_account_path %>
|
2
|
-
<div>
|
3
|
-
<% @accounts.each do |account| %>
|
4
|
-
<div>
|
5
|
-
<div>
|
6
|
-
Nome do aplicativo:
|
7
|
-
<span><%= account.app_name %></span>
|
8
|
-
</div>
|
9
|
-
<%= link_to "Editar", edit_admin_account_path(account.id) %>
|
10
|
-
<%= link_to "Excluir", admin_account_path(account.id), method: :delete %>
|
11
|
-
</div>
|
12
|
-
<% end %>
|
13
|
-
</div>
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class CreateSolidusBlingProducts < ActiveRecord::Migration[7.0]
|
2
|
-
def change
|
3
|
-
create_table :solidus_bling_products do |t|
|
4
|
-
t.string :external_id, null: false, index: { unique: true }
|
5
|
-
t.string :name, null: false
|
6
|
-
t.string :sku, null: false, index: { unique: true }
|
7
|
-
t.integer :account_id, null: false, index: true
|
8
|
-
|
9
|
-
t.timestamps
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
# Specs in this file have access to a helper object that includes
|
4
|
-
# the AccountsHelper. For example:
|
5
|
-
#
|
6
|
-
# describe AccountsHelper do
|
7
|
-
# describe "string concat" do
|
8
|
-
# it "concats two strings with spaces" do
|
9
|
-
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
-
# end
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
module SolidusBling
|
14
|
-
RSpec.describe AccountsHelper, type: :helper do
|
15
|
-
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
-
end
|
17
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
# Specs in this file have access to a helper object that includes
|
4
|
-
# the BlingProductsHelper. For example:
|
5
|
-
#
|
6
|
-
# describe BlingProductsHelper do
|
7
|
-
# describe "string concat" do
|
8
|
-
# it "concats two strings with spaces" do
|
9
|
-
# expect(helper.concat_strings("this","that")).to eq("this that")
|
10
|
-
# end
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
module SolidusBling
|
14
|
-
RSpec.describe BlingProductsHelper, type: :helper do
|
15
|
-
pending "add some examples to (or delete) #{__FILE__}"
|
16
|
-
end
|
17
|
-
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|