applidok 1.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/applidok.rb +44 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 721d175a5eae487a46683aae385c30bb352505c0
4
+ data.tar.gz: 9d7f3ba4cef8e5d8224f0eb59098fdd308e5ca70
5
+ SHA512:
6
+ metadata.gz: bb2960110c4d85768c00973825bc121a75a44ec740a45a7c3baa50e2cf3fc090f797feff1e581b62c5ccfbff24e7a2adceb36a9ab3a79fbba879ae1d67edd809
7
+ data.tar.gz: 855ab7f2ce2eb3d7d80ad82ee5c8757f7f01411b233daf62c0bfed43259da33da8063ec7dcca9168cc63df562a5c096fb01a29f01b3577c9fb651e6c39a0d242
data/lib/applidok.rb ADDED
@@ -0,0 +1,44 @@
1
+ module Applidok
2
+ require 'net/http'
3
+ require 'uri'
4
+
5
+ class Client
6
+ # token: Applidok application token
7
+ # template: ID of Applidok template
8
+ # values: Map of one string value per area name
9
+ # ssl: Whether should use SSL (true) or not (false)
10
+ def self.merge(token, template, values, ssl, &block)
11
+ if ssl == true
12
+ require 'openssl'
13
+ end
14
+
15
+ proto = (ssl == true) ? "https" : "http"
16
+
17
+ # Prepare HTTP client for Applidok API
18
+ uri = URI.parse(proto + "://go.applidok.com/api/merge")
19
+ http = Net::HTTP.new(uri.host, uri.port)
20
+
21
+ if ssl == true
22
+ http.use_ssl = true
23
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
24
+ end
25
+
26
+ # Prepare parameters
27
+ params = {
28
+ "applidok_token" => token,
29
+ "applidok_template" => template
30
+ }
31
+
32
+ values.each {|key, value| params[key] = value}
33
+
34
+ # Prepare request to merge feature
35
+ req = Net::HTTP::Post.new("/api/merge")
36
+ req.set_form_data(params)
37
+
38
+ # Send request, process response (there save it as file)
39
+ http.request req do |response|
40
+ yield response
41
+ end
42
+ end
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: applidok
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Applicius
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Client API for Applidok PDF templating
14
+ email: contact@applidok.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/applidok.rb
20
+ homepage: https://github.com/applicius/applidok-ruby
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: Applidok
44
+ test_files: []