Trait

class q2_smart.ts_endpoints.traits.UserTrait(trait_id, trait_value)[source]

Bases: object

Model that describes the payload for the set_user_traits endpoint.

trait_id: str

The id of the trait being set for the user

trait_value: str | bool | float | int

The value of the trait. The data type depends on the trait being set.

class q2_smart.ts_endpoints.traits.TraitBatch(user_id, trait_value)[source]

Bases: object

Model that describes the payload for the set_trait_batch endpoint.

user_id: int

The user id the trait is being set for

trait_value: str | bool | float | int

The value of the trait. The data type depends on the trait being set.

class q2_smart.ts_endpoints.traits.Traits(logger, config, cache)[source]

Bases: TSEndpoint

async get()[source]

Return visible trait metadata for the authenticated FI.

Return type:

TraitList

property mock_get_traits: dict
async set_trait(trait_id, user_id)[source]

Deprecated. Please use set_user_traits instead.

Return type:

bool

property mock_set_trait: dict
async set_user_traits(user_id, user_traits)[source]

Set multiple traits for a specific user in batch.

Parameters:
  • user_id (int) – The ID of the user to set traits for

  • user_traits (list[UserTrait]) – List of UserTrait objects containing trait_id and trait_value pairs

Return type:

dict

Returns:

Response data indicating the number of success, or error information

property mock_set_user_traits: dict
async set_trait_batch(trait_id, trait_batch)[source]

Set a specific trait for multiple users in batch.

Parameters:
  • trait_id (str) – The ID of the trait to set

  • trait_batch (list[TraitBatch]) – List of TraitBatch objects containing user_id and trait_value pairs

Return type:

dict

Returns:

Response data indicating the number of successfully set traits, and any error information

property mock_set_trait_batch: dict

GET traits models

class q2_smart.ts_endpoints.models.trait_list.TraitMetadata(id, display_name, description, type, source, users_count, total_users)[source]

Visible trait metadata.

users_count and total_users are snapshots from daily trait coverage processing, not live counts. They may be older when processing is delayed.

id: str
display_name: str
description: str
type: str
source: str | None
users_count: int
total_users: int
to_dict()[source]
Return type:

dict

class q2_smart.ts_endpoints.models.trait_list.TraitList(traits)[source]

TraitList(traits: list[q2_smart.ts_endpoints.models.trait_list.TraitMetadata])

traits: list[TraitMetadata]
classmethod from_response(payload)[source]
Return type:

TraitList

to_json()[source]
Return type:

dict