Class: Telnyx::Resources::Documents
- Inherits:
-
Object
- Object
- Telnyx::Resources::Documents
- Defined in:
- lib/telnyx/resources/documents.rb
Instance Method Summary collapse
-
#delete(id, request_options: {}) ⇒ Telnyx::Models::DocumentDeleteResponse
Delete a document.<br /><br />A document can only be deleted if it’s not linked to a service.
-
#download(id, request_options: {}) ⇒ StringIO
Download a document.
-
#generate_download_link(id, request_options: {}) ⇒ Telnyx::Models::DocumentGenerateDownloadLinkResponse
Generates a temporary pre-signed URL that can be used to download the document directly from the storage backend without authentication.
-
#initialize(client:) ⇒ Documents
constructor
private
A new instance of Documents.
-
#list(filter: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::DocServiceDocument>
Some parameter documentations has been truncated, see Models::DocumentListParams for more details.
-
#retrieve(id, request_options: {}) ⇒ Telnyx::Models::DocumentRetrieveResponse
Retrieve a document.
-
#update(document_id, customer_reference: nil, filename: nil, request_options: {}) ⇒ Telnyx::Models::DocumentUpdateResponse
Update a document.
-
#upload(document:, request_options: {}) ⇒ Telnyx::Models::DocumentUploadResponse
Upload a document.<br /><br />Uploaded files must be linked to a service within 30 minutes or they will be automatically deleted.
-
#upload_json(document:, request_options: {}) ⇒ Telnyx::Models::DocumentUploadJsonResponse
Upload a document.<br /><br />Uploaded files must be linked to a service within 30 minutes or they will be automatically deleted.
Constructor Details
#initialize(client:) ⇒ Documents
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Documents.
195 196 197 |
# File 'lib/telnyx/resources/documents.rb', line 195 def initialize(client:) @client = client end |
Instance Method Details
#delete(id, request_options: {}) ⇒ Telnyx::Models::DocumentDeleteResponse
Delete a document.<br /><br />A document can only be deleted if it’s not linked to a service. If it is linked to a service, it must be unlinked prior to deleting.
97 98 99 100 101 102 103 104 |
# File 'lib/telnyx/resources/documents.rb', line 97 def delete(id, params = {}) @client.request( method: :delete, path: ["documents/%1$s", id], model: Telnyx::Models::DocumentDeleteResponse, options: params[:request_options] ) end |
#download(id, request_options: {}) ⇒ StringIO
Download a document.
117 118 119 120 121 122 123 124 125 |
# File 'lib/telnyx/resources/documents.rb', line 117 def download(id, params = {}) @client.request( method: :get, path: ["documents/%1$s/download", id], headers: {"accept" => "application/octet-stream"}, model: StringIO, options: params[:request_options] ) end |
#generate_download_link(id, request_options: {}) ⇒ Telnyx::Models::DocumentGenerateDownloadLinkResponse
Generates a temporary pre-signed URL that can be used to download the document directly from the storage backend without authentication.
139 140 141 142 143 144 145 146 |
# File 'lib/telnyx/resources/documents.rb', line 139 def generate_download_link(id, params = {}) @client.request( method: :get, path: ["documents/%1$s/download_link", id], model: Telnyx::Models::DocumentGenerateDownloadLinkResponse, options: params[:request_options] ) end |
#list(filter: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::DocServiceDocument>
Some parameter documentations has been truncated, see Models::DocumentListParams for more details.
List all documents ordered by created_at descending.
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/telnyx/resources/documents.rb', line 72 def list(params = {}) parsed, = Telnyx::DocumentListParams.dump_request(params) @client.request( method: :get, path: "documents", query: parsed.transform_keys(page_number: "page[number]", page_size: "page[size]"), page: Telnyx::Internal::DefaultFlatPagination, model: Telnyx::DocServiceDocument, options: ) end |
#retrieve(id, request_options: {}) ⇒ Telnyx::Models::DocumentRetrieveResponse
Retrieve a document.
17 18 19 20 21 22 23 24 |
# File 'lib/telnyx/resources/documents.rb', line 17 def retrieve(id, params = {}) @client.request( method: :get, path: ["documents/%1$s", id], model: Telnyx::Models::DocumentRetrieveResponse, options: params[:request_options] ) end |
#update(document_id, customer_reference: nil, filename: nil, request_options: {}) ⇒ Telnyx::Models::DocumentUpdateResponse
Update a document.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/telnyx/resources/documents.rb', line 41 def update(document_id, params = {}) parsed, = Telnyx::DocumentUpdateParams.dump_request(params) @client.request( method: :patch, path: ["documents/%1$s", document_id], body: parsed, model: Telnyx::Models::DocumentUpdateResponse, options: ) end |
#upload(document:, request_options: {}) ⇒ Telnyx::Models::DocumentUploadResponse
Upload a document.<br /><br />Uploaded files must be linked to a service within 30 minutes or they will be automatically deleted.
159 160 161 162 163 164 165 166 167 168 |
# File 'lib/telnyx/resources/documents.rb', line 159 def upload(params) parsed, = Telnyx::DocumentUploadParams.dump_request(params) @client.request( method: :post, path: "documents?content-type=multipart", body: parsed[:document], model: Telnyx::Models::DocumentUploadResponse, options: ) end |
#upload_json(document:, request_options: {}) ⇒ Telnyx::Models::DocumentUploadJsonResponse
Upload a document.<br /><br />Uploaded files must be linked to a service within 30 minutes or they will be automatically deleted.
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/telnyx/resources/documents.rb', line 181 def upload_json(params) parsed, = Telnyx::DocumentUploadJsonParams.dump_request(params) @client.request( method: :post, path: "documents", body: parsed[:document], model: Telnyx::Models::DocumentUploadJsonResponse, options: ) end |