lytics / ios-sdk

MIT License
0 stars 0 forks source link

Add Lytics.getProfile() method #81

Closed RaeEversmann closed 1 year ago

RaeEversmann commented 1 year ago

Add method Lytics.getProfile()

https://github.com/lytics/android-sdk/blob/main/lytics-sdk/src/main/java/com/lytics/android/LyticsUser.kt

This method should take the following parameters:

   identifierKey: "string" // optional -- if defined, we must require a value 
   identifierValue: "string" // optional -- if defined, we must require a value 
   table: "string" // optional  

Default

   identifier: Lytics.configuration.primaryIdentityKey
   table: Lytics.configuration.defaultTable

When this method is called, it should send a request to the API (see reference below) and return the data received back from the API

API Reference: https://learn.lytics.com/documentation/developer/api-docs/personalization#personalization-personalization-get

example request to API

GET /api/entity/user/email/aaron@aaron.com where

"/api/entity" is Lytics.configuration.dataEndpoint "/user" is either Lytics.configuration.defaultTable or the table parameter "/email" is either Lytics.configuration.primaryIdentityKey or the identifier parameter "/aaron@aaron.com" is the value of Lytics.currentUser.identifiers[email]

example response from API

{
    // save this field to the user model
    "data": {
        "segments": [
            "email_us_based",
            "web_users",
            "all"
        ]
    },
    "message": "success",
   // ignore this field for now
    "meta": {
        "by_fields": [
            "user_id",
            "email",
            "fbuid",
            "_uids"
        ],
        "format": "json",
        "name": "user"
    },
    "status": 200
}
RaeEversmann commented 1 year ago

the identifierKey and identifierValue can be one type