sapos-print 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa9dbe51b563ee70ee2027c134a1bd153f324320b3de2fe8edeaf746cacf0074
4
- data.tar.gz: dbd27b3c96dbd8f3f16a1127380e863e7e39abd2281f9fbd0e661257e6f34628
3
+ metadata.gz: 6676d897cee608283071d8a13da6989e1db58cbbab4f4ba819be4b6fc9f80b30
4
+ data.tar.gz: 7c59412ee4b5d748389662823f5b9502d2aee835d1261c21c9673cee0d561da2
5
5
  SHA512:
6
- metadata.gz: 1ede8347459232583ccdef4f6b7f9750272c566b79f4c019fdc7043e30c9e685759527b3c2a5d692130abf53c81d012c2cd694d1feb423fc4cf089077e437fa8
7
- data.tar.gz: d10655107cdad90e67da0e0a4ec2c97af27087e85b91e3859eb6edc23d1beb9c2381bc5a6311b1dd80960d4c103a4d3efedb9b8b72690c379e720f7bedc4d3fd
6
+ metadata.gz: cc05e1cdecdca5672a07e874afe94dce4232af5ab3c159352897e61222a24a91a25cbf894fca48cd464fbbbe12d166815e6828fbebece534c12bf27b2b020937
7
+ data.tar.gz: c1300e4a85fb10fdcba5b1df562b3bcdbb73f612dccea867590ce0fd492fb32b9002c10483c451500a9c8861168f9e97838dc6511f15d76dbd88d5f201924805
@@ -12,12 +12,23 @@ module Sapos
12
12
  url = ask("Configuration URL")
13
13
  response = RestClient.get(url)
14
14
  data = JSON.parse(response)
15
+
16
+ config_file = "#{Sapos::Print.app_directory}/config.yml"
17
+ user_id = nil
18
+ if File.exist?(config_file)
19
+ template = ERB.new(File.read(config_file))
20
+ result = YAML.load(template.result(binding))
21
+ user_id = result[:user_id]
22
+ end
23
+
24
+ user_id = SecureRandom.uuid if user_id.nil?
15
25
 
16
26
  config[:q] = data["channel"]
17
27
  config[:key] = data["key"]
18
28
  config[:printer] = ask("Printer Name: ")
19
29
  config[:adapter] = ask("Printer Adapter: ", limited_to: ["console", "cups", "windows"])
20
30
  config[:interface] = ask("Interface", limited_to: ["text", "escp"])
31
+ config[:user_id] = user_id
21
32
 
22
33
  if yes?("Are you sure that you want to write the configuration file?")
23
34
  Sapos::Print::Configuration.write(config)
@@ -6,7 +6,7 @@ module Sapos
6
6
  module Print
7
7
  class Configuration
8
8
 
9
- attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal
9
+ attr_accessor :printer, :adapter, :interface, :q, :key, :emv_path, :emv_terminal, :user_id
10
10
 
11
11
  def self.write(args = {})
12
12
  config_file = "#{Sapos::Print.app_directory}/config.yml"
@@ -26,6 +26,7 @@ module Sapos
26
26
  @key = result[:key]
27
27
  @emv_path = result[:emv_path]
28
28
  @emv_terminal = result[:emv_terminal]
29
+ @user_id = result[:user_id]
29
30
  else
30
31
  raise Sapos::Print::Error, "Configuration is missing. Make sure to create this file: #{config_file}"
31
32
  end
@@ -44,7 +45,7 @@ module Sapos
44
45
  end
45
46
 
46
47
  def to_h
47
- {printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal }
48
+ {printer: @printer, adapter: @adapter, interface: @interface, q: @q, key: @key, emv_path: @emv_path, emv_terminal: @emv_terminal, user_id: @user_id }
48
49
  end
49
50
  end
50
51
  end
@@ -13,9 +13,17 @@ module Sapos
13
13
  reader = QReader.new
14
14
  callback = Pubnub::SubscribeCallback.new(
15
15
  message: -> (envelope){
16
- document = Base64.decode64(envelope.result[:data][:message]['document'])
17
- print_control = envelope.result[:data][:message]['print_control']
18
- document_number = envelope.result[:data][:message]['document_number']
16
+ msg = envelope.result[:data][:message]
17
+ print_control = nil
18
+ document_number = nil
19
+
20
+ if msg.is_a?(Hash)
21
+ msg = msg['document']
22
+ print_control = msg['print_control']
23
+ document_number = msg['document_number']
24
+ end
25
+
26
+ document = Base64.decode64(msg)
19
27
 
20
28
  if reader.printer.print(document: document, print_control: print_control, document_number: document_number)
21
29
  puts "OK"
@@ -37,7 +45,7 @@ module Sapos
37
45
  def initialize
38
46
  @config = QReader.printer_config
39
47
  @printer = Printer.new(@config)
40
- @pubnub = Pubnub.new(subscribe_key: @config.key)
48
+ @pubnub = Pubnub.new(subscribe_key: @config.key, user_id: @config.user_id)
41
49
  end
42
50
  end
43
51
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Sapos
4
4
  module Print
5
- VERSION = "1.0.6"
5
+ VERSION = "1.0.7"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sapos-print
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Sauter
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-09 00:00:00.000000000 Z
11
+ date: 2023-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
138
  - !ruby/object:Gem::Version
139
139
  version: '0'
140
140
  requirements: []
141
- rubygems_version: 3.2.3
141
+ rubygems_version: 3.1.4
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: SAPOSCLOUD PRINT