Skip to content

Commit

Permalink
feat models/product.rb: #7
Browse files Browse the repository at this point in the history
  synchronize_bling products
  • Loading branch information
Pauloparakleto committed Dec 20, 2023
1 parent bc15fe3 commit 0cf6dfa
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/models/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,19 @@ class Product < ApplicationRecord
end

def self.synchronize_bling(tenant, filter = {})
attributes = []
response = Services::Bling::Product.call(product_command: 'find_products', tenant: tenant)
response
response['data'].each do |bling_product|
attributes << {
name: bling_product['nome'],
price: bling_product['preco'],
sku: bling_product['codigo'],
active: bling_product['situacao'].eql?('A'),
account_id: tenant
}
end

Product.create(attributes)
end

def count_month_purchase_product(year, month)
Expand Down

0 comments on commit 0cf6dfa

Please sign in to comment.