@basetime/a2w-api-ts
Version:
Client library that communicates with the addtowallet API.
103 lines (102 loc) • 3.46 kB
TypeScript
import { Campaign } from '../types/Campaign';
import { CampaignStats } from '../types/CampaignStats';
import { Claim } from '../types/Claim';
import { Enrollment } from '../types/Enrollment';
import { Job } from '../types/Job';
import { MetaValues } from '../types/MetaValues';
import { Pass } from '../types/Pass';
import Endpoint from './Endpoint';
/**
* Communicate with the campaigns endpoints.
*/
export default class CampaignsEndpoint extends Endpoint {
/**
* Returns all of the campaigns for authenticated organization.
*
* @returns The campaigns.
*/
getAll: () => Promise<Campaign[]>;
/**
* Returns the details of a campaign.
*
* @param id The ID of the campaign.
*/
getById: (id: string) => Promise<Campaign>;
/**
* Returns the passes for a campaign.
*
* @param campaignId The ID of the campaign.
* @returns The passes.
*/
getPasses: (campaignId: string) => Promise<Pass[]>;
/**
* Returns the details for a pass.
*
* @param campaignId The campaign the pass belongs to.
* @param passId The ID of the pass.
* @param scanner The scanner that's being used to request the pass.
*/
getPass: (campaignId: string, passId: string, scanner?: any) => Promise<Pass>;
/**
* Updates the details of a pass.
*
* This method also updates the wallets that contain the pass.
*
* @param campaignId The ID of the campaign the pass belongs to.
* @param passId The ID of the pass.
* @param body The new pass values.
*/
updatePass: (campaignId: string, passId: string, body: Partial<Pick<Pass, "data" | "templateId" | "templateVersion" | "passTypeIdentifier">>) => Promise<Pass>;
/**
* Creates a pass bundle and returns the URL to the claims page.
*
* Example:
* ```ts
* const client = new Client(auth, console);
* const link = await client.campaigns.createBundle('123');
* console.log(link);
* ```
*
* @param campaignId The campaign the pass belongs to.
* @param metaValues The meta values to set.
* @param formValues The form values to set.
* @param utm The UTM values to pass along to the api.
*/
createBundle: (campaignId: string, metaValues?: MetaValues, formValues?: Record<string, any>, utm?: Record<string, string>) => Promise<string>;
/**
* Returns the passes for a job.
*
* @param campaignId The ID of the campaign.
* @param jobId The ID of the job.
* @returns The passes.
*/
getPassesByJob: (campaignId: string, jobId: string) => Promise<Pass[]>;
/**
* Returns the claims for a campaign.
*
* @param campaignId The ID of the campaign.
* @returns The claims.
*/
getClaims: (campaignId: string) => Promise<Claim[]>;
/**
* Returns the jobs for a campaign.
*
* @param campaignId The ID of the campaign.
* @returns The jobs.
*/
getJobs: (campaignId: string) => Promise<Job[]>;
/**
* Returns statistics for a campaign.
*
* @param campaignId The ID of the campaign.
* @returns The statistics.
*/
getStats: (campaignId: string) => Promise<CampaignStats>;
/**
* Returns the enrollments for a campaign.
*
* @param campaignId The ID of the campaign.
* @returns The enrollments.
*/
getEnrollments: (campaignId: string) => Promise<Enrollment[]>;
}