Skip to content

Configure client

Configuring a single marketing partner

Every operation is performed on a FanPointsClient object.

You can specify the partner you want to manage by using the following snippet:

import { createPartnerClient } from '@fanpoints/server-js';
const client = createPartnerClient({
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret',
defaultCurrency: 'chf',
});

You can generate the clientId and secret in the Fanpoints dashboard.

Testing your configuration

You can test your configuration by using the ping function:

client.ping().then(() => {
console.log('The client is working!');
});

Configuring multiple marketing partners

You can also specify multiple Marketing Partners and use the same client to interact with them:

import { createClient } from '@fanpoints/server-js';
const client = createClient({
otherPartnerConfigs: [
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret',
defaultCurrency: 'chf',
},
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret',
defaultCurrency: 'chf',
},
],
});

Configuring multiple Marketing Partners allows you to e.g. register a purchase with items bought at different partners.

Marketing partner labels

You can specify the partner labels that are used by the partner. This allows you to assign purchase items to the partners without having to specify the partner id for each purchase item. You can specify the purchase labels in the partner configuration:

import { createClient } from '@fanpoints/server-js';
const client = createClient({
otherPartnerConfigs: [
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret'
partnerLabels: ['tickets', 'gift_cards'],
defaultCurrency: 'chf'
},
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret'
partnerLabels: ['merchandise', 'sports_equipment'],
defaultCurrency: 'chf'
},
],
});

Configuring marketing partners and loyalty programs

You can also configure the client to interact with both Loyalty Programs and Marketing Partners:

import { createClient } from '@fanpoints/server-js';
const client = createClient({
loyaltyProgramConfig: {
loyaltyProgramId: 'the Loyalty Program id',
clientId: 'the client id',
secret: 'the client secret',
},
otherPartnerConfigs: [
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret'
partnerLabels: ['tickets', 'gift_cards'],
defaultCurrency: 'chf'
},
{
partnerId: 'the partner id',
clientId: 'the client id',
secret: 'the client secret'
partnerLabels: ['merchandise', 'sports_equipment'],
defaultCurrency: 'chf'
},
],
});