Class: Pandadoc::Api::Document
- Inherits:
-
Object
- Object
- Pandadoc::Api::Document
- Defined in:
- lib/pandadoc/api/document.rb
Constant Summary collapse
- DOCUMENT_STATUS_MAP =
{ 'document.draft': 0, 'document.sent': 1, 'document.completed': 2, 'document.viewed': 5, 'document.waiting_approval': 6, 'document.approved': 7, 'document.rejected': 8, 'document.waiting_pay': 9, 'document.paid': 10, 'document.voided': 11 }.freeze
Instance Method Summary collapse
- #create(token, params = {}) ⇒ Object
- #delete(token, document_id) ⇒ Object
- #details(token, document_id) ⇒ Object
- #download(token, document_id) ⇒ Object
- #link(token, document_id, params = {}) ⇒ Object
- #list(token, params = {}) ⇒ Object
-
#send_doc(token, document_id, params = {}) ⇒ Object
send is already a Ruby thing, overriding it would be bad.
- #status(token, document_id) ⇒ Object
Instance Method Details
#create(token, params = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# 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 }, images: { required: false, type: Array }, tags: { required: false, type: Array } } client.post_json '/documents', token, validated_params(params, validations) end |
#delete(token, document_id) ⇒ Object
82 83 84 |
# File 'lib/pandadoc/api/document.rb', line 82 def delete(token, document_id) client.delete "/documents/#{document_id}", token end |
#details(token, document_id) ⇒ Object
50 51 52 |
# File 'lib/pandadoc/api/document.rb', line 50 def details(token, document_id) client.get "/documents/#{document_id}/details", token end |
#download(token, document_id) ⇒ Object
78 79 80 |
# File 'lib/pandadoc/api/document.rb', line 78 def download(token, document_id) client.get "/documents/#{document_id}/download", token end |
#link(token, document_id, params = {}) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/pandadoc/api/document.rb', line 64 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 = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# 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 = {}) ⇒ Object
send is already a Ruby thing, overriding it would be bad
55 56 57 58 59 60 61 62 |
# File 'lib/pandadoc/api/document.rb', line 55 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) ⇒ Object
46 47 48 |
# File 'lib/pandadoc/api/document.rb', line 46 def status(token, document_id) client.get "/documents/#{document_id}", token end |