sendinblue/APIv3-typescript-library

Typescript

Closed this issue · 11 comments

i try to use it in nextjs / typescript, so i import using

import { TransactionalEmailsApi, SendSmtpEmail } from "sib-api-v3-typescript"

or

import * as SibApiV3Sdk from "sib-api-v3-typescript"

but i get this :

/node_modules/sib-api-v3-typescript/api/accountApi.ts:13:1
Type error: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod
"', or another module format instead.

any idea to fix this ??

Hi
It seems you are not using the latest version of the sdk. Can you please try with the latest version?

i am using this => "sib-api-v3-typescript": "^2.2.2" and nodejs 16.16.0
image

so let me know if i am using the last version ?

Hi
This is older version of the sdk, we have now moved the sdk to @sendinblue/client. You can find the latest package details here https://github.com/sendinblue/APIv3-typescript-library/pkgs/npm/client.

@aayush-sib can u share link of documentation for this last verison ?

i found this but not explain for example transaction mail !
https://github.com/sendinblue/APIv3-typescript-library

???

You can send transactional email like this

import * as SibApiV3Sdk from '@sendinblue/client'

let apiInstance = new SibApiV3Sdk.TransactionalEmailsApi()

apiInstance.setApiKey(SibApiV3Sdk.TransactionalEmailsApiApiKeys.apiKey, 'YOUR API KEY');

let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
sendSmtpEmail.subject = "My {{params.subject}}";
sendSmtpEmail.htmlContent = "<html><body><h1>This is my first transactional email {{params.parameter}}</h1></body></html>";
sendSmtpEmail.sender = {"name":"John Doe","email":"example@example.com"};
sendSmtpEmail.to = [{"email":"example@example.com","name":"Jane Doe"}];
sendSmtpEmail.cc = [{"email":"example2@example2.com","name":"Janice Doe"}];
sendSmtpEmail.bcc = [{"name":"John Doe","email":"example@example.com"}];
sendSmtpEmail.replyTo = {"email":"replyto@domain.com","name":"John Doe"};
sendSmtpEmail.headers = {"Some-Custom-Name":"unique-id-1234"};
sendSmtpEmail.params = {"parameter":"My param value","subject":"New Subject"};

apiInstance.sendTransacEmail(sendSmtpEmail).then(function(data) {
  console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
  console.error(error);
});

working on local but not on vercel using nextjs!!

It can be an environmental issue. Can you please share some logs from vercel?

I got the same issue

Seems to be solved using the @sendinblue/client lib !