How to create a profile and update its values

Follow

NOTE: You need to define the profile structure prior to using it within your app. There are two ways of creating a profile: visually from the user interface or by means of the REST API.

 

1. Create a profile from the user interface


Log in at Beemray Dashboard with your username at password. Go to section SETTINGS > PROFILES. Use the '+' sign to create a profile, add one or more categories to that profile and add elements of different types to those categories.

 

 

2. Create a profile using the REST API


Our REST API exposes some methods to create profiles, profile categories and profile elements.

Create profile:

POST /rest/profile/category HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.ProfileCategory",
    "profile":170784,
    "title":"Football fan category"
}

 

Create profile Response:

{
  "@class": "com.beemray.types.profile.Profile",
  "title": "Football fan",
  "description": "Interests of a football fan",
  "status": 1,
  "id": 170784,
  "created": "2015-07-22 10:28:59",
  "modified": "2015-07-22 10:28:59",
  "shareable": true,
  "categories": []
}

 

Create category

POST /rest/profile/category HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.ProfileCategory",
    "profile":170784,
    "title":"Football fan category"
}

 

Create category Response

{
  "@class": "com.beemray.types.profile.ProfileCategory",
  "title": "Football fan category",
  "status": 1,
  "id": 170796,
  "created": "2015-07-22 10:42:01",
  "modified": "2015-07-22 10:42:01",
  "shareable": true,
  "profile": 170784,
  "elements": []
}

 

Create 'Text' element

POST /rest/profile/category/170796/elements HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.StringElement",
    "key":"Favourite team"
}

 

Create 'Boolean' element

POST /rest/profile/category/170796/elements HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.BooleanElement",
    "key":"Season-ticket holder"
}

 

Create 'Date' element

POST /rest/profile/category/170796/elements HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.TimestampElement",
    "key":"Membership start date"
}

 

Create 'Number' element

POST /rest/profile/category/170796/elements HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.LongElement",
    "key":"Matches watched per week",
}

 

Create 'Number range' element

POST /rest/profile/category/170796/elements HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.LongRangeElement",
    "from":"12",
    "to":"99",
    "key":"Age",
    "extra":"years old"
}

 

Create 'Option list' element

POST /rest/profile/category/170796/elements HTTP/1.1
Host: app.beemray.com
Content-Type: application/json
X-Auth-Token: {your authentication token}
 
{
    "@class":"com.beemray.types.profile.OptionListElement",
    "key":"Days you watch matches",
    "multiselect":"true"
    "value":[
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Monday"
        },
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Tuesday"
        },
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Wednesday"
        },
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Thursday"
        },
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Friday"
        },
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Saturday"
        },
        {
            "@class":"com.beemray.types.profile.Option",
            "key":"Sunday"
        }]
}

 

Update profile values

When you integrate the Beemray service in your app (and configure with you account's API key), each user can set their own values for the profiles you have created.

App developer is responsible for creating the UI elements needed for user input. The SDK provides the necessary methods to send updated profile values to Beemray server.

For more information, please see:

 

 

Have more questions? Submit a request

Comments