THIS SDK IS NOT BEING MAINTAINED. REFER TO https://github.com/talon-one/talon_one.js
var TalonOne = require('talon-one')
var applicationId = 15025
var applicationKey = '41d3f05e76fd667b'
var client = new TalonOne.IntegrationClient('https://mycompany.talon.one', applicationId, applicationKey)
var sessionId = 'some-identifier-for-this-session'
var customerId = 'id-used-by-my-company'
client.updateCustomerProfile(customerId, {
attributes: {
// only include properties you want to update, null values are ignored
Name: 'Val Kust',
}
}, function (err, integrationState) {
if (err) {
console.log(err)
} else {
console.log(integrationState.profile)
console.log(integrationState.session)
console.log(integrationState.event)
}
})
client.updateCustomerSession(sessionId, {
// associate this session with the profile we created above
profileId: customerId,
// set referral ID for this session
referral: 'somereferral-identifier',
}, function (err, integrationState) {
if (err){
console.log(err)
} else {
console.log(integrationState.profile)
console.log(integrationState.session)
console.log(integrationState.event)
}
})
// sessionId, customerId, eventType, eventData, callback
client.trackEvent(sessionId, customerId, 'bought_upgrade', {
type: "premium"
}, function (err, integrationState) {
if (err) {
console.log(err)
} else {
console.log(integrationState.profile)
console.log(integrationState.session)
console.log(integrationState.event)
}
})
// campaignId, customerId, options
client.createReferral(campaignId, customerId, {
friendId: 'some-friend-id', // friendId - optional
start: '2014-07-07T00:00:00Z', // start date of eligibility - optional
end: '2014-07-14T00:00:00Z' // expiry date of eligibility - optional
}, function (err, integrationState) {
if (err) {
console.log(err)
} else {
console.log(integrationState.campaignId)
console.log(integrationState.advocateProfileIntegrationId)
console.log(integrationState.code)
/*
console.log(integrationState.friendProfileIntegrationId) // (if supplied)
console.log(integrationState.startDate) // (if supplied)
console.log(integrationState.expiryDate) // (if supplied)
*/
}
})
Kind: static class of talon-one/integration
Create an HTTP client that will handle signing requests for the integration API
Param | Type | Description |
---|---|---|
baseUrl | string |
The root URL for requests, e.g. https://mycompany.talon.one |
applicationId | number | string |
The ID of the application sending the request. |
applicationKey | string |
The hexadecimal API key for the application sending the request. |
context | object |
Data specific to this client instance that will be passed to global effect handlers. |
Update/create a customer session.
Kind: instance method of Client
See: http://developers.talon.one/integration-api/reference/#updateCustomerSession
Param | Type | Description |
---|---|---|
sessionId | string |
The integration ID of the customer |
updates | Object |
an object containing session properties to update |
Update/create a customer profile
Kind: instance method of Client
See: http://developers.talon.one/integration-api/reference/#updateCustomerProfile
Param | Type | Description |
---|---|---|
customerId | string |
The integration ID of the customer |
updates | Object |
an object containing profile properties to update |
Track a custom event
Kind: instance method of Client
See: http://developers.talon.one/integration-api/reference/#trackEvent
Param | Type | Description |
---|---|---|
sessionId | string |
The integration ID of the customer |
customerId | string |
The integration ID of the customer |
eventType | string |
Event type name |
eventData | Object |
an object containing event data to update |
Create a referral code
Kind: instance method of Client
See: http://developers.talon.one/integration-api/reference/#createReferral
Param | Type | Description |
---|---|---|
campaignId | number |
The ID of the campaign that the referral code belongs to |
customerId | string |
The integration ID of the customer |
options | Object | null |
an optional object containing referral's friend ID, start and expiry dates |
Register a global effect handler. This handler will be called whenever a
matching effect is returned by the API, with it's first argument being the
context
value of the client that performed the request. See the API docs on
handling effects to see which handlers should be registered and what their
remaining arguments will be.
Kind: static method of talon-one/integration
See: http://developers.talon.one/integration-api/handling-effects/
Param | Type | Description |
---|---|---|
effectName | string |
The name of the effect to handle. |
handler | function |
The handler callback. |