vidsigner_api 0.9.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.
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ .idea
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vidsigner_api.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Adrian Cepillo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # VidsignerApi
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'vidsigner_api'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install vidsigner_api
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/vidsigner_api/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,8 @@
1
+ development:
2
+ base_uri: "https://pre-vidsignercloud.validatedid.com/api"
3
+ username: "youruser"
4
+ password: "yourpassword"
5
+ production:
6
+ base_uri: "https://vidsignercloud.validatedid.com/api"
7
+ username: "youruser"
8
+ password: "yourpassword"
@@ -0,0 +1,7 @@
1
+ class VidsignerApiGenerator < Rails::Generators::Base
2
+ source_root(File.expand_path(File.dirname(__FILE__)))
3
+ def copy_initializer
4
+ copy_file 'vidsigner_api_initializer.rb', 'config/initializers/vidsigner_api_initializer.rb'
5
+ copy_file 'vidsigner_api_config.yml', 'config/vidsigner_api_config.yml'
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+
2
+ VidsignerApi::CONFIG = YAML.load_file("#{Rails.root}/config/vidsigner_api_config.yml")
@@ -0,0 +1,3 @@
1
+ module VidsignerApi
2
+ VERSION = "0.9.0"
3
+ end
@@ -0,0 +1,70 @@
1
+ require "vidsigner_api/version"
2
+
3
+ module VidsignerApi
4
+
5
+ if ENV[:vidsigner_path] and defined? Rails != "constant"
6
+ config_path = "#{ENV[:vidsigner_path]}/config/vidsigner_api_config.yml"
7
+ DATA = File.exists?(config_path) ? YAML.load_file(config_path) : raise
8
+ end
9
+
10
+ def devices(env = nil)
11
+ self.request("get", "devices", nil, env)
12
+ end
13
+
14
+ def create_document(data, env = nil)
15
+ self.request("post", "documents", data, env)
16
+ end
17
+
18
+ def destroy_document(id, env = nil)
19
+ self.request("delete", "documents", id, env)
20
+ end
21
+
22
+ def signed_documents(env = nil)
23
+ self.request("get", "signeddocuments", nil, env)
24
+ end
25
+
26
+ def signed_document(id, env = nil)
27
+ self.request("get", "signeddocuments", id, env)
28
+ end
29
+
30
+ def destroy_signed_document(id, env = nil)
31
+ self.request("delete", "signeddocuments", id, env)
32
+ end
33
+
34
+ def document_info(id, env = nil)
35
+ self.request("get", "documentinfo", id, env)
36
+ end
37
+
38
+ def document_list(param, env = nil)
39
+ self.request("get", "documentlist", param, env)
40
+ end
41
+
42
+ def destroy_document_list(param, env = nil)
43
+ self.request("delete", "documentlist", param, env)
44
+ end
45
+
46
+ private
47
+
48
+ def self.request(http_method, action, param = nil, env = nil)
49
+ data = env.blank? ? DATA[env.to_sym] : defined? Rails == "constant" ? DATA[Rails.env.to_sym] : DATA[ENV[:vidsigner_env].to_sym]
50
+
51
+ auth = "Basic "+Base64.encode64("#{data[:username]}:#{data[:password]}")
52
+ header = {"Authorization" => auth,
53
+ "Connection" => "Keep-Alive"}
54
+
55
+ http_method = http_method.lowercase
56
+ action_uri = http_method == "post" ? "#{data[:base_uri]}/#{action}" : "#{data[:base_uri]}/#{action}/#{param}"
57
+ uri = URI(action_uri)
58
+ req = "Net::HTTP::#{http_method.capitalize}".constantize.new(uri.path)
59
+ req.initialize_http_header(header)
60
+ req.body= param.to_json if http_method == "post"
61
+
62
+ http = Net::HTTP.new(uri.host, uri.port)
63
+ http.use_ssl = true
64
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
65
+
66
+ response = http.request(req)
67
+
68
+ return JSON.parse(response.body), response
69
+ end
70
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vidsigner_api/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vidsigner_api"
8
+ spec.version = VidsignerApi::VERSION
9
+ spec.authors = ["Adrian Cepillo"]
10
+ spec.email = ["adrian.cepillo@gmail.com"]
11
+ spec.summary = %q{Ruby gem for VidSigner API service}
12
+ spec.description = %q{Ruby gem for VidSigner API service}
13
+ spec.homepage = "http://github.com/adriancm/vidsigner_api"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vidsigner_api
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Adrian Cepillo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-07-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.7'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ description: Ruby gem for VidSigner API service
47
+ email:
48
+ - adrian.cepillo@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/generators/vidsigner_api_config.yml
59
+ - lib/generators/vidsigner_api_generator.rb
60
+ - lib/generators/vidsigner_api_initializer.rb
61
+ - lib/vidsigner_api.rb
62
+ - lib/vidsigner_api/version.rb
63
+ - vidsigner_api.gemspec
64
+ homepage: http://github.com/adriancm/vidsigner_api
65
+ licenses:
66
+ - MIT
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.29
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Ruby gem for VidSigner API service
89
+ test_files: []