-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
119 lines (95 loc) · 3.86 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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<string>
id_ignore_missing?: boolean
}
interface FiltersByEmail {
emails: Array<string>
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<void>
/** This will delete a person from Customer.io. */
destroy(customerId: string): Promise<void>
// 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<void>
/** 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<void>
/** Sending a page event includes sending over the customers id and the name of the page. */
trackPageView(customerId: string, url: string): Promise<void>
// MARK: - Device
/** Add a device to send push notifications. */
addDevice(customerId: string, deviceId: string, platform: CIO.Device.Platform, payload: CIO.Device.Payload): Promise<void>
/** Delete a device to remove it from the associated customer and stop sending push notifications to it. */
deleteDevice(customerId: string, deviceId: string): Promise<void>
// MARK: - Segments
/** Add customers to a manual segment. */
addToSegment(segmentId: string, customerIds: Array<string>): Promise<void>
/** Remove customers from a manual segment. */
removeFromSegment(segmentId: string, customerIds: Array<string>): Promise<void>
// MARK: - Broadcast
triggerBroadcast(campaignId: string, payload?: CIO.Broadcast.Payload, filters?: CIO.Broadcast.Filter): Promise<CIO.Broadcast.Response>
}