Skip to content

Commit 0f8438f

Browse files
author
klaviyo-sdk
committed
version 15.0.0
1 parent e0bba51 commit 0f8438f

File tree

47 files changed

+6076
-5536
lines changed

Some content is hidden

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

47 files changed

+6076
-5536
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,20 @@ 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+
## [15.0.0] - 2024-10-15
11+
### Added
12+
- Lazy imports (optional)
13+
- Set `KLAVIYO_PYTHON_SDK_LAZY_IMPORTS` environment variable to `true` to use lazy imports, which will reduce initial load time of library
14+
- Note that using this option may break imports from `openapi_client`
15+
- See [README](https://github.com/klaviyo/klaviyo-api-python-internal/blob/main/README.md#lazy-imports) for more details
16+
### Changed
17+
- **Breaking:** renamed several models:
18+
- `GetCampaignMessageTemplateRelationshipListResponse` -> `GetCampaignMessageTemplateRelationshipResponse`
19+
- `GetListFlowTriggersRelationshipResponseCollection` -> `GetListFlowTriggersRelationshipsResponseCollection`
20+
- `GetMetricFlowTriggersRelationshipResponseCollection` -> `GetMetricFlowTriggersRelationshipsResponseCollection`
21+
- `PostListCreateResponseDataRelationshipsFlowTriggers` -> `GetMetricResponseCollectionCompoundDocumentDataInnerAllOfRelationshipsFlowTriggers`
22+
- `GetMetricFlowTriggersRelationshipResponseCollectionDataInner` -> `GetMetricResponseCollectionCompoundDocumentDataInnerAllOfRelationshipsFlowTriggersDataInner`
23+
1024
## [14.0.0] - 2024-10-15
1125
### Added
1226
- Universal Content API

README.md

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

3-
- SDK version: 14.0.0
3+
- SDK version: 15.0.0
44
- API revision: 2024-10-15
55

66
## Table of Contents
@@ -44,6 +44,11 @@
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)
51+
* [Lazy Imports](#lazy-imports)
4752
<!-- TOC -->
4853

4954
## Helpful Resources
@@ -3367,11 +3372,15 @@ klaviyo.Profiles.create_profile_suppression_bulk_delete_job(body)
33673372

33683373
# body | dict
33693374

3370-
klaviyo.Profiles.create_or_update_profile(body)
3375+
## Keyword Arguments
3376+
3377+
# additional_fields_profile | List[str]
3378+
3379+
klaviyo.Profiles.create_or_update_profile(body, additional_fields_profile=additional_fields_profile)
33713380
```
33723381
##### Method alias:
33733382
```python
3374-
klaviyo.Profiles.create_profile_import(body)
3383+
klaviyo.Profiles.create_profile_import(body, additional_fields_profile=additional_fields_profile)
33753384
```
33763385

33773386

@@ -3384,7 +3393,11 @@ klaviyo.Profiles.create_profile_import(body)
33843393

33853394
# body | dict
33863395

3387-
klaviyo.Profiles.create_profile(body)
3396+
## Keyword Arguments
3397+
3398+
# additional_fields_profile | List[str]
3399+
3400+
klaviyo.Profiles.create_profile(body, additional_fields_profile=additional_fields_profile)
33883401
```
33893402

33903403

@@ -3829,7 +3842,11 @@ klaviyo.Profiles.create_profile_bulk_import_job(body)
38293842
# id | str
38303843
# body | dict
38313844

3832-
klaviyo.Profiles.update_profile(id, body)
3845+
## Keyword Arguments
3846+
3847+
# additional_fields_profile | List[str]
3848+
3849+
klaviyo.Profiles.update_profile(id, body, additional_fields_profile=additional_fields_profile)
38333850
```
38343851

38353852

@@ -5090,4 +5107,133 @@ class StaticScheduleOptions(BaseModel):
50905107
```python
50915108
schedule_options = StaticScheduleOptions(datetime_=datetime.datetime.strptime("2024-05-19T00:00:00+00:00", "%Y-%m-%dT%H:%M:%S%z")
50925109
print(schedule_options.datetime_)
5110+
```
5111+
5112+
## Filter Builder
5113+
Use this class to help construct filter query parameters.
5114+
```python
5115+
old_date = datetime.datetime(2023, 8, 15, 12, 30, 0, 0, tzinfo=datetime.timezone.utc)
5116+
5117+
f = FilterBuilder()
5118+
f.any("email", ["[email protected]", "[email protected]"])
5119+
f.greater_than("created", old_date)
5120+
5121+
# f.build() returns 'any(email,["[email protected]","[email protected]"]),greater-than(created,2023-08-15T12:30:00+00:00)'
5122+
profile_response = client.Profiles.get_profiles(filter=f.build())
5123+
5124+
# You can also chain FilterBuilder methods
5125+
f = FilterBuilder()
5126+
filters = f.any("email", ["[email protected]", "[email protected]"]).greater_than("created", date).build()
5127+
assert filters == "any(email,['[email protected]','[email protected]']),greater-than(created,2023-08-15T12:30:00+00:00)"
5128+
```
5129+
5130+
## Typed Responses
5131+
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:
5132+
```python
5133+
from klaviyo_api import KlaviyoAPI
5134+
5135+
client = KlaviyoAPI(
5136+
api_key,
5137+
max_delay=0,
5138+
max_retries=0
5139+
)
5140+
5141+
profiles = client.Profiles.get_profiles()
5142+
profile_id = profiles.data[0].id
5143+
profile = client.Profiles.get_profile(profile_id)
5144+
profile_id = profile.data.id
5145+
profile_email = profile.data.attributes.email
5146+
5147+
print(type(profile).__name__) # prints GetProfileResponseCompoundDocument
5148+
```
5149+
The class used in this example is found [here](src/openapi_client/models/get_profile_response_collection_compound_document.py).
5150+
5151+
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.
5152+
5153+
### Backwards Compatibility
5154+
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:
5155+
```python
5156+
from klaviyo_api import KlaviyoAPI
5157+
from openapi_client.api_arg_options import USE_DICTIONARY_FOR_RESPONSE_DATA
5158+
5159+
client = KlaviyoAPI(
5160+
api_key,
5161+
max_delay=0,
5162+
max_retries=0
5163+
)
5164+
5165+
# 1: Passing options to an individual API method
5166+
profiles = client.Profiles.get_profiles(options= {
5167+
USE_DICTIONARY_FOR_RESPONSE_DATA: True
5168+
})
5169+
profile_id = profiles["data"][0]['id']
5170+
profile_email = profiles["data"][0]['attributes']['email']
5171+
5172+
# 2: Passing options to API Client
5173+
dictionary_client = KlaviyoAPI(
5174+
api_key,
5175+
max_delay=0,
5176+
max_retries=0,
5177+
options={USE_DICTIONARY_FOR_RESPONSE_DATA : True}
5178+
)
5179+
profiles_ = dictionary_client.Profiles.get_profiles()
5180+
profile_0_id = profiles_["data"][0]['id']
5181+
5182+
profile_0 = dictionary_client.Profiles.get_profile(id=profile_0_id)
5183+
profile_0_email = profile_0["data"]['attributes']['email']
5184+
```
5185+
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.
5186+
5187+
## Untyped Response Data for Specific APIs
5188+
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.
5189+
- **Segments** - The subproperty `conditions` is not yet typed in responses for the following APIs:
5190+
- [Create Segment](https://developers.klaviyo.com/en/reference/create_segment)
5191+
- [Update Segment](https://developers.klaviyo.com/en/reference/update_segment)
5192+
- [Get Segment](https://developers.klaviyo.com/en/reference/get_segment)
5193+
- [Get Segments](https://developers.klaviyo.com/en/reference/get_segments)
5194+
- The `included` property is not typed in responses for the following APIs:
5195+
- [Get Event](https://developers.klaviyo.com/en/reference/get_event)
5196+
- [Get Events](https://developers.klaviyo.com/en/reference/get_events)
5197+
- [Get Profile](https://developers.klaviyo.com/en/reference/get_profile)
5198+
- [Get Profiles](https://developers.klaviyo.com/en/reference/get_profiles)
5199+
- [Get Flow](https://developers.klaviyo.com/en/reference/get_flow)
5200+
- [Get Flows](https://developers.klaviyo.com/en/reference/get_flows)
5201+
- [Get Flow Message](https://developers.klaviyo.com/en/reference/get_flow_message)
5202+
- [Get Campaign](https://developers.klaviyo.com/en/reference/get_campaign)
5203+
- [Get Campaigns](https://developers.klaviyo.com/en/reference/get_campaigns)
5204+
- The `tracking_options` subproperty is not typed in responses for the following APIs:
5205+
- [Get Flow Action](https://developers.klaviyo.com/en/reference/get_flow_action)
5206+
- [Get Actions for Flow](https://developers.klaviyo.com/en/reference/get_actions_for_flow)
5207+
- [Create Campaign](https://developers.klaviyo.com/en/reference/create_campaign)
5208+
- [Update Campaign](https://developers.klaviyo.com/en/reference/update_campaign)
5209+
- [Get Campaign](https://developers.klaviyo.com/en/reference/get_campaign)
5210+
- [Get Campaigns](https://developers.klaviyo.com/en/reference/get_campaigns)
5211+
- The `send_options` subproperty is not typed in responses for the following APIs:
5212+
- [Create Campaign](https://developers.klaviyo.com/en/reference/create_campaign)
5213+
- [Update Campaign](https://developers.klaviyo.com/en/reference/update_campaign)
5214+
- [Get Campaign](https://developers.klaviyo.com/en/reference/get_campaign)
5215+
- [Get Campaigns](https://developers.klaviyo.com/en/reference/get_campaigns)
5216+
- [Get Campaign for Campaign Message](https://developers.klaviyo.com/en/reference/get_campaign_for_campaign_message)
5217+
- [Get Messages for Campaign](https://developers.klaviyo.com/en/reference/get_messages_for_campaign)
5218+
- The `content` subproperty is not typed in responses for the following APIs:
5219+
- [Get Flow Message](https://developers.klaviyo.com/en/reference/get_flow_message)
5220+
- [Get Messages for Flow Action](https://developers.klaviyo.com/en/reference/get_messages_for_flow_action)
5221+
- [Get Campaign for Campaign Message](https://developers.klaviyo.com/en/reference/get_campaign_for_campaign_message)
5222+
- [Get Messages for Campaign](https://developers.klaviyo.com/en/reference/get_messages_for_campaign)
5223+
5224+
5225+
## Lazy Imports
5226+
If the `klaviyo_api` import has a long load time, you can set the following environment variable to speed it up:
5227+
```shell
5228+
export KLAVIYO_PYTHON_SDK_LAZY_IMPORTS=true
5229+
```
5230+
With this, API classes and models will be imported per-API (e.g. when you use the Profiles API, it only imports profiles-related classes).
5231+
5232+
**With this setting, you can no longer tersely import from `openapi_client`**. That is, instead of:
5233+
```python
5234+
from openapi_client import CampaignCreateQuery
5235+
```
5236+
you will need:
5237+
```python
5238+
from openapi_client.models.campaign_create_query import CampaignCreateQuery
50935239
```

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 = "14.0.0"
3+
version = "15.0.0"
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 = 14.0.0
3+
version = 15.0.0
44
author = Klaviyo Developers
55
author_email = [email protected]
66
description = Klaviyo Python SDK

0 commit comments

Comments
 (0)