UNPKG

@basetime/a2w-api-ts

Version:

Client library that communicates with the addtowallet API.

110 lines (109 loc) 3.9 kB
import { z } from 'zod'; import { Enrollment } from '../../types/Enrollment'; import { WalletUpdate } from '../../types/WalletUpdate'; import Endpoint from '../Endpoint'; /** * Pagination options accepted by {@link CampaignWalletsEndpoint.getAll}. */ export interface CampaignWalletsPagination { /** * The page number to fetch (1-indexed). */ page?: number; /** * The number of entries per page. */ perPage?: number; } /** * Schema for the response returned by {@link CampaignWalletsEndpoint.getAll}. * * Mirrors the backend's wallet listing response: a map of bundle IDs to request logs, the * corresponding bundles, and pagination metadata. */ export declare const CampaignWalletsResponseSchema: z.ZodObject<{ bundled: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodUnknown>>; bundles: z.ZodArray<z.ZodUnknown>; page: z.ZodNumber; totalItems: z.ZodNumber; totalPages: z.ZodNumber; }, z.core.$loose>; /** * Response shape returned by {@link CampaignWalletsEndpoint.getAll}. */ export type CampaignWalletsResponse = z.infer<typeof CampaignWalletsResponseSchema>; /** * Schema for the response returned by {@link CampaignWalletsEndpoint.getEnrollment}. */ export declare const CampaignWalletEnrollmentResponseSchema: z.ZodObject<{ campaign: z.ZodUnknown; enrollment: z.ZodNullable<z.ZodObject<{ id: z.ZodString; ui: z.ZodString; ip: z.ZodString; campaign: z.ZodString; primaryKey: z.ZodString; submitted: z.ZodRecord<z.ZodString, z.ZodString>; }, z.core.$loose>>; }, z.core.$loose>; /** * Response shape returned by {@link CampaignWalletsEndpoint.getEnrollment}. */ export type CampaignWalletEnrollmentResponse = { campaign: unknown; enrollment: Enrollment | null; }; /** * Communicate with the `/campaigns/:campaignId/wallets/*` sub-endpoints. * * Accessed via `client.campaigns.wallets`. Lists installed wallets, fetches per-pass push * logs, triggers template-driven pushes, and dismisses pending push notices. */ export default class CampaignWalletsEndpoint extends Endpoint { /** * Constructor. * * @param parent The parent `CampaignsEndpoint` whose `req`, `do`, and `qb` are * reused. */ constructor(parent: Endpoint); /** * Returns the wallets for a campaign, grouped by bundle. * * @param campaignId The ID of the campaign. * @param pagination Optional pagination overrides. */ getAll: (campaignId: string, pagination?: CampaignWalletsPagination) => Promise<CampaignWalletsResponse>; /** * Returns the details of a single wallet enrollment. * * @param campaignId The ID of the campaign. * @param enrollmentId The ID of the enrollment. */ getEnrollment: (campaignId: string, enrollmentId: string) => Promise<CampaignWalletEnrollmentResponse>; /** * Returns the push log history for a specific pass. * * @param campaignId The ID of the campaign. * @param passId The ID of the pass. */ getPushLogs: (campaignId: string, passId: string) => Promise<WalletUpdate[]>; /** * Pushes template updates to every wallet that has the campaign's passes installed. * * Returns the number of passes that were queued for update. * * @param campaignId The ID of the campaign. * @param templateIds The IDs of the templates whose changes should be pushed. */ pushTemplates: (campaignId: string, templateIds: string[]) => Promise<number>; /** * Dismisses the "pending pushes" notice for a campaign without actually pushing. * * Advances each template's last-pushed version to the current version so the dashboard * stops nagging about unpushed changes. * * @param campaignId The ID of the campaign. */ dismissPushes: (campaignId: string) => Promise<string>; }