Skip to content

After update to version 2.3.0 createContact attributes must now be object in Typescript #55

@xelaz

Description

@xelaz
const clientBrevo = new ContactsApi();

clientBrevo.setApiKey(
  ContactsApiApiKeys.apiKey,
  client.options.brevo.apiKey
);

await clientBrevo.createContact({
  email,
  attributes: {
    VORNAME: firstName,
    NACHNAME: lastName,
    FIRMA: company,
  },
  listIds: client.options.brevo.listId
    .split(',')
    .map((id) => parseInt(id, 10)),
  updateEnabled: true,
});

After update to version 2.3.0 TypeScript get Error on createBrevo

TS2322: Type string is not assignable to type object

In version 2.30

/**
* Pass the set of attributes and their values. These attributes must be present in your Brevo account. For eg. 
{'FNAME':'Elly', 'LNAME':'Roger', 'COUNTRIES':['India','China']}
*/
'attributes'?: { [key: string]: object; };

In version 2.2.0 it was as object

/**
* Pass the set of attributes and their values. The attribute\'s parameter should be passed in capital letter while creating a contact. Values that don\'t match the attribute type (e.g. text or string in a date attribute) will be ignored.These attributes must be present in your Brevo account. For eg. {\"FNAME\":\"Elly\", \"LNAME\":\"Roger\"}
*/
'attributes'?: object;

How i can pass obejct if i have string or string[]

And i can't use this alias and why:
attributes: {
VORNAME: firstName as object,
NACHNAME: lastName as any,
FIRMA: company,
},

How to Fix:
'attributes'?: { [key: string]: string | string[]; };

or with number or boolean what can be set as attribute.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions