sapos-print 1.0.6 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sapos/print/cli.rb +11 -0
- data/lib/sapos/print/configuration.rb +3 -2
- data/lib/sapos/print/q_reader.rb +12 -4
- data/lib/sapos/print/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6676d897cee608283071d8a13da6989e1db58cbbab4f4ba819be4b6fc9f80b30
|
4
|
+
data.tar.gz: 7c59412ee4b5d748389662823f5b9502d2aee835d1261c21c9673cee0d561da2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc05e1cdecdca5672a07e874afe94dce4232af5ab3c159352897e61222a24a91a25cbf894fca48cd464fbbbe12d166815e6828fbebece534c12bf27b2b020937
|
7
|
+
data.tar.gz: c1300e4a85fb10fdcba5b1df562b3bcdbb73f612dccea867590ce0fd492fb32b9002c10483c451500a9c8861168f9e97838dc6511f15d76dbd88d5f201924805
|
data/lib/sapos/print/cli.rb
CHANGED
@@ -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
|
data/lib/sapos/print/q_reader.rb
CHANGED
@@ -13,9 +13,17 @@ module Sapos
|
|
13
13
|
reader = QReader.new
|
14
14
|
callback = Pubnub::SubscribeCallback.new(
|
15
15
|
message: -> (envelope){
|
16
|
-
|
17
|
-
print_control =
|
18
|
-
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
|
data/lib/sapos/print/version.rb
CHANGED
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.
|
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:
|
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.
|
141
|
+
rubygems_version: 3.1.4
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: SAPOSCLOUD PRINT
|