Skip to content

Commit 094c4c5

Browse files
author
klaviyo-sdk
committed
version 11.0.1
1 parent ebfdcc4 commit 094c4c5

File tree

54 files changed

+3743
-307
lines changed

Some content is hidden

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

54 files changed

+3743
-307
lines changed

CHANGELOG.md

+3-90
Original file line numberDiff line numberDiff line change
@@ -7,99 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
NOTE: For more granular API-specific changes, please see our [API Changelog](https://developers.klaviyo.com/en/docs/changelog_)
99

10-
## [11.0.0] Typed SDK - revision 2024-07-15
11-
12-
### Added
13-
- Typed Responses (Breaking change)
14-
- By default, all API methods will return a type representing the response payload instead of dictionary, as was the case in previous versions of this SDK. Using the typed response, you can access fields of a response using dot notation, like so:
15-
```python
16-
from klaviyo_api import KlaviyoAPI
17-
18-
client = KlaviyoAPI(
19-
api_key,
20-
max_delay=0,
21-
max_retries=0
22-
)
23-
24-
profiles = client.Profiles.get_profiles()
25-
profile_id = profiles.data[0].id
26-
profile = client.Profiles.get_profile(profile_id)
27-
profile_id = profile.data.id
28-
profile_email = profile.data.attributes.email
29-
30-
print(type(profile).__name__) # prints GetProfileResponseCompoundDocument
31-
```
32-
The class used in this example is found [here](src/openapi_client/models/get_profile_response_collection_compound_document.py).
33-
34-
This is a breaking change, as response objects will now require dot notation to access their fields versus the subscriptable access method used for dictionaries, i.e. `profile.data.id` vs `profile['data']['id']`. We have provided a [backwards compatibility strategy](#backwards-compatibility) to smooth the transition from dictionary responses to typed responses.
35-
36-
#### Backwards Compatibility
37-
To maintain backwards compatibility with previous versions of this SDK, we have added an `options` argument that allows you to continue using dictionaries as response values. There are two ways to use this `options` argument:
38-
```python
39-
from klaviyo_api import KlaviyoAPI
40-
from openapi_client.api_arg_options import USE_DICTIONARY_FOR_RESPONSE_DATA
41-
42-
client = KlaviyoAPI(
43-
api_key,
44-
max_delay=0,
45-
max_retries=0
46-
)
47-
48-
49-
# 1: Passing options to an individual API method
50-
profiles = client.Profiles.get_profiles(options= {
51-
USE_DICTIONARY_FOR_RESPONSE_DATA: True
52-
})
53-
profile_id = profiles["data"][0]['id']
54-
profile_email = profiles["data"][0]['attributes']['email']
55-
56-
# 2: Passing options to API Client
57-
dictionary_client = KlaviyoAPI(
58-
api_key,
59-
max_delay=0,
60-
max_retries=0,
61-
options={USE_DICTIONARY_FOR_RESPONSE_DATA : True}
62-
)
63-
profiles_ = dictionary_client.Profiles.get_profiles()
64-
profile_0_id = profiles_["data"][0]['id']
65-
66-
profile_0 = dictionary_client.Profiles.get_profile(id=profile_0_id)
67-
profile_0_email = profile_0["data"]['attributes']['email']
68-
```
69-
The first way will only return a dictionary for that specific `get_profiles` call. The second makes it so that all API methods called using `dictionary_client` will return dictionaries as responses.
70-
71-
- Some API methods still return response data that is not fully typed. See the [Untyped Response Data for Specific APIs](README.md#untyped-response-data-for-specific-apis) in the README for more details.
72-
- Filter Builder - A new class to help construct filter query parameters.
73-
```python
74-
old_date = datetime.datetime(2023, 8, 15, 12, 30, 0, 0, tzinfo=datetime.timezone.utc)
75-
f = FilterBuilder()
76-
f.any("email", ["[email protected]", "[email protected]"])
77-
f.greater_than("created", old_date)
78-
79-
# f.build() returns 'any(email,["[email protected]","[email protected]"]),greater-than(created,2023-08-15T12:30:00+00:00)'
80-
profile_response = client.Profiles.get_profiles(filter=f.build())
81-
82-
# You can also chain FilterBuilder methods
83-
f = FilterBuilder()
84-
filters = f.any("email", ["[email protected]", "[email protected]"]).greater_than("created", date).build()
85-
assert filters == "any(email,['[email protected]','[email protected]']),greater-than(created,2023-08-15T12:30:00+00:00)"
86-
```
87-
88-
89-
## [10.0.0] - revision 2024-07-15
10+
## [11.0.1] - 2024-07-15
11+
### Fixed
12+
- Typing error when using `additional_fields_profile=['subscriptions']` on `get_profiles`. From issue https://github.com/klaviyo/klaviyo-api-python/issues/61
9013

91-
### Added
9214

93-
- Forms API
94-
- New `klaviyo.Forms` class with methods to get forms, form versions and relationships
95-
- Webhooks API
96-
- new `klaviyo.Webooks` class containing CRUD operations for webhooks
9715

98-
### Changed
99-
- `klaviyo.Profiles.subscribe()`
100-
- added `historical_import` flag for importing historically consented profiles can now be optionally supplied in the payload for the Subscribe Profiles endpoint.
101-
- When using this flag, a consented_at date must be provided and must be in the past.
102-
10316

10417
## [7.0.0] - revision 2024-02-15
10518

README.md

+72-118
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Klaviyo Python SDK
22

3-
- SDK version: 11.0.0
3+
- SDK version: 11.0.1
44
- API revision: 2024-07-15
55

66
## Table of Contents
@@ -44,10 +44,6 @@
4444
* [Parameters & Arguments](#parameters--arguments)
4545
* [Namespace](#namespace)
4646
* [Renamed Fields](#renamed-fields)
47-
* [Filter Builder](#filter-builder)
48-
* [Typed Responses](#typed-responses)
49-
* [Backwards Compatibility](#backwards-compatibility)
50-
* [Untyped Response Data for Specific APIs](#untyped-response-data-for-specific-apis)
5147
<!-- TOC -->
5248

5349
## Helpful Resources
@@ -133,6 +129,10 @@ This SDK is organized into the following resources:
133129

134130

135131

132+
- Tests
133+
134+
135+
136136
- Webhooks
137137

138138

@@ -3764,6 +3764,72 @@ klaviyo.Templates.update_template(id, body)
37643764

37653765

37663766

3767+
## Tests
3768+
3769+
#### [Get Test Bulk Create Photos Jobs](https://developers.klaviyo.com/en/v2024-07-15/reference/get_test_bulk_create_photos_jobs)
3770+
3771+
```python
3772+
3773+
## Keyword Arguments
3774+
3775+
# fields_test_bulk_create_photos_job | List[str]
3776+
3777+
klaviyo.Tests.get_test_bulk_create_photos_jobs(fields_test_bulk_create_photos_job=fields_test_bulk_create_photos_job)
3778+
```
3779+
3780+
3781+
3782+
3783+
#### [Get Test Cities](https://developers.klaviyo.com/en/v2024-07-15/reference/get_test_cities)
3784+
3785+
```python
3786+
3787+
## Keyword Arguments
3788+
3789+
# fields_test_city | List[str]
3790+
3791+
klaviyo.Tests.get_test_cities(fields_test_city=fields_test_city)
3792+
```
3793+
3794+
3795+
3796+
3797+
#### [Get Test Photographers](https://developers.klaviyo.com/en/v2024-07-15/reference/get_test_photographers)
3798+
3799+
```python
3800+
3801+
## Keyword Arguments
3802+
3803+
# fields_test_photographer | List[str]
3804+
# filter | str
3805+
# sort | str
3806+
3807+
klaviyo.Tests.get_test_photographers(fields_test_photographer=fields_test_photographer, filter=filter, sort=sort)
3808+
```
3809+
3810+
3811+
3812+
3813+
#### [Get Test Photos](https://developers.klaviyo.com/en/v2024-07-15/reference/get_test_photos)
3814+
3815+
```python
3816+
3817+
## Keyword Arguments
3818+
3819+
# additional_fields_test_photo | List[str]
3820+
# fields_test_photo | List[str]
3821+
# filter | str
3822+
# page_cursor | str
3823+
# sort | str
3824+
3825+
klaviyo.Tests.get_test_photos(additional_fields_test_photo=additional_fields_test_photo, fields_test_photo=fields_test_photo, filter=filter, page_cursor=page_cursor, sort=sort)
3826+
```
3827+
3828+
3829+
3830+
3831+
3832+
37673833
## Webhooks
37683834

37693835
#### [Create Webhook](https://developers.klaviyo.com/en/v2024-07-15/reference/create_webhook)
@@ -3922,116 +3988,4 @@ class StaticScheduleOptions(BaseModel):
39223988
```python
39233989
schedule_options = StaticScheduleOptions(datetime_=datetime.datetime.strptime("2024-05-19T00:00:00+00:00", "%Y-%m-%dT%H:%M:%S%z")
39243990
print(schedule_options.datetime_)
3925-
```
3926-
3927-
## Filter Builder
3928-
Use this class to help construct filter query parameters.
3929-
```python
3930-
old_date = datetime.datetime(2023, 8, 15, 12, 30, 0, 0, tzinfo=datetime.timezone.utc)
3931-
3932-
f = FilterBuilder()
3933-
f.any("email", ["[email protected]", "[email protected]"])
3934-
f.greater_than("created", old_date)
3935-
3936-
# f.build() returns 'any(email,["[email protected]","[email protected]"]),greater-than(created,2023-08-15T12:30:00+00:00)'
3937-
profile_response = client.Profiles.get_profiles(filter=f.build())
3938-
3939-
# You can also chain FilterBuilder methods
3940-
f = FilterBuilder()
3941-
filters = f.any("email", ["[email protected]", "[email protected]"]).greater_than("created", date).build()
3942-
assert filters == "any(email,['[email protected]','[email protected]']),greater-than(created,2023-08-15T12:30:00+00:00)"
3943-
```
3944-
3945-
## Typed Responses
3946-
By default, all API methods will return a type representing the response payload instead of dictionary, as was the case in previous versions of this SDK. Using the typed response, you can access fields of a response using dot notation, like so:
3947-
```python
3948-
from klaviyo_api import KlaviyoAPI
3949-
3950-
client = KlaviyoAPI(
3951-
api_key,
3952-
max_delay=0,
3953-
max_retries=0
3954-
)
3955-
3956-
profiles = client.Profiles.get_profiles()
3957-
profile_id = profiles.data[0].id
3958-
profile = client.Profiles.get_profile(profile_id)
3959-
profile_id = profile.data.id
3960-
profile_email = profile.data.attributes.email
3961-
3962-
print(type(profile).__name__) # prints GetProfileResponseCompoundDocument
3963-
```
3964-
The class used in this example is found [here](src/openapi_client/models/get_profile_response_collection_compound_document.py).
3965-
3966-
This is a breaking change, as response objects will now require dot notation to access their fields versus the subscriptable access method used for dictionaries, i.e. `profile.data.id` vs `profile['data']['id']`. We have provided a [backwards compatibility strategy](#backwards-compatibility) to smooth the transition from dictionary responses to typed responses.
3967-
3968-
### Backwards Compatibility
3969-
To maintain backwards compatibility with previous versions of this SDK, we have added an `options` argument that allows you to continue using dictionaries as response values. There are two ways to use this `options` argument:
3970-
```python
3971-
from klaviyo_api import KlaviyoAPI
3972-
from openapi_client.api_arg_options import USE_DICTIONARY_FOR_RESPONSE_DATA
3973-
3974-
client = KlaviyoAPI(
3975-
api_key,
3976-
max_delay=0,
3977-
max_retries=0
3978-
)
3979-
3980-
# 1: Passing options to an individual API method
3981-
profiles = client.Profiles.get_profiles(options= {
3982-
USE_DICTIONARY_FOR_RESPONSE_DATA: True
3983-
})
3984-
profile_id = profiles["data"][0]['id']
3985-
profile_email = profiles["data"][0]['attributes']['email']
3986-
3987-
# 2: Passing options to API Client
3988-
dictionary_client = KlaviyoAPI(
3989-
api_key,
3990-
max_delay=0,
3991-
max_retries=0,
3992-
options={USE_DICTIONARY_FOR_RESPONSE_DATA : True}
3993-
)
3994-
profiles_ = dictionary_client.Profiles.get_profiles()
3995-
profile_0_id = profiles_["data"][0]['id']
3996-
3997-
profile_0 = dictionary_client.Profiles.get_profile(id=profile_0_id)
3998-
profile_0_email = profile_0["data"]['attributes']['email']
3999-
```
4000-
The first way will only return a dictionary for that specific `get_profiles` call. The second makes it so that all API methods called using `dictionary_client` will return dictionaries as responses.
4001-
4002-
## Untyped Response Data for Specific APIs
4003-
Select APIs do not yet have fully typed responses. Please use our API docs to inspect the schema of the response data for the following APIs.
4004-
- **Segments** - The subproperty `conditions` is not yet typed in responses for the following APIs:
4005-
- [Create Segment](https://developers.klaviyo.com/en/reference/create_segment)
4006-
- [Update Segment](https://developers.klaviyo.com/en/reference/update_segment)
4007-
- [Get Segment](https://developers.klaviyo.com/en/reference/get_segment)
4008-
- [Get Segments](https://developers.klaviyo.com/en/reference/get_segments)
4009-
- The `included` property is not typed in responses for the following APIs:
4010-
- [Get Event](https://developers.klaviyo.com/en/reference/get_event)
4011-
- [Get Events](https://developers.klaviyo.com/en/reference/get_events)
4012-
- [Get Profile](https://developers.klaviyo.com/en/reference/get_profile)
4013-
- [Get Profiles](https://developers.klaviyo.com/en/reference/get_profiles)
4014-
- [Get Flow](https://developers.klaviyo.com/en/reference/get_flow)
4015-
- [Get Flows](https://developers.klaviyo.com/en/reference/get_flows)
4016-
- [Get Flow Message](https://developers.klaviyo.com/en/reference/get_flow_message)
4017-
- [Get Campaign](https://developers.klaviyo.com/en/reference/get_campaign)
4018-
- [Get Campaigns](https://developers.klaviyo.com/en/reference/get_campaigns)
4019-
- The `tracking_options` subproperty is not typed in responses for the following APIs:
4020-
- [Get Flow Action](https://developers.klaviyo.com/en/reference/get_flow_action)
4021-
- [Get Flow Actions](https://developers.klaviyo.com/en/reference/get_flow_flow_actions)
4022-
- [Create Campaign](https://developers.klaviyo.com/en/reference/create_campaign)
4023-
- [Update Campaign](https://developers.klaviyo.com/en/reference/update_campaign)
4024-
- [Get Campaign](https://developers.klaviyo.com/en/reference/get_campaign)
4025-
- [Get Campaigns](https://developers.klaviyo.com/en/reference/get_campaigns)
4026-
- The `send_options` subproperty is not typed in responses for the following APIs:
4027-
- [Create Campaign](https://developers.klaviyo.com/en/reference/create_campaign)
4028-
- [Update Campaign](https://developers.klaviyo.com/en/reference/update_campaign)
4029-
- [Get Campaign](https://developers.klaviyo.com/en/reference/get_campaign)
4030-
- [Get Campaigns](https://developers.klaviyo.com/en/reference/get_campaigns)
4031-
- [Get Campaign Message](https://developers.klaviyo.com/en/reference/get_campaign_message_campaign)
4032-
- [Get Campaign Messages](https://developers.klaviyo.com/en/reference/get_campaign_campaign_messages)
4033-
- The `content` subproperty is not typed in responses for the following APIs:
4034-
- [Get Flow Message](https://developers.klaviyo.com/en/reference/get_flow_message)
4035-
- [Get Flow Action Messages](https://developers.klaviyo.com/en/reference/get_flow_action_messages)
4036-
- [Get Campaign Message](https://developers.klaviyo.com/en/reference/get_campaign_message_campaign)
4037-
- [Get Campaign Messages](https://developers.klaviyo.com/en/reference/get_campaign_campaign_messages)
3991+
```

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "openapi_client"
3-
version = "11.0.0"
3+
version = "11.0.1"
44
description = "Klaviyo API"
55
authors = ["Klaviyo Developer Experience Team <[email protected]>"]
66
license = "License"

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = klaviyo-api
3-
version = 11.0.0
3+
version = 11.0.1
44
author = Klaviyo Developers
55
author_email = [email protected]
66
description = Klaviyo Python SDK

src/klaviyo_api/wrapper.py

+11
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from openapi_client.api import segments_api
2525
from openapi_client.api import tags_api
2626
from openapi_client.api import templates_api
27+
from openapi_client.api import tests_api
2728
from openapi_client.api import webhooks_api
2829

2930

@@ -405,6 +406,16 @@ def __post_init__(self):
405406
self.Templates.update_template=self._page_cursor_update(self.retry_logic(self.Templates.update_template))
406407

407408

409+
## Adding Tests to Client
410+
self.Tests=tests_api.TestsApi(self.api_client)
411+
412+
## Applying tenacity retry decorator to each endpoint in Tests
413+
self.Tests.get_test_bulk_create_photos_jobs=self._page_cursor_update(self.retry_logic(self.Tests.get_test_bulk_create_photos_jobs))
414+
self.Tests.get_test_cities=self._page_cursor_update(self.retry_logic(self.Tests.get_test_cities))
415+
self.Tests.get_test_photographers=self._page_cursor_update(self.retry_logic(self.Tests.get_test_photographers))
416+
self.Tests.get_test_photos=self._page_cursor_update(self.retry_logic(self.Tests.get_test_photos))
417+
418+
408419
## Adding Webhooks to Client
409420
self.Webhooks=webhooks_api.WebhooksApi(self.api_client)
410421

0 commit comments

Comments
 (0)