Skip to content

Commit

Permalink
feat product.rb: #7
Browse files Browse the repository at this point in the history
After create, create stock using synchronize_bling
  • Loading branch information
Pauloparakleto committed Dec 22, 2023
1 parent 5fcbcc0 commit cbd0a0b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/models/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ class Product < ApplicationRecord
validates :price, numericality: { greater_than: 0 }
end

after_create :create_stock

def self.synchronize_bling(tenant, filter = {})
attributes = []
response = Services::Bling::Product.call(product_command: 'find_products', tenant: tenant)
Expand Down Expand Up @@ -125,4 +127,10 @@ def datatable_order(order_column_index, order_dir)
order("#{Product::DATATABLE_COLUMNS[order_column_index]} #{order_dir}")
end
end

private

def create_stock
Stock.synchronize_bling(account_id, [bling_id])
end
end

0 comments on commit cbd0a0b

Please sign in to comment.