You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, allAPI 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 importUSE_DICTIONARY_FOR_RESPONSE_DATA
The first way will only return a dictionary for that specific `get_profiles` call. The second makes it so that allAPI 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`isnot yet typed in responses for the following APIs:
0 commit comments