sendinblue / APIv3-typescript-library

SendinBlue's API v3 client
40 stars 19 forks source link

Outdated documentation #67

Open cibulka opened 1 year ago

cibulka commented 1 year ago

Hi,

your README shows only 2 basic examples and for the rest, it refers to developers.sendinblue.com/reference/getting-started-1. This address, however, contains instructions for different library sib-api-v3-sdk with outdated instructions.

Case in point - I've tried to get up and working DOI signup with instructions at this page. I've tried two approaches:

  1. Follow the instructions and just swapped sib-api-v3-sdk with @sendinblue/client. That resulted in Typescript and "undefined" errors.
  2. Tried to intuitively modify the instructions in README of this repo to DOI flow (code below). No TS errors, success message (and correct errors in repeated submissions of the same e-mail address), but no e-mails are sent.

It is hard to know if I do things correctly, or not, as there is no documentation. Are there any plans to update it? Thank you!


Here are my efforts of making the new api work (the code is simplified):

import * as SibApiV3Sdk from '@sendinblue/client';

const apiInstance = new SibApiV3Sdk.ContactsApi();
apiInstance.setApiKey(SibApiV3Sdk.ContactsApiApiKeys.apiKey, process.env.SENDINBLUE_API_KEY!);

const contact = new SibApiV3Sdk.CreateDoiContact();

export async function POST(req: Request) {
  const { email } = await req.json();
  const listId = 2;
  const templateId = 3;
  const redirectionUrl = 'https://example.com';

  contact.email = email;
  contact.includeListIds = [listId];
  contact.templateId = 3;
  contact.redirectionUrl = redirectionUrl;

  return apiInstance
    .createContact(contact)
    .catch(console.error);
}

This code adds the user to the list (without any confirmation on their end), returns success message, but does not send any e-mail with confirmation link.