first working fetch

This commit is contained in:
2020-06-01 20:59:24 -07:00
parent 98e9bc5e70
commit c215c1d6e0
10 changed files with 4091 additions and 5 deletions

21
ncac.c
View File

@@ -25,6 +25,9 @@ int main(int argc, char **argv) {
case 'b':
draw_text("Goodbye, world!", &curs_x, &curs_y);
break;
case 'j':
get_me(&curs_x, &curs_y);
break;
case 'q':
finish(SIGTERM);
break;
@@ -40,8 +43,14 @@ static void finish(int sig) {
}
static void setup() {
char *pat = getenv("ASANA_PAT");
if (!pat) {
fprintf(stderr, "ASANA_PAT is not defined\n");
exit(1);
}
// initialize the asana client
if (!asana_init()) {
if (!asana_init(pat)) {
fprintf(stderr, "Unable to initialize the Asana client\n");
exit(1);
}
@@ -65,3 +74,13 @@ static void setup() {
signal(SIGKILL, &finish);
signal(SIGTERM, &finish);
}
void get_me(int *curs_x, int *curs_y) {
Response *response = asana_fetch("users/me");
*curs_x = 0;
(*curs_y)++;
draw_text(response->body, curs_x, curs_y);
asana_free_response(response);
}