Delphi DLL Google Calendar: Get Color Definitions

Back to Index

Returns the color definitions for calendars and events.

Documentation: https://developers.google.com/google-apps/calendar/v3/reference/colors/get


var
rest: HCkRest;
success: Boolean;
oauth2: HCkOAuth2;
sbJson: HCkStringBuilder;
json: HCkJsonObject;
kind: PWideChar;
updated: PWideChar;
calendar1Background: PWideChar;
calendar1Foreground: PWideChar;
calendar2Background: PWideChar;
calendar2Foreground: PWideChar;
calendar3Background: PWideChar;
calendar3Foreground: PWideChar;
calendar4Background: PWideChar;
calendar4Foreground: PWideChar;
calendar5Background: PWideChar;
calendar5Foreground: PWideChar;
calendar6Background: PWideChar;
calendar6Foreground: PWideChar;
calendar7Background: PWideChar;
calendar7Foreground: PWideChar;
calendar8Background: PWideChar;
calendar8Foreground: PWideChar;
calendar9Background: PWideChar;
calendar9Foreground: PWideChar;
calendar10Background: PWideChar;
calendar10Foreground: PWideChar;
calendar11Background: PWideChar;
calendar11Foreground: PWideChar;
calendar12Background: PWideChar;
calendar12Foreground: PWideChar;
calendar13Background: PWideChar;
calendar13Foreground: PWideChar;
calendar14Background: PWideChar;
calendar14Foreground: PWideChar;
calendar15Background: PWideChar;
calendar15Foreground: PWideChar;
calendar16Background: PWideChar;
calendar16Foreground: PWideChar;
calendar17Background: PWideChar;
calendar17Foreground: PWideChar;
calendar18Background: PWideChar;
calendar18Foreground: PWideChar;
calendar19Background: PWideChar;
calendar19Foreground: PWideChar;
calendar20Background: PWideChar;
calendar20Foreground: PWideChar;
calendar21Background: PWideChar;
calendar21Foreground: PWideChar;
calendar22Background: PWideChar;
calendar22Foreground: PWideChar;
calendar23Background: PWideChar;
calendar23Foreground: PWideChar;
calendar24Background: PWideChar;
calendar24Foreground: PWideChar;
event1Background: PWideChar;
event1Foreground: PWideChar;
event2Background: PWideChar;
event2Foreground: PWideChar;
event3Background: PWideChar;
event3Foreground: PWideChar;
event4Background: PWideChar;
event4Foreground: PWideChar;
event5Background: PWideChar;
event5Foreground: PWideChar;
event6Background: PWideChar;
event6Foreground: PWideChar;
event7Background: PWideChar;
event7Foreground: PWideChar;
event8Background: PWideChar;
event8Foreground: PWideChar;
event9Background: PWideChar;
event9Foreground: PWideChar;
event10Background: PWideChar;
event10Foreground: PWideChar;
event11Background: PWideChar;
event11Foreground: PWideChar;

begin
rest := CkRest_Create();

//   Provide a previously obtained OAuth2 access token.
oauth2 := CkOAuth2_Create();
CkOAuth2_putAccessToken(oauth2,'OAUTH2_ACCESS_TOKEN');
CkRest_SetAuthOAuth2(rest,oauth2);

success := CkRest_Connect(rest,'www.googleapis.com',443,True,True);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

sbJson := CkStringBuilder_Create();
success := CkRest_FullRequestNoBodySb(rest,'GET','/calendar/v3/colors',sbJson);
if (success <> True) then
  begin
    Memo1.Lines.Add(CkRest__lastErrorText(rest));
    Exit;
  end;

if (CkRest_getResponseStatusCode(rest) <> 200) then
  begin
    Memo1.Lines.Add('Received error response code: ' + IntToStr(CkRest_getResponseStatusCode(rest)));
    Memo1.Lines.Add('Response body:');
    Memo1.Lines.Add(CkStringBuilder__getAsString(sbJson));
    Exit;
  end;

json := CkJsonObject_Create();
CkJsonObject_LoadSb(json,sbJson);

//  The following code parses the JSON response.
//  A sample JSON response is shown below the sample code.

kind := CkJsonObject__stringOf(json,'kind');
updated := CkJsonObject__stringOf(json,'updated');
calendar1Background := CkJsonObject__stringOf(json,'calendar.1.background');
calendar1Foreground := CkJsonObject__stringOf(json,'calendar.1.foreground');
calendar2Background := CkJsonObject__stringOf(json,'calendar.2.background');
calendar2Foreground := CkJsonObject__stringOf(json,'calendar.2.foreground');
calendar3Background := CkJsonObject__stringOf(json,'calendar.3.background');
calendar3Foreground := CkJsonObject__stringOf(json,'calendar.3.foreground');
calendar4Background := CkJsonObject__stringOf(json,'calendar.4.background');
calendar4Foreground := CkJsonObject__stringOf(json,'calendar.4.foreground');
calendar5Background := CkJsonObject__stringOf(json,'calendar.5.background');
calendar5Foreground := CkJsonObject__stringOf(json,'calendar.5.foreground');
calendar6Background := CkJsonObject__stringOf(json,'calendar.6.background');
calendar6Foreground := CkJsonObject__stringOf(json,'calendar.6.foreground');
calendar7Background := CkJsonObject__stringOf(json,'calendar.7.background');
calendar7Foreground := CkJsonObject__stringOf(json,'calendar.7.foreground');
calendar8Background := CkJsonObject__stringOf(json,'calendar.8.background');
calendar8Foreground := CkJsonObject__stringOf(json,'calendar.8.foreground');
calendar9Background := CkJsonObject__stringOf(json,'calendar.9.background');
calendar9Foreground := CkJsonObject__stringOf(json,'calendar.9.foreground');
calendar10Background := CkJsonObject__stringOf(json,'calendar.10.background');
calendar10Foreground := CkJsonObject__stringOf(json,'calendar.10.foreground');
calendar11Background := CkJsonObject__stringOf(json,'calendar.11.background');
calendar11Foreground := CkJsonObject__stringOf(json,'calendar.11.foreground');
calendar12Background := CkJsonObject__stringOf(json,'calendar.12.background');
calendar12Foreground := CkJsonObject__stringOf(json,'calendar.12.foreground');
calendar13Background := CkJsonObject__stringOf(json,'calendar.13.background');
calendar13Foreground := CkJsonObject__stringOf(json,'calendar.13.foreground');
calendar14Background := CkJsonObject__stringOf(json,'calendar.14.background');
calendar14Foreground := CkJsonObject__stringOf(json,'calendar.14.foreground');
calendar15Background := CkJsonObject__stringOf(json,'calendar.15.background');
calendar15Foreground := CkJsonObject__stringOf(json,'calendar.15.foreground');
calendar16Background := CkJsonObject__stringOf(json,'calendar.16.background');
calendar16Foreground := CkJsonObject__stringOf(json,'calendar.16.foreground');
calendar17Background := CkJsonObject__stringOf(json,'calendar.17.background');
calendar17Foreground := CkJsonObject__stringOf(json,'calendar.17.foreground');
calendar18Background := CkJsonObject__stringOf(json,'calendar.18.background');
calendar18Foreground := CkJsonObject__stringOf(json,'calendar.18.foreground');
calendar19Background := CkJsonObject__stringOf(json,'calendar.19.background');
calendar19Foreground := CkJsonObject__stringOf(json,'calendar.19.foreground');
calendar20Background := CkJsonObject__stringOf(json,'calendar.20.background');
calendar20Foreground := CkJsonObject__stringOf(json,'calendar.20.foreground');
calendar21Background := CkJsonObject__stringOf(json,'calendar.21.background');
calendar21Foreground := CkJsonObject__stringOf(json,'calendar.21.foreground');
calendar22Background := CkJsonObject__stringOf(json,'calendar.22.background');
calendar22Foreground := CkJsonObject__stringOf(json,'calendar.22.foreground');
calendar23Background := CkJsonObject__stringOf(json,'calendar.23.background');
calendar23Foreground := CkJsonObject__stringOf(json,'calendar.23.foreground');
calendar24Background := CkJsonObject__stringOf(json,'calendar.24.background');
calendar24Foreground := CkJsonObject__stringOf(json,'calendar.24.foreground');
event1Background := CkJsonObject__stringOf(json,'event.1.background');
event1Foreground := CkJsonObject__stringOf(json,'event.1.foreground');
event2Background := CkJsonObject__stringOf(json,'event.2.background');
event2Foreground := CkJsonObject__stringOf(json,'event.2.foreground');
event3Background := CkJsonObject__stringOf(json,'event.3.background');
event3Foreground := CkJsonObject__stringOf(json,'event.3.foreground');
event4Background := CkJsonObject__stringOf(json,'event.4.background');
event4Foreground := CkJsonObject__stringOf(json,'event.4.foreground');
event5Background := CkJsonObject__stringOf(json,'event.5.background');
event5Foreground := CkJsonObject__stringOf(json,'event.5.foreground');
event6Background := CkJsonObject__stringOf(json,'event.6.background');
event6Foreground := CkJsonObject__stringOf(json,'event.6.foreground');
event7Background := CkJsonObject__stringOf(json,'event.7.background');
event7Foreground := CkJsonObject__stringOf(json,'event.7.foreground');
event8Background := CkJsonObject__stringOf(json,'event.8.background');
event8Foreground := CkJsonObject__stringOf(json,'event.8.foreground');
event9Background := CkJsonObject__stringOf(json,'event.9.background');
event9Foreground := CkJsonObject__stringOf(json,'event.9.foreground');
event10Background := CkJsonObject__stringOf(json,'event.10.background');
event10Foreground := CkJsonObject__stringOf(json,'event.10.foreground');
event11Background := CkJsonObject__stringOf(json,'event.11.background');
event11Foreground := CkJsonObject__stringOf(json,'event.11.foreground');

Memo1.Lines.Add('Example Completed.');

CkRest_Dispose(rest);
CkOAuth2_Dispose(oauth2);
CkStringBuilder_Dispose(sbJson);
CkJsonObject_Dispose(json);

Sample JSON Response Body

{
  "kind": "calendar#colors",
  "updated": "2012-02-14T00:00:00.000Z",
  "calendar": {
    "1": {
      "background": "#ac725e",
      "foreground": "#1d1d1d"
    },
    "2": {
      "background": "#d06b64",
      "foreground": "#1d1d1d"
    },
    "3": {
      "background": "#f83a22",
      "foreground": "#1d1d1d"
    },
    "4": {
      "background": "#fa573c",
      "foreground": "#1d1d1d"
    },
    "5": {
      "background": "#ff7537",
      "foreground": "#1d1d1d"
    },
    "6": {
      "background": "#ffad46",
      "foreground": "#1d1d1d"
    },
    "7": {
      "background": "#42d692",
      "foreground": "#1d1d1d"
    },
    "8": {
      "background": "#16a765",
      "foreground": "#1d1d1d"
    },
    "9": {
      "background": "#7bd148",
      "foreground": "#1d1d1d"
    },
    "10": {
      "background": "#b3dc6c",
      "foreground": "#1d1d1d"
    },
    "11": {
      "background": "#fbe983",
      "foreground": "#1d1d1d"
    },
    "12": {
      "background": "#fad165",
      "foreground": "#1d1d1d"
    },
    "13": {
      "background": "#92e1c0",
      "foreground": "#1d1d1d"
    },
    "14": {
      "background": "#9fe1e7",
      "foreground": "#1d1d1d"
    },
    "15": {
      "background": "#9fc6e7",
      "foreground": "#1d1d1d"
    },
    "16": {
      "background": "#4986e7",
      "foreground": "#1d1d1d"
    },
    "17": {
      "background": "#9a9cff",
      "foreground": "#1d1d1d"
    },
    "18": {
      "background": "#b99aff",
      "foreground": "#1d1d1d"
    },
    "19": {
      "background": "#c2c2c2",
      "foreground": "#1d1d1d"
    },
    "20": {
      "background": "#cabdbf",
      "foreground": "#1d1d1d"
    },
    "21": {
      "background": "#cca6ac",
      "foreground": "#1d1d1d"
    },
    "22": {
      "background": "#f691b2",
      "foreground": "#1d1d1d"
    },
    "23": {
      "background": "#cd74e6",
      "foreground": "#1d1d1d"
    },
    "24": {
      "background": "#a47ae2",
      "foreground": "#1d1d1d"
    }
  },
  "event": {
    "1": {
      "background": "#a4bdfc",
      "foreground": "#1d1d1d"
    },
    "2": {
      "background": "#7ae7bf",
      "foreground": "#1d1d1d"
    },
    "3": {
      "background": "#dbadff",
      "foreground": "#1d1d1d"
    },
    "4": {
      "background": "#ff887c",
      "foreground": "#1d1d1d"
    },
    "5": {
      "background": "#fbd75b",
      "foreground": "#1d1d1d"
    },
    "6": {
      "background": "#ffb878",
      "foreground": "#1d1d1d"
    },
    "7": {
      "background": "#46d6db",
      "foreground": "#1d1d1d"
    },
    "8": {
      "background": "#e1e1e1",
      "foreground": "#1d1d1d"
    },
    "9": {
      "background": "#5484ed",
      "foreground": "#1d1d1d"
    },
    "10": {
      "background": "#51b749",
      "foreground": "#1d1d1d"
    },
    "11": {
      "background": "#dc2127",
      "foreground": "#1d1d1d"
    }
  }
}