Paperd.Ink Library 0.0.5
Library for interacting with Paperd.Ink devices.
Loading...
Searching...
No Matches
PaperdinkUITodoListTodoistClass Class Reference

#include <todo_list.h>

Inheritance diagram for PaperdinkUITodoListTodoistClass:
PaperdinkUITodoListClass PaperdinkUIBaseClass

Public Member Functions

int8_t fetch_data (const char *token)
 
- Public Member Functions inherited from PaperdinkUITodoListClass
void display_list_style1 (GxEPD2_GFX &display, int16_t x, int16_t y, int16_t rows=TODO_LIST_MAX_TASKS, int16_t columns=1, uint16_t max_line_width=400)
 

Additional Inherited Members

- Public Attributes inherited from PaperdinkUITodoListClass
char tasks [TODO_LIST_MAX_TASKS][TODO_LIST_MAX_TODO_STR_LENGTH+1]
 
uint8_t task_count
 
String token
 
- Public Attributes inherited from PaperdinkUIBaseClass
const GFXfont * font = &PAPERDINK_FONT_SML
 
const GFXfont * font_bold = &PAPERDINK_FONT_SML_BOLD
 
int primary_color = GxEPD_BLACK
 
int secondary_color = GxEPD_WHITE
 
int tertiary_color = GxEPD_BLACK
 

Detailed Description

Definition at line 29 of file todo_list.h.

Member Function Documentation

◆ fetch_data()

int8_t PaperdinkUITodoListTodoistClass::fetch_data ( const char * token)

Definition at line 171 of file todo_list.cpp.

172{
173 int httpCode, ret = 0;
174 String payload;
175
176 WiFiClientSecure *client = new WiFiClientSecure;
177 client->setCACert(todoist_cert);
178
179 {
180 HTTPClient https;
181 /* Authenticate with Todoist server */
182 https.begin(*client, todoist_url.c_str());
183 https.addHeader("Content-Type", "application/json", 0, 0);
184 https.addHeader("Authorization", token, 0, 0);
185
186 httpCode = https.GET();
187
188 if (httpCode == HTTP_CODE_OK) {
189 DEBUG.printf("[HTTP] AUTH SUCCESS\r\n");
190 //String payload = https.getString();
191 //Serial.println(payload);
192 ArudinoStreamParser parser;
193 parser.setListener(&todoist_todo_listener);
194 https.writeToStream(&parser);
195 } else {
196 DEBUG.printf("[HTTP] AUTH... failed, error: %d::%s\r\n", httpCode, https.errorToString(httpCode).c_str());
197 ret = -1;
198 }
199
200 https.end();
201 }
202
203 delete client;
204 return ret;
205}
TodoTodoistJsonListener todoist_todo_listener
Definition todo_list.cpp:53
String todoist_url
Definition todo_list.cpp:52
#define DEBUG
Definition todo_list.h:6

The documentation for this class was generated from the following files: