solidus_bling 2.0.0 → 2.0.2

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: 81e47bc81b103b82f681395e85e63674a0950316711770d0bbe6ca6f854eef01
4
- data.tar.gz: 3983f4e929e14af2409202589016c7bb330376a2e38e0d1a33e02fcfa5620583
3
+ metadata.gz: cb30252c0e9c0cc28db34354c406558e6bd5c0287814985022f831d1e843a763
4
+ data.tar.gz: 4dffc04c53547441ea2100979aaba16a212a5dca7abbeae89939e99bd591bbd4
5
5
  SHA512:
6
- metadata.gz: 885bd2077efb3f7dc2d0b0cad3ba18e92f136c82608da254e35de9b6867ce235a587d11dfdee02d88ff086fff0e96ab19f5acf58c587ce6579b432fde861eb0b
7
- data.tar.gz: 754480ad38bc954d93577623a3aaee813dead59ee10aede1afed9a5aa48c425b675f62d03a04eb934459eb5e62cb238cb78cd71ea548c88b9c2854318f023a96
6
+ metadata.gz: 54da612e78e3aaffadf4fd10a128cc1618cf07239a7f98a40709cc5643c7f33a2f59d432e36305874d91a4f79519f54862f836851f0eeae182d0334e117fe160
7
+ data.tar.gz: e9c62701428a91238bd1d9789d00e6190f6fe42385d63c8fd7fd8e1653b1a6948431c7d6e380322ca3f1f387d8645293830b9748dfbbbcc776df04ebc27fcd22
@@ -10,8 +10,8 @@ module Spree
10
10
 
11
11
  def new
12
12
  @bling_account = SolidusBling::Account.new
13
- @payment_methods = Spree::PaymentMethod.all.pluck(:name, :id)
14
- @shipping_methods = Spree::ShippingMethod.all.pluck(:name, :id)
13
+ @payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
14
+ @shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
15
15
  @bling_account.payment_methods.build
16
16
  @bling_account.shipping_methods.build
17
17
  @bling_account.sellers.build
@@ -24,8 +24,8 @@ module Spree
24
24
 
25
25
  def edit
26
26
  @bling_account = SolidusBling::Account.find(params[:id])
27
- @payment_methods = Spree::PaymentMethod.all.pluck(:name, :id)
28
- @shipping_methods = Spree::ShippingMethod.all.pluck(:name, :id)
27
+ @payment_methods = ::Spree::PaymentMethod.all.pluck(:name, :id)
28
+ @shipping_methods = ::Spree::ShippingMethod.all.pluck(:name, :id)
29
29
  end
30
30
 
31
31
  def update
@@ -0,0 +1,13 @@
1
+ module SolidusBling
2
+ module Spree
3
+ module PaymentMethodDecorator
4
+ def self.prepended(base)
5
+ base.class_eval do
6
+ has_many :solidus_bling_payment_methods, class_name: "SolidusBling::PaymentMethod", foreign_key: "spree_payment_method_id"
7
+ end
8
+ end
9
+
10
+ ::Spree::PaymentMethod.prepend self
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module SolidusBling
2
+ module Spree
3
+ module ShippingMethodDecorator
4
+ def self.prepended(base)
5
+ base.class_eval do
6
+ has_many :solidus_bling_shipping_methods, class_name: "SolidusBling::ShippingMethod", foreign_key: "spree_shipping_method_id"
7
+ end
8
+ end
9
+
10
+ ::Spree::ShippingMethod.prepend self
11
+ end
12
+ end
13
+ end
@@ -39,7 +39,7 @@ module SolidusBling
39
39
  ensure
40
40
  json = JSON.parse(req.body)
41
41
  response_has_error?(json)
42
- Spree::Bus.publish :bling_contact_created, args: {order: order, contato: json}
42
+ ::Spree::Bus.publish :bling_contact_created, args: {order: order, contato: json}
43
43
  return json.dig("data", "id")
44
44
  end
45
45
  end
@@ -108,7 +108,7 @@ module SolidusBling
108
108
  },
109
109
  "volumes": [
110
110
  {
111
- "servico": order.shipments.last.selected_shipping_rate.name,
111
+ "servico": @account.shipping_methods.find_by(spree_shipping_method_id: order.shipments.last.shipping_method.id).alias,
112
112
  "codigoRastreamento": ""
113
113
  }
114
114
  ]
@@ -1,5 +1,6 @@
1
1
  module SolidusBling
2
2
  class PaymentMethod < ApplicationRecord
3
3
  belongs_to :account
4
+ belongs_to :spree_payment_method, class_name: "Spree::PaymentMethod"
4
5
  end
5
6
  end
@@ -4,7 +4,7 @@ module SolidusBling
4
4
 
5
5
  def self.update bling_account
6
6
  bling_api = SolidusBling::Api.new(bling_account)
7
- skus = Spree::Variant.pluck(:sku)
7
+ skus = ::Spree::Variant.pluck(:sku)
8
8
  hash_products = {}
9
9
  products = skus.map do |sku|
10
10
  begin
@@ -29,7 +29,7 @@ module SolidusBling
29
29
  end
30
30
  end.compact.uniq
31
31
  SolidusBling::Product.upsert_all(products, unique_by: :sku)
32
- Spree::Bus.publish :bling_products_updated, products: hash_products
32
+ ::Spree::Bus.publish :bling_products_updated, products: hash_products
33
33
  end
34
34
 
35
35
  end
@@ -1,5 +1,6 @@
1
1
  module SolidusBling
2
2
  class ShippingMethod < ApplicationRecord
3
3
  belongs_to :account
4
+ belongs_to :spree_shipping_method, class_name: "Spree::ShippingMethod"
4
5
  end
5
6
  end
@@ -1,5 +1,5 @@
1
1
  class AddBlingOrderIdToSpreeOrders < ActiveRecord::Migration[7.0]
2
2
  def change
3
- add_column :spree_orders, :bling_order_id, :string, default: nil
3
+ add_column :spree_orders, :bling_order_id, :string, default: nil, if_not_exists: true
4
4
  end
5
5
  end
@@ -36,6 +36,10 @@ module SolidusBling
36
36
  puts 'Skipping bin/rails db:migrate, don\'t forget to run it!' # rubocop:disable Rails/Output
37
37
  end
38
38
  end
39
+
40
+ def install_dependencies
41
+ puts "\nTo complete the installation, please run:\nbin/rails generate solidus_brazilian_adaptations:install"
42
+ end
39
43
  end
40
44
  end
41
45
  end
@@ -19,7 +19,7 @@ module SolidusBling
19
19
  [:bling_account],
20
20
  'exclamation',
21
21
  url: :admin_accounts_path,
22
- condition: -> { can?(:manage, Spree::Store) }
22
+ condition: -> { can?(:manage, ::Spree::Store) }
23
23
  )
24
24
  end
25
25
  end
@@ -29,10 +29,12 @@ module SolidusBling
29
29
  g.test_framework :rspec
30
30
  end
31
31
 
32
- config.to_prepare do
33
- Spree::Bus.register(:bling_products_updated)
34
- Spree::Bus.register(:bling_contact_created)
35
- SolidusBling::Subscriber.new.subscribe_to(Spree::Bus)
32
+ initializer "solidus_bling.pub_sub", after: "spree.core.pub_sub" do |app|
33
+ app.reloader.to_prepare do
34
+ ::Spree::Bus.register(:bling_products_updated)
35
+ ::Spree::Bus.register(:bling_contact_created)
36
+ SolidusBling::Subscriber.new.subscribe_to(::Spree::Bus)
37
+ end
36
38
  end
37
39
 
38
40
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBling
4
- VERSION = '2.0.0'
4
+ VERSION = '2.0.2'
5
5
  end
@@ -35,9 +35,4 @@ Gem::Specification.new do |spec|
35
35
 
36
36
  spec.add_development_dependency 'solidus_dev_support', '~> 2.7'
37
37
 
38
- spec.post_install_message = <<-MESSAGE
39
- To complete the installation, please run:
40
- bin/rails g solidus_brazilian_adaptations:install
41
- MESSAGE
42
-
43
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_bling
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ulysses-bull
@@ -109,6 +109,8 @@ files:
109
109
  - app/assets/stylesheets/spree/backend/solidus_bling.css
110
110
  - app/assets/stylesheets/spree/frontend/solidus_bling.css
111
111
  - app/controllers/spree/admin/accounts_controller.rb
112
+ - app/decorators/models/solidus_bling/spree/payment_method_decorator.rb
113
+ - app/decorators/models/solidus_bling/spree/shipping_method_decorator.rb
112
114
  - app/helpers/solidus_bling/accounts_helper.rb
113
115
  - app/jobs/solidus_bling/application_job.rb
114
116
  - app/jobs/solidus_bling/contact_job.rb
@@ -172,9 +174,7 @@ metadata:
172
174
  homepage_uri: https://github.com/ulysses-bull/solidus_bling#readme
173
175
  source_code_uri: https://github.com/ulysses-bull/solidus_bling
174
176
  changelog_uri: https://github.com/ulysses-bull/solidus_bling/blob/master/CHANGELOG.md
175
- post_install_message: |2
176
- To complete the installation, please run:
177
- bin/rails g solidus_brazilian_adaptations:install
177
+ post_install_message:
178
178
  rdoc_options: []
179
179
  require_paths:
180
180
  - lib