cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/addressing/loa-documents.ts
126lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | import { type Response } from '../../_shims/index'; |
| 6 | |
| 7 | export class LOADocuments extends APIResource { |
| 8 | /** |
| 9 | * Submit LOA document (pdf format) under the account. |
| 10 | * |
| 11 | * @example |
| 12 | * ```ts |
| 13 | * const loaDocument = |
| 14 | * await client.addressing.loaDocuments.create({ |
| 15 | * account_id: '258def64c72dae45f3e4c8516e2111f2', |
| 16 | * loa_document: '@document.pdf', |
| 17 | * }); |
| 18 | * ``` |
| 19 | */ |
| 20 | create( |
| 21 | params: LOADocumentCreateParams, |
| 22 | options?: Core.RequestOptions, |
| 23 | ): Core.APIPromise<LOADocumentCreateResponse> { |
| 24 | const { account_id, ...body } = params; |
| 25 | return ( |
| 26 | this._client.post( |
| 27 | `/accounts/${account_id}/addressing/loa_documents`, |
| 28 | Core.multipartFormRequestOptions({ body, ...options }), |
| 29 | ) as Core.APIPromise<{ result: LOADocumentCreateResponse }> |
| 30 | )._thenUnwrap((obj) => obj.result); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Download specified LOA document under the account. |
| 35 | * |
| 36 | * @example |
| 37 | * ```ts |
| 38 | * const loaDocument = |
| 39 | * await client.addressing.loaDocuments.get( |
| 40 | * 'd933b1530bc56c9953cf8ce166da8004', |
| 41 | * { account_id: '258def64c72dae45f3e4c8516e2111f2' }, |
| 42 | * ); |
| 43 | * |
| 44 | * const content = await loaDocument.blob(); |
| 45 | * console.log(content); |
| 46 | * ``` |
| 47 | */ |
| 48 | get( |
| 49 | loaDocumentId: string, |
| 50 | params: LOADocumentGetParams, |
| 51 | options?: Core.RequestOptions, |
| 52 | ): Core.APIPromise<Response> { |
| 53 | const { account_id } = params; |
| 54 | return this._client.get(`/accounts/${account_id}/addressing/loa_documents/${loaDocumentId}/download`, { |
| 55 | ...options, |
| 56 | headers: { Accept: 'application/pdf', ...options?.headers }, |
| 57 | __binaryResponse: true, |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | export interface LOADocumentCreateResponse { |
| 63 | /** |
| 64 | * Identifier for the uploaded LOA document. |
| 65 | */ |
| 66 | id?: string | null; |
| 67 | |
| 68 | /** |
| 69 | * Identifier of a Cloudflare account. |
| 70 | */ |
| 71 | account_id?: string; |
| 72 | |
| 73 | /** |
| 74 | * Whether the LOA has been auto-generated for the prefix owner by Cloudflare. |
| 75 | */ |
| 76 | auto_generated?: boolean; |
| 77 | |
| 78 | created?: string; |
| 79 | |
| 80 | /** |
| 81 | * Name of LOA document. Max file size 10MB, and supported filetype is pdf. |
| 82 | */ |
| 83 | filename?: string; |
| 84 | |
| 85 | /** |
| 86 | * File size of the uploaded LOA document. |
| 87 | */ |
| 88 | size_bytes?: number; |
| 89 | |
| 90 | /** |
| 91 | * Whether the LOA has been verified by Cloudflare staff. |
| 92 | */ |
| 93 | verified?: boolean; |
| 94 | |
| 95 | /** |
| 96 | * Timestamp of the moment the LOA was marked as validated. |
| 97 | */ |
| 98 | verified_at?: string | null; |
| 99 | } |
| 100 | |
| 101 | export interface LOADocumentCreateParams { |
| 102 | /** |
| 103 | * Path param: Identifier of a Cloudflare account. |
| 104 | */ |
| 105 | account_id: string; |
| 106 | |
| 107 | /** |
| 108 | * Body param: LOA document to upload. |
| 109 | */ |
| 110 | loa_document: string; |
| 111 | } |
| 112 | |
| 113 | export interface LOADocumentGetParams { |
| 114 | /** |
| 115 | * Identifier of a Cloudflare account. |
| 116 | */ |
| 117 | account_id: string; |
| 118 | } |
| 119 | |
| 120 | export declare namespace LOADocuments { |
| 121 | export { |
| 122 | type LOADocumentCreateResponse as LOADocumentCreateResponse, |
| 123 | type LOADocumentCreateParams as LOADocumentCreateParams, |
| 124 | type LOADocumentGetParams as LOADocumentGetParams, |
| 125 | }; |
| 126 | } |
| 127 | |