Skip to content

Commit 3367929

Browse files
author
klaviyo-sdk
committed
version 13.0.0
1 parent 3fd7b7a commit 3367929

35 files changed

+369
-271
lines changed

CHANGELOG.md

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

17815
## [7.0.0] - revision 2024-02-15
17916

@@ -448,4 +285,4 @@ For EmailMarketing:
448285
- client name: `Client``KlaviyoAPI`
449286
- Client variable name in readme examples: `client``klaviyo`
450287
- Some functions have changed name
451-
- New resources and endpoints: see [API Changelog](https://developers.klaviyo.com/en/docs/changelog_) for full details
288+
- New resources and endpoints: see [API Changelog](https://developers.klaviyo.com/en/docs/changelog_) for full details

README.md

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

3-
- SDK version: 12.0.0
3+
- SDK version: 13.0.0
44
- API revision: 2024-07-15
55

66
## Table of Contents

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

src/openapi_client/__init__.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
""" # noqa: E501
1616

1717

18-
__version__ = "12.0.0"
18+
__version__ = "13.0.0"
1919

2020
# import apis into sdk package
2121
from openapi_client.api.accounts_api import AccountsApi
@@ -467,6 +467,7 @@
467467
from openapi_client.models.get_form_version_form_relationship_response import GetFormVersionFormRelationshipResponse
468468
from openapi_client.models.get_form_version_form_relationship_response_data import GetFormVersionFormRelationshipResponseData
469469
from openapi_client.models.get_form_version_response import GetFormVersionResponse
470+
from openapi_client.models.get_form_version_response_collection import GetFormVersionResponseCollection
470471
from openapi_client.models.get_image_response import GetImageResponse
471472
from openapi_client.models.get_image_response_collection import GetImageResponseCollection
472473
from openapi_client.models.get_import_error_response_collection import GetImportErrorResponseCollection
@@ -485,11 +486,11 @@
485486
from openapi_client.models.get_list_retrieve_response_compound_document import GetListRetrieveResponseCompoundDocument
486487
from openapi_client.models.get_list_retrieve_response_compound_document_data import GetListRetrieveResponseCompoundDocumentData
487488
from openapi_client.models.get_list_tag_relationship_list_response_collection import GetListTagRelationshipListResponseCollection
488-
from openapi_client.models.get_metric_response_collection import GetMetricResponseCollection
489+
from openapi_client.models.get_metric_response import GetMetricResponse
489490
from openapi_client.models.get_metric_response_collection_compound_document import GetMetricResponseCollectionCompoundDocument
490-
from openapi_client.models.get_metric_response_collection_data_inner import GetMetricResponseCollectionDataInner
491-
from openapi_client.models.get_metric_response_collection_data_inner_all_of_relationships import GetMetricResponseCollectionDataInnerAllOfRelationships
492491
from openapi_client.models.get_metric_response_compound_document import GetMetricResponseCompoundDocument
492+
from openapi_client.models.get_metric_response_data import GetMetricResponseData
493+
from openapi_client.models.get_metric_response_data_all_of_relationships import GetMetricResponseDataAllOfRelationships
493494
from openapi_client.models.get_profile_import_job_list_relationships_response_collection import GetProfileImportJobListRelationshipsResponseCollection
494495
from openapi_client.models.get_profile_import_job_profile_relationships_response_collection import GetProfileImportJobProfileRelationshipsResponseCollection
495496
from openapi_client.models.get_profile_import_job_response_collection_compound_document import GetProfileImportJobResponseCollectionCompoundDocument
@@ -500,17 +501,18 @@
500501
from openapi_client.models.get_profile_import_job_response_collection_compound_document_data_inner_all_of_relationships_lists_data_inner import GetProfileImportJobResponseCollectionCompoundDocumentDataInnerAllOfRelationshipsListsDataInner
501502
from openapi_client.models.get_profile_import_job_response_compound_document import GetProfileImportJobResponseCompoundDocument
502503
from openapi_client.models.get_profile_list_relationships_response_collection import GetProfileListRelationshipsResponseCollection
504+
from openapi_client.models.get_profile_response import GetProfileResponse
503505
from openapi_client.models.get_profile_response_collection import GetProfileResponseCollection
504506
from openapi_client.models.get_profile_response_collection_compound_document import GetProfileResponseCollectionCompoundDocument
505-
from openapi_client.models.get_profile_response_collection_data_inner import GetProfileResponseCollectionDataInner
506-
from openapi_client.models.get_profile_response_collection_data_inner_all_of_relationships import GetProfileResponseCollectionDataInnerAllOfRelationships
507507
from openapi_client.models.get_profile_response_compound_document import GetProfileResponseCompoundDocument
508508
from openapi_client.models.get_profile_response_compound_document_data import GetProfileResponseCompoundDocumentData
509509
from openapi_client.models.get_profile_response_compound_document_data_all_of_relationships import GetProfileResponseCompoundDocumentDataAllOfRelationships
510510
from openapi_client.models.get_profile_response_compound_document_data_all_of_relationships_lists import GetProfileResponseCompoundDocumentDataAllOfRelationshipsLists
511511
from openapi_client.models.get_profile_response_compound_document_data_all_of_relationships_lists_data_inner import GetProfileResponseCompoundDocumentDataAllOfRelationshipsListsDataInner
512512
from openapi_client.models.get_profile_response_compound_document_data_all_of_relationships_segments import GetProfileResponseCompoundDocumentDataAllOfRelationshipsSegments
513513
from openapi_client.models.get_profile_response_compound_document_data_all_of_relationships_segments_data_inner import GetProfileResponseCompoundDocumentDataAllOfRelationshipsSegmentsDataInner
514+
from openapi_client.models.get_profile_response_data import GetProfileResponseData
515+
from openapi_client.models.get_profile_response_data_all_of_relationships import GetProfileResponseDataAllOfRelationships
514516
from openapi_client.models.get_profile_segment_relationships_response_collection import GetProfileSegmentRelationshipsResponseCollection
515517
from openapi_client.models.get_segment_list_response_collection_compound_document import GetSegmentListResponseCollectionCompoundDocument
516518
from openapi_client.models.get_segment_list_response_collection_compound_document_data_inner import GetSegmentListResponseCollectionCompoundDocumentDataInner

src/openapi_client/api/coupons_api.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -3858,7 +3858,7 @@ def get_coupon_for_coupon_code(
38583858
_headers: Optional[Dict[StrictStr, Any]] = None,
38593859
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
38603860
options: Dict[str, Any] = {},
3861-
) -> Union[GetCouponResponseCollection, Dict[str, object]]:
3861+
) -> Union[GetCouponResponse, Dict[str, object]]:
38623862
"""Get Coupon For Coupon Code
38633863
38643864
Get the coupon associated with a given coupon code ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `coupons:read`
@@ -3899,7 +3899,7 @@ def get_coupon_for_coupon_code(
38993899
)
39003900

39013901
_response_types_map: Dict[str, Optional[str]] = {
3902-
'200': "GetCouponResponseCollection",
3902+
'200': "GetCouponResponse",
39033903
'4XX': "GetAccounts4XXResponse",
39043904
'5XX': "GetAccounts4XXResponse",
39053905
}
@@ -3947,7 +3947,7 @@ def get_coupon_for_coupon_code_with_http_info(
39473947
_headers: Optional[Dict[StrictStr, Any]] = None,
39483948
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
39493949
options: Dict[str, Any] = {},
3950-
) -> ApiResponse[GetCouponResponseCollection]:
3950+
) -> ApiResponse[GetCouponResponse]:
39513951
"""Get Coupon For Coupon Code
39523952
39533953
Get the coupon associated with a given coupon code ID.<br><br>*Rate limits*:<br>Burst: `75/s`<br>Steady: `700/m` **Scopes:** `coupons:read`
@@ -3988,7 +3988,7 @@ def get_coupon_for_coupon_code_with_http_info(
39883988
)
39893989

39903990
_response_types_map: Dict[str, Optional[str]] = {
3991-
'200': "GetCouponResponseCollection",
3991+
'200': "GetCouponResponse",
39923992
'4XX': "GetAccounts4XXResponse",
39933993
'5XX': "GetAccounts4XXResponse",
39943994
}
@@ -4073,7 +4073,7 @@ def get_coupon_for_coupon_code_without_preload_content(
40734073
)
40744074

40754075
_response_types_map: Dict[str, Optional[str]] = {
4076-
'200': "GetCouponResponseCollection",
4076+
'200': "GetCouponResponse",
40774077
'4XX': "GetAccounts4XXResponse",
40784078
'5XX': "GetAccounts4XXResponse",
40794079
}

0 commit comments

Comments
 (0)