Ruby SDK for Mifiel API. Please read our documentation for instructions on how to start using the API.
Add this line to your application's Gemfile:
gem 'mifiel'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mifiel
For your convenience Mifiel offers a Sandbox environment where you can confidently test your code.
To start using the API in the Sandbox environment you need to first create an account at sandbox.mifiel.com.
Once you have an account you will need an APP_ID and an APP_SECRET which you can generate in sandbox.mifiel.com/access_tokens.
Then you can configure the gem with:
Mifiel.config do |config|
config.app_id = '<APP_ID>'
config.app_secret = '<APP_SECRET>'
config.base_url = 'https://app-sandbox.mifiel.com/api/v1' #remove this line when you wish to use the prod environment
end
Document methods:
- Find:
document = Mifiel::Document.find('id')
document.original_hash
document.file
document.file_signed
# ...
- Find all:
documents = Mifiel::Document.all
- Create:
Use only hash if you dont want us to have the file.
Either file or hash must be provided.
document = Mifiel::Document.create(
file: 'path/to/my-file.pdf',
signatories: [
{ name: 'Signer 1', email: 'signer1@email.com', tax_id: 'AAA010101AAA' },
{ name: 'Signer 2', email: 'signer2@email.com', tax_id: 'AAA010102AAA' }
]
)
# if you dont want us to have the PDF, you can just send us
# the original_hash and the name of the document. Both are required
document = Mifiel::Document.create(
hash: Digest::SHA256.hexdigest(File.read('path/to/my-file.pdf')),
name: 'my-file.pdf',
signatories: [...]
)
- Save Document related files
# save the original file
document.save_file('path/to/save/file.pdf')
# save the signed file (original file + signatures page)
document.save_file_signed('path/to/save/file-signed.pdf')
# save the signed xml file
document.save_xml('path/to/save/xml.xml')
-
Sign:
-
With a pre-created Certificate
certificate = Mifiel::Certificate.find('cert-id') document.sign(certificate_id: certificate.id)
-
With a new one
document.sign(certificate: File.read('FIEL_AAA010101AAA.cer'))
-
-
Delete
document.delete
Certificate methods:
-
Sat Certificates
sat_certificates = Mifiel::Certificate.sat
-
Find:
certificate = Mifiel::Certificate.find('id')
certificate.cer_hex
certificate.type_of
# ...
- Find all:
certificates = Mifiel::Certificate.all
-
Create
certificate = Mifiel::Certificate.create( file: 'path/to/my-certificate.cer' )
-
Delete
certificate.delete
User methods
-
Setup Widget
args = { email: 'some@email.com', tax_id: 'AAA010101AAA', callback_url: 'http://some-callback.url' } user = Mifiel::User.setup_widget(args) user.widget_id
Filtering Results
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):
document = Mifiel::Document.find('id')
document.signers.where(field: /receiver|issuer/, email: 'some@email.com')
- Fork it ( https://github.com/[my-github-username]/mifiel/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request