/* tslint:disable */ /* eslint-disable */ /** * Faraday REST API * The [Faraday](https://faraday.ai) API makes it easy to predict customer behavior programmatically. See our [API change policy](https://faraday.ai/legal). * * The version of the OpenAPI document: 1.0.0 * Contact: support@faraday.ai * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import { ArchiveConfig, InlineResponse200, Target, TargetAnalysis, TargetLookupRequest, TargetLookupResponse, TargetMergePatch, TargetPost, } from '../models'; export interface ArchiveTargetRequest { targetId: string; archiveConfig: ArchiveConfig; } export interface CreateTargetRequest { targetFields: TargetPost; } export interface CreateTargetPreviewRequest { targetId: string; } export interface DeleteTargetRequest { targetId: string; } export interface DownloadTargetRequest { targetId: string; } export interface ForceUpdateTargetRequest { targetId: string; } export interface GetTargetRequest { targetId: string; } export interface GetTargetAnalysisRequest { targetId: string; } export interface GetTargetAnalysisReportRequest { targetId: string; } export interface GetTargetsRequest { ids?: Array; } export interface LookupOnTargetRequest { targetId: string; targetLookupRequest: TargetLookupRequest; } export interface UnarchiveTargetRequest { targetId: string; archiveConfig: ArchiveConfig; } export interface UpdateTargetRequest { targetId: string; targetMergePatch: TargetMergePatch; } /** * */ export class TargetsApi extends runtime.BaseAPI { /** * Archive a target * Archive a target */ async archiveTargetRaw(requestParameters: ArchiveTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling archiveTarget.'); } if (requestParameters.archiveConfig === null || requestParameters.archiveConfig === undefined) { throw new runtime.RequiredError('archiveConfig','Required parameter requestParameters.archiveConfig was null or undefined when calling archiveTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/archive`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.archiveConfig, }); return new runtime.VoidApiResponse(response); } /** * Archive a target * Archive a target */ async archiveTarget(targetId: string, archiveConfig: ArchiveConfig, ): Promise { await this.archiveTargetRaw({ targetId: targetId, archiveConfig: archiveConfig }, ); } /** * Add a new target. Targets are configuration for exporting data from Faraday, possibly to an external environment (with /connections). There are three types of targets:
Target typeDescriptionAPI requirement
PublicationFaraday hosts your predictions for convenient retrieval as needed.Specify a type of hosted_csv in options. Omit connection_id.
ReplicationFaraday copies your predictions to systems you control. You may then push them to third parties like Facebook, Google Ads, etc.Specify a valid connection_id and the corresponding type of the connection in options.
ManagedFaraday manages a push to third parties like Facebook, Google Ads, and more.Must be on an enterprise plan. Contact Customer Success to set up.
* Create target */ async createTargetRaw(requestParameters: CreateTargetRequest, ): Promise> { if (requestParameters.targetFields === null || requestParameters.targetFields === undefined) { throw new runtime.RequiredError('targetFields','Required parameter requestParameters.targetFields was null or undefined when calling createTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.targetFields, }); return new runtime.JSONApiResponse(response); } /** * Add a new target. Targets are configuration for exporting data from Faraday, possibly to an external environment (with /connections). There are three types of targets:
Target typeDescriptionAPI requirement
PublicationFaraday hosts your predictions for convenient retrieval as needed.Specify a type of hosted_csv in options. Omit connection_id.
ReplicationFaraday copies your predictions to systems you control. You may then push them to third parties like Facebook, Google Ads, etc.Specify a valid connection_id and the corresponding type of the connection in options.
ManagedFaraday manages a push to third parties like Facebook, Google Ads, and more.Must be on an enterprise plan. Contact Customer Success to set up.
* Create target */ async createTarget(targetFields: TargetPost, ): Promise { const response = await this.createTargetRaw({ targetFields: targetFields }, ); return await response.value(); } /** * Trigger a preview delivery (first 1000 results) of a target * Start a preview delivery */ async createTargetPreviewRaw(requestParameters: CreateTargetPreviewRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling createTargetPreview.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/preview`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'POST', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Trigger a preview delivery (first 1000 results) of a target * Start a preview delivery */ async createTargetPreview(targetId: string, ): Promise { const response = await this.createTargetPreviewRaw({ targetId: targetId }, ); return await response.value(); } /** * Delete a target * Delete a target */ async deleteTargetRaw(requestParameters: DeleteTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling deleteTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'DELETE', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); } /** * Delete a target * Delete a target */ async deleteTarget(targetId: string, ): Promise { await this.deleteTargetRaw({ targetId: targetId }, ); } /** * Download the default output of a target */ async downloadTargetRaw(requestParameters: DownloadTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling downloadTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/download.csv`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.TextApiResponse(response) as any; } /** * Download the default output of a target */ async downloadTarget(targetId: string, ): Promise { const response = await this.downloadTargetRaw({ targetId: targetId }, ); return await response.value(); } /** * Trigger a rerun for this resource. Faraday automatically updates resources when their config changes, but this option is available in case of transient errors. * Trigger a rerun for this resource. */ async forceUpdateTargetRaw(requestParameters: ForceUpdateTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling forceUpdateTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/force_update`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'POST', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); } /** * Trigger a rerun for this resource. Faraday automatically updates resources when their config changes, but this option is available in case of transient errors. * Trigger a rerun for this resource. */ async forceUpdateTarget(targetId: string, ): Promise { await this.forceUpdateTargetRaw({ targetId: targetId }, ); } /** * Get details on a specific target * Retrieve a target */ async getTargetRaw(requestParameters: GetTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling getTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get details on a specific target * Retrieve a target */ async getTarget(targetId: string, ): Promise { const response = await this.getTargetRaw({ targetId: targetId }, ); return await response.value(); } /** * Get details on a target\'s analysis report for specific trait, attribute, and/or geography dimensions. * Retrieve a target\'s analysis */ async getTargetAnalysisRaw(requestParameters: GetTargetAnalysisRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling getTargetAnalysis.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/analysis`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get details on a target\'s analysis report for specific trait, attribute, and/or geography dimensions. * Retrieve a target\'s analysis */ async getTargetAnalysis(targetId: string, ): Promise { const response = await this.getTargetAnalysisRaw({ targetId: targetId }, ); return await response.value(); } /** * Gets a redirect URL to download a PDF report. * Retrieve target analysis report */ async getTargetAnalysisReportRaw(requestParameters: GetTargetAnalysisReportRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling getTargetAnalysisReport.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/analysis/pdf`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); } /** * Gets a redirect URL to download a PDF report. * Retrieve target analysis report */ async getTargetAnalysisReport(targetId: string, ): Promise { await this.getTargetAnalysisReportRaw({ targetId: targetId }, ); } /** * Get a list of targets defined on the account * List targets */ async getTargetsRaw(requestParameters: GetTargetsRequest, ): Promise>> { const queryParameters: any = {}; if (requestParameters.ids) { queryParameters['ids'] = requestParameters.ids; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets`, method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get a list of targets defined on the account * List targets */ async getTargets(ids?: Array, ): Promise> { const response = await this.getTargetsRaw({ ids: ids }, ); return await response.value(); } /** * Use either PII or a spatial aggregate to retrieve the payload of a Lookup API target. See the Lookup API specification\'s [quickstart](https://faraday.ai/docs/features/lookup-api#retrieve-predictions) for more details, including examples. * Perform a lookup on the target, if its type is Lookup API. */ async lookupOnTargetRaw(requestParameters: LookupOnTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling lookupOnTarget.'); } if (requestParameters.targetLookupRequest === null || requestParameters.targetLookupRequest === undefined) { throw new runtime.RequiredError('targetLookupRequest','Required parameter requestParameters.targetLookupRequest was null or undefined when calling lookupOnTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/lookup`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.targetLookupRequest, }); return new runtime.JSONApiResponse(response); } /** * Use either PII or a spatial aggregate to retrieve the payload of a Lookup API target. See the Lookup API specification\'s [quickstart](https://faraday.ai/docs/features/lookup-api#retrieve-predictions) for more details, including examples. * Perform a lookup on the target, if its type is Lookup API. */ async lookupOnTarget(targetId: string, targetLookupRequest: TargetLookupRequest, ): Promise { const response = await this.lookupOnTargetRaw({ targetId: targetId, targetLookupRequest: targetLookupRequest }, ); return await response.value(); } /** * Unarchive a target * Unarchive a target */ async unarchiveTargetRaw(requestParameters: UnarchiveTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling unarchiveTarget.'); } if (requestParameters.archiveConfig === null || requestParameters.archiveConfig === undefined) { throw new runtime.RequiredError('archiveConfig','Required parameter requestParameters.archiveConfig was null or undefined when calling unarchiveTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}/unarchive`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.archiveConfig, }); return new runtime.VoidApiResponse(response); } /** * Unarchive a target * Unarchive a target */ async unarchiveTarget(targetId: string, archiveConfig: ArchiveConfig, ): Promise { await this.unarchiveTargetRaw({ targetId: targetId, archiveConfig: archiveConfig }, ); } /** * Update the configuration of a target. * Update a target */ async updateTargetRaw(requestParameters: UpdateTargetRequest, ): Promise> { if (requestParameters.targetId === null || requestParameters.targetId === undefined) { throw new runtime.RequiredError('targetId','Required parameter requestParameters.targetId was null or undefined when calling updateTarget.'); } if (requestParameters.targetMergePatch === null || requestParameters.targetMergePatch === undefined) { throw new runtime.RequiredError('targetMergePatch','Required parameter requestParameters.targetMergePatch was null or undefined when calling updateTarget.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/merge-patch+json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/targets/{target_id}`.replace(`{${"target_id"}}`, encodeURIComponent(String(requestParameters.targetId))), method: 'PATCH', headers: headerParameters, query: queryParameters, body: requestParameters.targetMergePatch, }); return new runtime.JSONApiResponse(response); } /** * Update the configuration of a target. * Update a target */ async updateTarget(targetId: string, targetMergePatch: TargetMergePatch, ): Promise { const response = await this.updateTargetRaw({ targetId: targetId, targetMergePatch: targetMergePatch }, ); return await response.value(); } }