Class: Sync::ReceiptTemplatesWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/sync/receipt_templates_worker.rb

Instance Method Summary collapse

Instance Method Details

#performObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/workers/sync/receipt_templates_worker.rb', line 9

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