Class: CloudPDF::Client
- Inherits:
-
Object
- Object
- CloudPDF::Client
- Defined in:
- lib/cloudpdf/client.rb
Instance Method Summary collapse
- #account ⇒ Object
- #auth ⇒ Object
- #create_document(payload) ⇒ Object
- #create_new_file_version(id, payload) ⇒ Object
- #create_webhook(payload) ⇒ Object
- #delete_document(id) ⇒ Object
- #delete_webhook(id) ⇒ Object
- #get_document(id) ⇒ Object
- #get_document_file(documentId, fileId) ⇒ Object
- #get_viewer_token(params, expires_in = 60*60) ⇒ Object
- #get_webhook(id) ⇒ Object
- #get_webhooks ⇒ Object
-
#initialize(config) ⇒ Client
constructor
A new instance of Client.
- #setSigned(enabled) ⇒ Object
- #update_document(id, payload) ⇒ Object
- #update_webhook(id, payload) ⇒ Object
- #upload_document_file_complete(id, fileId) ⇒ Object
Constructor Details
#initialize(config) ⇒ Client
Returns a new instance of Client.
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/cloudpdf/client.rb', line 5 def initialize(config) @api_key = config.fetch(:api_key) @cloud_name = config.fetch(:cloud_name, nil) @signing_secret = config.fetch(:signing_secret, nil) @signed = false if !@signing_secret.nil? && !@cloud_name.nil? @signed = true end end |
Instance Method Details
#account ⇒ Object
24 25 26 |
# File 'lib/cloudpdf/client.rb', line 24 def account get_response("APIV2GetAccount", "/account") end |
#auth ⇒ Object
28 29 30 |
# File 'lib/cloudpdf/client.rb', line 28 def auth get_response("APIV2GetAuth", "/account") end |
#create_document(payload) ⇒ Object
32 33 34 |
# File 'lib/cloudpdf/client.rb', line 32 def create_document(payload) post_response("APIV2CreateDocument", "/documents", payload) end |
#create_new_file_version(id, payload) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/cloudpdf/client.rb', line 48 def create_new_file_version(id, payload) post_response( "APIV2CreateDocumentFile", "/documents/" + id + "/files", {id: id, **payload} ) end |
#create_webhook(payload) ⇒ Object
72 73 74 |
# File 'lib/cloudpdf/client.rb', line 72 def create_webhook(payload) post_response("APIV2CreateWebhook", "/webhooks", payload) end |
#delete_document(id) ⇒ Object
44 45 46 |
# File 'lib/cloudpdf/client.rb', line 44 def delete_document(id) delete_response("APIV2DeleteDocument", "/documents/" + id, {id: id}) end |
#delete_webhook(id) ⇒ Object
84 85 86 |
# File 'lib/cloudpdf/client.rb', line 84 def delete_webhook(id) delete_response("APIV2DeleteWebhook", "/webhooks/" + id, {id: id}) end |
#get_document(id) ⇒ Object
36 37 38 |
# File 'lib/cloudpdf/client.rb', line 36 def get_document(id) get_response("APIV2GetDocument", "/documents/" + id, {id: id}) end |
#get_document_file(documentId, fileId) ⇒ Object
64 65 66 |
# File 'lib/cloudpdf/client.rb', line 64 def get_document_file(documentId, fileId) get_response("APIV2GetDocumentFile", "/documents/" + documentId + "/files/" + fileId, {id: documentId, fileId: fileId}) end |
#get_viewer_token(params, expires_in = 60*60) ⇒ Object
68 69 70 |
# File 'lib/cloudpdf/client.rb', line 68 def get_viewer_token(params, expires_in = 60*60) get_signed_token("APIGetDocument", params, expires_in) end |
#get_webhook(id) ⇒ Object
76 77 78 |
# File 'lib/cloudpdf/client.rb', line 76 def get_webhook(id) get_response("APIV2GetWebhook", "/webhooks/" + id, {id: id}) end |
#get_webhooks ⇒ Object
88 89 90 |
# File 'lib/cloudpdf/client.rb', line 88 def get_webhooks() get_response("APIV2GetWebhooks", "/webhooks") end |
#setSigned(enabled) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/cloudpdf/client.rb', line 16 def setSigned(enabled) if @signing_secret.nil? || @cloud_name.nil? raise "signing_secret and cloud_name should be set" end @signed = enabled end |
#update_document(id, payload) ⇒ Object
40 41 42 |
# File 'lib/cloudpdf/client.rb', line 40 def update_document(id, payload) put_response("APIV2UpdateDocument", "/documents/" + id, {id: id, **payload}) end |
#update_webhook(id, payload) ⇒ Object
80 81 82 |
# File 'lib/cloudpdf/client.rb', line 80 def update_webhook(id, payload) put_response("APIV2UpdateWebhook", "/webhooks/" + id, {id: id, **payload}) end |
#upload_document_file_complete(id, fileId) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/cloudpdf/client.rb', line 56 def upload_document_file_complete(id, fileId) patch_response( "APIV2PatchDocumentFile", "/documents/" + id + "/files/" + fileId, {id: id, fileId: fileId, uploadCompleted: true} ) end |