-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutility.ts
More file actions
152 lines (133 loc) · 4.01 KB
/
Copy pathutility.ts
File metadata and controls
152 lines (133 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
import { APIPromise } from '../core/api-promise';
import { RequestOptions } from '../internal/request-options';
export class Utility extends APIResource {
/**
* Signal that you may fetch data soon to improve latency. The type field selects
* what to prefetch ('brand' queues a brand data fetch, 'styleguide' queues a
* styleguide extraction) and identifier carries exactly one lookup key: a domain,
* or an email whose domain is extracted and validated (free email providers and
* disposable email addresses are not allowed).
*
* @example
* ```ts
* const response = await client.utility.prefetch({
* identifier: { domain: 'xxx' },
* type: 'brand',
* });
* ```
*/
prefetch(body: UtilityPrefetchParams, options?: RequestOptions): APIPromise<UtilityPrefetchResponse> {
return this._client.post('/utility/prefetch', { body, ...options });
}
}
export interface UtilityPrefetchResponse {
/**
* Unique id of this API call, also sent in the X-Request-Id response header. Quote
* it when contacting support about a failed request.
*/
request_id: string;
/**
* The domain that was queued for prefetching
*/
domain?: string;
/**
* Credit usage, included whenever a valid API key is provided.
*/
key_metadata?: UtilityPrefetchResponse.KeyMetadata;
/**
* Success message
*/
message?: string;
/**
* Status of the response, e.g., 'ok'
*/
status?: string;
/**
* The type of prefetch that was queued, echoed from the request
*/
type?: 'brand' | 'styleguide';
}
export namespace UtilityPrefetchResponse {
/**
* Credit usage, included whenever a valid API key is provided.
*/
export interface KeyMetadata {
/**
* Credits used by this request.
*/
credits_consumed: number;
/**
* Credits remaining for your organization.
*/
credits_remaining: number;
}
}
export interface UtilityPrefetchParams {
/**
* Identifier of the target to prefetch. Provide exactly one of domain or email.
*/
identifier:
| UtilityPrefetchParams.UtilityPrefetchDomainIdentifier
| UtilityPrefetchParams.UtilityPrefetchEmailIdentifier;
/**
* What to prefetch: 'brand' warms the brand data cache, 'styleguide' warms the
* styleguide cache.
*/
type: 'brand' | 'styleguide';
/**
* Optional tags for tracking usage. Up to 20 tags, each 1 to 50 characters.
*/
tags?: Array<string>;
/**
* Optional request deadline and behavior on timeout. For GET requests, use
* timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded
* timeoutOpts object.
*/
timeoutOpts?: UtilityPrefetchParams.TimeoutOpts;
}
export namespace UtilityPrefetchParams {
/**
* Prefetch by domain.
*/
export interface UtilityPrefetchDomainIdentifier {
/**
* Domain name to prefetch data for
*/
domain: string;
}
/**
* Prefetch by email. The domain will be extracted and validated.
*/
export interface UtilityPrefetchEmailIdentifier {
/**
* Email address to prefetch data for. The domain will be extracted from the email.
* Free email providers (gmail.com, yahoo.com, etc.) and disposable email addresses
* are not allowed.
*/
email: string;
}
/**
* Optional request deadline and behavior on timeout. For GET requests, use
* timeoutOpts[milliseconds]=30000&timeoutOpts[behavior]=fail or a JSON-encoded
* timeoutOpts object.
*/
export interface TimeoutOpts {
/**
* Request deadline in milliseconds. Maximum: 300000 (5 minutes).
*/
milliseconds: number;
/**
* What to do at the deadline. This endpoint supports "fail": return 408
* REQUEST_TIMEOUT without charging credits.
*/
behavior?: 'fail';
}
}
export declare namespace Utility {
export {
type UtilityPrefetchResponse as UtilityPrefetchResponse,
type UtilityPrefetchParams as UtilityPrefetchParams,
};
}