AttributesEditor

Package: com.salesforce.marketingcloud.sfmcsdk.components.identity

Platform: androidJvm

Overview 

The AttributesEditor class wraps the Identity.Builder attribute map functions to provide an idiomatic Kotlin syntax for managing user attributes in the Salesforce Marketing Cloud SDK.

Usage Example 

1SFMCSdk.requestSdk { sdk ->
2  sdk.identity.edit {
3    attributes["key"] = "value" // assignment syntax
4    attributes += "key2" to "value2" // plus assignment syntax
5  }
6}

Constructor 

AttributesEditor 

1constructor(builder: Identity.Builder)

Creates an instance that wraps an Identity.Builder for attribute operations.

Parameters:

  • builder - The Identity.Builder instance to wrap

Methods 

clear 

1fun clear(vararg keys: String)

Clears the value of the specified attributes, effectively setting them to null.

Parameters:

  • keys - Variable number of attribute keys to clear

1fun clear(keys: List<String>)

Clears the value of the specified attributes, effectively setting them to null.

Parameters:

  • keys - List of attribute keys to clear

1fun clear(key: String)

Clears the value of the specified attribute, effectively setting it to null.

Parameters:

  • key - The attribute key to clear

clearAll 

1fun clearAll()

Clears the value of all attributes, effectively setting them to null.

plusAssign 

1operator fun plusAssign(entry: Pair<String, String?>)

Updates or adds the value of an entry for the given key in the attribute map using the += operator.

Parameters:

  • entry - A Pair containing the key and nullable value to add/update

put 

1fun put(key: String, value: String?)

Updates or adds the value of an entry for the given key in the attribute map.

Parameters:

  • key - The attribute key
  • value - The nullable attribute value

putAll 

1fun putAll(from: Map<out String, String?>)

Updates or adds all the values from the passed in map.

Parameters:

  • from - Map of attributes to add/update

set 

1fun set(from: Map<out String, String?>)

First clears the values of all existing attributes. Then updates or adds the values from the passed in map.

Note: Attribute keys cannot be removed, only the value can be cleared or set to null.

Parameters:

  • from - Map of attributes to set

1operator fun set(key: String, value: String?)

Updates or adds the value of an entry for the given key in the attribute map using array-style indexing syntax.

Parameters:

  • key - The attribute key
  • value - The nullable attribute value