postboost 1.8.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/.github/ISSUE_TEMPLATE/bug_report.yml +26 -0
  2. package/.github/ISSUE_TEMPLATE/config.yml +11 -0
  3. package/.github/ISSUE_TEMPLATE/feature_request.yml +14 -0
  4. package/.github/pull_request_template.md +6 -0
  5. package/CODE_OF_CONDUCT.md +7 -0
  6. package/CONTRIBUTING.md +31 -0
  7. package/README.md +46 -2
  8. package/SECURITY.md +9 -0
  9. package/api/aIApi.ts +460 -2
  10. package/api/accountGroupsApi.ts +501 -0
  11. package/api/accountsApi.ts +244 -2
  12. package/api/activityApi.ts +188 -0
  13. package/api/agentsApi.ts +918 -0
  14. package/api/analyticsApi.ts +551 -2
  15. package/api/apis.ts +19 -1
  16. package/api/competitorsApi.ts +412 -0
  17. package/api/hashtagGroupsApi.ts +501 -0
  18. package/api/inboxApi.ts +957 -0
  19. package/api/mediaApi.ts +97 -7
  20. package/api/mentionsApi.ts +5 -3
  21. package/api/postingScheduleApi.ts +497 -0
  22. package/api/postsApi.ts +1236 -99
  23. package/api/receiptsApi.ts +2 -2
  24. package/api/subscriptionsApi.ts +2 -2
  25. package/api/tagsApi.ts +5 -3
  26. package/api/templatesApi.ts +501 -0
  27. package/api/usersApi.ts +2 -2
  28. package/api/webhooksApi.ts +327 -0
  29. package/api/workspacesApi.ts +463 -2
  30. package/model/aICredits.ts +2 -2
  31. package/model/aIUsage.ts +39 -0
  32. package/model/aIUsageText.ts +52 -0
  33. package/model/account.ts +26 -4
  34. package/model/accountAnalytics.ts +2 -2
  35. package/model/accountAnalyticsInitialSync.ts +2 -2
  36. package/model/accountConnectionHealth.ts +124 -0
  37. package/model/accountErrorsInner.ts +50 -0
  38. package/model/accountErrorsInnerOneOf.ts +49 -0
  39. package/model/accountGroup.ts +49 -0
  40. package/model/accountGroupInput.ts +40 -0
  41. package/model/accountHealth.ts +90 -0
  42. package/model/accountHealthDailyCap.ts +43 -0
  43. package/model/accountSchedule.ts +2 -2
  44. package/model/addCompetitor202Response.ts +43 -0
  45. package/model/addCompetitor409Response.ts +37 -0
  46. package/model/addGenericSubscriptionRequest.ts +2 -2
  47. package/model/addPostToQueueRequest.ts +2 -2
  48. package/model/agentPageMeta.ts +49 -0
  49. package/model/agentProposal.ts +137 -0
  50. package/model/agentProposalDecision.ts +31 -0
  51. package/model/agentRun.ts +129 -0
  52. package/model/analyticsPeriod.ts +2 -2
  53. package/model/analyticsSummary.ts +2 -2
  54. package/model/analyticsSummaryData.ts +2 -2
  55. package/model/apiActivity.ts +94 -0
  56. package/model/apiActivityOutcome.ts +27 -0
  57. package/model/apiKey.ts +77 -0
  58. package/model/apiKeyAbility.ts +21 -0
  59. package/model/apiKeyInput.ts +56 -0
  60. package/model/approveAgentProposal200Response.ts +32 -0
  61. package/model/approveAgentProposal409Response.ts +38 -0
  62. package/model/approveInboxReplyDraft403Response.ts +43 -0
  63. package/model/approvePostRequest.ts +2 -2
  64. package/model/bestPostingTimes.ts +2 -2
  65. package/model/bestPostingTimesTimesInner.ts +2 -2
  66. package/model/blogToSocial200Response.ts +9 -2
  67. package/model/blogToSocial429Response.ts +2 -2
  68. package/model/blogToSocialCaption.ts +2 -2
  69. package/model/blogToSocialInput.ts +11 -2
  70. package/model/blogToSocialMedia.ts +2 -2
  71. package/model/blogToSocialResponse.ts +2 -2
  72. package/model/brandVoice.ts +136 -0
  73. package/model/brandVoiceInput.ts +142 -0
  74. package/model/brandVoiceMeta.ts +34 -0
  75. package/model/cancelSubscription422Response.ts +2 -2
  76. package/model/cancelSubscription422ResponseErrors.ts +2 -2
  77. package/model/cancelSubscriptionRequest.ts +2 -2
  78. package/model/changeSubscriptionPlanRequest.ts +2 -2
  79. package/model/channelAccount.ts +101 -0
  80. package/model/checkoutSubscription200Response.ts +2 -2
  81. package/model/checkoutSubscriptionRequest.ts +2 -2
  82. package/model/codedError.ts +46 -0
  83. package/model/competitor.ts +82 -0
  84. package/model/competitorDetail.ts +96 -0
  85. package/model/competitorInput.ts +43 -0
  86. package/model/competitorMedia.ts +61 -0
  87. package/model/competitorSnapshot.ts +43 -0
  88. package/model/completeChunkedUploadRequest.ts +2 -2
  89. package/model/connectChannelInput.ts +64 -0
  90. package/model/createAccountGroup201Response.ts +32 -0
  91. package/model/createAgent201Response.ts +32 -0
  92. package/model/createApiKey201Response.ts +32 -0
  93. package/model/createApiKey201ResponseData.ts +86 -0
  94. package/model/createHashtagGroup201Response.ts +32 -0
  95. package/model/createInboxReplyDraft201Response.ts +32 -0
  96. package/model/createMediaFolderRequest.ts +2 -2
  97. package/model/createMention201Response.ts +2 -2
  98. package/model/createRecyclingRule201Response.ts +32 -0
  99. package/model/createReportExport201Response.ts +32 -0
  100. package/model/createResellerClient201Response.ts +32 -0
  101. package/model/createRssFeed201Response.ts +32 -0
  102. package/model/createTemplate201Response.ts +32 -0
  103. package/model/createWebhookSubscription201Response.ts +32 -0
  104. package/model/createWebhookSubscription201ResponseData.ts +70 -0
  105. package/model/deleteAgent200Response.ts +31 -0
  106. package/model/deleteMediaBulkRequest.ts +2 -2
  107. package/model/deleteMediaBulkRequestItemsInner.ts +2 -2
  108. package/model/deleteMediaFolderRequest.ts +2 -2
  109. package/model/deleteMode.ts +2 -2
  110. package/model/deletePostRequest.ts +2 -2
  111. package/model/deletePostsBulkRequest.ts +2 -2
  112. package/model/deleteReceiptsBulkRequest.ts +2 -2
  113. package/model/deleteResult.ts +2 -2
  114. package/model/deleteUser400Response.ts +2 -2
  115. package/model/deleteUsersBulkRequest.ts +2 -2
  116. package/model/deleteWorkspacesBulkRequest.ts +2 -2
  117. package/model/getAccountHealth200Response.ts +32 -0
  118. package/model/getBrandVoice200Response.ts +32 -0
  119. package/model/getCompetitor200Response.ts +32 -0
  120. package/model/getInboxConversation200Response.ts +32 -0
  121. package/model/getPostingSchedule200Response.ts +32 -0
  122. package/model/getRemoteUploadStatus200Response.ts +2 -2
  123. package/model/getReportBranding200Response.ts +32 -0
  124. package/model/guardrailError.ts +82 -0
  125. package/model/hashtagGroup.ts +46 -0
  126. package/model/hashtagGroupInput.ts +37 -0
  127. package/model/imageAltText200Response.ts +2 -2
  128. package/model/imageAltTextInput.ts +2 -2
  129. package/model/imageAltTextResponse.ts +2 -2
  130. package/model/imageCreditBalance.ts +67 -0
  131. package/model/imageEditInput.ts +11 -2
  132. package/model/imageGenerate200Response.ts +9 -2
  133. package/model/imageGenerate429Response.ts +2 -2
  134. package/model/imageGenerateInput.ts +14 -2
  135. package/model/imageGenerationResponse.ts +2 -2
  136. package/model/imagePrompt200Response.ts +9 -2
  137. package/model/imagePrompt429Response.ts +2 -2
  138. package/model/imagePromptInput.ts +14 -2
  139. package/model/imagePromptResponse.ts +2 -2
  140. package/model/imageVariations200Response.ts +2 -2
  141. package/model/imageVariationsInput.ts +2 -2
  142. package/model/imageVariationsResponse.ts +2 -2
  143. package/model/inboxAuthor.ts +43 -0
  144. package/model/inboxConversation.ts +139 -0
  145. package/model/inboxConversationAccount.ts +49 -0
  146. package/model/inboxConversationUpdate.ts +43 -0
  147. package/model/inboxMessage.ts +95 -0
  148. package/model/inboxMessageAuthor.ts +43 -0
  149. package/model/inboxReplyDraft.ts +132 -0
  150. package/model/inboxReplyDraftApprove.ts +34 -0
  151. package/model/inboxReplyDraftEdit.ts +31 -0
  152. package/model/inboxReplyDraftInput.ts +43 -0
  153. package/model/initiateChunkedUpload201Response.ts +2 -2
  154. package/model/initiateChunkedUploadRequest.ts +2 -2
  155. package/model/initiateRemoteUpload201Response.ts +2 -2
  156. package/model/initiateRemoteUpload201ResponseOneOf.ts +2 -2
  157. package/model/initiateRemoteUploadRequest.ts +2 -2
  158. package/model/learnBrandVoiceInput.ts +61 -0
  159. package/model/learnBrandVoiceResponse.ts +39 -0
  160. package/model/learnBrandVoiceResponseMeta.ts +55 -0
  161. package/model/listAccountGroups200Response.ts +46 -0
  162. package/model/listAccounts200Response.ts +2 -2
  163. package/model/listAgentProposals200Response.ts +39 -0
  164. package/model/listAgentRuns200Response.ts +39 -0
  165. package/model/listAgents200Response.ts +32 -0
  166. package/model/listApiActivity200Response.ts +46 -0
  167. package/model/listApiKeys200Response.ts +32 -0
  168. package/model/listCompetitors200Response.ts +32 -0
  169. package/model/listHashtagGroups200Response.ts +46 -0
  170. package/model/listInboxConversations200Response.ts +46 -0
  171. package/model/listInboxReplyDrafts200Response.ts +46 -0
  172. package/model/listMedia200Response.ts +2 -2
  173. package/model/listMediaFolders200Response.ts +2 -2
  174. package/model/listMentions200Response.ts +2 -2
  175. package/model/listMyWorkspaces200Response.ts +2 -2
  176. package/model/listPosts200Response.ts +2 -2
  177. package/model/listReceipts200Response.ts +2 -2
  178. package/model/listRecyclingRules200Response.ts +32 -0
  179. package/model/listRecyclingRuns200Response.ts +32 -0
  180. package/model/listReportExports200Response.ts +32 -0
  181. package/model/listResellerClients200Response.ts +39 -0
  182. package/model/listRssFeeds200Response.ts +32 -0
  183. package/model/listTags200Response.ts +2 -2
  184. package/model/listTemplates200Response.ts +46 -0
  185. package/model/listUsers200Response.ts +2 -2
  186. package/model/listWebhookSubscriptions200Response.ts +32 -0
  187. package/model/listWorkspaces200Response.ts +2 -2
  188. package/model/media.ts +2 -2
  189. package/model/mediaBase64Input.ts +61 -0
  190. package/model/mediaFolder.ts +2 -2
  191. package/model/mediaFolderInput.ts +2 -2
  192. package/model/mediaFolderRef.ts +2 -2
  193. package/model/mention.ts +2 -2
  194. package/model/mentionIdentity.ts +2 -2
  195. package/model/mentionIdentityInput.ts +2 -2
  196. package/model/mentionInput.ts +2 -2
  197. package/model/messageOnly.ts +31 -0
  198. package/model/models.ts +475 -0
  199. package/model/paginationMeta.ts +2 -2
  200. package/model/paginationMetaLinks.ts +4 -4
  201. package/model/paginationMetaMeta.ts +4 -4
  202. package/model/pollRssFeed200Response.ts +50 -0
  203. package/model/post.ts +2 -2
  204. package/model/postAnalytics.ts +2 -2
  205. package/model/postContent.ts +6 -3
  206. package/model/postInput.ts +20 -2
  207. package/model/postOptionsInstagram.ts +59 -0
  208. package/model/postOptionsTikTok.ts +97 -0
  209. package/model/postOptionsYoutube.ts +62 -0
  210. package/model/postStatus.ts +2 -2
  211. package/model/postVersion.ts +7 -6
  212. package/model/postVersionOptions.ts +55 -0
  213. package/model/postingSchedule.ts +74 -0
  214. package/model/postingScheduleDay.ts +50 -0
  215. package/model/postingScheduleDayTimesInner.ts +34 -0
  216. package/model/postingScheduleInput.ts +53 -0
  217. package/model/postingTimeSlot.ts +2 -2
  218. package/model/postingTimes.ts +2 -2
  219. package/model/postingTimesBestInner.ts +2 -2
  220. package/model/postingTimesDayIntervalsInnerInner.ts +2 -2
  221. package/model/postingTimesDaysInner.ts +2 -2
  222. package/model/preflightResult.ts +69 -0
  223. package/model/publicWorkspace.ts +2 -2
  224. package/model/publicWorkspacePivot.ts +2 -2
  225. package/model/publishProgress.ts +2 -2
  226. package/model/queueSlots.ts +43 -0
  227. package/model/receipt.ts +2 -2
  228. package/model/receiptInput.ts +2 -2
  229. package/model/receiptUpdateInput.ts +2 -2
  230. package/model/recommendedPostingTimes.ts +61 -0
  231. package/model/reconnectLink.ts +46 -0
  232. package/model/recyclingRule.ts +117 -0
  233. package/model/recyclingRuleInput.ts +114 -0
  234. package/model/recyclingRuleSettings.ts +83 -0
  235. package/model/recyclingRuleUpdate.ts +71 -0
  236. package/model/recyclingRun.ts +71 -0
  237. package/model/removeGenericSubscription422Response.ts +2 -2
  238. package/model/removeUserFromWorkspaceRequest.ts +2 -2
  239. package/model/reportBranding.ts +61 -0
  240. package/model/reportBrandingInput.ts +55 -0
  241. package/model/reportExport.ts +121 -0
  242. package/model/reportExportInput.ts +91 -0
  243. package/model/repurposeContent200Response.ts +39 -0
  244. package/model/repurposeInput.ts +213 -0
  245. package/model/repurposeInputTheme.ts +46 -0
  246. package/model/repurposeResult.ts +89 -0
  247. package/model/repurposeResultMedia.ts +40 -0
  248. package/model/repurposeResultSource.ts +51 -0
  249. package/model/repurposeSlide.ts +43 -0
  250. package/model/resellerClient.ts +82 -0
  251. package/model/resellerClientInput.ts +31 -0
  252. package/model/resellerClientUsage.ts +43 -0
  253. package/model/retryPostAccountResult.ts +2 -2
  254. package/model/rssFeed.ts +100 -0
  255. package/model/rssFeedInput.ts +79 -0
  256. package/model/rssFeedUpdate.ts +73 -0
  257. package/model/runAgent202Response.ts +32 -0
  258. package/model/schedulePostRequest.ts +2 -2
  259. package/model/scheduleResult.ts +2 -2
  260. package/model/subscription.ts +2 -2
  261. package/model/subscriptionInput.ts +2 -2
  262. package/model/subscriptionStatus.ts +2 -2
  263. package/model/subscriptionUpdateInput.ts +2 -2
  264. package/model/tag.ts +2 -2
  265. package/model/tagInput.ts +2 -2
  266. package/model/template.ts +47 -0
  267. package/model/templateContentItem.ts +40 -0
  268. package/model/templateInput.ts +41 -0
  269. package/model/templateInputContentInner.ts +40 -0
  270. package/model/updateMediaRequest.ts +2 -2
  271. package/model/uploadChunk201Response.ts +2 -2
  272. package/model/user.ts +2 -2
  273. package/model/userInput.ts +2 -2
  274. package/model/userUpdateInput.ts +2 -2
  275. package/model/webhookEventName.ts +31 -0
  276. package/model/webhookEventPayload.ts +43 -0
  277. package/model/webhookSubscription.ts +61 -0
  278. package/model/webhookSubscriptionInput.ts +67 -0
  279. package/model/workspace.ts +2 -2
  280. package/model/workspaceAgent.ts +91 -0
  281. package/model/workspaceAgentInput.ts +67 -0
  282. package/model/workspaceAgentSettings.ts +70 -0
  283. package/model/workspaceAgentUpdate.ts +58 -0
  284. package/model/workspaceInput.ts +2 -2
  285. package/model/workspaceUserInput.ts +2 -2
  286. package/model/xUsage.ts +68 -0
  287. package/model/xUsageCounter.ts +40 -0
  288. package/package.json +1 -1
@@ -0,0 +1,918 @@
1
+ /**
2
+ * PostBoost API
3
+ * The PostBoost REST API lets you publish, schedule, and analyze social media posts across 12+ platforms from a single integration. No OAuth apps to maintain — PostBoost handles platform authorization for you. ## Base URL All workspace-scoped endpoints are prefixed with `/{workspaceUuid}`. Panel/admin endpoints are prefixed with `/panel`. ## Plan access Every workspace-scoped endpoint returns `403` when the workspace\'s plan does not include API access (capability `api`). ## Dates and times Post dates and times (`date`, `time`, `accounts_schedule`) are read in the request\'s `timezone` when one is given, otherwise in the workspace timezone. ## Idempotent requests Send an `Idempotency-Key` header (any unique string, for example a UUID) with a `POST`. Repeating the request with the same key within 24 hours returns the stored response with `Idempotent-Replayed: true` and creates nothing new. Reusing a key with a different body returns `422`; a request still in progress with the same key returns `409`. `5xx` and `429` responses are not stored, so they can be retried with the same key. ## Guardrails for automated clients Create and update requests are checked before anything is written: a post whose content matches one created for the same account in the last 24 hours returns `409` (`code: duplicate_post`, override with `allow_duplicate: true`), scheduling past an account\'s daily cap returns `429` (`code: account_daily_cap_reached`), and scheduling to an account that must be reconnected returns `422` (`code: account_unauthorized` or `account_token_missing`). Use `POST /{workspaceUuid}/posts/validate` for a dry run and `GET /{workspaceUuid}/activity` to review what API clients did. ## Authentication All requests require a Bearer token in the `Authorization` header. Generate tokens in your PostBoost dashboard under **Settings → Access Tokens**. ``` Authorization: Bearer YOUR_API_TOKEN ```
4
+ *
5
+ * The version of the OpenAPI document: 1.14.0
6
+ * Contact: hi@postboost.co
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+
13
+
14
+ import localVarRequest from 'request';
15
+ import http from 'http';
16
+
17
+ /* tslint:disable:no-unused-locals */
18
+ import { AgentProposalDecision } from '../model/agentProposalDecision';
19
+ import { ApproveAgentProposal200Response } from '../model/approveAgentProposal200Response';
20
+ import { ApproveAgentProposal409Response } from '../model/approveAgentProposal409Response';
21
+ import { CreateAgent201Response } from '../model/createAgent201Response';
22
+ import { DeleteAgent200Response } from '../model/deleteAgent200Response';
23
+ import { ListAgentProposals200Response } from '../model/listAgentProposals200Response';
24
+ import { ListAgentRuns200Response } from '../model/listAgentRuns200Response';
25
+ import { ListAgents200Response } from '../model/listAgents200Response';
26
+ import { MessageOnly } from '../model/messageOnly';
27
+ import { RunAgent202Response } from '../model/runAgent202Response';
28
+ import { WorkspaceAgentInput } from '../model/workspaceAgentInput';
29
+ import { WorkspaceAgentUpdate } from '../model/workspaceAgentUpdate';
30
+
31
+ import { ObjectSerializer, Authentication, VoidAuth, Interceptor } from '../model/models';
32
+ import { HttpBasicAuth, HttpBearerAuth, ApiKeyAuth, OAuth } from '../model/models';
33
+
34
+ import { HttpError, RequestFile } from './apis';
35
+
36
+ let defaultBasePath = 'https://postboost.co/app/api';
37
+
38
+ // ===============================================
39
+ // This file is autogenerated - Please do not edit
40
+ // ===============================================
41
+
42
+ export enum AgentsApiApiKeys {
43
+ }
44
+
45
+ export class AgentsApi {
46
+ protected _basePath = defaultBasePath;
47
+ protected _defaultHeaders : any = {};
48
+ protected _useQuerystring : boolean = false;
49
+
50
+ protected authentications = {
51
+ 'default': <Authentication>new VoidAuth(),
52
+ 'bearerAuth': new HttpBearerAuth(),
53
+ }
54
+
55
+ protected interceptors: Interceptor[] = [];
56
+
57
+ constructor(basePath?: string);
58
+ constructor(basePathOrUsername: string, password?: string, basePath?: string) {
59
+ if (password) {
60
+ if (basePath) {
61
+ this.basePath = basePath;
62
+ }
63
+ } else {
64
+ if (basePathOrUsername) {
65
+ this.basePath = basePathOrUsername
66
+ }
67
+ }
68
+ }
69
+
70
+ set useQuerystring(value: boolean) {
71
+ this._useQuerystring = value;
72
+ }
73
+
74
+ set basePath(basePath: string) {
75
+ this._basePath = basePath;
76
+ }
77
+
78
+ set defaultHeaders(defaultHeaders: any) {
79
+ this._defaultHeaders = defaultHeaders;
80
+ }
81
+
82
+ get defaultHeaders() {
83
+ return this._defaultHeaders;
84
+ }
85
+
86
+ get basePath() {
87
+ return this._basePath;
88
+ }
89
+
90
+ public setDefaultAuthentication(auth: Authentication) {
91
+ this.authentications.default = auth;
92
+ }
93
+
94
+ public setApiKey(key: AgentsApiApiKeys, value: string) {
95
+ (this.authentications as any)[AgentsApiApiKeys[key]].apiKey = value;
96
+ }
97
+
98
+ set accessToken(accessToken: string | (() => string)) {
99
+ this.authentications.bearerAuth.accessToken = accessToken;
100
+ }
101
+
102
+ public addInterceptor(interceptor: Interceptor) {
103
+ this.interceptors.push(interceptor);
104
+ }
105
+
106
+ /**
107
+ * Applies the proposal at once: `hold_post` moves the post back to draft, `edit_caption` replaces the caption. When the post was edited, deleted or left the schedule since the proposal was made, nothing changes and the proposal becomes `stale`. Admins and members only.
108
+ * @summary Approve and apply an agent proposal
109
+ * @param workspaceUuid UUID of the workspace.
110
+ * @param proposalUuid
111
+ * @param agentProposalDecision
112
+ */
113
+ public async approveAgentProposal (workspaceUuid: string, proposalUuid: string, agentProposalDecision?: AgentProposalDecision, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ApproveAgentProposal200Response; }> {
114
+ const localVarPath = this.basePath + '/{workspaceUuid}/agent-proposals/{proposalUuid}/approve'
115
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
116
+ .replace('{' + 'proposalUuid' + '}', encodeURIComponent(String(proposalUuid)));
117
+ let localVarQueryParameters: any = {};
118
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
119
+ const produces = ['application/json'];
120
+ // give precedence to 'application/json'
121
+ if (produces.indexOf('application/json') >= 0) {
122
+ localVarHeaderParams.Accept = 'application/json';
123
+ } else {
124
+ localVarHeaderParams.Accept = produces.join(',');
125
+ }
126
+ let localVarFormParams: any = {};
127
+
128
+ // verify required parameter 'workspaceUuid' is not null or undefined
129
+ if (workspaceUuid === null || workspaceUuid === undefined) {
130
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling approveAgentProposal.');
131
+ }
132
+
133
+ // verify required parameter 'proposalUuid' is not null or undefined
134
+ if (proposalUuid === null || proposalUuid === undefined) {
135
+ throw new Error('Required parameter proposalUuid was null or undefined when calling approveAgentProposal.');
136
+ }
137
+
138
+ (<any>Object).assign(localVarHeaderParams, options.headers);
139
+
140
+ let localVarUseFormData = false;
141
+
142
+ let localVarRequestOptions: localVarRequest.Options = {
143
+ method: 'POST',
144
+ qs: localVarQueryParameters,
145
+ headers: localVarHeaderParams,
146
+ uri: localVarPath,
147
+ useQuerystring: this._useQuerystring,
148
+ json: true,
149
+ body: ObjectSerializer.serialize(agentProposalDecision, "AgentProposalDecision")
150
+ };
151
+
152
+ let authenticationPromise = Promise.resolve();
153
+ if (this.authentications.bearerAuth.accessToken) {
154
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
155
+ }
156
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
157
+
158
+ let interceptorPromise = authenticationPromise;
159
+ for (const interceptor of this.interceptors) {
160
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
161
+ }
162
+
163
+ return interceptorPromise.then(() => {
164
+ if (Object.keys(localVarFormParams).length) {
165
+ if (localVarUseFormData) {
166
+ (<any>localVarRequestOptions).formData = localVarFormParams;
167
+ } else {
168
+ localVarRequestOptions.form = localVarFormParams;
169
+ }
170
+ }
171
+ return new Promise<{ response: http.IncomingMessage; body: ApproveAgentProposal200Response; }>((resolve, reject) => {
172
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
173
+ if (error) {
174
+ reject(error);
175
+ } else {
176
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
177
+ body = ObjectSerializer.deserialize(body, "ApproveAgentProposal200Response");
178
+ resolve({ response: response, body: body });
179
+ } else {
180
+ reject(new HttpError(response, body, response.statusCode));
181
+ }
182
+ }
183
+ });
184
+ });
185
+ });
186
+ }
187
+ /**
188
+ * Creates an agent (one per type per workspace). It first runs within five minutes, then on its `schedule`. **Pre-publish checker** looks at posts scheduled in the next `horizon_hours` and proposes holding (back to draft) posts that would fail: disconnected accounts, network requirements, daily caps, the X allowance and links that answer an error. It proposes caption edits that drop `banned_phrases`. With `ai_review: true` it also asks AI to review up to `max_ai_reviews_per_run` posts per run (one AI credit each). Admins and members only.
189
+ * @summary Switch on a background agent
190
+ * @param workspaceUuid UUID of the workspace.
191
+ * @param workspaceAgentInput
192
+ */
193
+ public async createAgent (workspaceUuid: string, workspaceAgentInput: WorkspaceAgentInput, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreateAgent201Response; }> {
194
+ const localVarPath = this.basePath + '/{workspaceUuid}/agents'
195
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)));
196
+ let localVarQueryParameters: any = {};
197
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
198
+ const produces = ['application/json'];
199
+ // give precedence to 'application/json'
200
+ if (produces.indexOf('application/json') >= 0) {
201
+ localVarHeaderParams.Accept = 'application/json';
202
+ } else {
203
+ localVarHeaderParams.Accept = produces.join(',');
204
+ }
205
+ let localVarFormParams: any = {};
206
+
207
+ // verify required parameter 'workspaceUuid' is not null or undefined
208
+ if (workspaceUuid === null || workspaceUuid === undefined) {
209
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling createAgent.');
210
+ }
211
+
212
+ // verify required parameter 'workspaceAgentInput' is not null or undefined
213
+ if (workspaceAgentInput === null || workspaceAgentInput === undefined) {
214
+ throw new Error('Required parameter workspaceAgentInput was null or undefined when calling createAgent.');
215
+ }
216
+
217
+ (<any>Object).assign(localVarHeaderParams, options.headers);
218
+
219
+ let localVarUseFormData = false;
220
+
221
+ let localVarRequestOptions: localVarRequest.Options = {
222
+ method: 'POST',
223
+ qs: localVarQueryParameters,
224
+ headers: localVarHeaderParams,
225
+ uri: localVarPath,
226
+ useQuerystring: this._useQuerystring,
227
+ json: true,
228
+ body: ObjectSerializer.serialize(workspaceAgentInput, "WorkspaceAgentInput")
229
+ };
230
+
231
+ let authenticationPromise = Promise.resolve();
232
+ if (this.authentications.bearerAuth.accessToken) {
233
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
234
+ }
235
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
236
+
237
+ let interceptorPromise = authenticationPromise;
238
+ for (const interceptor of this.interceptors) {
239
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
240
+ }
241
+
242
+ return interceptorPromise.then(() => {
243
+ if (Object.keys(localVarFormParams).length) {
244
+ if (localVarUseFormData) {
245
+ (<any>localVarRequestOptions).formData = localVarFormParams;
246
+ } else {
247
+ localVarRequestOptions.form = localVarFormParams;
248
+ }
249
+ }
250
+ return new Promise<{ response: http.IncomingMessage; body: CreateAgent201Response; }>((resolve, reject) => {
251
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
252
+ if (error) {
253
+ reject(error);
254
+ } else {
255
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
256
+ body = ObjectSerializer.deserialize(body, "CreateAgent201Response");
257
+ resolve({ response: response, body: body });
258
+ } else {
259
+ reject(new HttpError(response, body, response.statusCode));
260
+ }
261
+ }
262
+ });
263
+ });
264
+ });
265
+ }
266
+ /**
267
+ * Removes the agent. Its run history and proposals stay. Admins and members only.
268
+ * @summary Delete a background agent
269
+ * @param workspaceUuid UUID of the workspace.
270
+ * @param agentUuid
271
+ */
272
+ public async deleteAgent (workspaceUuid: string, agentUuid: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: DeleteAgent200Response; }> {
273
+ const localVarPath = this.basePath + '/{workspaceUuid}/agents/{agentUuid}'
274
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
275
+ .replace('{' + 'agentUuid' + '}', encodeURIComponent(String(agentUuid)));
276
+ let localVarQueryParameters: any = {};
277
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
278
+ const produces = ['application/json'];
279
+ // give precedence to 'application/json'
280
+ if (produces.indexOf('application/json') >= 0) {
281
+ localVarHeaderParams.Accept = 'application/json';
282
+ } else {
283
+ localVarHeaderParams.Accept = produces.join(',');
284
+ }
285
+ let localVarFormParams: any = {};
286
+
287
+ // verify required parameter 'workspaceUuid' is not null or undefined
288
+ if (workspaceUuid === null || workspaceUuid === undefined) {
289
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling deleteAgent.');
290
+ }
291
+
292
+ // verify required parameter 'agentUuid' is not null or undefined
293
+ if (agentUuid === null || agentUuid === undefined) {
294
+ throw new Error('Required parameter agentUuid was null or undefined when calling deleteAgent.');
295
+ }
296
+
297
+ (<any>Object).assign(localVarHeaderParams, options.headers);
298
+
299
+ let localVarUseFormData = false;
300
+
301
+ let localVarRequestOptions: localVarRequest.Options = {
302
+ method: 'DELETE',
303
+ qs: localVarQueryParameters,
304
+ headers: localVarHeaderParams,
305
+ uri: localVarPath,
306
+ useQuerystring: this._useQuerystring,
307
+ json: true,
308
+ };
309
+
310
+ let authenticationPromise = Promise.resolve();
311
+ if (this.authentications.bearerAuth.accessToken) {
312
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
313
+ }
314
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
315
+
316
+ let interceptorPromise = authenticationPromise;
317
+ for (const interceptor of this.interceptors) {
318
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
319
+ }
320
+
321
+ return interceptorPromise.then(() => {
322
+ if (Object.keys(localVarFormParams).length) {
323
+ if (localVarUseFormData) {
324
+ (<any>localVarRequestOptions).formData = localVarFormParams;
325
+ } else {
326
+ localVarRequestOptions.form = localVarFormParams;
327
+ }
328
+ }
329
+ return new Promise<{ response: http.IncomingMessage; body: DeleteAgent200Response; }>((resolve, reject) => {
330
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
331
+ if (error) {
332
+ reject(error);
333
+ } else {
334
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
335
+ body = ObjectSerializer.deserialize(body, "DeleteAgent200Response");
336
+ resolve({ response: response, body: body });
337
+ } else {
338
+ reject(new HttpError(response, body, response.statusCode));
339
+ }
340
+ }
341
+ });
342
+ });
343
+ });
344
+ }
345
+ /**
346
+ *
347
+ * @summary Get an agent run with its proposals
348
+ * @param workspaceUuid UUID of the workspace.
349
+ * @param runUuid
350
+ */
351
+ public async getAgentRun (workspaceUuid: string, runUuid: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RunAgent202Response; }> {
352
+ const localVarPath = this.basePath + '/{workspaceUuid}/agent-runs/{runUuid}'
353
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
354
+ .replace('{' + 'runUuid' + '}', encodeURIComponent(String(runUuid)));
355
+ let localVarQueryParameters: any = {};
356
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
357
+ const produces = ['application/json'];
358
+ // give precedence to 'application/json'
359
+ if (produces.indexOf('application/json') >= 0) {
360
+ localVarHeaderParams.Accept = 'application/json';
361
+ } else {
362
+ localVarHeaderParams.Accept = produces.join(',');
363
+ }
364
+ let localVarFormParams: any = {};
365
+
366
+ // verify required parameter 'workspaceUuid' is not null or undefined
367
+ if (workspaceUuid === null || workspaceUuid === undefined) {
368
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling getAgentRun.');
369
+ }
370
+
371
+ // verify required parameter 'runUuid' is not null or undefined
372
+ if (runUuid === null || runUuid === undefined) {
373
+ throw new Error('Required parameter runUuid was null or undefined when calling getAgentRun.');
374
+ }
375
+
376
+ (<any>Object).assign(localVarHeaderParams, options.headers);
377
+
378
+ let localVarUseFormData = false;
379
+
380
+ let localVarRequestOptions: localVarRequest.Options = {
381
+ method: 'GET',
382
+ qs: localVarQueryParameters,
383
+ headers: localVarHeaderParams,
384
+ uri: localVarPath,
385
+ useQuerystring: this._useQuerystring,
386
+ json: true,
387
+ };
388
+
389
+ let authenticationPromise = Promise.resolve();
390
+ if (this.authentications.bearerAuth.accessToken) {
391
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
392
+ }
393
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
394
+
395
+ let interceptorPromise = authenticationPromise;
396
+ for (const interceptor of this.interceptors) {
397
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
398
+ }
399
+
400
+ return interceptorPromise.then(() => {
401
+ if (Object.keys(localVarFormParams).length) {
402
+ if (localVarUseFormData) {
403
+ (<any>localVarRequestOptions).formData = localVarFormParams;
404
+ } else {
405
+ localVarRequestOptions.form = localVarFormParams;
406
+ }
407
+ }
408
+ return new Promise<{ response: http.IncomingMessage; body: RunAgent202Response; }>((resolve, reject) => {
409
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
410
+ if (error) {
411
+ reject(error);
412
+ } else {
413
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
414
+ body = ObjectSerializer.deserialize(body, "RunAgent202Response");
415
+ resolve({ response: response, body: body });
416
+ } else {
417
+ reject(new HttpError(response, body, response.statusCode));
418
+ }
419
+ }
420
+ });
421
+ });
422
+ });
423
+ }
424
+ /**
425
+ * Proposals of all agents in the workspace, newest first. Defaults to `pending`.
426
+ * @summary List agent proposals (approval queue)
427
+ * @param workspaceUuid UUID of the workspace.
428
+ * @param status
429
+ * @param perPage
430
+ * @param page
431
+ */
432
+ public async listAgentProposals (workspaceUuid: string, status?: 'pending' | 'applied' | 'rejected' | 'stale' | 'failed' | 'expired', perPage?: number, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ListAgentProposals200Response; }> {
433
+ const localVarPath = this.basePath + '/{workspaceUuid}/agent-proposals'
434
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)));
435
+ let localVarQueryParameters: any = {};
436
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
437
+ const produces = ['application/json'];
438
+ // give precedence to 'application/json'
439
+ if (produces.indexOf('application/json') >= 0) {
440
+ localVarHeaderParams.Accept = 'application/json';
441
+ } else {
442
+ localVarHeaderParams.Accept = produces.join(',');
443
+ }
444
+ let localVarFormParams: any = {};
445
+
446
+ // verify required parameter 'workspaceUuid' is not null or undefined
447
+ if (workspaceUuid === null || workspaceUuid === undefined) {
448
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling listAgentProposals.');
449
+ }
450
+
451
+ if (status !== undefined) {
452
+ localVarQueryParameters['status'] = ObjectSerializer.serialize(status, "'pending' | 'applied' | 'rejected' | 'stale' | 'failed' | 'expired'");
453
+ }
454
+
455
+ if (perPage !== undefined) {
456
+ localVarQueryParameters['per_page'] = ObjectSerializer.serialize(perPage, "number");
457
+ }
458
+
459
+ if (page !== undefined) {
460
+ localVarQueryParameters['page'] = ObjectSerializer.serialize(page, "number");
461
+ }
462
+
463
+ (<any>Object).assign(localVarHeaderParams, options.headers);
464
+
465
+ let localVarUseFormData = false;
466
+
467
+ let localVarRequestOptions: localVarRequest.Options = {
468
+ method: 'GET',
469
+ qs: localVarQueryParameters,
470
+ headers: localVarHeaderParams,
471
+ uri: localVarPath,
472
+ useQuerystring: this._useQuerystring,
473
+ json: true,
474
+ };
475
+
476
+ let authenticationPromise = Promise.resolve();
477
+ if (this.authentications.bearerAuth.accessToken) {
478
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
479
+ }
480
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
481
+
482
+ let interceptorPromise = authenticationPromise;
483
+ for (const interceptor of this.interceptors) {
484
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
485
+ }
486
+
487
+ return interceptorPromise.then(() => {
488
+ if (Object.keys(localVarFormParams).length) {
489
+ if (localVarUseFormData) {
490
+ (<any>localVarRequestOptions).formData = localVarFormParams;
491
+ } else {
492
+ localVarRequestOptions.form = localVarFormParams;
493
+ }
494
+ }
495
+ return new Promise<{ response: http.IncomingMessage; body: ListAgentProposals200Response; }>((resolve, reject) => {
496
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
497
+ if (error) {
498
+ reject(error);
499
+ } else {
500
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
501
+ body = ObjectSerializer.deserialize(body, "ListAgentProposals200Response");
502
+ resolve({ response: response, body: body });
503
+ } else {
504
+ reject(new HttpError(response, body, response.statusCode));
505
+ }
506
+ }
507
+ });
508
+ });
509
+ });
510
+ }
511
+ /**
512
+ * Runs of the agent, newest first, with what each checked and proposed and the AI credits it used.
513
+ * @summary Run history of an agent
514
+ * @param workspaceUuid UUID of the workspace.
515
+ * @param agentUuid
516
+ * @param perPage
517
+ * @param page
518
+ */
519
+ public async listAgentRuns (workspaceUuid: string, agentUuid: string, perPage?: number, page?: number, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ListAgentRuns200Response; }> {
520
+ const localVarPath = this.basePath + '/{workspaceUuid}/agents/{agentUuid}/runs'
521
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
522
+ .replace('{' + 'agentUuid' + '}', encodeURIComponent(String(agentUuid)));
523
+ let localVarQueryParameters: any = {};
524
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
525
+ const produces = ['application/json'];
526
+ // give precedence to 'application/json'
527
+ if (produces.indexOf('application/json') >= 0) {
528
+ localVarHeaderParams.Accept = 'application/json';
529
+ } else {
530
+ localVarHeaderParams.Accept = produces.join(',');
531
+ }
532
+ let localVarFormParams: any = {};
533
+
534
+ // verify required parameter 'workspaceUuid' is not null or undefined
535
+ if (workspaceUuid === null || workspaceUuid === undefined) {
536
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling listAgentRuns.');
537
+ }
538
+
539
+ // verify required parameter 'agentUuid' is not null or undefined
540
+ if (agentUuid === null || agentUuid === undefined) {
541
+ throw new Error('Required parameter agentUuid was null or undefined when calling listAgentRuns.');
542
+ }
543
+
544
+ if (perPage !== undefined) {
545
+ localVarQueryParameters['per_page'] = ObjectSerializer.serialize(perPage, "number");
546
+ }
547
+
548
+ if (page !== undefined) {
549
+ localVarQueryParameters['page'] = ObjectSerializer.serialize(page, "number");
550
+ }
551
+
552
+ (<any>Object).assign(localVarHeaderParams, options.headers);
553
+
554
+ let localVarUseFormData = false;
555
+
556
+ let localVarRequestOptions: localVarRequest.Options = {
557
+ method: 'GET',
558
+ qs: localVarQueryParameters,
559
+ headers: localVarHeaderParams,
560
+ uri: localVarPath,
561
+ useQuerystring: this._useQuerystring,
562
+ json: true,
563
+ };
564
+
565
+ let authenticationPromise = Promise.resolve();
566
+ if (this.authentications.bearerAuth.accessToken) {
567
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
568
+ }
569
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
570
+
571
+ let interceptorPromise = authenticationPromise;
572
+ for (const interceptor of this.interceptors) {
573
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
574
+ }
575
+
576
+ return interceptorPromise.then(() => {
577
+ if (Object.keys(localVarFormParams).length) {
578
+ if (localVarUseFormData) {
579
+ (<any>localVarRequestOptions).formData = localVarFormParams;
580
+ } else {
581
+ localVarRequestOptions.form = localVarFormParams;
582
+ }
583
+ }
584
+ return new Promise<{ response: http.IncomingMessage; body: ListAgentRuns200Response; }>((resolve, reject) => {
585
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
586
+ if (error) {
587
+ reject(error);
588
+ } else {
589
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
590
+ body = ObjectSerializer.deserialize(body, "ListAgentRuns200Response");
591
+ resolve({ response: response, body: body });
592
+ } else {
593
+ reject(new HttpError(response, body, response.statusCode));
594
+ }
595
+ }
596
+ });
597
+ });
598
+ });
599
+ }
600
+ /**
601
+ * Background agents switched on for the workspace. Agents run on a schedule, record every run and never change a post themselves: each change is a proposal that a workspace admin or member approves. Available type: `pre_publish_checker`.
602
+ * @summary List background agents
603
+ * @param workspaceUuid UUID of the workspace.
604
+ */
605
+ public async listAgents (workspaceUuid: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ListAgents200Response; }> {
606
+ const localVarPath = this.basePath + '/{workspaceUuid}/agents'
607
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)));
608
+ let localVarQueryParameters: any = {};
609
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
610
+ const produces = ['application/json'];
611
+ // give precedence to 'application/json'
612
+ if (produces.indexOf('application/json') >= 0) {
613
+ localVarHeaderParams.Accept = 'application/json';
614
+ } else {
615
+ localVarHeaderParams.Accept = produces.join(',');
616
+ }
617
+ let localVarFormParams: any = {};
618
+
619
+ // verify required parameter 'workspaceUuid' is not null or undefined
620
+ if (workspaceUuid === null || workspaceUuid === undefined) {
621
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling listAgents.');
622
+ }
623
+
624
+ (<any>Object).assign(localVarHeaderParams, options.headers);
625
+
626
+ let localVarUseFormData = false;
627
+
628
+ let localVarRequestOptions: localVarRequest.Options = {
629
+ method: 'GET',
630
+ qs: localVarQueryParameters,
631
+ headers: localVarHeaderParams,
632
+ uri: localVarPath,
633
+ useQuerystring: this._useQuerystring,
634
+ json: true,
635
+ };
636
+
637
+ let authenticationPromise = Promise.resolve();
638
+ if (this.authentications.bearerAuth.accessToken) {
639
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
640
+ }
641
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
642
+
643
+ let interceptorPromise = authenticationPromise;
644
+ for (const interceptor of this.interceptors) {
645
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
646
+ }
647
+
648
+ return interceptorPromise.then(() => {
649
+ if (Object.keys(localVarFormParams).length) {
650
+ if (localVarUseFormData) {
651
+ (<any>localVarRequestOptions).formData = localVarFormParams;
652
+ } else {
653
+ localVarRequestOptions.form = localVarFormParams;
654
+ }
655
+ }
656
+ return new Promise<{ response: http.IncomingMessage; body: ListAgents200Response; }>((resolve, reject) => {
657
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
658
+ if (error) {
659
+ reject(error);
660
+ } else {
661
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
662
+ body = ObjectSerializer.deserialize(body, "ListAgents200Response");
663
+ resolve({ response: response, body: body });
664
+ } else {
665
+ reject(new HttpError(response, body, response.statusCode));
666
+ }
667
+ }
668
+ });
669
+ });
670
+ });
671
+ }
672
+ /**
673
+ * Records the rejection (and optional note); nothing changes on the post. Admins and members only.
674
+ * @summary Reject an agent proposal
675
+ * @param workspaceUuid UUID of the workspace.
676
+ * @param proposalUuid
677
+ * @param agentProposalDecision
678
+ */
679
+ public async rejectAgentProposal (workspaceUuid: string, proposalUuid: string, agentProposalDecision?: AgentProposalDecision, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: ApproveAgentProposal200Response; }> {
680
+ const localVarPath = this.basePath + '/{workspaceUuid}/agent-proposals/{proposalUuid}/reject'
681
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
682
+ .replace('{' + 'proposalUuid' + '}', encodeURIComponent(String(proposalUuid)));
683
+ let localVarQueryParameters: any = {};
684
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
685
+ const produces = ['application/json'];
686
+ // give precedence to 'application/json'
687
+ if (produces.indexOf('application/json') >= 0) {
688
+ localVarHeaderParams.Accept = 'application/json';
689
+ } else {
690
+ localVarHeaderParams.Accept = produces.join(',');
691
+ }
692
+ let localVarFormParams: any = {};
693
+
694
+ // verify required parameter 'workspaceUuid' is not null or undefined
695
+ if (workspaceUuid === null || workspaceUuid === undefined) {
696
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling rejectAgentProposal.');
697
+ }
698
+
699
+ // verify required parameter 'proposalUuid' is not null or undefined
700
+ if (proposalUuid === null || proposalUuid === undefined) {
701
+ throw new Error('Required parameter proposalUuid was null or undefined when calling rejectAgentProposal.');
702
+ }
703
+
704
+ (<any>Object).assign(localVarHeaderParams, options.headers);
705
+
706
+ let localVarUseFormData = false;
707
+
708
+ let localVarRequestOptions: localVarRequest.Options = {
709
+ method: 'POST',
710
+ qs: localVarQueryParameters,
711
+ headers: localVarHeaderParams,
712
+ uri: localVarPath,
713
+ useQuerystring: this._useQuerystring,
714
+ json: true,
715
+ body: ObjectSerializer.serialize(agentProposalDecision, "AgentProposalDecision")
716
+ };
717
+
718
+ let authenticationPromise = Promise.resolve();
719
+ if (this.authentications.bearerAuth.accessToken) {
720
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
721
+ }
722
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
723
+
724
+ let interceptorPromise = authenticationPromise;
725
+ for (const interceptor of this.interceptors) {
726
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
727
+ }
728
+
729
+ return interceptorPromise.then(() => {
730
+ if (Object.keys(localVarFormParams).length) {
731
+ if (localVarUseFormData) {
732
+ (<any>localVarRequestOptions).formData = localVarFormParams;
733
+ } else {
734
+ localVarRequestOptions.form = localVarFormParams;
735
+ }
736
+ }
737
+ return new Promise<{ response: http.IncomingMessage; body: ApproveAgentProposal200Response; }>((resolve, reject) => {
738
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
739
+ if (error) {
740
+ reject(error);
741
+ } else {
742
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
743
+ body = ObjectSerializer.deserialize(body, "ApproveAgentProposal200Response");
744
+ resolve({ response: response, body: body });
745
+ } else {
746
+ reject(new HttpError(response, body, response.statusCode));
747
+ }
748
+ }
749
+ });
750
+ });
751
+ });
752
+ }
753
+ /**
754
+ * Queues a run outside the schedule (`trigger: manual`). Six per hour. Admins and members only.
755
+ * @summary Run a background agent now
756
+ * @param workspaceUuid UUID of the workspace.
757
+ * @param agentUuid
758
+ */
759
+ public async runAgent (workspaceUuid: string, agentUuid: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: RunAgent202Response; }> {
760
+ const localVarPath = this.basePath + '/{workspaceUuid}/agents/{agentUuid}/run'
761
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
762
+ .replace('{' + 'agentUuid' + '}', encodeURIComponent(String(agentUuid)));
763
+ let localVarQueryParameters: any = {};
764
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
765
+ const produces = ['application/json'];
766
+ // give precedence to 'application/json'
767
+ if (produces.indexOf('application/json') >= 0) {
768
+ localVarHeaderParams.Accept = 'application/json';
769
+ } else {
770
+ localVarHeaderParams.Accept = produces.join(',');
771
+ }
772
+ let localVarFormParams: any = {};
773
+
774
+ // verify required parameter 'workspaceUuid' is not null or undefined
775
+ if (workspaceUuid === null || workspaceUuid === undefined) {
776
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling runAgent.');
777
+ }
778
+
779
+ // verify required parameter 'agentUuid' is not null or undefined
780
+ if (agentUuid === null || agentUuid === undefined) {
781
+ throw new Error('Required parameter agentUuid was null or undefined when calling runAgent.');
782
+ }
783
+
784
+ (<any>Object).assign(localVarHeaderParams, options.headers);
785
+
786
+ let localVarUseFormData = false;
787
+
788
+ let localVarRequestOptions: localVarRequest.Options = {
789
+ method: 'POST',
790
+ qs: localVarQueryParameters,
791
+ headers: localVarHeaderParams,
792
+ uri: localVarPath,
793
+ useQuerystring: this._useQuerystring,
794
+ json: true,
795
+ };
796
+
797
+ let authenticationPromise = Promise.resolve();
798
+ if (this.authentications.bearerAuth.accessToken) {
799
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
800
+ }
801
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
802
+
803
+ let interceptorPromise = authenticationPromise;
804
+ for (const interceptor of this.interceptors) {
805
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
806
+ }
807
+
808
+ return interceptorPromise.then(() => {
809
+ if (Object.keys(localVarFormParams).length) {
810
+ if (localVarUseFormData) {
811
+ (<any>localVarRequestOptions).formData = localVarFormParams;
812
+ } else {
813
+ localVarRequestOptions.form = localVarFormParams;
814
+ }
815
+ }
816
+ return new Promise<{ response: http.IncomingMessage; body: RunAgent202Response; }>((resolve, reject) => {
817
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
818
+ if (error) {
819
+ reject(error);
820
+ } else {
821
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
822
+ body = ObjectSerializer.deserialize(body, "RunAgent202Response");
823
+ resolve({ response: response, body: body });
824
+ } else {
825
+ reject(new HttpError(response, body, response.statusCode));
826
+ }
827
+ }
828
+ });
829
+ });
830
+ });
831
+ }
832
+ /**
833
+ * Changes the name, schedule, settings or `enabled`. Settings you leave out keep their value. Admins and members only.
834
+ * @summary Update a background agent
835
+ * @param workspaceUuid UUID of the workspace.
836
+ * @param agentUuid
837
+ * @param workspaceAgentUpdate
838
+ */
839
+ public async updateAgent (workspaceUuid: string, agentUuid: string, workspaceAgentUpdate: WorkspaceAgentUpdate, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.IncomingMessage; body: CreateAgent201Response; }> {
840
+ const localVarPath = this.basePath + '/{workspaceUuid}/agents/{agentUuid}'
841
+ .replace('{' + 'workspaceUuid' + '}', encodeURIComponent(String(workspaceUuid)))
842
+ .replace('{' + 'agentUuid' + '}', encodeURIComponent(String(agentUuid)));
843
+ let localVarQueryParameters: any = {};
844
+ let localVarHeaderParams: any = (<any>Object).assign({}, this._defaultHeaders);
845
+ const produces = ['application/json'];
846
+ // give precedence to 'application/json'
847
+ if (produces.indexOf('application/json') >= 0) {
848
+ localVarHeaderParams.Accept = 'application/json';
849
+ } else {
850
+ localVarHeaderParams.Accept = produces.join(',');
851
+ }
852
+ let localVarFormParams: any = {};
853
+
854
+ // verify required parameter 'workspaceUuid' is not null or undefined
855
+ if (workspaceUuid === null || workspaceUuid === undefined) {
856
+ throw new Error('Required parameter workspaceUuid was null or undefined when calling updateAgent.');
857
+ }
858
+
859
+ // verify required parameter 'agentUuid' is not null or undefined
860
+ if (agentUuid === null || agentUuid === undefined) {
861
+ throw new Error('Required parameter agentUuid was null or undefined when calling updateAgent.');
862
+ }
863
+
864
+ // verify required parameter 'workspaceAgentUpdate' is not null or undefined
865
+ if (workspaceAgentUpdate === null || workspaceAgentUpdate === undefined) {
866
+ throw new Error('Required parameter workspaceAgentUpdate was null or undefined when calling updateAgent.');
867
+ }
868
+
869
+ (<any>Object).assign(localVarHeaderParams, options.headers);
870
+
871
+ let localVarUseFormData = false;
872
+
873
+ let localVarRequestOptions: localVarRequest.Options = {
874
+ method: 'PUT',
875
+ qs: localVarQueryParameters,
876
+ headers: localVarHeaderParams,
877
+ uri: localVarPath,
878
+ useQuerystring: this._useQuerystring,
879
+ json: true,
880
+ body: ObjectSerializer.serialize(workspaceAgentUpdate, "WorkspaceAgentUpdate")
881
+ };
882
+
883
+ let authenticationPromise = Promise.resolve();
884
+ if (this.authentications.bearerAuth.accessToken) {
885
+ authenticationPromise = authenticationPromise.then(() => this.authentications.bearerAuth.applyToRequest(localVarRequestOptions));
886
+ }
887
+ authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
888
+
889
+ let interceptorPromise = authenticationPromise;
890
+ for (const interceptor of this.interceptors) {
891
+ interceptorPromise = interceptorPromise.then(() => interceptor(localVarRequestOptions));
892
+ }
893
+
894
+ return interceptorPromise.then(() => {
895
+ if (Object.keys(localVarFormParams).length) {
896
+ if (localVarUseFormData) {
897
+ (<any>localVarRequestOptions).formData = localVarFormParams;
898
+ } else {
899
+ localVarRequestOptions.form = localVarFormParams;
900
+ }
901
+ }
902
+ return new Promise<{ response: http.IncomingMessage; body: CreateAgent201Response; }>((resolve, reject) => {
903
+ localVarRequest(localVarRequestOptions, (error, response, body) => {
904
+ if (error) {
905
+ reject(error);
906
+ } else {
907
+ if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
908
+ body = ObjectSerializer.deserialize(body, "CreateAgent201Response");
909
+ resolve({ response: response, body: body });
910
+ } else {
911
+ reject(new HttpError(response, body, response.statusCode));
912
+ }
913
+ }
914
+ });
915
+ });
916
+ });
917
+ }
918
+ }