simplprinter 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 481e593602ad543bf5936035d64b7dd8b6c0b4ed
4
- data.tar.gz: 0c2c8d4e920e4792b6b40c7ad8f73350e360b53f
3
+ metadata.gz: e87ce3f7a84c5154f3507feb856c95a22c5d42e3
4
+ data.tar.gz: abeb7a635f62e780bbcb849c38b8e61793f4dab2
5
5
  SHA512:
6
- metadata.gz: df39147e2f0a581da894f8763694fc1ad81e831fb8d9fe128cdbf834791279a4be22469900195c6415bc8e35e49cdde52c4a636299e45c3fe258b082cd49ab51
7
- data.tar.gz: 2c6e143b90f55cf7c058ad0f0e7706c01c85da834c48a7d1fc43fb745e4acc3a0bd159146bcb681bd28597e138de8eb27c5f9d26e13e41530846407f4c38edee
6
+ metadata.gz: 4704ee86865442fadf52cb61a4809933fba67b32e2c3469a596f65216e4550a16fdc29be2e7e47868752aa6943b77a9e294cadeeade5e5b7f4dca6f94923d2e9
7
+ data.tar.gz: 8c4edbbc0f073369b5f4948563f9f1af515af98f0843830eb4c17df6ef54a8bea2740d81733d2c034646ff0ded7e59e43f32fcad786edd24e0f679079d440b83
@@ -0,0 +1,8 @@
1
+ module Simplprinter
2
+ module_function
3
+
4
+ def new_request(mandate_id, api_token, callback_url, simplprinter_base_url="http://app.simplprinter.ch")
5
+ Requester.new(mandate_id, api_token, callback_url, simplprinter_base_url)
6
+ end
7
+
8
+ end
@@ -0,0 +1,43 @@
1
+ module Simplprinter
2
+ class Requester
3
+
4
+ attr_reader :mandate_id, :api_token, :jobs_arr
5
+
6
+ def initialize(mandate_id, api_token, callback_url, simplprinter_base_url="http://app.simplprinter.ch")
7
+ @mandate_id = mandate_id
8
+ @api_token = api_token
9
+ @simplprinter_base_url = simplprinter_base_url
10
+ @jobs_arr = []
11
+ end
12
+
13
+ def add_job(content, opt={})
14
+ require 'ostruct'
15
+
16
+ j = OpenStruct.new
17
+ j.action = opt.fetch('action', 'print_pdf')
18
+ j.template = opt.fetch('template', 'a4_portrait_standard')
19
+ j.isdraft = opt.fetch('isdraft', 'true')
20
+ j.uuid = opt.fetch('uuid', '')
21
+ j.callback_url = opt.fetch('callback_url', callback_url)
22
+ j.content = content
23
+
24
+ job = j.marshal_dump
25
+
26
+ jobs_arr << job
27
+ job
28
+ end
29
+
30
+ def send_it
31
+ require "uri"
32
+ require "net/http"
33
+
34
+ u = URI.parse("#{simplprinter_base_url}?access_token=#{api_token}&mandate_id=#{mandate_id}")
35
+
36
+ payload = { 'jobs' => jobs_arr.to_json }
37
+
38
+ resp = Net::HTTP.post_form(u, payload)
39
+ resp
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ module Simplprinter
2
+ VERSION = "0.1.3"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplprinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - rmuzzi/salespitcher
@@ -46,6 +46,9 @@ extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
48
  - lib/simplprinter.rb
49
+ - lib/simplprinter/api.rb
50
+ - lib/simplprinter/requester.rb
51
+ - lib/simplprinter/version.rb
49
52
  homepage: http://www.simplprinter.ch
50
53
  licenses:
51
54
  - MIT