Skip to content

Commit 16a87f9

Browse files
author
klaviyo-sdk
committed
version 12.0.0
1 parent 3e039d3 commit 16a87f9

File tree

75 files changed

+1279
-3524
lines changed

Some content is hidden

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

75 files changed

+1279
-3524
lines changed

CHANGELOG.md

+5-158
Original file line numberDiff line numberDiff line change
@@ -7,165 +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.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
13-
14-
15-
## [11.0.0] Typed SDK - revision 2024-07-15
16-
10+
## [12.0.0] - 2024-07-15
1711
### Added
18-
- Typed Responses (Breaking change)
19-
- 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:
20-
```python
21-
from klaviyo_api import KlaviyoAPI
22-
23-
client = KlaviyoAPI(
24-
api_key,
25-
max_delay=0,
26-
max_retries=0
27-
)
28-
29-
profiles = client.Profiles.get_profiles()
30-
profile_id = profiles.data[0].id
31-
profile = client.Profiles.get_profile(profile_id)
32-
profile_id = profile.data.id
33-
profile_email = profile.data.attributes.email
34-
35-
print(type(profile).__name__) # prints GetProfileResponseCompoundDocument
36-
```
37-
The class used in this example is found [here](src/openapi_client/models/get_profile_response_collection_compound_document.py).
38-
39-
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.
40-
41-
#### Backwards Compatibility
42-
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:
43-
```python
44-
from klaviyo_api import KlaviyoAPI
45-
from openapi_client.api_arg_options import USE_DICTIONARY_FOR_RESPONSE_DATA
46-
47-
client = KlaviyoAPI(
48-
api_key,
49-
max_delay=0,
50-
max_retries=0
51-
)
52-
53-
54-
# 1: Passing options to an individual API method
55-
profiles = client.Profiles.get_profiles(options= {
56-
USE_DICTIONARY_FOR_RESPONSE_DATA: True
57-
})
58-
profile_id = profiles["data"][0]['id']
59-
profile_email = profiles["data"][0]['attributes']['email']
60-
61-
# 2: Passing options to API Client
62-
dictionary_client = KlaviyoAPI(
63-
api_key,
64-
max_delay=0,
65-
max_retries=0,
66-
options={USE_DICTIONARY_FOR_RESPONSE_DATA : True}
67-
)
68-
profiles_ = dictionary_client.Profiles.get_profiles()
69-
profile_0_id = profiles_["data"][0]['id']
70-
71-
profile_0 = dictionary_client.Profiles.get_profile(id=profile_0_id)
72-
profile_0_email = profile_0["data"]['attributes']['email']
73-
```
74-
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.
75-
76-
- 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.
77-
- Filter Builder - A new class to help construct filter query parameters.
78-
```python
79-
old_date = datetime.datetime(2023, 8, 15, 12, 30, 0, 0, tzinfo=datetime.timezone.utc)
80-
f = FilterBuilder()
81-
f.any("email", ["[email protected]", "[email protected]"])
82-
f.greater_than("created", old_date)
83-
84-
# f.build() returns 'any(email,["[email protected]","[email protected]"]),greater-than(created,2023-08-15T12:30:00+00:00)'
85-
profile_response = client.Profiles.get_profiles(filter=f.build())
86-
87-
# You can also chain FilterBuilder methods
88-
f = FilterBuilder()
89-
filters = f.any("email", ["[email protected]", "[email protected]"]).greater_than("created", date).build()
90-
assert filters == "any(email,['[email protected]','[email protected]']),greater-than(created,2023-08-15T12:30:00+00:00)"
91-
```
92-
93-
94-
## [10.0.0] - revision 2024-07-15
95-
96-
### Added
97-
98-
- Forms API
99-
- New `klaviyo.Forms` class with methods to get forms, form versions and relationships
100-
- Webhooks API
101-
- new `klaviyo.Webooks` class containing CRUD operations for webhooks
102-
103-
### Changed
104-
- `klaviyo.Profiles.subscribe()`
105-
- added `historical_import` flag for importing historically consented profiles can now be optionally supplied in the payload for the Subscribe Profiles endpoint.
106-
- When using this flag, a consented_at date must be provided and must be in the past.
107-
108-
109-
## [9.0.0] - revision 2024-06-15
110-
111-
### Added
112-
- Segments Api
113-
- New create segment endpoint `SegmentsApi.createSegment()`.
114-
- New delete segment endpoint `SegementsApi.deleteSegment()`.
115-
- Updated exisiting segments endpoints to include the segment definition
116-
- For more information, see our [Segments API overview](https://developers.klaviyo.com/en/reference/segments_api_overview).
117-
118-
- Flows Api
119-
- New delete flows endpoint `FlowsApi.deleteFlow()`
120-
121-
122-
## [8.0.1] - revision 2024-05-15
123-
124-
### Added
125-
126-
- Fixes issue where `filter` query params for any API call were being duplicated on request send. See issue: https://github.com/klaviyo/klaviyo-api-python/issues/51
127-
128-
129-
## [8.0.0] - revision 2024-05-15
130-
131-
### Added
132-
133-
- Bulk Create Events API with
134-
- We have added support for creating events in bulk via the EventsApi.bulkCreateEvents method
135-
- Create multiple events for new and existing profiles and/or update profile properties in a single API call. For more information, see our [Events API overview](https://developers.klaviyo.com/en/reference/events_api_overview).
136-
137-
### Changed
138-
139-
- Accounts API
140-
- `Accounts.get_account` and `Accounts.get_accounts` have been updated to return the account's locale, e.g. `"en-US"`.
141-
142-
- **Breaking**
143-
- Subscribe API Synchronous Validation Improved
144-
- To provide better feedback for handling SMS subscriptions, we’ve added improved validation behavior to ProfilesApi.subscribeProfiles method. In prior revisions, such requests may appear as 202s but will fail to update SMS consent. To handle this issue, 400 validation errors are returned for the following cases
145-
1. If a profile is subscribed to SMS marketing and [age-gating is enabled](https://help.klaviyo.com/hc/en-us/articles/4408311712667) but age_gated_date_of_birth is not provided, or the DOB does not meet the region's requirements.
146-
2. If the account does not have a sending number in the phone number’s region.
147-
3. If the phone number is in a region not supported by Klaviyo.
148-
4. If consented_at is set and the list or global setting is double opt-in.
149-
- Pydantic V2
150-
- This SDK now uses Pydantic V2. This may cause some compatibility issues if your source code depends on Pydantic V1.
151-
- Renamed Fields in SDK
152-
- As of the 2024-05-15 release, some models fields are named differently than they appear in API documentation. These fields are
153-
- `datetime`: renamed to `datetime_`
154-
- `date`: renamed to `date_`
155-
156-
This is to manage compatibility with Pydantic v2. An example of this can be seen in [StaticScheduleOptions](src/openapi_client/models/static_schedule_options.py).
157-
158-
```python
159-
class StaticScheduleOptions(BaseModel):
160-
"""
161-
StaticScheduleOptions
162-
""" # noqa: E501
163-
datetime_: datetime = Field(description="The time to send at", alias="datetime")
164-
165-
schedule_options = StaticScheduleOptions(datetime_=datetime.datetime.strptime("2024-05-19T00:00:00+00:00", "%Y-%m-%dT%H:%M:%S%z")
166-
print(schedule_options.datetime_)
167-
```
168-
12+
- Added several method aliases based on previous operation IDs
13+
### Fixed
14+
- **Breaking**
15+
- Removed incorrect `links` property from several DTO classes
16916

17017
## [7.0.0] - revision 2024-02-15
17118

0 commit comments

Comments
 (0)