Sha256: 75b81b2bd36d121b03877c9fa5c0a847fafc7bfc0fac72f607f723ab0fbb13e7

Contents?: true

Size: 686 Bytes

Versions: 28

Compression:

Stored size: 686 Bytes

Contents

require 'rest-client'

module Sync
  class ReceiptTemplatesWorker
    include Sidekiq::Worker

    sidekiq_options :retry => false, :queue => :sync

    def perform
      params = {
        :terminal => Terminal.config.keyword
      }

      response  = RestClient.get "#{Terminal.config.host}/system_receipt_templates?#{params.to_query}"
      templates = JSON.parse(response.to_s, :symbolize_names => true)

      templates.each do |entry|
        Sidekiq::Logging.logger.info "Got #{entry[:keyword]} receipt template"

        ReceiptTemplate.find_or_create_by_keyword(entry[:keyword]).
          update_attributes :template => entry[:template]
      end

      nil
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
smartkiosk-client-0.2.1 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.2 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.19 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.18 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.17 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.16 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.15 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.14 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.13 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.12 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.11 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.10 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.9 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.8 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.7 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.6 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.5 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.4 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.3 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.1.2 app/workers/sync/receipt_templates_worker.rb