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

#include <todo_list.h>

Inheritance diagram for PaperdinkUITodoListTaigaClass:
PaperdinkUITodoListClass PaperdinkUIBaseClass

Public Member Functions

int8_t fetch_data (const char *project_name, const char *project_username, const char *project_password)
 
- 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)
 

Public Attributes

String project_id
 
- 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 21 of file todo_list.h.

Member Function Documentation

◆ fetch_data()

int8_t PaperdinkUITodoListTaigaClass::fetch_data ( const char * project_name,
const char * project_username,
const char * project_password )

Definition at line 77 of file todo_list.cpp.

78{
79 int httpCode, ret = 0;
80 String payload;
81
82 WiFiClientSecure *client = new WiFiClientSecure;
83 client->setCACert(taiga_cert);
84
85 {
86 HTTPClient https;
87 /* Authenticate with Taiga server */
88 https.begin(*client, taiga_auth_url.c_str());
89 https.addHeader("Content-Type", "application/json", 0, 0);
90
91 taiga_post_data.replace("{0}", project_username);
92 taiga_post_data.replace("{1}", project_password);
93 httpCode = https.POST(taiga_post_data);
94
95 if (httpCode == HTTP_CODE_OK) {
96 DEBUG.printf("[HTTP] AUTH SUCCESS\r\n");
97 //String payload = https.getString();
98 //Serial.println(payload);
100 parser.setListener(&taiga_todo_listener);
101 https.writeToStream(&parser);
102 } else {
103 DEBUG.printf("[HTTP] AUTH... failed, error: %s\r\n", https.errorToString(httpCode).c_str());
104 ret = -1;
105 }
106
107 https.end();
108 }
109
110 if (ret != 0) {
111 delete client;
112 return ret;
113 }
114
115 /* Get the slug */
116 taiga_slug_url.replace("{0}", project_username);
117 taiga_slug_url.replace("{1}", project_name);
118
119 {
120 HTTPClient https;
121 https.begin(*client, taiga_slug_url.c_str());
122 https.addHeader("Authorization", token, 0, 0);
123 httpCode = https.GET();
124
125 if (httpCode == HTTP_CODE_OK) {
126 DEBUG.printf("[HTTP] SLUG SUCCESS\r\n");
127 //payload = https.getString();
128 //DEBUG.println(payload);
129 ArudinoStreamParser parser;
130 parser.setListener(&taiga_todo_listener);
131 https.writeToStream(&parser);
132 } else {
133 DEBUG.printf("[HTTP] SLUG... failed, error: %s\r\n", https.errorToString(httpCode).c_str());
134 ret = -1;
135 }
136 https.end();
137 }
138
139 if (ret != 0) {
140 delete client;
141 return ret;
142 }
143
144 /* Get the tasks list */
146
147 {
148 HTTPClient https;
149 https.begin(*client, taiga_tasks_url.c_str());
150 https.addHeader("Authorization", token, 0, 0);
151 httpCode = https.GET();
152
153 if (httpCode == HTTP_CODE_OK) {
154 DEBUG.printf("[HTTP] TASKS SUCCESS\r\n");
155 //payload = https.getString();
156 //DEBUG.println(payload);
157 ArudinoStreamParser parser;
158 parser.setListener(&taiga_todo_listener);
159 https.writeToStream(&parser);
160 } else {
161 DEBUG.printf("[HTTP] TASKS... failed, error: %s\r\n", https.errorToString(httpCode).c_str());
162 }
163
164 https.end();
165 }
166
167 delete client;
168 return ret;
169}
String taiga_post_data
Definition todo_list.cpp:12
String taiga_tasks_url
Definition todo_list.cpp:11
String taiga_auth_url
Definition todo_list.cpp:9
TodoTaigaJsonListener taiga_todo_listener
Definition todo_list.cpp:13
String taiga_slug_url
Definition todo_list.cpp:10
#define DEBUG
Definition todo_list.h:6

Member Data Documentation

◆ project_id

String PaperdinkUITodoListTaigaClass::project_id

Definition at line 24 of file todo_list.h.


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