Class: Telnyx::Resources::Documents
- Inherits:
-
Object
- Object
- Telnyx::Resources::Documents
- Defined in:
- lib/telnyx/resources/documents.rb
Overview
Documents
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.
197 198 199 |
# File 'lib/telnyx/resources/documents.rb', line 197 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.
99 100 101 102 103 104 105 106 |
# File 'lib/telnyx/resources/documents.rb', line 99 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.
119 120 121 122 123 124 125 126 127 |
# File 'lib/telnyx/resources/documents.rb', line 119 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.
141 142 143 144 145 146 147 148 |
# File 'lib/telnyx/resources/documents.rb', line 141 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.
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/telnyx/resources/documents.rb', line 73 def list(params = {}) parsed, = Telnyx::DocumentListParams.dump_request(params) query = Telnyx::Internal::Util.encode_query_params(parsed) @client.request( method: :get, path: "documents", query: query.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.
18 19 20 21 22 23 24 25 |
# File 'lib/telnyx/resources/documents.rb', line 18 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.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/telnyx/resources/documents.rb', line 42 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.
161 162 163 164 165 166 167 168 169 170 |
# File 'lib/telnyx/resources/documents.rb', line 161 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.
183 184 185 186 187 188 189 190 191 192 |
# File 'lib/telnyx/resources/documents.rb', line 183 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 |