class Pandadoc::Api::Document
Constants
- DOCUMENT_STATUS_MAP
Public Instance Methods
create(token, params = {})
click to toggle source
# File lib/pandadoc/api/document.rb, line 30 def create(token, params = {}) validations = { name: { required: true, type: String }, template_uuid: { required: true, type: String }, recipients: { required: true, type: Array }, tokens: { required: false, type: Array }, fields: { required: false, type: Hash }, metadata: { required: false, type: Hash }, pricing_tables: { required: false, type: Array }, tags: { required: false, type: Array } } client.post_json '/documents', token, validated_params(params, validations) end
delete(token, document_id)
click to toggle source
# File lib/pandadoc/api/document.rb, line 81 def delete(token, document_id) client.delete "/documents/#{document_id}", token end
details(token, document_id)
click to toggle source
# File lib/pandadoc/api/document.rb, line 49 def details(token, document_id) client.get "/documents/#{document_id}/details", token end
download(token, document_id)
click to toggle source
# File lib/pandadoc/api/document.rb, line 77 def download(token, document_id) client.get "/documents/#{document_id}/download", token end
link(token, document_id, params = {})
click to toggle source
# File lib/pandadoc/api/document.rb, line 63 def link(token, document_id, params = {}) validations = { recipient: { required: true, type: String }, lifetime: { required: false, type: Integer } } response = client.post_json "/documents/#{document_id}/session", token, validated_params(params, validations) json_response = JSON.parse(response.body, symbolize_names: true) session_id = json_response[:id] "https://app.pandadoc.com/s/#{session_id}" end
list(token, params = {})
click to toggle source
# File lib/pandadoc/api/document.rb, line 17 def list(token, params = {}) validations = { q: { required: false, type: String }, tag: { required: false, type: String }, status: { required: false, type: Integer }, count: { required: false, type: Integer }, page: { required: false, type: Integer }, metadata: { required: false, type: Hash } } client.get '/documents', token, validated_params(params, validations) end
send_doc(token, document_id, params = {})
click to toggle source
send is already a Ruby thing, overriding it would be bad
# File lib/pandadoc/api/document.rb, line 54 def send_doc(token, document_id, params = {}) validations = { message: { required: false, type: String }, silent: { required: false, type: [TrueClass, FalseClass] } } client.post_json "/documents/#{document_id}/send", token, validated_params(params, validations) end
status(token, document_id)
click to toggle source
# File lib/pandadoc/api/document.rb, line 45 def status(token, document_id) client.get "/documents/#{document_id}", token end
Private Instance Methods
client()
click to toggle source
# File lib/pandadoc/api/document.rb, line 87 def client @client ||= Pandadoc::Api::Client.new end
validated_params(params, validations)
click to toggle source
# File lib/pandadoc/api/document.rb, line 91 def validated_params(params, validations) Pandadoc::Api::ParamsValidator.validate(params, validations) end