pingen-client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +1 -2
- data/Gemfile.lock +1 -1
- data/bin/check +4 -0
- data/lib/pingen/client.rb +6 -46
- data/lib/pingen/documents.rb +48 -0
- data/lib/pingen/sends.rb +24 -0
- data/pingen-client.gemspec +3 -11
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0fa20ad4aed09cdf236b031a30a9dd568841ffa41abb499d3357b70fee5fb3e
|
4
|
+
data.tar.gz: b2ac3124e1a4b8e0f63a9c00d051b339efedaf19b2528b29c7e738812a44d5f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d3342d0757a943ddcd98451b6c989c55bf33027cc33114c178d20ae8db4dc9e4ad6f06dcbb5c1310e0b2416b1324ed2e7508092ea599b9d42a8f25865f82f721
|
7
|
+
data.tar.gz: 305840fc5a481901e1fed4af32275dd0102046a55c5bfd9dec85588de3cc7a50f2549104cbe2f63d35b62c4bbdf5c61499da3e85b68dc30b8d1d7ec14aed7ecf
|
data/.semaphore/semaphore.yml
CHANGED
data/Gemfile.lock
CHANGED
data/bin/check
ADDED
data/lib/pingen/client.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require "net/http"
|
2
2
|
require "net/http/post/multipart"
|
3
3
|
require_relative "response"
|
4
|
+
require_relative "documents"
|
5
|
+
require_relative "sends"
|
4
6
|
|
5
7
|
module Pingen
|
6
8
|
class Client
|
@@ -18,48 +20,12 @@ module Pingen
|
|
18
20
|
@logger = logger
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
+
def documents
|
24
|
+
@documents ||= Documents.new(self)
|
23
25
|
end
|
24
26
|
|
25
|
-
def
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
# send_params:
|
30
|
-
# fast_send: true | false, default: false.
|
31
|
-
# true - A Post
|
32
|
-
# false - B Post
|
33
|
-
# color: true | false, default: false
|
34
|
-
def upload(pdf, send: false, **send_params)
|
35
|
-
data = {send: send}.merge(send ? parse_send_params(send_params) : {})
|
36
|
-
post_multipart_request("/document/upload", pdf, data: data.to_json)
|
37
|
-
end
|
38
|
-
|
39
|
-
def pdf(id)
|
40
|
-
get_request("/document/pdf/id/#{id}")
|
41
|
-
end
|
42
|
-
|
43
|
-
def delete(id)
|
44
|
-
post_request("/document/delete/id/#{id}", {})
|
45
|
-
end
|
46
|
-
|
47
|
-
# send_params:
|
48
|
-
# fast_send: true | false, default: false.
|
49
|
-
# true - A Post
|
50
|
-
# false - B Post
|
51
|
-
# color: true | false, default: false
|
52
|
-
def schedule_send(id, **send_params)
|
53
|
-
post_request("/document/send/id/#{id}", parse_send_params(send_params))
|
54
|
-
end
|
55
|
-
|
56
|
-
# allows you to cancel a pending send
|
57
|
-
def cancel_send(send_id)
|
58
|
-
get_request("/send/cancel/id/#{send_id}")
|
59
|
-
end
|
60
|
-
|
61
|
-
def track(send_id)
|
62
|
-
get_request("/send/track/id/#{send_id}")
|
27
|
+
def sends
|
28
|
+
@sends ||= Sends.new(self)
|
63
29
|
end
|
64
30
|
|
65
31
|
def get_request(path, params = nil, request_params = {})
|
@@ -127,11 +93,5 @@ module Pingen
|
|
127
93
|
request["Content-Type"] = "application/json"
|
128
94
|
request["Accept"] = "application/json"
|
129
95
|
end
|
130
|
-
|
131
|
-
private
|
132
|
-
|
133
|
-
def parse_send_params(**params)
|
134
|
-
{color: params[:color] ? 1 : 0, speed: params[:fast_send] ? 1 : 2}
|
135
|
-
end
|
136
96
|
end
|
137
97
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Pingen
|
2
|
+
class Documents
|
3
|
+
def initialize(client = Client.new)
|
4
|
+
@client = client
|
5
|
+
end
|
6
|
+
|
7
|
+
def list
|
8
|
+
@client.get_request("/document/list")
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id)
|
12
|
+
@client.get_request("/document/get/id/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# send_params:
|
16
|
+
# fast_send: true | false, default: false.
|
17
|
+
# true - A Post
|
18
|
+
# false - B Post
|
19
|
+
# color: true | false, default: false
|
20
|
+
def upload(pdf, send: false, **send_params)
|
21
|
+
data = {send: send}.merge(send ? parse_send_params(send_params) : {})
|
22
|
+
@client.post_multipart_request("/document/upload", pdf, data: data.to_json)
|
23
|
+
end
|
24
|
+
|
25
|
+
# send_params:
|
26
|
+
# fast_send: true | false, default: false.
|
27
|
+
# true - A Post
|
28
|
+
# false - B Post
|
29
|
+
# color: true | false, default: false
|
30
|
+
def send(id, **send_params)
|
31
|
+
@client.post_request("/document/send/id/#{id}", parse_send_params(send_params))
|
32
|
+
end
|
33
|
+
|
34
|
+
def pdf(id)
|
35
|
+
@client.get_request("/document/pdf/id/#{id}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete(id)
|
39
|
+
@client.post_request("/document/delete/id/#{id}", {})
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def parse_send_params(**params)
|
45
|
+
{color: params[:color] ? 1 : 0, speed: params[:fast_send] ? 1 : 2}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/pingen/sends.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Pingen
|
2
|
+
class Sends
|
3
|
+
def initialize(client = Client.new)
|
4
|
+
@client = client
|
5
|
+
end
|
6
|
+
|
7
|
+
def list
|
8
|
+
@client.get_request("/send/list")
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id)
|
12
|
+
@client.get_request("/send/get/id/#{id}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# allows you to cancel a pending send
|
16
|
+
def cancel(id)
|
17
|
+
@client.get_request("/send/cancel/id/#{id}")
|
18
|
+
end
|
19
|
+
|
20
|
+
def track(id)
|
21
|
+
@client.get_request("/send/track/id/#{id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/pingen-client.gemspec
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "pingen-client"
|
5
|
-
spec.version = "0.
|
6
|
-
spec.authors = ["Martin Cavoj"]
|
7
|
-
spec.email = ["
|
5
|
+
spec.version = "0.2.0"
|
6
|
+
spec.authors = ["Martin Cavoj", "Alessandro Rodi"]
|
7
|
+
spec.email = ["alessandro.rodi@renuo.ch"]
|
8
8
|
|
9
9
|
spec.summary = "Invoke Pingen API easily with Ruby"
|
10
10
|
spec.description = "This gem allows you to connect to Pingen API and use the services provided"
|
@@ -16,18 +16,10 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.metadata["source_code_uri"] = "https://github.com/renuo/pingen-client"
|
17
17
|
spec.metadata["changelog_uri"] = "https://github.com/renuo/pingen-client/CHANGELOG.md"
|
18
18
|
|
19
|
-
# Specify which files should be added to the gem when it is released.
|
20
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
19
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
20
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
23
21
|
end
|
24
22
|
spec.bindir = "exe"
|
25
23
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
26
24
|
spec.require_paths = ["lib"]
|
27
|
-
|
28
|
-
# Uncomment to register a new dependency of your gem
|
29
|
-
# spec.add_dependency "example-gem", "~> 1.0"
|
30
|
-
|
31
|
-
# For more information and examples about making a new gem, checkout our
|
32
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
33
25
|
end
|
metadata
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingen-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Cavoj
|
8
|
+
- Alessandro Rodi
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2021-
|
12
|
+
date: 2021-09-20 00:00:00.000000000 Z
|
12
13
|
dependencies: []
|
13
14
|
description: This gem allows you to connect to Pingen API and use the services provided
|
14
15
|
email:
|
15
|
-
-
|
16
|
+
- alessandro.rodi@renuo.ch
|
16
17
|
executables: []
|
17
18
|
extensions: []
|
18
19
|
extra_rdoc_files: []
|
@@ -27,10 +28,13 @@ files:
|
|
27
28
|
- LICENSE.txt
|
28
29
|
- README.md
|
29
30
|
- Rakefile
|
31
|
+
- bin/check
|
30
32
|
- bin/console
|
31
33
|
- bin/setup
|
32
34
|
- lib/pingen/client.rb
|
35
|
+
- lib/pingen/documents.rb
|
33
36
|
- lib/pingen/response.rb
|
37
|
+
- lib/pingen/sends.rb
|
34
38
|
- pingen-client.gemspec
|
35
39
|
homepage: https://github.com/renuo/pingen-client
|
36
40
|
licenses:
|