Sha256: 81113a862fc4f9f3d756d549ba0d587d3c30db6e2b1e83d63ff5410ddf0170ba

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

module Bling
  class Subscriber
    include Omnes::Subscriber

    handle :order_finalized,
    with: :send_order_to_bling,
    id: :send_order_to_bling

    handle :erp_products_updated,
    with: :products_updated,
    id: :products_updated

    handle :erp_contato_created,
    with: :contato_created,
    id: :contato_created

    def send_order_to_bling event
      order = event.payload[:order]
      subscriber_name = event.omnes_event_name
      method = __method__.to_s
      ErpOrderJob.perform_later(order: order, event_name: subscriber_name, method_name: method)
    end

    def contato_created event
      contato = event.payload[:args][:contato]
      order = event.payload[:args][:order]
      subscriber_name = event.omnes_event_name
      method = __method__.to_s
      ErpContactJob.perform_later(order: order, contact: contato, event_name: subscriber_name, method_name: method)
    end

    def products_updated event
      products = event.payload[:products]
      method = __method__.to_s
      subscriber_name = event.omnes_event_name
      ErpProductJob.perform_later(products: products, event_name: subscriber_name, method_name: method)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
solidus_bling-1.0.1 app/subscribers/bling/subscriber.rb
solidus_bling-1.0.0 app/subscribers/bling/subscriber.rb