PandaDoc gem is a simple wrapper for PandaDoc.com API. Please check the official API documenation for more details.
Add this line to your application's Gemfile:
gem 'panda_doc'
And then execute:
$ bundle
Or install it yourself as:
$ gem install panda_doc
Please refer to the Authentication documentation to get the idea how to get an access token.
PandaDoc.configure do |config|
config.access_token = "an access token"
end
Every response wrapped into a ruby object with values coerced in corresponding types.
document = PandaDoc::Document.create(
name: "Sample Document",
url: "url_to_a_document",
recipients: [
{
email: "[email protected]",
first_name: "John",
last_name: "Appleseed",
role: "Signer",
default: false
}
],
fields: {
field_id: {
title: "Field 1"
}
}
)
document.uuid # => "oovHPtkwDqEAvaKmdud"
document.name # => "Sample Document"
document.status # => "uploaded"
document.created_at # => #<DateTime: 2016-02-03T14:56:21-08:00>
document.updated_at # => #<DateTime: 2016-02-03T14:56:21-08:00>
file = UploadIO.new("/path/to/file.pdf", "application/pdf")
document = PandaDoc::Document.create(
name: "Sample Document",
file: file,
recipients: [
{
email: "[email protected]",
first_name: "John",
last_name: "Appleseed",
role: "Signer",
default: false
}
],
fields: {
field_id: {
title: "Field 1"
}
}
)
document = PandaDoc::Document.create(
name: "Sample Document",
template_uuid: "uuid_of_the_template",
recipients: [
{
email: "[email protected]",
first_name: "John",
last_name: "Appleseed",
role: "Signer",
default: false
}
],
fields: {
field_id: {
value: "Field 1"
}
}
)
document = PandaDoc::Document.find("UUID")
document.status # => "draft"
document.updated_at # => <DateTime: 2016-02-03T17:41:00-08:00>
PandaDoc::Document.send("UUID", message: "A message to include into the email")
session = PandaDoc::Document.session("UUID",
recipient: "[email protected]",
lifetime: 300
)
session.id # => "adssdAvyDXBS"
session.expires_at # => #<DateTime: 2016-02-03T14:56:21-08:00>
If an error occurs during an API request it will be wrapped into a plain ruby object as well.
begin
PandaDoc::Document.create(name: "Sample Document")
rescue PandaDoc::FailureResult => e
puts e.detail
puts e.response
end
You can configure a logger if you need to debug your requests/responses
PandaDoc.configure do |config|
config.logger = Logger.new(STDOUT)
end
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.
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.
Bug reports and pull requests are welcome on GitHub at https://github.com/opti/panda_doc.
- Fork it ( https://github.com/opti/panda_doc/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
The gem is available as open source under the terms of the MIT License.