esignatur 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.hound +3 -0
- data/.rspec +3 -0
- data/.rubocop.yml +35 -0
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +109 -0
- data/LICENSE.txt +21 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/esignatur.gemspec +46 -0
- data/lib/esignatur.rb +14 -0
- data/lib/esignatur/api.rb +41 -0
- data/lib/esignatur/api/response.rb +36 -0
- data/lib/esignatur/client.rb +19 -0
- data/lib/esignatur/error.rb +3 -0
- data/lib/esignatur/order.rb +40 -0
- data/lib/esignatur/orders.rb +58 -0
- data/lib/esignatur/pades.rb +27 -0
- data/lib/esignatur/version.rb +5 -0
- metadata +222 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c68634e762f47f536b57c23fb203b250aa8b5a7f14245f93c3de44e8ffc93f82
|
4
|
+
data.tar.gz: 18f4482bb8f1a05b6dbf036037028e0913e2cc4e55a75e5bc5ce64b4eaaf71c1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7456e5bd9dd0accf4fe20283c27646a26b520513875828999d1d33ad88c3f2e01a4ddc92fd442de025263278cc0692abc30b559f3891a155f5f251a01b981e70
|
7
|
+
data.tar.gz: 29f3d732f689c76ce42a2adb05c7c38c965e25e9d0fde5ddd19d0adfa312867922cdce062aca7101c26783f2eb7c702b355fc230587cf15e55812fffdb1996f2
|
data/.gitignore
ADDED
data/.hound
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
RSpec/NestedGroups:
|
4
|
+
Enabled: false
|
5
|
+
|
6
|
+
Metrics/LineLength:
|
7
|
+
Enabled: true
|
8
|
+
Max: 120
|
9
|
+
|
10
|
+
Metrics/BlockLength:
|
11
|
+
Exclude:
|
12
|
+
- spec/**/*.rb
|
13
|
+
Metrics/ModuleLength:
|
14
|
+
Exclude:
|
15
|
+
- spec/**/*_spec.rb
|
16
|
+
|
17
|
+
Lint/AmbiguousBlockAssociation:
|
18
|
+
Exclude:
|
19
|
+
- spec/**/*.rb
|
20
|
+
|
21
|
+
Naming/UncommunicativeMethodParamName:
|
22
|
+
AllowedNames:
|
23
|
+
- 'to'
|
24
|
+
- 'at'
|
25
|
+
- 'on'
|
26
|
+
- 'id'
|
27
|
+
- 'in'
|
28
|
+
- 'as'
|
29
|
+
|
30
|
+
AllCops:
|
31
|
+
TargetRubyVersion: 2.5
|
32
|
+
Exclude:
|
33
|
+
- bin/*
|
34
|
+
- esignatur.gemspec
|
35
|
+
- Rakefile
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at povilas@samesystem.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
esignatur (1.0.0)
|
5
|
+
activesupport (>= 3.0)
|
6
|
+
faraday (>= 0.10)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (5.2.1)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
addressable (2.5.2)
|
17
|
+
public_suffix (>= 2.0.2, < 4.0)
|
18
|
+
ast (2.4.0)
|
19
|
+
byebug (10.0.2)
|
20
|
+
codecov (0.1.10)
|
21
|
+
json
|
22
|
+
simplecov
|
23
|
+
url
|
24
|
+
coderay (1.1.2)
|
25
|
+
concurrent-ruby (1.0.5)
|
26
|
+
crack (0.4.3)
|
27
|
+
safe_yaml (~> 1.0.0)
|
28
|
+
diff-lcs (1.3)
|
29
|
+
docile (1.3.1)
|
30
|
+
faraday (0.15.2)
|
31
|
+
multipart-post (>= 1.2, < 3)
|
32
|
+
hashdiff (0.3.7)
|
33
|
+
i18n (1.1.0)
|
34
|
+
concurrent-ruby (~> 1.0)
|
35
|
+
jaro_winkler (1.5.1)
|
36
|
+
json (2.1.0)
|
37
|
+
method_source (0.9.0)
|
38
|
+
minitest (5.11.3)
|
39
|
+
multipart-post (2.0.0)
|
40
|
+
parallel (1.12.1)
|
41
|
+
parser (2.5.1.0)
|
42
|
+
ast (~> 2.4.0)
|
43
|
+
powerpack (0.1.2)
|
44
|
+
pry (0.11.3)
|
45
|
+
coderay (~> 1.1.0)
|
46
|
+
method_source (~> 0.9.0)
|
47
|
+
pry-byebug (3.6.0)
|
48
|
+
byebug (~> 10.0)
|
49
|
+
pry (~> 0.10)
|
50
|
+
public_suffix (3.0.3)
|
51
|
+
rainbow (3.0.0)
|
52
|
+
rake (10.5.0)
|
53
|
+
rspec (3.7.0)
|
54
|
+
rspec-core (~> 3.7.0)
|
55
|
+
rspec-expectations (~> 3.7.0)
|
56
|
+
rspec-mocks (~> 3.7.0)
|
57
|
+
rspec-core (3.7.1)
|
58
|
+
rspec-support (~> 3.7.0)
|
59
|
+
rspec-expectations (3.7.0)
|
60
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
61
|
+
rspec-support (~> 3.7.0)
|
62
|
+
rspec-mocks (3.7.0)
|
63
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
64
|
+
rspec-support (~> 3.7.0)
|
65
|
+
rspec-support (3.7.1)
|
66
|
+
rubocop (0.57.2)
|
67
|
+
jaro_winkler (~> 1.5.1)
|
68
|
+
parallel (~> 1.10)
|
69
|
+
parser (>= 2.5)
|
70
|
+
powerpack (~> 0.1)
|
71
|
+
rainbow (>= 2.2.2, < 4.0)
|
72
|
+
ruby-progressbar (~> 1.7)
|
73
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
74
|
+
rubocop-rspec (1.27.0)
|
75
|
+
rubocop (>= 0.56.0)
|
76
|
+
ruby-progressbar (1.9.0)
|
77
|
+
safe_yaml (1.0.4)
|
78
|
+
simplecov (0.16.1)
|
79
|
+
docile (~> 1.1)
|
80
|
+
json (>= 1.8, < 3)
|
81
|
+
simplecov-html (~> 0.10.0)
|
82
|
+
simplecov-html (0.10.2)
|
83
|
+
thread_safe (0.3.6)
|
84
|
+
tzinfo (1.2.5)
|
85
|
+
thread_safe (~> 0.1)
|
86
|
+
unicode-display_width (1.4.0)
|
87
|
+
url (0.3.2)
|
88
|
+
webmock (3.4.2)
|
89
|
+
addressable (>= 2.3.6)
|
90
|
+
crack (>= 0.3.2)
|
91
|
+
hashdiff
|
92
|
+
|
93
|
+
PLATFORMS
|
94
|
+
ruby
|
95
|
+
|
96
|
+
DEPENDENCIES
|
97
|
+
bundler (>= 1.16)
|
98
|
+
codecov (>= 0.1.10)
|
99
|
+
esignatur!
|
100
|
+
pry-byebug
|
101
|
+
rake (>= 10.0)
|
102
|
+
rspec (>= 3.0)
|
103
|
+
rubocop (>= 0.57)
|
104
|
+
rubocop-rspec (>= 1.27)
|
105
|
+
simplecov (>= 0.16.1)
|
106
|
+
webmock (>= 3.4)
|
107
|
+
|
108
|
+
BUNDLED WITH
|
109
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Povilas Jurcys
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Esignatur
|
2
|
+
|
3
|
+
https://api.esignatur.dk api ruby client
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'esignatur'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install esignatur
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
esignatur = Esignatur::Client.new(api_key: your_api_key)
|
25
|
+
esignatur.create_order()
|
26
|
+
esignatur.orders.where(modified_since: Date.new(2000, 1, 1))
|
27
|
+
|
28
|
+
order = esignatur.orders.find(1)
|
29
|
+
order.status
|
30
|
+
order.download_pades
|
31
|
+
```
|
32
|
+
|
33
|
+
TODO: Write usage instructions here
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/esignatur. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
48
|
+
|
49
|
+
## Code of Conduct
|
50
|
+
|
51
|
+
Everyone interacting in the Esignatur project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/esignatur/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "esignatur"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/esignatur.gemspec
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "esignatur/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "esignatur"
|
8
|
+
spec.version = Esignatur::VERSION
|
9
|
+
spec.authors = ["Povilas Jurcys"]
|
10
|
+
spec.email = ["po.jurcys@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{ruby API client for esignatur.dk}
|
13
|
+
spec.homepage = "https://github.com/samesystem/esignatur"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
# if spec.respond_to?(:metadata)
|
19
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
# else
|
21
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
# "public gem pushes."
|
23
|
+
# end
|
24
|
+
|
25
|
+
# Specify which files should be added to the gem when it is released.
|
26
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
27
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
28
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
29
|
+
end
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_dependency "faraday", ">= 0.10"
|
35
|
+
spec.add_dependency "activesupport", ">= 3.0"
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", ">= 1.16"
|
38
|
+
spec.add_development_dependency "rake", ">= 10.0"
|
39
|
+
spec.add_development_dependency "rspec", ">= 3.0"
|
40
|
+
spec.add_development_dependency "rubocop", '>= 0.57'
|
41
|
+
spec.add_development_dependency "rubocop-rspec", '>= 1.27'
|
42
|
+
spec.add_development_dependency "webmock", '>= 3.4'
|
43
|
+
spec.add_development_dependency "codecov", '>= 0.1.10'
|
44
|
+
spec.add_development_dependency "simplecov", '>= 0.16.1'
|
45
|
+
spec.add_development_dependency "pry-byebug"
|
46
|
+
end
|
data/lib/esignatur.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'esignatur/version'
|
4
|
+
|
5
|
+
require 'esignatur/api'
|
6
|
+
require 'esignatur/client'
|
7
|
+
require 'esignatur/error'
|
8
|
+
|
9
|
+
require 'esignatur/orders'
|
10
|
+
require 'esignatur/order'
|
11
|
+
|
12
|
+
# root module
|
13
|
+
module Esignatur
|
14
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'esignatur/api/response'
|
4
|
+
|
5
|
+
module Esignatur
|
6
|
+
# all raw http requests are made using Api instance
|
7
|
+
class Api
|
8
|
+
require 'faraday'
|
9
|
+
|
10
|
+
DEFAULT_BASE_URL = 'https://api.esignatur.dk'
|
11
|
+
|
12
|
+
def initialize(api_key:, base_url: DEFAULT_BASE_URL)
|
13
|
+
@api_key = api_key.to_s
|
14
|
+
@base_url = base_url
|
15
|
+
end
|
16
|
+
|
17
|
+
def post(relative_url, data:, headers: {})
|
18
|
+
make_request(:post, relative_url, data: data, extra_headers: headers)
|
19
|
+
end
|
20
|
+
|
21
|
+
def get(relative_url, headers: {})
|
22
|
+
make_request(:get, relative_url, extra_headers: headers)
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_reader :base_url, :api_key
|
28
|
+
|
29
|
+
def make_request(http_method, relative_url, extra_headers: {}, data: nil)
|
30
|
+
url = URI.join(base_url, relative_url).to_s
|
31
|
+
|
32
|
+
headers = default_headers.merge(extra_headers)
|
33
|
+
raw_response = Faraday.public_send(http_method, url, data&.to_json, headers)
|
34
|
+
Esignatur::Api::Response.new(raw_response)
|
35
|
+
end
|
36
|
+
|
37
|
+
def default_headers
|
38
|
+
{ 'X-eSignatur-Id' => api_key }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Esignatur
|
4
|
+
class Api
|
5
|
+
# api response wrapper
|
6
|
+
class Response
|
7
|
+
attr_reader :original_response
|
8
|
+
|
9
|
+
def initialize(original_response)
|
10
|
+
@original_response = original_response
|
11
|
+
end
|
12
|
+
|
13
|
+
def body
|
14
|
+
original_response.body
|
15
|
+
end
|
16
|
+
|
17
|
+
def json_body
|
18
|
+
JSON.parse(body)
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(method_name, *args)
|
22
|
+
original_respond_to?(method_name, *args) ? original_response.public_send(method_name, *args) : super
|
23
|
+
end
|
24
|
+
|
25
|
+
def respond_to_missing?(method_name, *args)
|
26
|
+
original_respond_to?(method_name, *args) || super
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def original_respond_to?(method_name, *args)
|
32
|
+
original_response.respond_to?(method_name, *args)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Esignatur
|
4
|
+
class Client
|
5
|
+
DEFAULT_BASE_URL = 'https://api.esignatur.dk'.freeze
|
6
|
+
|
7
|
+
def initialize(api_key:, base_url: DEFAULT_BASE_URL)
|
8
|
+
@api = Esignatur::Api.new(api_key: api_key, base_url: base_url)
|
9
|
+
end
|
10
|
+
|
11
|
+
def orders
|
12
|
+
Orders.new(api: api)
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
attr_reader :api
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'esignatur/pades'
|
4
|
+
require 'active_support/core_ext/string/inflections'
|
5
|
+
|
6
|
+
module Esignatur
|
7
|
+
# esignatur order representation
|
8
|
+
# More info: https://api.esignatur.dk/Documentation/Order
|
9
|
+
class Order
|
10
|
+
attr_reader :id, :response_body
|
11
|
+
|
12
|
+
def self.create(attributes, api:)
|
13
|
+
response = api.post('Order/Create', data: attributes)
|
14
|
+
body = response.json_body
|
15
|
+
new(body.fetch('OrderId'), response_body: response.body, api: api)
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(id, response_body: nil, api:)
|
19
|
+
@id = id
|
20
|
+
@response_body = response_body
|
21
|
+
@api = api
|
22
|
+
end
|
23
|
+
|
24
|
+
def status
|
25
|
+
api.get("status/get/#{id}")
|
26
|
+
end
|
27
|
+
|
28
|
+
def cancel
|
29
|
+
api.get("Order/Cancel/#{id}").success?
|
30
|
+
end
|
31
|
+
|
32
|
+
def pades
|
33
|
+
Pades.new(order: self, api: api)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
attr_reader :api
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Esignatur
|
4
|
+
# esignatur order info collection representation.
|
5
|
+
# more info: https://api.esignatur.dk/Documentation/OrderInfo
|
6
|
+
class Orders
|
7
|
+
include Enumerable
|
8
|
+
|
9
|
+
def initialize(scope: {}, api:)
|
10
|
+
@scope = scope
|
11
|
+
@api = api
|
12
|
+
end
|
13
|
+
|
14
|
+
def create(attributes)
|
15
|
+
Order.create(attributes, api: api)
|
16
|
+
end
|
17
|
+
|
18
|
+
def where(new_scope)
|
19
|
+
self.class.new(scope: scope.merge(new_scope), api: api)
|
20
|
+
end
|
21
|
+
|
22
|
+
def all
|
23
|
+
@all ||= begin
|
24
|
+
response = api.get("OrderInfo/OrdersForAdministrator/#{creator_id}", headers: headers_for_all_query)
|
25
|
+
response.json_body.fetch('SignOrders').map do |raw_order|
|
26
|
+
Order.new(raw_order.fetch('SignOrderId'), response_body: raw_order, api: api)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def each(&block)
|
32
|
+
all.each(&block)
|
33
|
+
end
|
34
|
+
|
35
|
+
def find(id)
|
36
|
+
Order.new(id, api: api)
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
attr_reader :api, :scope
|
42
|
+
|
43
|
+
def headers_for_all_query
|
44
|
+
modified_since = scope[:modified_since]&.iso8601
|
45
|
+
modified_since ? { 'If-Modified-Since' => modified_since } : {}
|
46
|
+
end
|
47
|
+
|
48
|
+
def creator_id
|
49
|
+
scope.fetch(:creator_id) do
|
50
|
+
raise(
|
51
|
+
Esignatur::Error,
|
52
|
+
'You need to specify creator_id in order to fech orders. ' \
|
53
|
+
'You can do this with `esignatur.orders.where(creator_id: 123)`'
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Esignatur
|
4
|
+
# esignature PAdES document representation.
|
5
|
+
# More info: https://api.esignatur.dk/Documentation/Pades
|
6
|
+
class Pades
|
7
|
+
attr_reader :order
|
8
|
+
|
9
|
+
def initialize(order:, api:)
|
10
|
+
@order = order
|
11
|
+
@api = api
|
12
|
+
end
|
13
|
+
|
14
|
+
def document_data
|
15
|
+
Base64.decode64(response_body.fetch('DocumentData'))
|
16
|
+
end
|
17
|
+
|
18
|
+
def response_body
|
19
|
+
@response_body ||= \
|
20
|
+
api.post('Pades/Download', data: { 'Id' => order.id, 'DocumentIndex' => 0 }).json_body
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
attr_reader :api
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,222 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: esignatur
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Povilas Jurcys
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.10'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.16'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.57'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.57'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.27'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.27'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.4'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: codecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 0.1.10
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: 0.1.10
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.16.1
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.16.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-byebug
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
description:
|
168
|
+
email:
|
169
|
+
- po.jurcys@gmail.com
|
170
|
+
executables: []
|
171
|
+
extensions: []
|
172
|
+
extra_rdoc_files: []
|
173
|
+
files:
|
174
|
+
- ".gitignore"
|
175
|
+
- ".hound"
|
176
|
+
- ".rspec"
|
177
|
+
- ".rubocop.yml"
|
178
|
+
- ".ruby-version"
|
179
|
+
- ".travis.yml"
|
180
|
+
- CODE_OF_CONDUCT.md
|
181
|
+
- Gemfile
|
182
|
+
- Gemfile.lock
|
183
|
+
- LICENSE.txt
|
184
|
+
- README.md
|
185
|
+
- Rakefile
|
186
|
+
- bin/console
|
187
|
+
- bin/setup
|
188
|
+
- esignatur.gemspec
|
189
|
+
- lib/esignatur.rb
|
190
|
+
- lib/esignatur/api.rb
|
191
|
+
- lib/esignatur/api/response.rb
|
192
|
+
- lib/esignatur/client.rb
|
193
|
+
- lib/esignatur/error.rb
|
194
|
+
- lib/esignatur/order.rb
|
195
|
+
- lib/esignatur/orders.rb
|
196
|
+
- lib/esignatur/pades.rb
|
197
|
+
- lib/esignatur/version.rb
|
198
|
+
homepage: https://github.com/samesystem/esignatur
|
199
|
+
licenses:
|
200
|
+
- MIT
|
201
|
+
metadata: {}
|
202
|
+
post_install_message:
|
203
|
+
rdoc_options: []
|
204
|
+
require_paths:
|
205
|
+
- lib
|
206
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
207
|
+
requirements:
|
208
|
+
- - ">="
|
209
|
+
- !ruby/object:Gem::Version
|
210
|
+
version: '0'
|
211
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
requirements: []
|
217
|
+
rubyforge_project:
|
218
|
+
rubygems_version: 2.7.6
|
219
|
+
signing_key:
|
220
|
+
specification_version: 4
|
221
|
+
summary: ruby API client for esignatur.dk
|
222
|
+
test_files: []
|