Profiles

Retrieving profile objects

class ProfileMixin

This class defines all functions related to BlueConic profiles.

get_profile(profile_id: str, properties: Sequence[str] = None, include_timeline_events: bool = False, timeline_events_filter: blueconic.client.timeline_events_filter.TimelineEventsFilter = None) → blueconic.domain.profile.Profile

Gets the profile with the profile ID and returns it as a BlueConic profile.

Parameters:
  • profile_id (str) – ID of the profile to return
  • properties ([str], optional) – The profile properties to return with the profile. Leave empty for all the profile properties. Defaults to None.
  • include_timeline_events (bool. Defaults to False.) – Add timeline events to profile
  • timeline_events_filter (TimelineEventsFilter, optional) – Timeline filters to limit the returned timeline events. See filtering timeline events for details.
Raises:

HTTPError: Request fails

Returns:

A profile with the requested properties

Return type:

Profile

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> profile = bc.get_profile('example_profile_id', include_timeline_events=True)
>>> profile.id
Example Profile id
get_profiles(segment_id: str, start: int = 0, count: int = 1000, properties: Sequence[str] = None, progress_bar: bool = True, required_properties: Sequence[str] = None, step: int = None, filters: Union[blueconic.client.filters.FilterConfig, Sequence[blueconic.client.filters.FilterConfig]] = None, include_timeline_events: bool = False, timeline_events_filter: blueconic.client.timeline_events_filter.TimelineEventsFilter = None) → Iterator[blueconic.domain.profile.Profile]

Gets all profiles and returns them in a generator with all BlueConic profiles.

Parameters:
  • segment_id (str) – Profiles are retrieved from the segment with this ID.
  • start (int, optional) – The profile to start from. Defaults to 0.
  • count (int, optional) – The number of profiles to retrieve. To get all profiles in a segment, use count=0. Defaults to 1000.
  • properties ([str], optional) – The profile properties that should be retrieved. Leave empty to retrieve all profile properties. Defaults to None.
  • progress_bar (bool, optional) – Enables the view of the progress bar, which shows the progress of the profile retrieval. Defaults to True.
  • required_properties ([str], optional) – Profile properties that should be filled. Defaults to None.
  • filters (Union[FilterConfig, Sequence[FilterConfig]], optional) – Property filters to limit the returned profiles. See filtering profiles for details.
  • include_timeline_events (bool. Defaults to False.) – Add timeline events to profile
  • timeline_events_filter (TimelineEventsFilter, optional) – Timeline filters to limit the returned timeline events. See filtering timeline events for details.
Raises:

ValueError – If count or start is lower than 0

Returns:

Iterator with Profiles

Return type:

Iterator[Profile]

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> segment_id = bc.get_blueconic_parameter_value("My segment","segment")
>>> profiles = bc.get_profiles(segment_id, count=10000)
>>> with bc.get_profile_bulkhandler() as bh:
>>>     for profile in profiles:
>>>         print(profile.id)
>>>         next_best_product_for_this_profile = calculate_next_best_product_for_this_profile()
>>>         profile.add_value('next_best_product', next_best_product_for_this_profile)
>>>         bh.write(profile)

Using profile objects

class Profile
__init__(profile_id: str = None, properties: MutableMapping[str, MutableSequence[Union[int, str, float, bool, datetime.date, datetime.datetime, datetime.time, PropertiesMap]]] = None, segments: Sequence[str] = None, permission_level: str = None, privacy_legislation: str = None, consented_objectives: str = None, refused_objectives: str = None, timeline_events: List[blueconic.domain.timeline_event.TimelineEvent] = None)

This class represents a BlueConic profile.

Parameters:
  • profile_id (str) – The ID of the profile
  • properties ([str]) – The profile properties of this profile
  • segments (Segment, optional) – The segments this profile occurs in at this moment. Defaults to None.
  • permission_level (str, optional) – The permission level of this profile. Defaults to None.
  • privacy_legislation (str, optional) – The privacy legislation of this profile. Defaults to None.
  • consented_objectives (str, optional) – The objectives this profile consented to. Defaults to None.
  • refused_objectives (str, optional,) – The objectives this profile refused. Defaults to None.
  • timeline_events (Iterable[Event]) – The timeline events of this profile. Defaults to None.
add_timeline_event(timeline_event: blueconic.domain.timeline_event.TimelineEvent)

Add a single timeline event to this profile.

Parameters:timeline_event (TimelineEvent) – The timeline event to be added to the profile.
add_timeline_events(*timeline_events)

Add a list of timeline event to this profile.

Parameters:timeline_events ([TimelineEvent]) – The timeline events to be added to the profile.
add_value(property_id: str, property_value: Union[int, str, float, bool, datetime.date, datetime.datetime, datetime.time, PropertiesMap])

Adds one value to the property. Keeps existing values intact.

Parameters:
get_value(property_id: str) → Union[int, str, float, bool, datetime.date, datetime.datetime, datetime.time, blueconic.domain.hash_map.PropertiesMap, None]

Gets the first value of a property.

Parameters:property_id (str) – The ID of the property to retrieve the value from
Raises:KeyError – If the ID does not refer to an existing property
Returns:The first value of the property
Return type:str
get_values(property_id: str) → Sequence[Union[int, str, float, bool, datetime.date, datetime.datetime, datetime.time, blueconic.domain.hash_map.PropertiesMap]]

Gets all values of a property.

Parameters:property_id (str) – The ID of the property to retrieve the values from
Raises:KeyError – If the ID does not refer to an existing property
Returns:All the values of the property
Return type:[str]
set_value(property_id: str, property_value: Union[int, str, float, bool, datetime.date, datetime.datetime, datetime.time, PropertiesMap], set_if_empty: bool = False)

Sets one value for this property. Removes all values that were already present.

Parameters:
  • property_id (str) – The ID of the property
  • property_value (int or str or bool or float or datetime.datetime) – The value to set. All values are cast to a string
  • set_if_empty (bool, optional) – When set to False, the existing value will always be replaced with the new value. Set this parameter to True to set the new value only when there was no value yet present in the property. Defaults to False.
Raises:

KeyError – If the ID does not refer to an existing property

set_values(property_id: str, property_values: Sequence[Union[int, str, float, bool, datetime.date, datetime.datetime, datetime.time, PropertiesMap]], set_if_empty: bool = False)

Sets multiple values for this property. Remove all values that were already present.

Parameters:
  • property_id (str) – The ID of the property
  • property_values ([int or str or bool or float or datetime.datetime]) – A list of values. All values are cast to a string
  • set_if_empty (bool) – When set to False, the existing values will always be replaced with the new values. Set this parameter to True to set the new values only when there were no values yet present in the property. Defaults to False.
consented_objectives

Returns the consented objectives of this profile.

id

Returns the ID of this profile.

permission_level

Returns the permission level of this profile.

privacy_legislation

Returns the privacy legislation of this profile.

properties

Returns the properties of this object.

property_ids

Returns the property IDs of this object.

refused_objectives

Returns the refused objectives of this profile.

segments

Returns the segment IDs of this profile.

timeline_events

Returns the timeline events of this profile.