Tcl 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



load ./chilkat.dll

set rest [new_CkRest]

#   Provide a previously obtained OAuth2 access token.
set oauth2 [new_CkOAuth2]

CkOAuth2_put_AccessToken $oauth2 "OAUTH2_ACCESS_TOKEN"
CkRest_SetAuthOAuth2 $rest $oauth2

set success [CkRest_Connect $rest "www.googleapis.com" 443 1 1]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkOAuth2 $oauth2
    exit
}

set sbJson [new_CkStringBuilder]

set success [CkRest_FullRequestNoBodySb $rest "GET" "/calendar/v3/colors" $sbJson]
if {[expr $success != 1]} then {
    puts [CkRest_lastErrorText $rest]
    delete_CkRest $rest
    delete_CkOAuth2 $oauth2
    delete_CkStringBuilder $sbJson
    exit
}

if {[expr [CkRest_ResponseStatusCode $rest] != 200]} then {
    puts "Received error response code: [CkRest_ResponseStatusCode $rest]"
    puts "Response body:"
    puts [CkStringBuilder_getAsString $sbJson]
    delete_CkRest $rest
    delete_CkOAuth2 $oauth2
    delete_CkStringBuilder $sbJson
    exit
}

set json [new_CkJsonObject]

CkJsonObject_LoadSb $json $sbJson

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

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

puts "Example Completed."

delete_CkRest $rest
delete_CkOAuth2 $oauth2
delete_CkStringBuilder $sbJson
delete_CkJsonObject $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"
    }
  }
}