Sha256: 468dce8d1b15a5f3ab82013228d8d4bae2abfd5c99da1766e9b1062b9b5e5113

Contents?: true

Size: 649 Bytes

Versions: 7

Compression:

Stored size: 649 Bytes

Contents

require 'rest-client'

Application.load 'lib/smartkiosk/sidekiq'

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|
        ReceiptTemplate.find_or_create_by_keyword(entry[:keyword]).
          update_attributes :template => entry[:template]
      end

      nil
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
smartkiosk-client-0.0.10 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.0.9 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.0.8 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.0.7 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.0.6 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.0.5 app/workers/sync/receipt_templates_worker.rb
smartkiosk-client-0.0.4 app/workers/sync/receipt_templates_worker.rb