mifiel 1.2.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +2 -0
- data/.rubocop.yml +6 -15
- data/.travis.yml +25 -6
- data/Appraisals +11 -0
- data/Gemfile +2 -6
- data/README.md +25 -0
- data/Rakefile +2 -0
- data/gemfiles/rails_5.gemfile +12 -0
- data/gemfiles/rails_6.gemfile +12 -0
- data/lib/mifiel/base.rb +2 -0
- data/lib/mifiel/certificate.rb +2 -0
- data/lib/mifiel/config.rb +7 -5
- data/lib/mifiel/document.rb +20 -8
- data/lib/mifiel/errors.rb +2 -0
- data/lib/mifiel/template.rb +5 -2
- data/lib/mifiel/user.rb +29 -0
- data/lib/mifiel/version.rb +3 -1
- data/lib/mifiel.rb +4 -1
- data/mifiel.gemspec +19 -25
- data/spec/mifiel/base_spec.rb +2 -0
- data/spec/mifiel/certificate_spec.rb +2 -1
- data/spec/mifiel/document_spec.rb +18 -0
- data/spec/mifiel/template_spec.rb +2 -0
- data/spec/mifiel/user_spec.rb +16 -0
- data/spec/spec_helper.rb +8 -5
- data/spec/support/fake_mifiel.rb +61 -54
- metadata +70 -110
- data/Guardfile +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1569646681fcf22ebc9758654ea1cd69335c0de8fea3be1d91a2141c0c06f83d
|
4
|
+
data.tar.gz: fab079bd4ba6f4edb93a458c934b8e2f783b90296c00bc4e0d0ae0b9d8992d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34ea17ff1b1e888dec3ee6f9f5c2b3460bfa29dfc3629330880d0dfe831760e60e3271c2f80511d8edf2b9e0de3f5708944f221581cbf424b9ac13f7c3be303f
|
7
|
+
data.tar.gz: 6f04cbd056834f0709067c43223c2f695c63e9ea9d2d51a2d6419cef800047065be3d46fe739406c9ed9d260cb7c01a6a123b89ae7e21bb6800b6f57726248ac
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,27 +1,18 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.
|
3
|
-
|
4
|
-
|
5
|
-
Enabled: false
|
6
|
-
|
7
|
-
Style/AlignHash:
|
8
|
-
Enabled: false
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
Exclude:
|
4
|
+
- 'gemfiles/**/*'
|
9
5
|
|
10
|
-
|
11
|
-
|
6
|
+
Layout/LineLength:
|
7
|
+
Max: 190
|
12
8
|
|
13
9
|
Style/Documentation:
|
14
10
|
Enabled: false
|
15
11
|
|
16
|
-
Style/EmptyLinesAroundBlockBody:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
Metrics/LineLength:
|
20
|
-
Max: 190
|
21
|
-
|
22
12
|
Style/HashSyntax:
|
23
13
|
EnforcedStyle: ruby19
|
24
14
|
|
25
15
|
Metrics/BlockLength:
|
26
16
|
Exclude:
|
27
17
|
- 'spec/**/*'
|
18
|
+
- '*.gemspec'
|
data/.travis.yml
CHANGED
@@ -1,15 +1,34 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
sudo: false
|
4
|
+
|
5
|
+
gemfile:
|
6
|
+
- gemfiles/rails_5.gemfile
|
7
|
+
- gemfiles/rails_6.gemfile
|
8
|
+
|
4
9
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.
|
7
|
-
- 2.
|
10
|
+
- 2.3
|
11
|
+
- 2.4
|
12
|
+
- 2.5
|
13
|
+
- 2.6
|
14
|
+
- 2.7
|
15
|
+
- 3.0
|
16
|
+
- 3.1
|
17
|
+
|
8
18
|
notifications:
|
9
19
|
email:
|
10
20
|
on_success: change
|
11
21
|
on_failure: always
|
22
|
+
|
12
23
|
script:
|
13
|
-
- mkdir ./tmp/
|
14
|
-
- bundle exec rubocop
|
15
|
-
- bundle exec rspec
|
24
|
+
- mkdir ./tmp/
|
25
|
+
- bundle exec rubocop
|
26
|
+
- bundle exec rspec
|
27
|
+
|
28
|
+
matrix:
|
29
|
+
exclude:
|
30
|
+
- rvm: 2.3
|
31
|
+
gemfile: gemfiles/rails_6.gemfile
|
32
|
+
- rvm: 2.4
|
33
|
+
gemfile: gemfiles/rails_6.gemfile
|
34
|
+
fast_finish: true
|
data/Appraisals
ADDED
data/Gemfile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in mifiel.gemspec
|
@@ -5,10 +7,4 @@ gemspec
|
|
5
7
|
|
6
8
|
group :development, :test do
|
7
9
|
gem 'coveralls', require: false
|
8
|
-
gem 'guard', '2.13.0'
|
9
|
-
gem 'guard-rspec'
|
10
|
-
# compatible with ruby >= 1.9.3
|
11
|
-
gem 'guard-rubocop'
|
12
|
-
gem 'listen', '3.0.8'
|
13
|
-
gem 'terminal-notifier-guard'
|
14
10
|
end
|
data/README.md
CHANGED
@@ -38,6 +38,7 @@ Then you can configure the gem with:
|
|
38
38
|
Mifiel.config do |config|
|
39
39
|
config.app_id = '<APP_ID>'
|
40
40
|
config.app_secret = '<APP_SECRET>'
|
41
|
+
config.base_url = 'https://app-sandbox.mifiel.com/api/v1' #remove this line when you wish to use the prod environment
|
41
42
|
end
|
42
43
|
```
|
43
44
|
|
@@ -149,6 +150,30 @@ Certificate methods:
|
|
149
150
|
certificate.delete
|
150
151
|
```
|
151
152
|
|
153
|
+
User methods
|
154
|
+
|
155
|
+
- Setup Widget
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
args = {
|
159
|
+
email: 'some@email.com',
|
160
|
+
tax_id: 'AAA010101AAA',
|
161
|
+
callback_url: 'http://some-callback.url'
|
162
|
+
}
|
163
|
+
|
164
|
+
user = Mifiel::User.setup_widget(args)
|
165
|
+
user.widget_id
|
166
|
+
```
|
167
|
+
|
168
|
+
Filtering Results
|
169
|
+
|
170
|
+
Our API returns a JSON list of items, this result can be filtered using a `where` method matching a specified criteria (or matching using regular expressions):
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
document = Mifiel::Document.find('id')
|
174
|
+
document.signers.where(field: /receiver|issuer/, email: 'some@email.com')
|
175
|
+
```
|
176
|
+
|
152
177
|
## Contributing
|
153
178
|
|
154
179
|
1. Fork it ( https://github.com/[my-github-username]/mifiel/fork )
|
data/Rakefile
CHANGED
data/lib/mifiel/base.rb
CHANGED
data/lib/mifiel/certificate.rb
CHANGED
data/lib/mifiel/config.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Mifiel
|
2
4
|
module Config
|
3
5
|
class << self
|
@@ -26,11 +28,11 @@ module Mifiel
|
|
26
28
|
|
27
29
|
private
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
def set_api_auth_credentials
|
32
|
+
Flexirest::Base.base_url = base_url
|
33
|
+
Flexirest::Base.api_auth_credentials(app_id, app_secret)
|
34
|
+
Flexirest::Base.request_body_type = :json
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
reset
|
data/lib/mifiel/document.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'open3'
|
2
4
|
require 'api-auth'
|
3
5
|
|
@@ -19,6 +21,7 @@ module Mifiel
|
|
19
21
|
callback_url = args[:callback_url]
|
20
22
|
raise ArgumentError, 'Either file or hash must be provided' if !file && !hash
|
21
23
|
raise ArgumentError, 'Only one of file or hash must be provided' if file && hash
|
24
|
+
|
22
25
|
payload = {
|
23
26
|
signatories: build_signatories(signatories),
|
24
27
|
callback_url: callback_url,
|
@@ -33,20 +36,30 @@ module Mifiel
|
|
33
36
|
end
|
34
37
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
35
38
|
|
36
|
-
def request_signature(email, cc: nil)
|
39
|
+
def request_signature(email, cc: nil) # rubocop:disable Naming/MethodParameterName
|
37
40
|
params = { email: email }
|
38
41
|
params[:cc] = cc if cc.is_a?(Array)
|
39
42
|
Mifiel::Document._request("#{Mifiel.config.base_url}/documents/#{id}/request_signature", :post, params)
|
40
43
|
end
|
41
44
|
|
42
|
-
def
|
45
|
+
def raw_data
|
43
46
|
response = Mifiel::Document.process_request("/documents/#{id}/file", :get)
|
44
|
-
|
47
|
+
|
48
|
+
response.body
|
45
49
|
end
|
46
50
|
|
47
|
-
def
|
51
|
+
def save_file(path)
|
52
|
+
File.open(path, 'wb') { |file| file.write(raw_data) }
|
53
|
+
end
|
54
|
+
|
55
|
+
def raw_signed_data
|
48
56
|
response = Mifiel::Document.process_request("/documents/#{id}/file_signed", :get)
|
49
|
-
|
57
|
+
|
58
|
+
response.body
|
59
|
+
end
|
60
|
+
|
61
|
+
def save_file_signed(path)
|
62
|
+
File.open(path, 'wb') { |file| file.write(raw_signed_data) }
|
50
63
|
end
|
51
64
|
|
52
65
|
def save_xml(path)
|
@@ -54,10 +67,9 @@ module Mifiel
|
|
54
67
|
File.open(path, 'w') { |file| file.write(response) }
|
55
68
|
end
|
56
69
|
|
57
|
-
def self.process_request(path, method, payload=nil)
|
58
|
-
path[0] = '' if path[0] == '/'
|
70
|
+
def self.process_request(path, method, payload = nil)
|
59
71
|
rest_request = RestClient::Request.new(
|
60
|
-
url: "#{Mifiel.config.base_url}/#{path}",
|
72
|
+
url: "#{Mifiel.config.base_url}/#{path.gsub(%r{^\/}, '')}",
|
61
73
|
method: method,
|
62
74
|
payload: payload,
|
63
75
|
ssl_version: 'SSLv23'
|
data/lib/mifiel/errors.rb
CHANGED
data/lib/mifiel/template.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Mifiel
|
2
4
|
class Template < Mifiel::Base
|
3
5
|
get :all, '/templates'
|
@@ -5,14 +7,15 @@ module Mifiel
|
|
5
7
|
put :save, '/templates/:id'
|
6
8
|
post :create, '/templates'
|
7
9
|
delete :delete, '/templates/:id'
|
10
|
+
get :fields, '/templates/:id/fields'
|
8
11
|
|
9
12
|
def generate_document(args = {})
|
10
13
|
Mifiel::Document.create_from_template(args.merge(template_id: id))
|
11
14
|
end
|
12
15
|
|
13
|
-
def generate_documents(callback_url:, identifier: nil
|
16
|
+
def generate_documents(callback_url:, documents:, identifier: nil)
|
14
17
|
Mifiel::Document.create_many_from_template(
|
15
|
-
template_id:
|
18
|
+
template_id: id,
|
16
19
|
identifier: identifier,
|
17
20
|
documents: documents,
|
18
21
|
callback_url: callback_url
|
data/lib/mifiel/user.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mifiel
|
4
|
+
class User < Mifiel::Base
|
5
|
+
post :setup_widget, '/users/setup-widget'
|
6
|
+
|
7
|
+
def self.setup_widget(args) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
8
|
+
email = args[:email]
|
9
|
+
tax_id = args[:tax_id]
|
10
|
+
callback_url = args[:callback_url]
|
11
|
+
|
12
|
+
raise ArgumentError, 'Email must be provided' unless email
|
13
|
+
raise ArgumentError, 'Tax id must be provided' unless tax_id
|
14
|
+
|
15
|
+
rest_request = RestClient::Request.new(
|
16
|
+
url: "#{Mifiel.config.base_url}/users/setup-widget",
|
17
|
+
method: :post,
|
18
|
+
payload: {
|
19
|
+
email: email,
|
20
|
+
tax_id: tax_id,
|
21
|
+
callback_url: callback_url
|
22
|
+
},
|
23
|
+
ssl_version: 'SSLv23'
|
24
|
+
)
|
25
|
+
req = ApiAuth.sign!(rest_request, Mifiel.config.app_id, Mifiel.config.app_secret)
|
26
|
+
Mifiel::User.new(JSON.parse(req.execute))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/mifiel/version.rb
CHANGED
data/lib/mifiel.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'flexirest'
|
2
4
|
|
3
5
|
module Mifiel
|
@@ -7,8 +9,9 @@ module Mifiel
|
|
7
9
|
autoload :Certificate, 'mifiel/certificate'
|
8
10
|
autoload :Template, 'mifiel/template'
|
9
11
|
autoload :Config, 'mifiel/config'
|
12
|
+
autoload :User, 'mifiel/user'
|
10
13
|
|
11
|
-
BASE_URL = 'https://www.mifiel.com/api/v1'
|
14
|
+
BASE_URL = 'https://www.mifiel.com/api/v1'
|
12
15
|
|
13
16
|
def self.config
|
14
17
|
if block_given?
|
data/mifiel.gemspec
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
4
6
|
require 'mifiel/version'
|
5
7
|
|
6
|
-
# rubocop:disable Metrics/BlockLength
|
7
8
|
Gem::Specification.new do |spec|
|
8
9
|
spec.name = 'mifiel'
|
9
10
|
spec.version = Mifiel::VERSION
|
@@ -17,28 +18,21 @@ Gem::Specification.new do |spec|
|
|
17
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
20
|
spec.require_paths = ['lib']
|
20
|
-
spec.required_ruby_version = '
|
21
|
+
spec.required_ruby_version = '>= 2.3'
|
21
22
|
|
22
|
-
spec.add_runtime_dependency '
|
23
|
-
spec.add_runtime_dependency '
|
24
|
-
spec.add_runtime_dependency '
|
25
|
-
|
26
|
-
|
27
|
-
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('2.2.2')
|
28
|
-
spec.add_runtime_dependency 'activesupport'
|
29
|
-
else
|
30
|
-
spec.add_runtime_dependency 'activesupport', '< 5.0.0'
|
31
|
-
end
|
32
|
-
spec.add_runtime_dependency 'flexirest', '~> 1.3.35'
|
23
|
+
spec.add_runtime_dependency 'activesupport'
|
24
|
+
spec.add_runtime_dependency 'api-auth', '~> 1.4'
|
25
|
+
spec.add_runtime_dependency 'flexirest', '~> 1.6'
|
26
|
+
spec.add_runtime_dependency 'json', '>= 1.8'
|
27
|
+
spec.add_runtime_dependency 'rest-client', '>= 1.8'
|
33
28
|
|
34
|
-
spec.add_development_dependency '
|
35
|
-
spec.add_development_dependency '
|
36
|
-
spec.add_development_dependency '
|
37
|
-
spec.add_development_dependency '
|
38
|
-
spec.add_development_dependency '
|
39
|
-
spec.add_development_dependency '
|
40
|
-
spec.add_development_dependency '
|
41
|
-
spec.add_development_dependency 'sinatra'
|
42
|
-
spec.add_development_dependency '
|
43
|
-
spec.add_development_dependency 'simplecov', '~> 0.15'
|
29
|
+
spec.add_development_dependency 'appraisal'
|
30
|
+
spec.add_development_dependency 'bump', '~> 0.5', '>= 0.5.3'
|
31
|
+
spec.add_development_dependency 'bundler'
|
32
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.10'
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 1.24'
|
35
|
+
spec.add_development_dependency 'simplecov', '~> 0.21'
|
36
|
+
spec.add_development_dependency 'sinatra'
|
37
|
+
spec.add_development_dependency 'webmock'
|
44
38
|
end
|
data/spec/mifiel/base_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
describe Mifiel::Document do
|
2
4
|
let!(:certificate) { File.read('spec/fixtures/FIEL_AAA010101AAA.cer') }
|
3
5
|
let!(:private_key) { File.read('spec/fixtures/FIEL_AAA010101AAA.key') }
|
@@ -68,6 +70,22 @@ describe Mifiel::Document do
|
|
68
70
|
describe 'working with a document' do
|
69
71
|
let!(:document) { Mifiel::Document.all.first }
|
70
72
|
|
73
|
+
describe '#raw_data' do
|
74
|
+
let(:document_content) { 'some-pdf-formatted-string' }
|
75
|
+
|
76
|
+
it 'should get the file raw data' do
|
77
|
+
expect(document.raw_data).to eq document_content
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#raw_signed_data' do
|
82
|
+
let(:document_content) { 'some-pdf-formatted-string' }
|
83
|
+
|
84
|
+
it 'should get the file raw signed data' do
|
85
|
+
expect(document.raw_signed_data).to eq document_content
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
71
89
|
describe '#save_file' do
|
72
90
|
let!(:path) { 'tmp/the-file.pdf' }
|
73
91
|
before { File.unlink(path) if File.exist?(path) }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Mifiel::User do
|
4
|
+
describe '#setup_widget' do
|
5
|
+
let(:user) do
|
6
|
+
Mifiel::User.setup_widget(
|
7
|
+
email: 'user@email.com',
|
8
|
+
tax_id: 'AAA010101AAA',
|
9
|
+
callback_url: 'http://some-callback.url/mifiel'
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
it { expect(user.success).to be_truthy }
|
14
|
+
it { expect(user.widget_id).to_not be_nil }
|
15
|
+
end
|
16
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,26 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'pry'
|
2
|
-
require 'byebug'
|
3
|
-
require 'pry-byebug'
|
4
4
|
require 'mifiel'
|
5
5
|
require 'webmock/rspec'
|
6
|
-
|
7
6
|
require 'simplecov'
|
8
7
|
require 'coveralls'
|
8
|
+
|
9
9
|
SimpleCov.start do
|
10
10
|
add_filter '/spec/'
|
11
11
|
end
|
12
|
+
|
12
13
|
Coveralls.wear!
|
13
14
|
|
14
|
-
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
15
|
+
Dir['./spec/support/**/*.rb'].sort.each { |f| require f }
|
15
16
|
|
16
17
|
RSpec.configure do |config|
|
17
|
-
|
18
18
|
config.before(:suite) do
|
19
19
|
Mifiel.config do |conf|
|
20
20
|
conf.app_id = 'APP_ID'
|
21
21
|
conf.app_secret = 'APP_SECRET'
|
22
22
|
conf.base_url = 'http://www.mifiel.com/api/v1'
|
23
23
|
end
|
24
|
+
|
25
|
+
# Creates ruby-api-client/tmp folder so signed files can be saved correctly
|
26
|
+
Dir.mkdir 'tmp' unless File.directory? 'tmp'
|
24
27
|
end
|
25
28
|
|
26
29
|
config.before(:each) do
|
data/spec/support/fake_mifiel.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sinatra/base'
|
2
|
-
|
3
|
-
class FakeMifiel < Sinatra::Base
|
4
|
+
|
5
|
+
class FakeMifiel < Sinatra::Base # rubocop:disable Metrics/ClassLength
|
4
6
|
get '/api/v1/keys' do
|
5
7
|
content_type :json
|
6
8
|
status 200
|
@@ -99,61 +101,66 @@ class FakeMifiel < Sinatra::Base
|
|
99
101
|
{ bla: 'Correo enviado' }.to_json
|
100
102
|
end
|
101
103
|
|
104
|
+
post '/api/v1/users/setup-widget' do
|
105
|
+
content_type :json
|
106
|
+
status 200
|
107
|
+
{ widget_id: '123bc', success: true }.to_json
|
108
|
+
end
|
109
|
+
|
102
110
|
private
|
103
111
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
112
|
+
def template(args = {})
|
113
|
+
{
|
114
|
+
id: args[:id] || SecureRandom.uuid,
|
115
|
+
name: 'some-template',
|
116
|
+
content: '<div><field name="name">NAME</field></div>'
|
117
|
+
}
|
118
|
+
end
|
119
|
+
|
120
|
+
def key(args = {})
|
121
|
+
id = args[:id] || SecureRandom.uuid
|
122
|
+
{
|
123
|
+
id: id,
|
124
|
+
type_of: 'FIEL',
|
125
|
+
cer_hex: '308204cf30...1303030303030323',
|
126
|
+
owner: 'JORGE MORALES MENDEZ',
|
127
|
+
tax_id: 'MOMJ811012643',
|
128
|
+
expires_at: '2017-04-28T19:43:23.000Z',
|
129
|
+
expired: false
|
130
|
+
}
|
131
|
+
end
|
132
|
+
|
133
|
+
def document(args = {}) # rubocop:disable Metrics/MethodLength
|
134
|
+
id = args[:id] || SecureRandom.uuid
|
135
|
+
{
|
136
|
+
id: id,
|
137
|
+
original_hash: Digest::SHA256.hexdigest(id),
|
138
|
+
file_file_name: 'test-pdf.pdf',
|
139
|
+
signed_by_all: true,
|
140
|
+
signed: true,
|
141
|
+
signed_at: Time.now.utc.iso8601,
|
142
|
+
status: [1, 'Firmado'],
|
143
|
+
owner: {
|
144
|
+
email: 'signer1@email.com',
|
145
|
+
name: 'Jorge Morales'
|
146
|
+
},
|
147
|
+
file: "/api/v1/documents/#{id}/file",
|
148
|
+
file_download: "/api/v1/documents/#{id}/file?download=true",
|
149
|
+
file_signed: "/api/v1/documents/#{id}/file_signed",
|
150
|
+
file_signed_download: "/api/v1/documents/#{id}/file_signed?download=true",
|
151
|
+
file_zipped: "/api/v1/documents/#{id}/zip",
|
152
|
+
signatures: [{
|
153
|
+
email: 'signer1@email.com',
|
133
154
|
signed: true,
|
134
|
-
signed_at: Time.now.utc.iso8601,
|
135
|
-
|
136
|
-
|
155
|
+
signed_at: (Time.now.utc - 10_000).iso8601,
|
156
|
+
certificate_number: '20001000000200001410',
|
157
|
+
tax_id: 'AAA010101AAA',
|
158
|
+
signature: '77cd5156779c..4e276ef1056c1de11b7f70bed28',
|
159
|
+
user: {
|
137
160
|
email: 'signer1@email.com',
|
138
161
|
name: 'Jorge Morales'
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
file_signed_download: "/api/v1/documents/#{id}/file_signed?download=true",
|
144
|
-
file_zipped: "/api/v1/documents/#{id}/zip",
|
145
|
-
signatures: [{
|
146
|
-
email: 'signer1@email.com',
|
147
|
-
signed: true,
|
148
|
-
signed_at: (Time.now.utc - 10_000).iso8601,
|
149
|
-
certificate_number: '20001000000200001410',
|
150
|
-
tax_id: 'AAA010101AAA',
|
151
|
-
signature: '77cd5156779c..4e276ef1056c1de11b7f70bed28',
|
152
|
-
user: {
|
153
|
-
email: 'signer1@email.com',
|
154
|
-
name: 'Jorge Morales'
|
155
|
-
}
|
156
|
-
}]
|
157
|
-
}
|
158
|
-
end
|
162
|
+
}
|
163
|
+
}]
|
164
|
+
}
|
165
|
+
end
|
159
166
|
end
|
metadata
CHANGED
@@ -1,262 +1,218 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mifiel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genaro Madrid
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: api-auth
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: flexirest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.6'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: '1.8'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: '1.8'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rest-client
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.
|
75
|
+
version: '1.8'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.
|
82
|
+
version: '1.8'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: appraisal
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: bump
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '0.5'
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: 0.5.3
|
104
107
|
type: :development
|
105
108
|
prerelease: false
|
106
109
|
version_requirements: !ruby/object:Gem::Requirement
|
107
110
|
requirements:
|
108
111
|
- - "~>"
|
109
112
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
113
|
+
version: '0.5'
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 0.5.3
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
118
|
+
name: bundler
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
114
120
|
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '3.1'
|
118
121
|
- - ">="
|
119
122
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
123
|
+
version: '0'
|
121
124
|
type: :development
|
122
125
|
prerelease: false
|
123
126
|
version_requirements: !ruby/object:Gem::Requirement
|
124
127
|
requirements:
|
125
|
-
- - "~>"
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
version: '3.1'
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
130
|
+
version: '0'
|
131
131
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
132
|
+
name: rake
|
133
133
|
requirement: !ruby/object:Gem::Requirement
|
134
134
|
requirements:
|
135
135
|
- - "~>"
|
136
136
|
- !ruby/object:Gem::Version
|
137
|
-
version: '
|
138
|
-
- - "<"
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
version: 9.0.6
|
137
|
+
version: '13.0'
|
141
138
|
type: :development
|
142
139
|
prerelease: false
|
143
140
|
version_requirements: !ruby/object:Gem::Requirement
|
144
141
|
requirements:
|
145
142
|
- - "~>"
|
146
143
|
- !ruby/object:Gem::Version
|
147
|
-
version: '
|
148
|
-
- - "<"
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: 9.0.6
|
144
|
+
version: '13.0'
|
151
145
|
- !ruby/object:Gem::Dependency
|
152
|
-
name:
|
146
|
+
name: rspec
|
153
147
|
requirement: !ruby/object:Gem::Requirement
|
154
148
|
requirements:
|
155
149
|
- - "~>"
|
156
150
|
- !ruby/object:Gem::Version
|
157
|
-
version: '3.
|
158
|
-
- - ">="
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
version: 3.3.0
|
151
|
+
version: '3.10'
|
161
152
|
type: :development
|
162
153
|
prerelease: false
|
163
154
|
version_requirements: !ruby/object:Gem::Requirement
|
164
155
|
requirements:
|
165
156
|
- - "~>"
|
166
157
|
- !ruby/object:Gem::Version
|
167
|
-
version: '3.
|
168
|
-
- - ">="
|
169
|
-
- !ruby/object:Gem::Version
|
170
|
-
version: 3.3.0
|
158
|
+
version: '3.10'
|
171
159
|
- !ruby/object:Gem::Dependency
|
172
|
-
name:
|
160
|
+
name: rubocop
|
173
161
|
requirement: !ruby/object:Gem::Requirement
|
174
162
|
requirements:
|
175
163
|
- - "~>"
|
176
164
|
- !ruby/object:Gem::Version
|
177
|
-
version: '
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 0.5.3
|
165
|
+
version: '1.24'
|
181
166
|
type: :development
|
182
167
|
prerelease: false
|
183
168
|
version_requirements: !ruby/object:Gem::Requirement
|
184
169
|
requirements:
|
185
170
|
- - "~>"
|
186
171
|
- !ruby/object:Gem::Version
|
187
|
-
version: '
|
188
|
-
- - ">="
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version: 0.5.3
|
172
|
+
version: '1.24'
|
191
173
|
- !ruby/object:Gem::Dependency
|
192
|
-
name:
|
174
|
+
name: simplecov
|
193
175
|
requirement: !ruby/object:Gem::Requirement
|
194
176
|
requirements:
|
195
177
|
- - "~>"
|
196
178
|
- !ruby/object:Gem::Version
|
197
|
-
version: '
|
198
|
-
- - ">="
|
199
|
-
- !ruby/object:Gem::Version
|
200
|
-
version: 1.22.2
|
179
|
+
version: '0.21'
|
201
180
|
type: :development
|
202
181
|
prerelease: false
|
203
182
|
version_requirements: !ruby/object:Gem::Requirement
|
204
183
|
requirements:
|
205
184
|
- - "~>"
|
206
185
|
- !ruby/object:Gem::Version
|
207
|
-
version: '
|
208
|
-
- - ">="
|
209
|
-
- !ruby/object:Gem::Version
|
210
|
-
version: 1.22.2
|
186
|
+
version: '0.21'
|
211
187
|
- !ruby/object:Gem::Dependency
|
212
188
|
name: sinatra
|
213
189
|
requirement: !ruby/object:Gem::Requirement
|
214
190
|
requirements:
|
215
|
-
- - "~>"
|
216
|
-
- !ruby/object:Gem::Version
|
217
|
-
version: '1.4'
|
218
191
|
- - ">="
|
219
192
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
193
|
+
version: '0'
|
221
194
|
type: :development
|
222
195
|
prerelease: false
|
223
196
|
version_requirements: !ruby/object:Gem::Requirement
|
224
197
|
requirements:
|
225
|
-
- - "~>"
|
226
|
-
- !ruby/object:Gem::Version
|
227
|
-
version: '1.4'
|
228
198
|
- - ">="
|
229
199
|
- !ruby/object:Gem::Version
|
230
|
-
version:
|
200
|
+
version: '0'
|
231
201
|
- !ruby/object:Gem::Dependency
|
232
|
-
name:
|
233
|
-
requirement: !ruby/object:Gem::Requirement
|
234
|
-
requirements:
|
235
|
-
- - '='
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
version: 0.47.1
|
238
|
-
type: :development
|
239
|
-
prerelease: false
|
240
|
-
version_requirements: !ruby/object:Gem::Requirement
|
241
|
-
requirements:
|
242
|
-
- - '='
|
243
|
-
- !ruby/object:Gem::Version
|
244
|
-
version: 0.47.1
|
245
|
-
- !ruby/object:Gem::Dependency
|
246
|
-
name: simplecov
|
202
|
+
name: webmock
|
247
203
|
requirement: !ruby/object:Gem::Requirement
|
248
204
|
requirements:
|
249
|
-
- - "
|
205
|
+
- - ">="
|
250
206
|
- !ruby/object:Gem::Version
|
251
|
-
version: '0
|
207
|
+
version: '0'
|
252
208
|
type: :development
|
253
209
|
prerelease: false
|
254
210
|
version_requirements: !ruby/object:Gem::Requirement
|
255
211
|
requirements:
|
256
|
-
- - "
|
212
|
+
- - ">="
|
257
213
|
- !ruby/object:Gem::Version
|
258
|
-
version: '0
|
259
|
-
description:
|
214
|
+
version: '0'
|
215
|
+
description:
|
260
216
|
email:
|
261
217
|
- genmadrid@gmail.com
|
262
218
|
executables: []
|
@@ -268,12 +224,14 @@ files:
|
|
268
224
|
- ".rspec"
|
269
225
|
- ".rubocop.yml"
|
270
226
|
- ".travis.yml"
|
227
|
+
- Appraisals
|
271
228
|
- Gemfile
|
272
|
-
- Guardfile
|
273
229
|
- LICENSE.txt
|
274
230
|
- README.md
|
275
231
|
- Rakefile
|
276
232
|
- bump
|
233
|
+
- gemfiles/rails_5.gemfile
|
234
|
+
- gemfiles/rails_6.gemfile
|
277
235
|
- lib/mifiel.rb
|
278
236
|
- lib/mifiel/base.rb
|
279
237
|
- lib/mifiel/certificate.rb
|
@@ -281,6 +239,7 @@ files:
|
|
281
239
|
- lib/mifiel/document.rb
|
282
240
|
- lib/mifiel/errors.rb
|
283
241
|
- lib/mifiel/template.rb
|
242
|
+
- lib/mifiel/user.rb
|
284
243
|
- lib/mifiel/version.rb
|
285
244
|
- mifiel-ruby-api-client.sublime-project
|
286
245
|
- mifiel.gemspec
|
@@ -291,30 +250,30 @@ files:
|
|
291
250
|
- spec/mifiel/certificate_spec.rb
|
292
251
|
- spec/mifiel/document_spec.rb
|
293
252
|
- spec/mifiel/template_spec.rb
|
253
|
+
- spec/mifiel/user_spec.rb
|
294
254
|
- spec/spec_helper.rb
|
295
255
|
- spec/support/fake_mifiel.rb
|
296
256
|
homepage: https://www.mifiel.com
|
297
257
|
licenses:
|
298
258
|
- MIT
|
299
259
|
metadata: {}
|
300
|
-
post_install_message:
|
260
|
+
post_install_message:
|
301
261
|
rdoc_options: []
|
302
262
|
require_paths:
|
303
263
|
- lib
|
304
264
|
required_ruby_version: !ruby/object:Gem::Requirement
|
305
265
|
requirements:
|
306
|
-
- - "
|
266
|
+
- - ">="
|
307
267
|
- !ruby/object:Gem::Version
|
308
|
-
version: '2.
|
268
|
+
version: '2.3'
|
309
269
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
310
270
|
requirements:
|
311
271
|
- - ">="
|
312
272
|
- !ruby/object:Gem::Version
|
313
273
|
version: '0'
|
314
274
|
requirements: []
|
315
|
-
|
316
|
-
|
317
|
-
signing_key:
|
275
|
+
rubygems_version: 3.1.6
|
276
|
+
signing_key:
|
318
277
|
specification_version: 4
|
319
278
|
summary: Ruby SDK for mifiel.com.
|
320
279
|
test_files:
|
@@ -325,5 +284,6 @@ test_files:
|
|
325
284
|
- spec/mifiel/certificate_spec.rb
|
326
285
|
- spec/mifiel/document_spec.rb
|
327
286
|
- spec/mifiel/template_spec.rb
|
287
|
+
- spec/mifiel/user_spec.rb
|
328
288
|
- spec/spec_helper.rb
|
329
289
|
- spec/support/fake_mifiel.rb
|
data/Guardfile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
notification :terminal_notifier
|
2
|
-
|
3
|
-
rspec_options = {
|
4
|
-
all_after_pass: false,
|
5
|
-
cmd: 'rspec spec',
|
6
|
-
failed_mode: :focus
|
7
|
-
}
|
8
|
-
|
9
|
-
clearing :on
|
10
|
-
|
11
|
-
guard :rspec, rspec_options do
|
12
|
-
require 'ostruct'
|
13
|
-
|
14
|
-
# Generic Ruby apps
|
15
|
-
rspec = OpenStruct.new
|
16
|
-
rspec.spec = ->(m) { "spec/#{m}_spec.rb" }
|
17
|
-
rspec.spec_dir = 'spec'
|
18
|
-
rspec.spec_helper = 'spec/spec_helper.rb'
|
19
|
-
|
20
|
-
watch(%r{^spec/.+_spec\.rb$})
|
21
|
-
watch(%r{^lib/mifiel/(.+)\.rb$}) do |m|
|
22
|
-
"spec/mifiel/#{m[1]}_spec.rb"
|
23
|
-
end
|
24
|
-
watch(%r{^lib/mifiel/(.+)\.rb$}) do |m|
|
25
|
-
"spec/mifiel/integration/#{m[1]}_spec.rb"
|
26
|
-
end
|
27
|
-
watch(rspec.spec_helper) { rspec.spec_dir }
|
28
|
-
end
|
29
|
-
|
30
|
-
rubocop_opts = {
|
31
|
-
all_on_start: false,
|
32
|
-
cli: '--format html -o rubocop.html'
|
33
|
-
}
|
34
|
-
guard :rubocop, rubocop_opts do
|
35
|
-
watch(/.+\.rb$/)
|
36
|
-
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
37
|
-
end
|