-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathautomated.ts
More file actions
225 lines (192 loc) · 6.03 KB
/
automated.ts
File metadata and controls
225 lines (192 loc) · 6.03 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// 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';
import { path } from '../../internal/utils/path';
export class Automated extends APIResource {
/**
* Enqueue an automated job.
*
* `data_sync_all`: Enqueue a job to re-sync all data for a connection.
* `data_sync_all` has a concurrency limit of 1 job at a time per connection. This
* means that if this endpoint is called while a job is already in progress for
* this connection, Finch will return the `job_id` of the job that is currently in
* progress. Finch allows a fixed window rate limit of 1 forced refresh per hour
* per connection.
*
* `w4_form_employee_sync`: Enqueues a job for sync W-4 data for a particular
* individual, identified by `individual_id`. This feature is currently in beta.
*
* This endpoint is available for _Scale_ tier customers as an add-on. To request
* access to this endpoint, please contact your Finch account manager.
*/
create(body: AutomatedCreateParams, options?: RequestOptions): APIPromise<AutomatedCreateResponse> {
return this._client.post('/jobs/automated', { body, ...options, __security: { bearerAuth: true } });
}
/**
* Get an automated job by `job_id`.
*/
retrieve(jobID: string, options?: RequestOptions): APIPromise<AutomatedAsyncJob> {
return this._client.get(path`/jobs/automated/${jobID}`, { ...options, __security: { bearerAuth: true } });
}
/**
* Get all automated jobs. Automated jobs are completed by a machine. By default,
* jobs are sorted in descending order by submission time. For scheduled jobs such
* as data syncs, only the next scheduled job is shown.
*/
list(
query: AutomatedListParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<AutomatedListResponse> {
return this._client.get('/jobs/automated', { query, ...options, __security: { bearerAuth: true } });
}
}
export interface AutomatedAsyncJob {
/**
* The datetime the job completed.
*/
completed_at: string | null;
/**
* The datetime when the job was created. for scheduled jobs, this will be the
* initial connection time. For ad-hoc jobs, this will be the time the creation
* request was received.
*/
created_at: string;
/**
* The id of the job that has been created.
*/
job_id: string;
/**
* The url that can be used to retrieve the job status
*/
job_url: string;
/**
* The input parameters for the job.
*/
params: AutomatedAsyncJob.Params | null;
/**
* The datetime a job is scheduled to be run. For scheduled jobs, this datetime can
* be in the future if the job has not yet been enqueued. For ad-hoc jobs, this
* field will be null.
*/
scheduled_at: string | null;
/**
* The datetime a job entered into the job queue.
*/
started_at: string | null;
status: 'pending' | 'in_progress' | 'complete' | 'error' | 'reauth_error' | 'permissions_error';
/**
* The type of automated job
*/
type: 'data_sync_all' | 'w4_form_employee_sync';
}
export namespace AutomatedAsyncJob {
/**
* The input parameters for the job.
*/
export interface Params {
/**
* The ID of the individual that the job was completed for.
*/
individual_id?: string;
}
}
export interface AutomatedCreateResponse {
/**
* The number of allowed refreshes per hour (per hour, fixed window)
*/
allowed_refreshes: number;
/**
* The number of remaining refreshes available (per hour, fixed window)
*/
remaining_refreshes: number;
/**
* The id of the job that has been created.
*/
job_id?: string;
/**
* The url that can be used to retrieve the job status
*/
job_url?: string;
/**
* ISO 8601 timestamp indicating when to retry the request
*/
retry_at?: string;
}
export interface AutomatedListResponse {
data: Array<AutomatedAsyncJob>;
meta: AutomatedListResponse.Meta;
}
export namespace AutomatedListResponse {
export interface Meta {
/**
* Information about remaining quotas for this connection. Only applicable for
* customers opted in to use Finch's Data Sync Refresh endpoint
* (`POST /jobs/automated`). Please contact a Finch representative for more
* details.
*/
quotas?: Meta.Quotas;
}
export namespace Meta {
/**
* Information about remaining quotas for this connection. Only applicable for
* customers opted in to use Finch's Data Sync Refresh endpoint
* (`POST /jobs/automated`). Please contact a Finch representative for more
* details.
*/
export interface Quotas {
data_sync_all?: Quotas.DataSyncAll;
}
export namespace Quotas {
export interface DataSyncAll {
allowed_refreshes?: number;
remaining_refreshes?: number;
}
}
}
}
export type AutomatedCreateParams =
| AutomatedCreateParams.DataSyncAll
| AutomatedCreateParams.W4FormEmployeeSync;
export declare namespace AutomatedCreateParams {
export interface DataSyncAll {
/**
* The type of job to start.
*/
type: 'data_sync_all';
}
export interface W4FormEmployeeSync {
params: W4FormEmployeeSync.Params;
/**
* The type of job to start.
*/
type: 'w4_form_employee_sync';
}
export namespace W4FormEmployeeSync {
export interface Params {
/**
* The unique ID of the individual for W-4 data sync.
*/
individual_id: string;
}
}
}
export interface AutomatedListParams {
/**
* Number of items to return
*/
limit?: number;
/**
* Index to start from (defaults to 0)
*/
offset?: number;
}
export declare namespace Automated {
export {
type AutomatedAsyncJob as AutomatedAsyncJob,
type AutomatedCreateResponse as AutomatedCreateResponse,
type AutomatedListResponse as AutomatedListResponse,
type AutomatedCreateParams as AutomatedCreateParams,
type AutomatedListParams as AutomatedListParams,
};
}