smartkiosk-client 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,7 @@ class Terminal
15
15
  value :payment_in_progress, :global => true
16
16
 
17
17
  value :support_phone, :global => true
18
+ value :logo_url, :global => true
18
19
  value :providers_updates, :global => true, :marshal => true
19
20
 
20
21
  #
@@ -37,21 +37,35 @@ class PingWorker
37
37
  return
38
38
  end
39
39
 
40
- unless Terminal.support_phone.value == response[:support_phone]
41
- Terminal.support_phone = response[:support_phone]
42
- Terminal.modified_at = DateTime.now
43
- end
44
-
45
40
  Sidekiq::Logging.logger.info "Response: #{response.inspect}"
46
41
 
42
+ #
43
+ # PROFILE
44
+ #
45
+ unless Terminal.modified_at == response[:profile][:modified_at]
46
+ Terminal.support_phone = response[:profile][:support_phone]
47
+ Terminal.modified_at = response[:profile][:modified_at]
48
+ Sync::LogoWorker.perform_async response[:profile][:logo]
49
+ end
50
+
47
51
  #
48
52
  # ORDERS
49
53
  #
50
- response[:orders].each do |order|
51
- next unless Order.find_by_foreign_id(order[:id]).blank?
54
+ response[:orders].each do |foreign|
55
+ existing = Order.find_by_foreign_id(foreign[:id])
56
+
57
+ unless existing.nil?
58
+ if existing.foreign_created_at == foreign[:created_at] || # same order, not yet acknowleged
59
+ !existing.complete? # not completed yet
60
+ next
61
+ end
62
+
63
+ existing.destroy
64
+ end
52
65
 
53
- order[:foreign_id] = order.delete(:id)
54
- order = Order.create!(order)
66
+ foreign[:foreign_id] = foreign.delete(:id)
67
+ foreign[:foreign_created_at] = foreign.delete(:created_at)
68
+ order = Order.create!(foreign)
55
69
 
56
70
  order.acknowledge
57
71
  order.perform
@@ -0,0 +1,19 @@
1
+ require 'rest-client'
2
+
3
+ module Sync
4
+ class LogoWorker
5
+ include Sidekiq::Worker
6
+
7
+ sidekiq_options :retry => true, :queue => :sync
8
+
9
+ def perform(url)
10
+ if url.nil?
11
+ Terminal.logo_url = nil
12
+ else
13
+ uploader = IconUploader.new
14
+ uploader.download! "#{Terminal.config.host}/#{url}"
15
+ Terminal.logo_url = uploader.url
16
+ end
17
+ end
18
+ end
19
+ end
data/config/boot.rb CHANGED
@@ -80,7 +80,7 @@ module Smartkiosk
80
80
  Dir[File.expand_path "../../app/#{dir}/**/*.rb", __FILE__].each {|file| require file }
81
81
  end
82
82
 
83
- CarrierWave.root = ->() { Application.public_folder }
83
+ CarrierWave.root = Application.public_folder
84
84
 
85
85
  self
86
86
  end
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  smartguard_host: druby://localhost:10000
3
3
  keyword: LOCAL
4
- host: http://localhost:3000
4
+ host: http://admin.smartkiosk-mkb.rdlk.biz
@@ -1,12 +1,13 @@
1
1
  class CreateOrders < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :orders do |t|
4
- t.integer :foreign_id
5
- t.string :keyword
6
- t.text :args
7
- t.string :error
8
- t.boolean :acknowledged
9
- t.boolean :complete
4
+ t.integer :foreign_id
5
+ t.datetime :foreign_created_at
6
+ t.string :keyword
7
+ t.text :args
8
+ t.string :error
9
+ t.boolean :acknowledged
10
+ t.boolean :complete
10
11
 
11
12
  t.timestamps
12
13
  end
@@ -2,6 +2,6 @@ require 'sinatra/base'
2
2
 
3
3
  module Smartkiosk
4
4
  class Client < Sinatra::Base
5
- VERSION = '0.0.17'
5
+ VERSION = '0.0.18'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smartkiosk-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -554,6 +554,7 @@ files:
554
554
  - app/workers/payments/pay_worker.rb
555
555
  - app/workers/ping_worker.rb
556
556
  - app/workers/sync/icons_worker.rb
557
+ - app/workers/sync/logo_worker.rb
557
558
  - app/workers/sync/receipt_templates_worker.rb
558
559
  - bin/smartkiosk-client
559
560
  - config/boot.rb
@@ -606,7 +607,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
606
607
  version: '0'
607
608
  segments:
608
609
  - 0
609
- hash: -1513265429066480138
610
+ hash: -4222507669661345488
610
611
  required_rubygems_version: !ruby/object:Gem::Requirement
611
612
  none: false
612
613
  requirements:
@@ -615,7 +616,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
615
616
  version: '0'
616
617
  segments:
617
618
  - 0
618
- hash: -1513265429066480138
619
+ hash: -4222507669661345488
619
620
  requirements: []
620
621
  rubyforge_project:
621
622
  rubygems_version: 1.8.24