feathers-sendwithus
Feathers service for sending mailers with sendwithus.
STATUS: Under development (used in production since 0.0.4)
Installation
npm install --save feathers-sendwithus
Usage
const sendwithusService = ; module { const app = this; const config = appsendwithus; app;};
Client usage:
Data is just passed to the sendwithus
api except
template
which is mapped using the template mapper.
app;
Works with batches too:
app; This will use the `sendwithus` batch apihttps://www.sendwithus.com/docs/api#batch-api-requests).In batch the request will always succeed and return the result of each request ## Configuration `apiKey` - Sendwithus api `templateNameMapping` - Will map template names to IDs when doing api `templateNameCacheExpiry` - Duration before templates are fetched again to be mapped *Set larger or smaller depending on how often you create or change template names default `templateMapper` - Custom e.g. `batchChunkSize` - default: 10, for the batch api, how many sends to chunk together in a request. Sendwithus [recommend 10](https://www.sendwithus.com/docs/api#batch-api). ## Custom template mapper `templateMapper` is responsible for mapping given template names (data.template) to template ids that sendwithus understands.We implement one that fetches all templates and caches it until `templateNameCacheExpiry` time passes.You can mix ids and names, it will just map the names it finds and leave the rest. If you want to do your own mapping, say if you want to hard code the template names and ids in a configto remove the need for fetching you could implement your own mapper: ```javascriptconst myMap = { friendly: 'templateId' }; const service = ; service will send template: 'templateId' ;