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