Brands

Methods to manage brands using Java SDK

Brands are used for personalizing communication on behalf of some other entity/organization.

In SuprSend, Brands are workspace level entity. By default, SuprSend creates a brand with brand_id="default" (representing your organization) in each of your workspaces. You can create more brands using one of our backend SDKs.

Data structure of Brand:

{
	"brand_id": "br-01",
	"brand_name": "Awesome Brand",
	"logo": "https://ik.imagekit.io/l0quatz6utm/suprsend/staging/media/suprsend-only-logo_c8aa27faef118418e8c5bd7b31a1cafc74e09200.png",
	"primary_color": "#ff0000",
	"secondary_color": "#00ff00",
	"tertiary_color": "#0000ff",
	"social_links": {
		"website": "https://suprsend.com",
		"facebook": "",
		"linkedin": "",
		"twitter": "",
		"instagram": "",
		"medium": "",
		"discord": "",
		"telegram": "",
		"youtube": "",
	},
	"properties": {
		"prop1": "value1",
		"prop2": "value2"
	}
}

Field Description:

brand_id (*mandatory)

brand-id can be of max 64 characters. It can contain characters [a-z0-9_-] i.e. alphanumeric characters, _(underscore) and -(hyphen).
brand_id is case-insensitive. Suprsend will first converts brand_id to lowercase before storing it or doing any sort of comparison on it.

brand_name (*mandatory)

Name of the brand

logo (optional)

url of the brand logo

brand colors viz. primary_color, secondary_color, tertiary_color (optional)

brand colors settings are mainly used while designing templates.
If you don't provide any of the colors for the brand, SuprSend will assume you want to use the default values, so color settings will automatically be set to the color settings of default brand.

social_links: (optional)

urls of social media accounts of the brand

While updating a social link, if you pass its value as null, then SuprSend will ignore it. If you really want to remove the value you must the value="" (instead of null)
e.g. If you want to remove social_link url for facebook, you must pass facebook=""
{
"social_links": {
"facebook": ""
}
}

properties:

Custom properties associated with the brand.
Update operation on properties works like upsert on 1st-level keys (i.e. if top level key doesn't already exists, then it will added, otherwise its value will be replace by new value. All other key-value pair will remain unchanged).
e.g
1st update: {"properties": {"k1": "v1", "k2": 1.0}}
2nd update:{"properties": {"k1": "v2", "k3": {"nested_k": "v"}}}
after these 2 updates, value for properties will be
{ "k1": "v2", "k2": 1.0, "k3": { "nested_k": "v" } }


Accessing Brand using suprsend-java-sdk

1. Upsert brand (Create a new Brand OR Update an existing Brand)

import org.json.JSONObject;

import suprsend.Suprsend;
import suprsend.SuprsendAPIException;

public class Brands {
  public static void main(String[] args) throws Exception {
    updateBrand();
  }
  
  private static Subscriber updateBrand() throws SuprsendException {
		Suprsend suprsendClient = new Suprsend("_workspace_key_", "_workspace_secret_");
		
    // Create Brand data JSON
    String brandId = "br-01";
    JSONObject payload = new JSONObject()
      .put("brand_name", "awesome brand")
      .put("logo", "https://ik.imagekit.io/l0quatz6utm/suprsend/staging/media/suprsend-only-logo_c8aa27faef118418e8c5bd7b31a1cafc74e09200.png")
      .put("primary_color", "#ff0000")
      .put("secondary_color", "#0000ff")
      .put("tertiary_color", "#00ffff")
      .put("social_links", new JSONObject()
           .put("website", "https://www.company.com")
           .put("youtube", "https://www.company.com/youtube")
           .put("twitter", "https://www.company.com/twitter")
           .put("facebook", "")
           .put("linkedin", "")
           .put("instagram", "")
           .put("discord", "")
           .put("medium", "")
           .put("telegram", "")
          )
      .put("properties", new JSONObject()
           .put("address", "my company address")
          )
      ;
    try {
      JSONObject res = suprClient.brands.upsert(brandId, payload);
      System.out.println(res);
    } catch (SuprsendException e) {
      System.out.println(e);
    }
  }
	}

2. Get brand data

import org.json.JSONObject;

import suprsend.Suprsend;
import suprsend.SuprsendAPIException;

public class Brands {
  public static void main(String[] args) throws Exception {
    getBrand();
  }
  
  private static Subscriber getBrand() throws SuprsendException {
		Suprsend suprsendClient = new Suprsend("_workspace_key_", "_workspace_secret_");
		
   try {
            String brandId = "_brand_id_";
            // String brandId = "default";
            JSONObject res = suprClient.brands.get(brandId);
            System.out.println(res);
        } catch (SuprsendException e) {
            System.out.println(e);
        }
	}

Response

{
	"brand_id": "brand-id",
	"brand_name": "Brand Name",
	"logo": "https://logo.url",
	"primary_color": "#ff0000",
	"secondary_color": "#00ff00",
	"tertiary_color": "#0000ff",
	"social_links": {
		"website": "",
		"facebook": "",
		"linkedin": "",
		"twitter": "",
		"instagram": "",
		"medium": "",
		"discord": "",
		"telegram": "",
		"youtube": "",
	},
	"properties": {
		"prop1": "value1",
		"prop2": "value2"
	}
}

3. Get Brands list

By default limit=20 . Value for limit must be < 1000

import org.json.JSONObject;

import suprsend.Suprsend;
import suprsend.SuprsendAPIException;

public class Brands {
  public static void main(String[] args) throws Exception {
    getBrand();
  }
  
  private static Subscriber getBrand() throws SuprsendException {
		Suprsend suprsendClient = new Suprsend("_workspace_key_", "_workspace_secret_");
		
    try {
      JSONObject res = suprClient.brands.list();
      
      //Get list with offset = 10 and limit = 20
      //JSONObject res = suprClient.brands.list(20,10);
      
      System.out.println(res);
    } catch (SuprsendException e) {
      System.out.println(e);
    }
	}

Response

{
  "meta": {
  	"limit": 20,
    "offset": 0,
    "count": 1
  },
  "results": [
    {
      "brand_id": "brand-id",
      "brand_name": "Brand Name",
      "logo": "https://logo.url",
      "primary_color": "#ff0000",
      "secondary_color": "#00ff00",
      "tertiary_color": "#0000ff",
      "social_links": {
        "website": "",
        "facebook": "",
        "linkedin": "",
        "twitter": "",
        "instagram": "",
        "medium": "",
        "discord": "",
        "telegram": "",
        "youtube": "",
      },
      "properties": {
        "prop1": "value1",
        "prop2": "value2"
      }
    }
  ]
}