-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Mifiel | ||
class Template < Mifiel::Base | ||
get :all, '/templates' | ||
get :find, '/templates/:id' | ||
put :save, '/templates/:id' | ||
post :create, '/templates' | ||
delete :delete, '/templates/:id' | ||
|
||
def generate_document(args = {}) | ||
Mifiel::Document.create_from_template(args.merge(template_id: id)) | ||
end | ||
|
||
def generate_documents(callback_url:, identifier: nil, documents:) | ||
Mifiel::Document.create_many_from_template( | ||
template_id: template_id, | ||
identifier: identifier, | ||
documents: documents, | ||
callback_url: callback_url | ||
) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Mifiel | ||
VERSION = '1.1.5'.freeze | ||
VERSION = '1.2.0'.freeze | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
describe Mifiel::Template do | ||
let!(:template_id) { 'bb7d65b4-47f1-470e-85e4-22ddae86f9ea' } | ||
|
||
shared_examples 'a valid template' do | ||
it { expect(template).to be_a(Mifiel::Template) } | ||
it { expect(template).to respond_to(:id) } | ||
it { expect(template).to respond_to(:name) } | ||
end | ||
|
||
describe '#create' do | ||
let!(:template) do | ||
Mifiel::Template.create( | ||
name: 'Some Template', | ||
content: '<div>Some <field name="name" type="string">NAME</field></div>', | ||
header: 'Genaros Header', | ||
footer: 'Genaros Footer' | ||
) | ||
end | ||
it_behaves_like 'a valid template' | ||
end | ||
|
||
describe '#find' do | ||
let!(:template) { Mifiel::Template.find(template_id) } | ||
|
||
it_behaves_like 'a valid template' | ||
it { expect(template.id).to eq(template_id) } | ||
end | ||
|
||
describe '#all' do | ||
it 'should respond with many templates' do | ||
templates = Mifiel::Template.all | ||
expect(templates.count).to be > 0 | ||
expect(templates.first).to be_a(Mifiel::Template) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters