mifiel 1.1.5 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f69a5effdcf36a00714f822894e9d8bae1575df
4
- data.tar.gz: e4e318ac7d2bf6d08cfaa55e1d2c453136a28a03
3
+ metadata.gz: 1772670719d1f6b0a3701a741a365e1365aed0e5
4
+ data.tar.gz: 6c35a0f222ce5fe6d21d7559fb813a6f41f2a1c9
5
5
  SHA512:
6
- metadata.gz: 2bd326f9cc687b91bc2d51cd5bafb7f055a6dd29e5a54ea5825be696f85e41ceb8130e9e35a82f216f64d218ef0465b1dabff910fc89c848b1920f8ddc44f4be
7
- data.tar.gz: 6a7c20d3cba57c93b264d2114b8f23d231fa5fed876c6cdf2a4e4e16afa72a757642664ebb6d0a0b837057b4776d0c5f50b0c33db63201768e434c0ee35ad4ae
6
+ metadata.gz: dd0ca66ba48690fcfb88f5186293b0e8b4dcf1a96f2d903c5aa0f173ceecc6ba5cb5abbee468b567d21501707be7e23b73d7f3460506b509562cf05c8219a8b7
7
+ data.tar.gz: 22f6a6bb79aa959591450e0e7267e078e20d543e460b61b58995ca808b4720004c9ddcf6a4dd3f5efbe13699616bb25c07866214231d64871547a2f7139f90a4
@@ -5,6 +5,7 @@ module Mifiel
5
5
  autoload :Base, 'mifiel/base'
6
6
  autoload :Document, 'mifiel/document'
7
7
  autoload :Certificate, 'mifiel/certificate'
8
+ autoload :Template, 'mifiel/template'
8
9
  autoload :Config, 'mifiel/config'
9
10
 
10
11
  BASE_URL = 'https://www.mifiel.com/api/v1'.freeze
@@ -7,6 +7,8 @@ module Mifiel
7
7
  get :find, '/documents/:id'
8
8
  put :save, '/documents/:id'
9
9
  delete :delete, '/documents/:id'
10
+ post :create_from_template, '/templates/:template_id/generate_document', timeout: 60
11
+ post :create_many_from_template, '/templates/:template_id/generate_documents', timeout: 60
10
12
 
11
13
  # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
12
14
  def self.create(args)
@@ -0,0 +1,22 @@
1
+ module Mifiel
2
+ class Template < Mifiel::Base
3
+ get :all, '/templates'
4
+ get :find, '/templates/:id'
5
+ put :save, '/templates/:id'
6
+ post :create, '/templates'
7
+ delete :delete, '/templates/:id'
8
+
9
+ def generate_document(args = {})
10
+ Mifiel::Document.create_from_template(args.merge(template_id: id))
11
+ end
12
+
13
+ def generate_documents(callback_url:, identifier: nil, documents:)
14
+ Mifiel::Document.create_many_from_template(
15
+ template_id: template_id,
16
+ identifier: identifier,
17
+ documents: documents,
18
+ callback_url: callback_url
19
+ )
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Mifiel
2
- VERSION = '1.1.5'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
@@ -19,8 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ['lib']
20
20
  spec.required_ruby_version = '~> 2.1'
21
21
 
22
- spec.add_runtime_dependency 'rest-client', '>= 1.7'
23
- spec.add_runtime_dependency 'json', '> 0'
22
+ spec.add_runtime_dependency 'rest-client', '>= 1.8'
23
+ spec.add_runtime_dependency 'json', '~> 1.8'
24
24
  spec.add_runtime_dependency 'api-auth', '~> 1.4'
25
25
  # Use Gem::Version to parse the Ruby version for reliable comparison
26
26
  # ActiveSupport 5+ requires Ruby 2.2.2
@@ -34,11 +34,11 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'bundler', '~> 1.6'
35
35
  spec.add_development_dependency 'rake', '~> 10.0'
36
36
  spec.add_development_dependency 'rspec', '~> 3.1', '>= 3.1.7'
37
- spec.add_development_dependency 'pry', '~> 0.10', '>= 0.10.1'
38
- spec.add_development_dependency 'pry-byebug', '~> 3.3', '>= 3.3.0'
37
+ spec.add_development_dependency 'byebug', '~> 9.0', '< 9.0.6'
38
+ spec.add_development_dependency 'pry-byebug', '~> 3.4', '>= 3.3.0'
39
39
  spec.add_development_dependency 'bump', '~> 0.5', '>= 0.5.3'
40
40
  spec.add_development_dependency 'webmock', '~> 1.22', '>= 1.22.2'
41
41
  spec.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.7'
42
42
  spec.add_development_dependency 'rubocop', '0.47.1'
43
- spec.add_development_dependency 'simplecov', '~> 0.11'
43
+ spec.add_development_dependency 'simplecov', '~> 0.15'
44
44
  end
@@ -17,6 +17,52 @@ describe Mifiel::Document do
17
17
 
18
18
  it { expect(document).to be_a(Mifiel::Document) }
19
19
  end
20
+
21
+ context 'from template' do
22
+ let!(:template_id) { 'c6c29866-7fd6-4f77-9ecd-eae8bc3a772a' }
23
+ let!(:document) do
24
+ Mifiel::Document.create_from_template(
25
+ template_id: template_id,
26
+ fields: {
27
+ name: 'some'
28
+ },
29
+ signatories: [{
30
+ name: 'Signer',
31
+ email: 'signer@email.com'
32
+ }, {
33
+ name: 'Signer',
34
+ email: 'signer@email.com'
35
+ }]
36
+ )
37
+ end
38
+
39
+ it { expect(document).to be_a Mifiel::Document }
40
+ end
41
+
42
+ context 'many from template' do
43
+ let!(:template_id) { 'c6c29866-7fd6-4f77-9ecd-eae8bc3a772a' }
44
+ let!(:documents) do
45
+ Mifiel::Document.create_many_from_template(
46
+ template_id: template_id,
47
+ callback_url: 'http://some-callback.url/mifiel',
48
+ identifier: 'name',
49
+ documents: [{
50
+ fields: {
51
+ name: 'Some Name'
52
+ },
53
+ signatories: [{
54
+ name: 'Signer',
55
+ email: 'signer@email.com'
56
+ }, {
57
+ name: 'Signer',
58
+ email: 'signer@email.com'
59
+ }]
60
+ }]
61
+ )
62
+ end
63
+
64
+ it { expect(documents.status).to eq 'success' }
65
+ end
20
66
  end
21
67
 
22
68
  describe 'working with a document' do
@@ -0,0 +1,36 @@
1
+ describe Mifiel::Template do
2
+ let!(:template_id) { 'bb7d65b4-47f1-470e-85e4-22ddae86f9ea' }
3
+
4
+ shared_examples 'a valid template' do
5
+ it { expect(template).to be_a(Mifiel::Template) }
6
+ it { expect(template).to respond_to(:id) }
7
+ it { expect(template).to respond_to(:name) }
8
+ end
9
+
10
+ describe '#create' do
11
+ let!(:template) do
12
+ Mifiel::Template.create(
13
+ name: 'Some Template',
14
+ content: '<div>Some <field name="name" type="string">NAME</field></div>',
15
+ header: 'Genaros Header',
16
+ footer: 'Genaros Footer'
17
+ )
18
+ end
19
+ it_behaves_like 'a valid template'
20
+ end
21
+
22
+ describe '#find' do
23
+ let!(:template) { Mifiel::Template.find(template_id) }
24
+
25
+ it_behaves_like 'a valid template'
26
+ it { expect(template.id).to eq(template_id) }
27
+ end
28
+
29
+ describe '#all' do
30
+ it 'should respond with many templates' do
31
+ templates = Mifiel::Template.all
32
+ expect(templates.count).to be > 0
33
+ expect(templates.first).to be_a(Mifiel::Template)
34
+ end
35
+ end
36
+ end
@@ -10,6 +10,39 @@ class FakeMifiel < Sinatra::Base
10
10
  ].to_json
11
11
  end
12
12
 
13
+ get '/api/v1/templates' do
14
+ content_type :json
15
+ status 200
16
+ [
17
+ template,
18
+ template
19
+ ].to_json
20
+ end
21
+
22
+ get '/api/v1/templates/:id' do
23
+ content_type :json
24
+ status 200
25
+ template(id: params[:id]).to_json
26
+ end
27
+
28
+ post '/api/v1/templates' do
29
+ content_type :json
30
+ status 200
31
+ template.to_json
32
+ end
33
+
34
+ post '/api/v1/templates/:id/generate_documents' do
35
+ content_type :json
36
+ status 200
37
+ { status: :success }.to_json
38
+ end
39
+
40
+ post '/api/v1/templates/:id/generate_document' do
41
+ content_type :json
42
+ status 200
43
+ document(id: params[:id]).to_json
44
+ end
45
+
13
46
  post '/api/v1/keys' do
14
47
  content_type :json
15
48
  status 200
@@ -68,6 +101,14 @@ class FakeMifiel < Sinatra::Base
68
101
 
69
102
  private
70
103
 
104
+ def template(args = {})
105
+ {
106
+ id: args[:id] || SecureRandom.uuid,
107
+ name: 'some-template',
108
+ content: '<div><field name="name">NAME</field></div>'
109
+ }
110
+ end
111
+
71
112
  def key(args={})
72
113
  id = args[:id] || SecureRandom.uuid
73
114
  {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mifiel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-10 00:00:00.000000000 Z
11
+ date: 2017-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '1.8'
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: '1.7'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">"
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '1.8'
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: '0'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: api-auth
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -129,32 +129,32 @@ dependencies:
129
129
  - !ruby/object:Gem::Version
130
130
  version: 3.1.7
131
131
  - !ruby/object:Gem::Dependency
132
- name: pry
132
+ name: byebug
133
133
  requirement: !ruby/object:Gem::Requirement
134
134
  requirements:
135
135
  - - "~>"
136
136
  - !ruby/object:Gem::Version
137
- version: '0.10'
138
- - - ">="
137
+ version: '9.0'
138
+ - - "<"
139
139
  - !ruby/object:Gem::Version
140
- version: 0.10.1
140
+ version: 9.0.6
141
141
  type: :development
142
142
  prerelease: false
143
143
  version_requirements: !ruby/object:Gem::Requirement
144
144
  requirements:
145
145
  - - "~>"
146
146
  - !ruby/object:Gem::Version
147
- version: '0.10'
148
- - - ">="
147
+ version: '9.0'
148
+ - - "<"
149
149
  - !ruby/object:Gem::Version
150
- version: 0.10.1
150
+ version: 9.0.6
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: pry-byebug
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '3.3'
157
+ version: '3.4'
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
160
  version: 3.3.0
@@ -164,7 +164,7 @@ dependencies:
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '3.3'
167
+ version: '3.4'
168
168
  - - ">="
169
169
  - !ruby/object:Gem::Version
170
170
  version: 3.3.0
@@ -248,14 +248,14 @@ dependencies:
248
248
  requirements:
249
249
  - - "~>"
250
250
  - !ruby/object:Gem::Version
251
- version: '0.11'
251
+ version: '0.15'
252
252
  type: :development
253
253
  prerelease: false
254
254
  version_requirements: !ruby/object:Gem::Requirement
255
255
  requirements:
256
256
  - - "~>"
257
257
  - !ruby/object:Gem::Version
258
- version: '0.11'
258
+ version: '0.15'
259
259
  description:
260
260
  email:
261
261
  - genmadrid@gmail.com
@@ -280,6 +280,7 @@ files:
280
280
  - lib/mifiel/config.rb
281
281
  - lib/mifiel/document.rb
282
282
  - lib/mifiel/errors.rb
283
+ - lib/mifiel/template.rb
283
284
  - lib/mifiel/version.rb
284
285
  - mifiel-ruby-api-client.sublime-project
285
286
  - mifiel.gemspec
@@ -289,6 +290,7 @@ files:
289
290
  - spec/mifiel/base_spec.rb
290
291
  - spec/mifiel/certificate_spec.rb
291
292
  - spec/mifiel/document_spec.rb
293
+ - spec/mifiel/template_spec.rb
292
294
  - spec/spec_helper.rb
293
295
  - spec/support/fake_mifiel.rb
294
296
  homepage: https://www.mifiel.com
@@ -322,5 +324,6 @@ test_files:
322
324
  - spec/mifiel/base_spec.rb
323
325
  - spec/mifiel/certificate_spec.rb
324
326
  - spec/mifiel/document_spec.rb
327
+ - spec/mifiel/template_spec.rb
325
328
  - spec/spec_helper.rb
326
329
  - spec/support/fake_mifiel.rb