cloudflare/cloudflare-typescript

Public

mirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
v6.0.0-beta.2

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/resources/addressing/loa-documents.ts

136lines · modecode

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