From e2bf217df3433d89e5d681051b8514b05d424538 Mon Sep 17 00:00:00 2001 From: Stefano Bourscheid Date: Fri, 22 Jan 2021 12:36:35 +0100 Subject: [PATCH] Add existing TS declaration file --- index.d.ts | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..9753dde --- /dev/null +++ b/index.d.ts @@ -0,0 +1,119 @@ +export = CIO + + declare namespace CIO { + namespace Customer { + interface Payload { + email: string + created_at?: number + [key: string]: any + } + } + + // MARK: - Track + namespace Track { + interface Payload { + name: string + data?: object + } + } + + namespace TrackAnonymous { + interface Payload { + name: string, + data?: { + [key: string]: any + recipient?: string + from_address?: string + reply_to?: string + } + } + } + + // MARK: - Device + namespace Device { + type Payload = object + type Platform = 'ios' | 'android' + } + + // MARK: - Broadcast + namespace Broadcast { + type Payload = object + + interface FilterPerDataFile { + data_file_url: string + } + + interface FilterPerUserData { + per_user_data: Array<{ id: string, data: object } | { email: string, data: object }> + id_ignore_missing?: boolean + email_ignore_missing?: boolean + email_add_duplicates?: boolean + } + + interface FiltersById { + ids: Array + id_ignore_missing?: boolean + } + + interface FiltersByEmail { + emails: Array + email_ignore_missing?: boolean + email_add_duplicates?: boolean + } + + interface FiltersByRecipients { + recipients: { segment: { id: number } } + } + + type Filter = FiltersById | FiltersByEmail | FiltersByRecipients | FilterPerDataFile | FilterPerUserData + + interface Response { + id: number + } + } + + } + + /** + * Creating a new instance + * + * Both the siteId and apiKey are required in order to create a Basic Authorization header, allowing us to associate the data with your account. + */ + declare class CIO { + constructor(siteId: string, apiKey: string) + + // MARK: - Customers + /** Creating a person is as simple as identifying them with this call. You can also use this method to update a persons data. */ + identify(customerId: string, payload: CIO.Customer.Payload): Promise + + /** This will delete a person from Customer.io. */ + destroy(customerId: string): Promise + + // MARK: - Tracking + /** The track method will trigger events within Customer.io. When sending data along with your event, + * it is required to send a name key/value pair in you data object. */ + track(customerId: string, payload: CIO.Track.Payload): Promise + + /** Anonymous event tracking does not require a customer ID and these events will not be associated with a tracked profile in Customer.io */ + trackAnonymous(payload: CIO.TrackAnonymous.Payload): Promise + + /** Sending a page event includes sending over the customers id and the name of the page. */ + trackPageView(customerId: string, url: string): Promise + + // MARK: - Device + /** Add a device to send push notifications. */ + addDevice(customerId: string, deviceId: string, platform: CIO.Device.Platform, payload: CIO.Device.Payload): Promise + + /** Delete a device to remove it from the associated customer and stop sending push notifications to it. */ + deleteDevice(customerId: string, deviceId: string): Promise + + // MARK: - Segments + /** Add customers to a manual segment. */ + addToSegment(segmentId: string, customerIds: Array): Promise + + /** Remove customers from a manual segment. */ + removeFromSegment(segmentId: string, customerIds: Array): Promise + + // MARK: - Broadcast + triggerBroadcast(campaignId: string, payload?: CIO.Broadcast.Payload, filters?: CIO.Broadcast.Filter): Promise + } \ No newline at end of file