Skip to content

Commit 49c9f68

Browse files
author
klaviyo-sdk
committed
version 14.0.0
1 parent 4ecac9e commit 49c9f68

56 files changed

Lines changed: 1160 additions & 1909 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [14.0.0] - 2024-10-15
5+
### Changed
6+
- **Breaking:** Providing `RetryWithExponentialBackoff` class for smart retries to replace the `RetryOptions` wrapper around the `exponential-backoff` package
7+
- **Breaking:** renamed several models:
8+
- `GetCampaignMessageTemplateRelationshipListResponse` -> `GetCampaignMessageTemplateRelationshipResponse`
9+
- `GetListFlowTriggersRelationshipResponseCollection` -> `GetListFlowTriggersRelationshipsResponseCollection`
10+
- `GetMetricFlowTriggersRelationshipResponseCollection` -> `GetMetricFlowTriggersRelationshipsResponseCollection`
11+
- `PostListCreateResponseDataRelationshipsFlowTriggers` -> `GetMetricResponseCollectionCompoundDocumentDataInnerAllOfRelationshipsFlowTriggers`
12+
- `GetMetricFlowTriggersRelationshipResponseCollectionDataInner` -> `GetMetricResponseCollectionCompoundDocumentDataInnerAllOfRelationshipsFlowTriggersDataInner`
13+
### Fixed
14+
- Fixed `flow-triggers` relationships missing the `data` property
15+
416
## [13.0.0] - revision 2024-10-15
517
### Added
618
- Universal Content API

README.md

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Klaviyo Typescript SDK
22

3-
- SDK version: 13.0.0
3+
- SDK version: 14.0.0
44

55
- Revision: 2024-10-15
66

@@ -52,7 +52,7 @@ This SDK is organized into the following resources:
5252

5353
You can install this library using `npm`.
5454

55-
`npm install klaviyo-api@13.0.0`
55+
`npm install klaviyo-api@14.0.0`
5656

5757

5858
## source code
@@ -123,22 +123,16 @@ profilesApi.createProfile(profile).then(result => {
123123

124124
### Retry Options
125125

126-
Constructing an API object also has optional property `RetryOptions`, this acts as a light wrapper with some different defaults around the `exponential-backoff` library
126+
Constructing an API object also has optional property `RetryWithExponentialBackoff`, which attempts retries on failed API calls with exponential backoff.
127127

128-
you can override
129-
- maxRetryAttempts
130-
- timeMultiple
131-
- startingDelay
128+
The default configs are:
129+
- retryCodes: [429, 503, 504, 524]
130+
- numRetries: 3
131+
- maxInterval: 60
132132

133133
```Typescript
134-
const retryOptions: RetryOptions = new RetryOptions({numOfAttempts: 3, timeMultiple: 5, startingDelay: 500)
135-
const session = new ApiKeySession("< YOUR API KEY HERE >", retryOptions)
136-
```
137-
138-
if you have used exponential backoff before you can bypass the all the settings by just setting the options with a `BackoffOptions` object
139-
```Typescript
140-
const retryOptions: RetryOptions = new RetryOptions()
141-
retryOptions.options = { "BUILD YOUR OWN BackoffOptions object here" }
134+
const retryWithExponentialBackoff: RetryWithExponentialBackoff = new RetryWithExponentialBackoff({ retryCodes: [429, 503, 504, 524], numRetries: 3, maxInterval: 60})
135+
const session = new ApiKeySession("< YOUR API KEY HERE >", retryWithExponentialBackoff)
142136
```
143137

144138
### Organizational Helpers
@@ -147,7 +141,7 @@ There is also an optional `Klaviyo` import that has all the Apis and Auth, if yo
147141
```Typescript
148142
import { Klaviyo } from 'klaviyo-api'
149143

150-
const profilesApi = new Klaviyo.ProfilesApi(new Klaviyo.Auth.ApiKeySession("< YOUR API KEY HERE >", retryOptions))
144+
const profilesApi = new Klaviyo.ProfilesApi(new Klaviyo.Auth.ApiKeySession("< YOUR API KEY HERE >", retry))
151145
````
152146

153147
### Inspecting Errors
@@ -262,7 +256,7 @@ To make an API call, you need to create an `OAuthSession` instance. This session
262256
It takes two properties
263257
1. `customerIdentifier` - This is how the session is going to grab a user's authentication information and let your implementation of `TokenStorage` know where to save any update `access token`
264258
2. `oauthApi` - This is the instance of `OAuthApi` created above. It will dictate how the session `saves` and `retrieves` the `access tokens`
265-
3. `retryOptions` - OPTIONAL - the `RetryOptions` instance outlines your desired exponential backoff retry options, outlined in [Retry Options](#retry-options) above
259+
3. `retryWithExponentialBackoff` - OPTIONAL - the `RetryWithExponentialBackoff` instance outlines your desired exponential backoff configs, outlined in [Retry Options](#retry-options) above
266260

267261
```typescript
268262
import { OAuthSession, ProfilesApi } from 'klaviyo-api';
@@ -278,7 +272,7 @@ If you don't want to deal with any of the helpers above or don't want `klaviyo-a
278272

279273
The `OAuthBasicSession` takes up to two parameters
280274
1. `accessToken` - The token is used in the API calls' authentication
281-
2. `retryOptions` - OPTIONAL - the `RetryOptions` instance outlines your desired exponential backoff retry options, outlined in [Retry Options](#retry-options) above
275+
3. `retryWithExponentialBackoff` - OPTIONAL - the `RetryWithExponentialBackoff` instance outlines your desired exponential backoff configs, outlined in [Retry Options](#retry-options) above
282276

283277
```typescript
284278
import { OAuthBasicSession } from 'klaviyo-api';
@@ -2294,18 +2288,18 @@ _______________________________
22942288
[Create or Update Profile](https://developers.klaviyo.com/en/v2024-10-15/reference/create_or_update_profile)
22952289

22962290
```typescript
2297-
ProfilesApi.createOrUpdateProfile(profileUpsertQuery: ProfileUpsertQuery)
2291+
ProfilesApi.createOrUpdateProfile(profileUpsertQuery: ProfileUpsertQuery, options)
22982292
```
22992293
##### Method alias:
23002294
```typescript
2301-
ProfilesApi.createProfileImport(profileUpsertQuery: ProfileUpsertQuery)
2295+
ProfilesApi.createProfileImport(profileUpsertQuery: ProfileUpsertQuery, options)
23022296
```
23032297
_______________________________
23042298

23052299
[Create Profile](https://developers.klaviyo.com/en/v2024-10-15/reference/create_profile)
23062300

23072301
```typescript
2308-
ProfilesApi.createProfile(profileCreateQuery: ProfileCreateQuery)
2302+
ProfilesApi.createProfile(profileCreateQuery: ProfileCreateQuery, options)
23092303
```
23102304
_______________________________
23112305

@@ -2552,7 +2546,7 @@ _______________________________
25522546
[Update Profile](https://developers.klaviyo.com/en/v2024-10-15/reference/update_profile)
25532547

25542548
```typescript
2555-
ProfilesApi.updateProfile(id: string, profilePartialUpdateQuery: ProfilePartialUpdateQuery)
2549+
ProfilesApi.updateProfile(id: string, profilePartialUpdateQuery: ProfilePartialUpdateQuery, options)
25562550
```
25572551
_______________________________
25582552
## ReportingApi

api/accountsApi.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
const axios = require('axios');
1414
import {AxiosRequestConfig, AxiosResponse} from "axios";
15-
import { backOff, BackoffOptions } from 'exponential-backoff';
1615
import FormData from 'form-data'
1716

1817
/* tslint:disable:no-unused-locals */
@@ -22,7 +21,7 @@ import { GetAccounts4XXResponse } from '../model/getAccounts4XXResponse';
2221

2322
import { ObjectSerializer } from '../model/models';
2423

25-
import {RequestFile, queryParamPreProcessor, RetryOptions, Session} from './apis';
24+
import {RequestFile, queryParamPreProcessor, RetryWithExponentialBackoff, Session} from './apis';
2625

2726
let defaultBasePath = 'https://a.klaviyo.com';
2827

@@ -33,7 +32,6 @@ let defaultBasePath = 'https://a.klaviyo.com';
3332

3433
export class AccountsApi {
3534

36-
protected backoffOptions: BackoffOptions = new RetryOptions().options
3735
session: Session
3836

3937
protected _basePath = defaultBasePath;
@@ -106,7 +104,7 @@ export class AccountsApi {
106104

107105
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetAccountResponse; }> => {
108106
try {
109-
const axiosResponse = await axios(config)
107+
const axiosResponse = await this.session.requestWithRetry(config)
110108
let body;
111109
body = ObjectSerializer.deserialize(axiosResponse.data, "GetAccountResponse");
112110
return ({response: axiosResponse, body: body});
@@ -119,10 +117,7 @@ export class AccountsApi {
119117
}
120118
}
121119

122-
return backOff<{ response: AxiosResponse; body: GetAccountResponse; }>(
123-
() => {return request(config)},
124-
this.session.getRetryOptions()
125-
);
120+
return request(config)
126121
}
127122
/**
128123
* Retrieve the account(s) associated with a given private API key. This will return 1 account object within the array. You can use this to retrieve account-specific data (contact information, timezone, currency, Public API key, etc.) or test if a Private API Key belongs to the correct account prior to performing subsequent actions with the API.<br><br>*Rate limits*:<br>Burst: `1/s`<br>Steady: `15/m` **Scopes:** `accounts:read`
@@ -160,7 +155,7 @@ export class AccountsApi {
160155

161156
const request = async (config: AxiosRequestConfig, retried = false): Promise<{ response: AxiosResponse; body: GetAccountResponseCollection; }> => {
162157
try {
163-
const axiosResponse = await axios(config)
158+
const axiosResponse = await this.session.requestWithRetry(config)
164159
let body;
165160
body = ObjectSerializer.deserialize(axiosResponse.data, "GetAccountResponseCollection");
166161
return ({response: axiosResponse, body: body});
@@ -173,9 +168,6 @@ export class AccountsApi {
173168
}
174169
}
175170

176-
return backOff<{ response: AxiosResponse; body: GetAccountResponseCollection; }>(
177-
() => {return request(config)},
178-
this.session.getRetryOptions()
179-
);
171+
return request(config)
180172
}
181173
}

0 commit comments

Comments
 (0)