/* Todoist.c generated by valac 0.56.19, the Vala compiler
 * generated from Todoist.vala, do not modify */

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include "planify.h"
#include <libsoup/soup.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <json-glib/json-glib.h>
#include <gee.h>
#include <glib/gi18n-lib.h>
#include <gxml/gxml.h>
#include <gobject/gvaluecollector.h>

#define SERVICES_TODOIST_TODOIST_SYNC_URL "https://api.todoist.com/api/v1/sync"
#define SERVICES_TODOIST_RESOURCE_TYPES "[\"user\", \"projects\", \"sections\", \"items\", \"labels\", \"remind" \
"ers\"]"
#define SERVICES_TODOIST_PROJECTS_COLLECTION "projects"
#define SERVICES_TODOIST_SECTIONS_COLLECTION "sections"
#define SERVICES_TODOIST_ITEMS_COLLECTION "items"
#define SERVICES_TODOIST_LABELS_COLLECTION "labels"
#define SERVICES_TODOIST_REMINDERS_COLLECTION "reminders"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	SERVICES_TODOIST_0_PROPERTY,
	SERVICES_TODOIST_NUM_PROPERTIES
};
static GParamSpec* services_todoist_properties[SERVICES_TODOIST_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _http_response_unref0(var) ((var == NULL) ? NULL : (var = (http_response_unref (var), NULL)))
typedef struct _ServicesTodoistLoginData ServicesTodoistLoginData;
typedef struct _ServicesTodoistLoginTokenData ServicesTodoistLoginTokenData;
typedef struct _ServicesTodoistAddTodoistAccountData ServicesTodoistAddTodoistAccountData;
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
#define _json_object_unref0(var) ((var == NULL) ? NULL : (var = (json_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _ServicesTodoistSyncData ServicesTodoistSyncData;
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
typedef struct _ServicesTodoistQueueData ServicesTodoistQueueData;
typedef struct _ServicesTodoistAddData ServicesTodoistAddData;
typedef struct _ServicesTodoistUpdateData ServicesTodoistUpdateData;
typedef struct _ServicesTodoistDeleteData ServicesTodoistDeleteData;
typedef struct _ServicesTodoistCompleteItemData ServicesTodoistCompleteItemData;
typedef struct _ServicesTodoistCloseItemData ServicesTodoistCloseItemData;
typedef struct _ServicesTodoistMoveItemData ServicesTodoistMoveItemData;
typedef struct _ServicesTodoistUpdateItemsData ServicesTodoistUpdateItemsData;
typedef struct _ServicesTodoistMoveProjectSectionData ServicesTodoistMoveProjectSectionData;
typedef struct _ServicesTodoistDuplicateProjectData ServicesTodoistDuplicateProjectData;
typedef struct _ParamSpecHttpResponse ParamSpecHttpResponse;

struct _ServicesTodoistPrivate {
	SoupSession* session;
	ServicesTodoistAuth* _auth;
	ServicesTodoistItems* _items;
	ServicesTodoistProjects* _projects;
	gboolean _queue_running;
};

struct _ServicesTodoistLoginData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	gchar* _url;
	ObjectsSource* migrate_source;
	HttpResponse* result;
	ServicesTodoistAuth* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistLoginTokenData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	gchar* token;
	ObjectsSource* migrate_source;
	HttpResponse* result;
	ServicesTodoistAuth* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistAddTodoistAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	gchar* token;
	HttpResponse* response;
	ObjectsSource* migrate_source;
	ServicesTodoistAuth* _tmp0_;
};

struct _ServicesTodoistSyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsSource* source;
	ObjectsSourceTodoistData* _tmp0_;
	ObjectsSourceTodoistData* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	SoupMessage* message;
	SoupMessage* _tmp4_;
	SoupMessage* _tmp5_;
	SoupMessageHeaders* _tmp6_;
	SoupMessageHeaders* _tmp7_;
	ObjectsSourceTodoistData* _tmp8_;
	ObjectsSourceTodoistData* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* form_data;
	ObjectsSourceTodoistData* _tmp14_;
	ObjectsSourceTodoistData* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	gchar* _tmp18_;
	SoupMessage* _tmp19_;
	const gchar* _tmp20_;
	guint8* _tmp21_;
	gint _tmp21__length1;
	gint _tmp22_;
	guint8* _tmp23_;
	gint _tmp23__length1;
	GBytes* _tmp24_;
	GBytes* _tmp25_;
	GBytes* stream;
	SoupSession* _tmp26_;
	SoupMessage* _tmp27_;
	GBytes* _tmp28_;
	JsonParser* parser;
	JsonParser* _tmp29_;
	JsonParser* _tmp30_;
	GBytes* _tmp31_;
	gsize _tmp32_;
	guint8* _tmp33_;
	JsonParser* _tmp34_;
	JsonNode* _tmp35_;
	JsonObject* _tmp36_;
	ObjectsSourceTodoistData* _tmp37_;
	ObjectsSourceTodoistData* _tmp38_;
	JsonParser* _tmp39_;
	JsonNode* _tmp40_;
	JsonObject* _tmp41_;
	const gchar* _tmp42_;
	JsonParser* _tmp43_;
	JsonNode* _tmp44_;
	JsonObject* _tmp45_;
	JsonObject* user_object;
	JsonParser* _tmp46_;
	JsonNode* _tmp47_;
	JsonObject* _tmp48_;
	JsonObject* _tmp49_;
	JsonObject* _tmp50_;
	ObjectsSourceTodoistData* _tmp51_;
	ObjectsSourceTodoistData* _tmp52_;
	JsonObject* _tmp53_;
	const gchar* _tmp54_;
	ObjectsSourceTodoistData* _tmp55_;
	ObjectsSourceTodoistData* _tmp56_;
	JsonObject* _tmp57_;
	ObjectsSourceTodoistData* _tmp58_;
	ObjectsSourceTodoistData* _tmp59_;
	JsonObject* _tmp60_;
	const gchar* _tmp61_;
	ObjectsSourceTodoistData* _tmp62_;
	ObjectsSourceTodoistData* _tmp63_;
	JsonObject* _tmp64_;
	const gchar* _tmp65_;
	JsonArray* _labels;
	JsonParser* _tmp66_;
	JsonNode* _tmp67_;
	JsonObject* _tmp68_;
	JsonArray* _tmp69_;
	JsonArray* _tmp70_;
	GList* _tmp71_;
	GList* _node_collection;
	GList* _node_it;
	JsonNode* _node;
	gchar* _id;
	JsonNode* _tmp72_;
	JsonObject* _tmp73_;
	const gchar* _tmp74_;
	gchar* _tmp75_;
	ObjectsLabel* label;
	ServicesStore* _tmp76_;
	const gchar* _tmp77_;
	ObjectsLabel* _tmp78_;
	ObjectsLabel* _tmp79_;
	JsonNode* _tmp80_;
	JsonObject* _tmp81_;
	ServicesStore* _tmp82_;
	ObjectsLabel* _tmp83_;
	ObjectsLabel* _tmp84_;
	JsonNode* _tmp85_;
	ServicesStore* _tmp86_;
	ObjectsLabel* _tmp87_;
	ObjectsLabel* _label;
	JsonNode* _tmp88_;
	ObjectsLabel* _tmp89_;
	ObjectsLabel* _tmp90_;
	const gchar* _tmp91_;
	const gchar* _tmp92_;
	ServicesStore* _tmp93_;
	ObjectsLabel* _tmp94_;
	JsonArray* projects;
	JsonParser* _tmp95_;
	JsonNode* _tmp96_;
	JsonObject* _tmp97_;
	JsonArray* _tmp98_;
	JsonArray* _tmp99_;
	GList* _tmp100_;
	GList* _vala1__node_collection;
	GList* _vala1__node_it;
	JsonNode* _vala1__node;
	ObjectsProject* project;
	ServicesStore* _tmp101_;
	JsonNode* _tmp102_;
	JsonObject* _tmp103_;
	const gchar* _tmp104_;
	ObjectsProject* _tmp105_;
	ObjectsProject* _tmp106_;
	JsonNode* _tmp107_;
	JsonObject* _tmp108_;
	ServicesStore* _tmp109_;
	ObjectsProject* _tmp110_;
	gchar* old_parent_id;
	ObjectsProject* _tmp111_;
	const gchar* _tmp112_;
	const gchar* _tmp113_;
	gchar* _tmp114_;
	gboolean old_is_favorite;
	ObjectsProject* _tmp115_;
	gboolean _tmp116_;
	gboolean _tmp117_;
	ObjectsProject* _tmp118_;
	JsonNode* _tmp119_;
	ServicesStore* _tmp120_;
	ObjectsProject* _tmp121_;
	ObjectsProject* _tmp122_;
	const gchar* _tmp123_;
	const gchar* _tmp124_;
	const gchar* _tmp125_;
	ServicesEventBus* _tmp126_;
	ServicesEventBus* _tmp127_;
	ObjectsProject* _tmp128_;
	const gchar* _tmp129_;
	ObjectsProject* _tmp130_;
	gboolean _tmp131_;
	gboolean _tmp132_;
	ServicesEventBus* _tmp133_;
	ServicesEventBus* _tmp134_;
	ObjectsProject* _tmp135_;
	ObjectsProject* _project;
	JsonNode* _tmp136_;
	ObjectsProject* _tmp137_;
	ObjectsProject* _tmp138_;
	const gchar* _tmp139_;
	const gchar* _tmp140_;
	ServicesStore* _tmp141_;
	ObjectsProject* _tmp142_;
	GeeArrayList* _project_list;
	ServicesStore* _tmp143_;
	const gchar* _tmp144_;
	const gchar* _tmp145_;
	GeeArrayList* _tmp146_;
	gint _project_size;
	GeeArrayList* _tmp147_;
	gint _tmp148_;
	gint _tmp149_;
	gint _project_index;
	gint _tmp150_;
	gint _tmp151_;
	ObjectsProject* _vala1_project;
	GeeArrayList* _tmp152_;
	gpointer _tmp153_;
	ObjectsProject* _tmp154_;
	JsonArray* sections;
	JsonParser* _tmp155_;
	JsonNode* _tmp156_;
	JsonObject* _tmp157_;
	JsonArray* _tmp158_;
	JsonArray* _tmp159_;
	GList* _tmp160_;
	GList* _vala2__node_collection;
	GList* _vala2__node_it;
	JsonNode* _vala2__node;
	ObjectsSection* section;
	ServicesStore* _tmp161_;
	JsonNode* _tmp162_;
	JsonObject* _tmp163_;
	const gchar* _tmp164_;
	ObjectsSection* _tmp165_;
	ObjectsSection* _tmp166_;
	JsonNode* _tmp167_;
	JsonObject* _tmp168_;
	ServicesStore* _tmp169_;
	ObjectsSection* _tmp170_;
	ObjectsSection* _tmp171_;
	JsonNode* _tmp172_;
	ServicesStore* _tmp173_;
	ObjectsSection* _tmp174_;
	JsonNode* _tmp175_;
	JsonArray* items;
	JsonParser* _tmp176_;
	JsonNode* _tmp177_;
	JsonObject* _tmp178_;
	JsonArray* _tmp179_;
	JsonArray* _tmp180_;
	GList* _tmp181_;
	GList* _vala3__node_collection;
	GList* _vala3__node_it;
	JsonNode* _vala3__node;
	JsonNode* _tmp182_;
	JsonArray* reminders;
	JsonParser* _tmp183_;
	JsonNode* _tmp184_;
	JsonObject* _tmp185_;
	JsonArray* _tmp186_;
	JsonArray* _tmp187_;
	GList* _tmp188_;
	GList* _vala4__node_collection;
	GList* _vala4__node_it;
	JsonNode* _vala4__node;
	ObjectsReminder* reminder;
	ServicesStore* _tmp189_;
	JsonNode* _tmp190_;
	JsonObject* _tmp191_;
	const gchar* _tmp192_;
	ObjectsReminder* _tmp193_;
	ObjectsReminder* _tmp194_;
	JsonNode* _tmp195_;
	JsonObject* _tmp196_;
	ServicesStore* _tmp197_;
	ObjectsReminder* _tmp198_;
	JsonNode* _tmp199_;
	ObjectsReminder* _tmp200_;
	ObjectsItem* item;
	ServicesStore* _tmp201_;
	ObjectsReminder* _tmp202_;
	const gchar* _tmp203_;
	const gchar* _tmp204_;
	ObjectsItem* _tmp205_;
	ObjectsItem* _tmp206_;
	ObjectsItem* _tmp207_;
	ObjectsReminder* _tmp208_;
	ObjectsReminder* _tmp209_;
	ObjectsReminder* _tmp210_;
	GError* e;
	ServicesLogService* _tmp211_;
	ServicesLogService* _tmp212_;
	GError* _tmp213_;
	const gchar* _tmp214_;
	gchar* _tmp215_;
	gchar* _tmp216_;
	GDateTime* _tmp217_;
	GDateTime* _tmp218_;
	gchar* _tmp219_;
	gchar* _tmp220_;
	GeeArrayList* _vala1__project_list;
	ServicesStore* _tmp221_;
	const gchar* _tmp222_;
	const gchar* _tmp223_;
	GeeArrayList* _tmp224_;
	gint _vala1__project_size;
	GeeArrayList* _tmp225_;
	gint _tmp226_;
	gint _tmp227_;
	gint _vala1__project_index;
	gint _tmp228_;
	gint _tmp229_;
	ObjectsProject* _vala2_project;
	GeeArrayList* _tmp230_;
	gpointer _tmp231_;
	ObjectsProject* _tmp232_;
	ObjectsProject* _tmp233_;
	ServicesStore* _tmp234_;
	ObjectsProject* _tmp235_;
	GError* _inner_error0_;
};

struct _ServicesTodoistQueueData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsSource* source;
	ServicesLogService* _tmp0_;
	ServicesLogService* _tmp1_;
	GeeArrayList* queue_collection;
	ServicesDatabase* _tmp2_;
	ServicesDatabase* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gchar* json;
	GeeArrayList* _tmp11_;
	ObjectsSourceTodoistData* _tmp12_;
	ObjectsSourceTodoistData* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	ServicesLogService* _tmp17_;
	ServicesLogService* _tmp18_;
	GeeArrayList* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	ServicesLogService* _tmp24_;
	ServicesLogService* _tmp25_;
	const gchar* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	SoupMessage* message;
	SoupMessage* _tmp29_;
	SoupMessage* _tmp30_;
	SoupMessageHeaders* _tmp31_;
	SoupMessageHeaders* _tmp32_;
	ObjectsSourceTodoistData* _tmp33_;
	ObjectsSourceTodoistData* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	SoupMessage* _tmp39_;
	const gchar* _tmp40_;
	guint8* _tmp41_;
	gint _tmp41__length1;
	gint _tmp42_;
	guint8* _tmp43_;
	gint _tmp43__length1;
	GBytes* _tmp44_;
	GBytes* _tmp45_;
	GBytes* stream;
	SoupSession* _tmp46_;
	SoupMessage* _tmp47_;
	GBytes* _tmp48_;
	JsonParser* parser;
	JsonParser* _tmp49_;
	JsonParser* _tmp50_;
	GBytes* _tmp51_;
	gsize _tmp52_;
	guint8* _tmp53_;
	JsonObject* node;
	JsonParser* _tmp54_;
	JsonNode* _tmp55_;
	JsonObject* _tmp56_;
	JsonObject* _tmp57_;
	ObjectsSourceTodoistData* _tmp58_;
	ObjectsSourceTodoistData* _tmp59_;
	JsonObject* _tmp60_;
	const gchar* _tmp61_;
	GeeArrayList* _q_list;
	GeeArrayList* _tmp62_;
	gint _q_size;
	GeeArrayList* _tmp63_;
	gint _tmp64_;
	gint _tmp65_;
	gint _q_index;
	gint _tmp66_;
	gint _tmp67_;
	ObjectsQueue* q;
	GeeArrayList* _tmp68_;
	gpointer _tmp69_;
	JsonNode* uuid_member;
	JsonObject* _tmp70_;
	JsonObject* _tmp71_;
	ObjectsQueue* _tmp72_;
	const gchar* _tmp73_;
	const gchar* _tmp74_;
	JsonNode* _tmp75_;
	JsonNode* _tmp76_;
	ServicesLogService* _tmp77_;
	ServicesLogService* _tmp78_;
	ObjectsQueue* _tmp79_;
	const gchar* _tmp80_;
	const gchar* _tmp81_;
	ObjectsQueue* _tmp82_;
	const gchar* _tmp83_;
	const gchar* _tmp84_;
	ObjectsQueue* _tmp85_;
	const gchar* _tmp86_;
	const gchar* _tmp87_;
	gchar* _tmp88_;
	gchar* _tmp89_;
	JsonNode* _tmp90_;
	JsonObject* temp_id_mapping;
	JsonObject* _tmp91_;
	JsonObject* _tmp92_;
	JsonObject* _tmp93_;
	gboolean success;
	ObjectsQueue* _tmp94_;
	const gchar* _tmp95_;
	const gchar* _tmp96_;
	JsonObject* _tmp97_;
	ObjectsQueue* _tmp98_;
	const gchar* _tmp99_;
	const gchar* _tmp100_;
	gchar* id;
	JsonObject* _tmp101_;
	ObjectsQueue* _tmp102_;
	const gchar* _tmp103_;
	const gchar* _tmp104_;
	const gchar* _tmp105_;
	gchar* _tmp106_;
	ServicesStore* _tmp107_;
	ObjectsQueue* _tmp108_;
	const gchar* _tmp109_;
	const gchar* _tmp110_;
	const gchar* _tmp111_;
	ServicesDatabase* _tmp112_;
	ServicesDatabase* _tmp113_;
	ObjectsQueue* _tmp114_;
	const gchar* _tmp115_;
	const gchar* _tmp116_;
	ServicesLogService* _tmp117_;
	ServicesLogService* _tmp118_;
	ObjectsQueue* _tmp119_;
	const gchar* _tmp120_;
	const gchar* _tmp121_;
	gchar* _tmp122_;
	gchar* _tmp123_;
	ObjectsQueue* _tmp124_;
	const gchar* _tmp125_;
	const gchar* _tmp126_;
	JsonObject* _tmp127_;
	ObjectsQueue* _tmp128_;
	const gchar* _tmp129_;
	const gchar* _tmp130_;
	gchar* _vala1_id;
	JsonObject* _tmp131_;
	ObjectsQueue* _tmp132_;
	const gchar* _tmp133_;
	const gchar* _tmp134_;
	const gchar* _tmp135_;
	gchar* _tmp136_;
	ServicesStore* _tmp137_;
	ObjectsQueue* _tmp138_;
	const gchar* _tmp139_;
	const gchar* _tmp140_;
	const gchar* _tmp141_;
	ServicesDatabase* _tmp142_;
	ServicesDatabase* _tmp143_;
	ObjectsQueue* _tmp144_;
	const gchar* _tmp145_;
	const gchar* _tmp146_;
	ServicesLogService* _tmp147_;
	ServicesLogService* _tmp148_;
	ObjectsQueue* _tmp149_;
	const gchar* _tmp150_;
	const gchar* _tmp151_;
	gchar* _tmp152_;
	gchar* _tmp153_;
	ObjectsQueue* _tmp154_;
	const gchar* _tmp155_;
	const gchar* _tmp156_;
	JsonObject* _tmp157_;
	ObjectsQueue* _tmp158_;
	const gchar* _tmp159_;
	const gchar* _tmp160_;
	gchar* _vala2_id;
	JsonObject* _tmp161_;
	ObjectsQueue* _tmp162_;
	const gchar* _tmp163_;
	const gchar* _tmp164_;
	const gchar* _tmp165_;
	gchar* _tmp166_;
	ServicesStore* _tmp167_;
	ObjectsQueue* _tmp168_;
	const gchar* _tmp169_;
	const gchar* _tmp170_;
	const gchar* _tmp171_;
	ServicesDatabase* _tmp172_;
	ServicesDatabase* _tmp173_;
	ObjectsQueue* _tmp174_;
	const gchar* _tmp175_;
	const gchar* _tmp176_;
	ServicesLogService* _tmp177_;
	ServicesLogService* _tmp178_;
	ObjectsQueue* _tmp179_;
	const gchar* _tmp180_;
	const gchar* _tmp181_;
	gchar* _tmp182_;
	gchar* _tmp183_;
	ServicesDatabase* _tmp184_;
	ServicesDatabase* _tmp185_;
	ObjectsQueue* _tmp186_;
	const gchar* _tmp187_;
	const gchar* _tmp188_;
	JsonObject* sync_status;
	JsonObject* _tmp189_;
	JsonObject* _tmp190_;
	JsonObject* _tmp191_;
	JsonObject* _tmp192_;
	ObjectsQueue* _tmp193_;
	const gchar* _tmp194_;
	const gchar* _tmp195_;
	JsonObject* error_obj;
	JsonObject* _tmp196_;
	ObjectsQueue* _tmp197_;
	const gchar* _tmp198_;
	const gchar* _tmp199_;
	JsonObject* _tmp200_;
	JsonObject* _tmp201_;
	ServicesLogService* _tmp202_;
	ServicesLogService* _tmp203_;
	ObjectsQueue* _tmp204_;
	const gchar* _tmp205_;
	const gchar* _tmp206_;
	JsonObject* _tmp207_;
	const gchar* _tmp208_;
	gchar* _tmp209_;
	gchar* _tmp210_;
	ServicesDatabase* _tmp211_;
	ServicesDatabase* _tmp212_;
	ObjectsQueue* _tmp213_;
	const gchar* _tmp214_;
	const gchar* _tmp215_;
	JsonObject* _tmp216_;
	JsonObject* _tmp217_;
	JsonArray* _tmp218_;
	GList* _tmp219_;
	GList* _node_collection;
	GList* _node_it;
	JsonNode* _node;
	JsonNode* _tmp220_;
	GError* e;
	GError* _tmp221_;
	const gchar* _tmp222_;
	GError* _inner_error0_;
};

struct _ServicesTodoistAddData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsBaseObject* object;
	HttpResponse* result;
	ServicesTodoistItems* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistUpdateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsBaseObject* object;
	HttpResponse* result;
	ServicesTodoistItems* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistDeleteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsBaseObject* object;
	HttpResponse* result;
	ServicesTodoistItems* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistCompleteItemData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsItem* item;
	HttpResponse* result;
	ServicesTodoistItems* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistCloseItemData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsItem* item;
	HttpResponse* result;
	ServicesTodoistItems* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistMoveItemData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsItem* item;
	gchar* type;
	gchar* id;
	HttpResponse* result;
	ServicesTodoistItems* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistUpdateItemsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	GeeArrayList* objects;
	ServicesTodoistItems* _tmp0_;
};

struct _ServicesTodoistMoveProjectSectionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsBaseObject* base_object;
	gchar* project_id;
	HttpResponse* result;
	ServicesTodoistProjects* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _ServicesTodoistDuplicateProjectData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ServicesTodoist* self;
	ObjectsProject* project;
	HttpResponse* result;
	ServicesTodoistProjects* _tmp0_;
	HttpResponse* _tmp1_;
};

struct _HttpResponsePrivate {
	gboolean _status;
	gchar* _error;
	gint _error_code;
	gint _http_code;
	gchar* _data;
	GValue _data_object;
};

struct _ParamSpecHttpResponse {
	GParamSpec parent_instance;
};

static gint ServicesTodoist_private_offset;
static gpointer services_todoist_parent_class = NULL;
static ServicesTodoist* services_todoist__instance;
static ServicesTodoist* services_todoist__instance = NULL;
static gint HttpResponse_private_offset;
static gpointer http_response_parent_class = NULL;

static void services_todoist_login_data_free (gpointer _data);
static gboolean services_todoist_login_co (ServicesTodoistLoginData* _data_);
static void services_todoist_login_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_);
static void services_todoist_login_token_data_free (gpointer _data);
static gboolean services_todoist_login_token_co (ServicesTodoistLoginTokenData* _data_);
static void services_todoist_login_token_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
static void services_todoist_add_todoist_account_data_free (gpointer _data);
static gboolean services_todoist_add_todoist_account_co (ServicesTodoistAddTodoistAccountData* _data_);
static void services_todoist_add_todoist_account_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
static void services_todoist_process_item_node (ServicesTodoist* self,
                                         JsonNode* _node);
static void services_todoist_sync_data_free (gpointer _data);
static gboolean services_todoist_sync_co (ServicesTodoistSyncData* _data_);
static void services_todoist_sync_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_);
static void services_todoist_queue_data_free (gpointer _data);
static gboolean services_todoist_queue_co (ServicesTodoistQueueData* _data_);
static void services_todoist_queue_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_);
static JsonNode* _vala_JsonNode_copy (JsonNode* self);
static void _vala_JsonNode_free (JsonNode* self);
static gchar* services_todoist_resolve_id (ServicesTodoist* self,
                                    const gchar* id);
static void services_todoist_begin_command (ServicesTodoist* self,
                                     JsonBuilder* builder,
                                     const gchar* type,
                                     const gchar* uuid,
                                     const gchar* temp_id);
static void services_todoist_end_command (ServicesTodoist* self,
                                   JsonBuilder* builder);
static void services_todoist_add_data_free (gpointer _data);
static gboolean services_todoist_add_co (ServicesTodoistAddData* _data_);
static void services_todoist_add_ready (GObject* source_object,
                                 GAsyncResult* _res_,
                                 gpointer _user_data_);
static void services_todoist_update_data_free (gpointer _data);
static gboolean services_todoist_update_co (ServicesTodoistUpdateData* _data_);
static void services_todoist_update_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_);
static void services_todoist_delete_data_free (gpointer _data);
static gboolean services_todoist_delete_co (ServicesTodoistDeleteData* _data_);
static void services_todoist_delete_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_);
static void services_todoist_complete_item_data_free (gpointer _data);
static gboolean services_todoist_complete_item_co (ServicesTodoistCompleteItemData* _data_);
static void services_todoist_complete_item_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void services_todoist_close_item_data_free (gpointer _data);
static gboolean services_todoist_close_item_co (ServicesTodoistCloseItemData* _data_);
static void services_todoist_close_item_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_);
static void services_todoist_move_item_data_free (gpointer _data);
static gboolean services_todoist_move_item_co (ServicesTodoistMoveItemData* _data_);
static void services_todoist_move_item_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void services_todoist_update_items_data_free (gpointer _data);
static gboolean services_todoist_update_items_co (ServicesTodoistUpdateItemsData* _data_);
static void services_todoist_update_items_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void services_todoist_move_project_section_data_free (gpointer _data);
static gboolean services_todoist_move_project_section_co (ServicesTodoistMoveProjectSectionData* _data_);
static void services_todoist_move_project_section_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void services_todoist_duplicate_project_data_free (gpointer _data);
static gboolean services_todoist_duplicate_project_co (ServicesTodoistDuplicateProjectData* _data_);
static void services_todoist_duplicate_project_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void services_todoist_finalize (GObject * obj);
static GType services_todoist_get_type_once (void);
static void http_response_finalize (HttpResponse * obj);
static GType http_response_get_type_once (void);

static inline gpointer
services_todoist_get_instance_private (ServicesTodoist* self)
{
	return G_STRUCT_MEMBER_P (self, ServicesTodoist_private_offset);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

ServicesTodoist*
services_todoist_get_default (void)
{
	ServicesTodoist* _tmp0_;
	ServicesTodoist* _tmp2_;
	ServicesTodoist* _tmp3_;
	ServicesTodoist* result;
	_tmp0_ = services_todoist__instance;
	if (_tmp0_ == NULL) {
		ServicesTodoist* _tmp1_;
		_tmp1_ = services_todoist_new ();
		_g_object_unref0 (services_todoist__instance);
		services_todoist__instance = _tmp1_;
	}
	_tmp2_ = services_todoist__instance;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	return result;
}

ServicesTodoist*
services_todoist_construct (GType object_type)
{
	ServicesTodoist * self = NULL;
	SoupSession* _tmp0_;
	SoupSession* _tmp1_;
	ServicesTodoistAuth* _tmp2_;
	SoupSession* _tmp3_;
	ServicesTodoistItems* _tmp4_;
	SoupSession* _tmp5_;
	ServicesTodoistProjects* _tmp6_;
	self = (ServicesTodoist*) g_object_new (object_type, NULL);
	_tmp0_ = soup_session_new ();
	_g_object_unref0 (self->priv->session);
	self->priv->session = _tmp0_;
	_tmp1_ = self->priv->session;
	_tmp2_ = services_todoist_auth_new (_tmp1_);
	_g_object_unref0 (self->priv->_auth);
	self->priv->_auth = _tmp2_;
	_tmp3_ = self->priv->session;
	_tmp4_ = services_todoist_items_new (_tmp3_);
	_g_object_unref0 (self->priv->_items);
	self->priv->_items = _tmp4_;
	_tmp5_ = self->priv->session;
	_tmp6_ = services_todoist_projects_new (_tmp5_);
	_g_object_unref0 (self->priv->_projects);
	self->priv->_projects = _tmp6_;
	return self;
}

ServicesTodoist*
services_todoist_new (void)
{
	return services_todoist_construct (SERVICES_TYPE_TODOIST);
}

static void
services_todoist_login_data_free (gpointer _data)
{
	ServicesTodoistLoginData* _data_;
	_data_ = _data;
	_g_free0 (_data_->_url);
	_g_object_unref0 (_data_->migrate_source);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistLoginData, _data_);
}

void
services_todoist_login (ServicesTodoist* self,
                        const gchar* _url,
                        ObjectsSource* migrate_source,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_)
{
	ServicesTodoistLoginData* _data_;
	ServicesTodoist* _tmp0_;
	gchar* _tmp1_;
	ObjectsSource* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (_url != NULL);
	_data_ = g_slice_new0 (ServicesTodoistLoginData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_login_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (_url);
	_g_free0 (_data_->_url);
	_data_->_url = _tmp1_;
	_tmp2_ = _g_object_ref0 (migrate_source);
	_g_object_unref0 (_data_->migrate_source);
	_data_->migrate_source = _tmp2_;
	services_todoist_login_co (_data_);
}

HttpResponse*
services_todoist_login_finish (ServicesTodoist* self,
                               GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistLoginData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_login_ready (GObject* source_object,
                              GAsyncResult* _res_,
                              gpointer _user_data_)
{
	ServicesTodoistLoginData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_login_co (_data_);
}

static gboolean
services_todoist_login_co (ServicesTodoistLoginData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_auth;
	_data_->_state_ = 1;
	services_todoist_auth_login (_data_->_tmp0_, _data_->_url, _data_->migrate_source, services_todoist_login_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_auth_login_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_login_token_data_free (gpointer _data)
{
	ServicesTodoistLoginTokenData* _data_;
	_data_ = _data;
	_g_free0 (_data_->token);
	_g_object_unref0 (_data_->migrate_source);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistLoginTokenData, _data_);
}

void
services_todoist_login_token (ServicesTodoist* self,
                              const gchar* token,
                              ObjectsSource* migrate_source,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	ServicesTodoistLoginTokenData* _data_;
	ServicesTodoist* _tmp0_;
	gchar* _tmp1_;
	ObjectsSource* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (token != NULL);
	_data_ = g_slice_new0 (ServicesTodoistLoginTokenData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_login_token_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (token);
	_g_free0 (_data_->token);
	_data_->token = _tmp1_;
	_tmp2_ = _g_object_ref0 (migrate_source);
	_g_object_unref0 (_data_->migrate_source);
	_data_->migrate_source = _tmp2_;
	services_todoist_login_token_co (_data_);
}

HttpResponse*
services_todoist_login_token_finish (ServicesTodoist* self,
                                     GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistLoginTokenData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_login_token_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	ServicesTodoistLoginTokenData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_login_token_co (_data_);
}

static gboolean
services_todoist_login_token_co (ServicesTodoistLoginTokenData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_auth;
	_data_->_state_ = 1;
	services_todoist_auth_login_token (_data_->_tmp0_, _data_->token, _data_->migrate_source, services_todoist_login_token_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_auth_login_token_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_add_todoist_account_data_free (gpointer _data)
{
	ServicesTodoistAddTodoistAccountData* _data_;
	_data_ = _data;
	_g_free0 (_data_->token);
	_http_response_unref0 (_data_->response);
	_g_object_unref0 (_data_->migrate_source);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistAddTodoistAccountData, _data_);
}

static gpointer
_http_response_ref0 (gpointer self)
{
	return self ? http_response_ref (self) : NULL;
}

void
services_todoist_add_todoist_account (ServicesTodoist* self,
                                      const gchar* token,
                                      HttpResponse* response,
                                      ObjectsSource* migrate_source,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	ServicesTodoistAddTodoistAccountData* _data_;
	ServicesTodoist* _tmp0_;
	gchar* _tmp1_;
	HttpResponse* _tmp2_;
	ObjectsSource* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (token != NULL);
	g_return_if_fail (response != NULL);
	_data_ = g_slice_new0 (ServicesTodoistAddTodoistAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_add_todoist_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (token);
	_g_free0 (_data_->token);
	_data_->token = _tmp1_;
	_tmp2_ = _http_response_ref0 (response);
	_http_response_unref0 (_data_->response);
	_data_->response = _tmp2_;
	_tmp3_ = _g_object_ref0 (migrate_source);
	_g_object_unref0 (_data_->migrate_source);
	_data_->migrate_source = _tmp3_;
	services_todoist_add_todoist_account_co (_data_);
}

void
services_todoist_add_todoist_account_finish (ServicesTodoist* self,
                                             GAsyncResult* _res_)
{
	ServicesTodoistAddTodoistAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
services_todoist_add_todoist_account_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	ServicesTodoistAddTodoistAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_add_todoist_account_co (_data_);
}

static gboolean
services_todoist_add_todoist_account_co (ServicesTodoistAddTodoistAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_auth;
	_data_->_state_ = 1;
	services_todoist_auth_add_todoist_account (_data_->_tmp0_, _data_->token, _data_->response, _data_->migrate_source, services_todoist_add_todoist_account_ready, _data_);
	return FALSE;
	_state_1:
	services_todoist_auth_add_todoist_account_finish (_data_->_tmp0_, _data_->_res_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_process_item_node (ServicesTodoist* self,
                                    JsonNode* _node)
{
	ObjectsItem* item = NULL;
	ServicesStore* _tmp0_;
	JsonObject* _tmp1_;
	const gchar* _tmp2_;
	ObjectsItem* _tmp3_;
	ObjectsItem* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (_node != NULL);
	_tmp0_ = services_store_instance ();
	_tmp1_ = json_node_get_object (_node);
	_tmp2_ = json_object_get_string_member (_tmp1_, "id");
	_tmp3_ = services_store_get_item (_tmp0_, _tmp2_);
	item = _tmp3_;
	_tmp4_ = item;
	if (_tmp4_ != NULL) {
		JsonObject* _tmp5_;
		_tmp5_ = json_node_get_object (_node);
		if (json_object_get_boolean_member (_tmp5_, "is_deleted")) {
			ServicesStore* _tmp6_;
			ObjectsItem* _tmp7_;
			_tmp6_ = services_store_instance ();
			_tmp7_ = item;
			services_store_delete_item (_tmp6_, _tmp7_);
		} else {
			gchar* old_project_id = NULL;
			ObjectsItem* _tmp8_;
			const gchar* _tmp9_;
			const gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* old_section_id = NULL;
			ObjectsItem* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			gchar* _tmp15_;
			gchar* old_parent_id = NULL;
			ObjectsItem* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			gchar* _tmp19_;
			gboolean old_checked = FALSE;
			ObjectsItem* _tmp20_;
			gboolean _tmp21_;
			gboolean _tmp22_;
			ObjectsItem* _tmp23_;
			gboolean _tmp24_;
			gboolean _tmp25_;
			ObjectsItem* _tmp26_;
			ServicesStore* _tmp27_;
			ObjectsItem* _tmp28_;
			gboolean _tmp29_ = FALSE;
			gboolean _tmp30_ = FALSE;
			const gchar* _tmp31_;
			ObjectsItem* _tmp32_;
			const gchar* _tmp33_;
			const gchar* _tmp34_;
			ObjectsItem* _tmp49_;
			gboolean _tmp50_;
			gboolean _tmp51_;
			_tmp8_ = item;
			_tmp9_ = objects_item_get_project_id (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = g_strdup (_tmp10_);
			old_project_id = _tmp11_;
			_tmp12_ = item;
			_tmp13_ = objects_item_get_section_id (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = g_strdup (_tmp14_);
			old_section_id = _tmp15_;
			_tmp16_ = item;
			_tmp17_ = objects_item_get_parent_id (_tmp16_);
			_tmp18_ = _tmp17_;
			_tmp19_ = g_strdup (_tmp18_);
			old_parent_id = _tmp19_;
			_tmp20_ = item;
			_tmp21_ = objects_item_get_checked (_tmp20_);
			_tmp22_ = _tmp21_;
			old_checked = _tmp22_;
			_tmp23_ = item;
			_tmp24_ = objects_base_object_get_loading ((ObjectsBaseObject*) _tmp23_);
			_tmp25_ = _tmp24_;
			if (_tmp25_) {
				_g_free0 (old_parent_id);
				_g_free0 (old_section_id);
				_g_free0 (old_project_id);
				_g_object_unref0 (item);
				return;
			}
			_tmp26_ = item;
			objects_item_update_from_json (_tmp26_, _node);
			_tmp27_ = services_store_instance ();
			_tmp28_ = item;
			services_store_update_item (_tmp27_, _tmp28_, "");
			_tmp31_ = old_project_id;
			_tmp32_ = item;
			_tmp33_ = objects_item_get_project_id (_tmp32_);
			_tmp34_ = _tmp33_;
			if (g_strcmp0 (_tmp31_, _tmp34_) != 0) {
				_tmp30_ = TRUE;
			} else {
				const gchar* _tmp35_;
				ObjectsItem* _tmp36_;
				const gchar* _tmp37_;
				const gchar* _tmp38_;
				_tmp35_ = old_section_id;
				_tmp36_ = item;
				_tmp37_ = objects_item_get_section_id (_tmp36_);
				_tmp38_ = _tmp37_;
				_tmp30_ = g_strcmp0 (_tmp35_, _tmp38_) != 0;
			}
			if (_tmp30_) {
				_tmp29_ = TRUE;
			} else {
				const gchar* _tmp39_;
				ObjectsItem* _tmp40_;
				const gchar* _tmp41_;
				const gchar* _tmp42_;
				_tmp39_ = old_parent_id;
				_tmp40_ = item;
				_tmp41_ = objects_item_get_parent_id (_tmp40_);
				_tmp42_ = _tmp41_;
				_tmp29_ = g_strcmp0 (_tmp39_, _tmp42_) != 0;
			}
			if (_tmp29_) {
				ServicesEventBus* _tmp43_;
				ServicesEventBus* _tmp44_;
				ObjectsItem* _tmp45_;
				const gchar* _tmp46_;
				const gchar* _tmp47_;
				const gchar* _tmp48_;
				_tmp43_ = services_event_bus_get_default ();
				_tmp44_ = _tmp43_;
				_tmp45_ = item;
				_tmp46_ = old_project_id;
				_tmp47_ = old_section_id;
				_tmp48_ = old_parent_id;
				g_signal_emit_by_name (_tmp44_, "item-moved", _tmp45_, _tmp46_, _tmp47_, _tmp48_);
				_g_object_unref0 (_tmp44_);
			}
			_tmp49_ = item;
			_tmp50_ = objects_item_get_checked (_tmp49_);
			_tmp51_ = _tmp50_;
			if (old_checked != _tmp51_) {
				ServicesStore* _tmp52_;
				ObjectsItem* _tmp53_;
				_tmp52_ = services_store_instance ();
				_tmp53_ = item;
				services_store_complete_item (_tmp52_, _tmp53_, old_checked, TRUE);
			}
			_g_free0 (old_parent_id);
			_g_free0 (old_section_id);
			_g_free0 (old_project_id);
		}
	} else {
		services_todoist_add_item_if_not_exists (self, _node);
	}
	_g_object_unref0 (item);
}

static void
services_todoist_sync_data_free (gpointer _data)
{
	ServicesTodoistSyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistSyncData, _data_);
}

void
services_todoist_sync (ServicesTodoist* self,
                       ObjectsSource* source,
                       GAsyncReadyCallback _callback_,
                       gpointer _user_data_)
{
	ServicesTodoistSyncData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsSource* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	_data_ = g_slice_new0 (ServicesTodoistSyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_sync_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (_data_->source);
	_data_->source = _tmp1_;
	services_todoist_sync_co (_data_);
}

void
services_todoist_sync_finish (ServicesTodoist* self,
                              GAsyncResult* _res_)
{
	ServicesTodoistSyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
services_todoist_sync_ready (GObject* source_object,
                             GAsyncResult* _res_,
                             gpointer _user_data_)
{
	ServicesTodoistSyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_sync_co (_data_);
}

static gpointer
_json_object_ref0 (gpointer self)
{
	return self ? json_object_ref (self) : NULL;
}

static gchar*
g_date_time_to_string (GDateTime* self)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_date_time_format (self, "%FT%H:%M:%S%z");
	result = _tmp0_;
	return result;
}

static gboolean
services_todoist_sync_co (ServicesTodoistSyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = objects_source_get_todoist_data (_data_->source);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = objects_source_todoist_data_get_access_token (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	if (_data_->_tmp3_ == NULL) {
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	if (objects_source_needs_migration (_data_->source)) {
		g_signal_emit_by_name (_data_->source, "sync-failed", NULL);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_signal_emit_by_name (_data_->source, "sync-started");
	_data_->_tmp4_ = soup_message_new ("POST", SERVICES_TODOIST_TODOIST_SYNC_URL);
	_data_->message = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->message;
	_data_->_tmp6_ = soup_message_get_request_headers (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = objects_source_get_todoist_data (_data_->source);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_tmp10_ = objects_source_todoist_data_get_access_token (_data_->_tmp9_);
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp12_ = g_strdup_printf ("Bearer %s", _data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	soup_message_headers_append (_data_->_tmp7_, "Authorization", _data_->_tmp13_);
	_g_free0 (_data_->_tmp13_);
	_data_->_tmp14_ = objects_source_get_todoist_data (_data_->source);
	_data_->_tmp15_ = _data_->_tmp14_;
	_data_->_tmp16_ = objects_source_todoist_data_get_sync_token (_data_->_tmp15_);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_tmp18_ = g_strdup_printf ("sync_token=%s&resource_types=%s", _data_->_tmp17_, SERVICES_TODOIST_RESOURCE_TYPES);
	_data_->form_data = _data_->_tmp18_;
	_data_->_tmp19_ = _data_->message;
	_data_->_tmp20_ = _data_->form_data;
	_data_->_tmp22_ = 0;
	_data_->_tmp21_ = string_get_data (_data_->_tmp20_, &_data_->_tmp22_);
	_data_->_tmp21__length1 = _data_->_tmp22_;
	_data_->_tmp23_ = _data_->_tmp21_;
	_data_->_tmp23__length1 = _data_->_tmp21__length1;
	_data_->_tmp24_ = g_bytes_new (_data_->_tmp23_, _data_->_tmp23__length1);
	_data_->_tmp25_ = _data_->_tmp24_;
	soup_message_set_request_body_from_bytes (_data_->_tmp19_, "application/x-www-form-urlencoded", _data_->_tmp25_);
	_g_bytes_unref0 (_data_->_tmp25_);
	{
		_data_->_tmp26_ = _data_->self->priv->session;
		_data_->_tmp27_ = _data_->message;
		_data_->_state_ = 1;
		soup_session_send_and_read_async (_data_->_tmp26_, _data_->_tmp27_, G_PRIORITY_LOW, NULL, services_todoist_sync_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp28_ = soup_session_send_and_read_finish (_data_->_tmp26_, _data_->_res_, &_data_->_inner_error0_);
		_data_->stream = _data_->_tmp28_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp29_ = json_parser_new ();
		_data_->parser = _data_->_tmp29_;
		_data_->_tmp30_ = _data_->parser;
		_data_->_tmp31_ = _data_->stream;
		_data_->_tmp32_ = 0;
		_data_->_tmp33_ = g_bytes_get_data (_data_->_tmp31_, &_data_->_tmp32_);
		json_parser_load_from_data (_data_->_tmp30_, (const gchar*) _data_->_tmp33_, (gssize) -1, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->parser);
			_g_bytes_unref0 (_data_->stream);
			goto __catch0_g_error;
		}
		_data_->_tmp34_ = _data_->parser;
		_data_->_tmp35_ = json_parser_get_root (_data_->_tmp34_);
		_data_->_tmp36_ = json_node_get_object (_data_->_tmp35_);
		if (!json_object_has_member (_data_->_tmp36_, "error")) {
			_data_->_tmp37_ = objects_source_get_todoist_data (_data_->source);
			_data_->_tmp38_ = _data_->_tmp37_;
			_data_->_tmp39_ = _data_->parser;
			_data_->_tmp40_ = json_parser_get_root (_data_->_tmp39_);
			_data_->_tmp41_ = json_node_get_object (_data_->_tmp40_);
			_data_->_tmp42_ = json_object_get_string_member (_data_->_tmp41_, "sync_token");
			objects_source_todoist_data_set_sync_token (_data_->_tmp38_, _data_->_tmp42_);
			_data_->_tmp43_ = _data_->parser;
			_data_->_tmp44_ = json_parser_get_root (_data_->_tmp43_);
			_data_->_tmp45_ = json_node_get_object (_data_->_tmp44_);
			if (json_object_has_member (_data_->_tmp45_, "user")) {
				_data_->_tmp46_ = _data_->parser;
				_data_->_tmp47_ = json_parser_get_root (_data_->_tmp46_);
				_data_->_tmp48_ = json_node_get_object (_data_->_tmp47_);
				_data_->_tmp49_ = json_object_get_object_member (_data_->_tmp48_, "user");
				_data_->_tmp50_ = _json_object_ref0 (_data_->_tmp49_);
				_data_->user_object = _data_->_tmp50_;
				_data_->_tmp51_ = objects_source_get_todoist_data (_data_->source);
				_data_->_tmp52_ = _data_->_tmp51_;
				_data_->_tmp53_ = _data_->user_object;
				_data_->_tmp54_ = json_object_get_string_member (_data_->_tmp53_, "id");
				objects_source_todoist_data_set_user_id (_data_->_tmp52_, _data_->_tmp54_);
				_data_->_tmp55_ = objects_source_get_todoist_data (_data_->source);
				_data_->_tmp56_ = _data_->_tmp55_;
				_data_->_tmp57_ = _data_->user_object;
				objects_source_todoist_data_set_user_is_premium (_data_->_tmp56_, json_object_get_boolean_member (_data_->_tmp57_, "is_premium"));
				_data_->_tmp58_ = objects_source_get_todoist_data (_data_->source);
				_data_->_tmp59_ = _data_->_tmp58_;
				_data_->_tmp60_ = _data_->user_object;
				_data_->_tmp61_ = json_object_get_string_member (_data_->_tmp60_, "email");
				objects_source_todoist_data_set_user_email (_data_->_tmp59_, _data_->_tmp61_);
				_data_->_tmp62_ = objects_source_get_todoist_data (_data_->source);
				_data_->_tmp63_ = _data_->_tmp62_;
				_data_->_tmp64_ = _data_->user_object;
				_data_->_tmp65_ = json_object_get_string_member (_data_->_tmp64_, "full_name");
				objects_source_todoist_data_set_user_name (_data_->_tmp63_, _data_->_tmp65_);
				_json_object_unref0 (_data_->user_object);
			}
			_data_->_tmp66_ = _data_->parser;
			_data_->_tmp67_ = json_parser_get_root (_data_->_tmp66_);
			_data_->_tmp68_ = json_node_get_object (_data_->_tmp67_);
			_data_->_tmp69_ = json_object_get_array_member (_data_->_tmp68_, SERVICES_TODOIST_LABELS_COLLECTION);
			_data_->_labels = _data_->_tmp69_;
			_data_->_tmp70_ = _data_->_labels;
			_data_->_tmp71_ = json_array_get_elements (_data_->_tmp70_);
			{
				_data_->_node_collection = _data_->_tmp71_;
				for (_data_->_node_it = _data_->_node_collection; _data_->_node_it != NULL; _data_->_node_it = _data_->_node_it->next) {
					_data_->_node = (JsonNode*) _data_->_node_it->data;
					{
						_data_->_tmp72_ = _data_->_node;
						_data_->_tmp73_ = json_node_get_object (_data_->_tmp72_);
						_data_->_tmp74_ = json_object_get_string_member (_data_->_tmp73_, "id");
						_data_->_tmp75_ = g_strdup (_data_->_tmp74_);
						_data_->_id = _data_->_tmp75_;
						_data_->_tmp76_ = services_store_instance ();
						_data_->_tmp77_ = _data_->_id;
						_data_->_tmp78_ = services_store_get_label (_data_->_tmp76_, _data_->_tmp77_);
						_data_->label = _data_->_tmp78_;
						_data_->_tmp79_ = _data_->label;
						if (_data_->_tmp79_ != NULL) {
							_data_->_tmp80_ = _data_->_node;
							_data_->_tmp81_ = json_node_get_object (_data_->_tmp80_);
							if (json_object_get_boolean_member (_data_->_tmp81_, "is_deleted")) {
								_data_->_tmp82_ = services_store_instance ();
								_data_->_tmp83_ = _data_->label;
								services_store_delete_label (_data_->_tmp82_, _data_->_tmp83_);
							} else {
								_data_->_tmp84_ = _data_->label;
								_data_->_tmp85_ = _data_->_node;
								objects_label_update_from_json (_data_->_tmp84_, _data_->_tmp85_);
								_data_->_tmp86_ = services_store_instance ();
								_data_->_tmp87_ = _data_->label;
								services_store_update_label (_data_->_tmp86_, _data_->_tmp87_);
							}
						} else {
							_data_->_tmp88_ = _data_->_node;
							_data_->_tmp89_ = objects_label_new_from_json (_data_->_tmp88_);
							_data_->_label = _data_->_tmp89_;
							_data_->_tmp90_ = _data_->_label;
							_data_->_tmp91_ = objects_base_object_get_id ((ObjectsBaseObject*) _data_->source);
							_data_->_tmp92_ = _data_->_tmp91_;
							objects_label_set_source_id (_data_->_tmp90_, _data_->_tmp92_);
							_data_->_tmp93_ = services_store_instance ();
							_data_->_tmp94_ = _data_->_label;
							services_store_insert_label (_data_->_tmp93_, _data_->_tmp94_);
							_g_object_unref0 (_data_->_label);
						}
						_g_object_unref0 (_data_->label);
						_g_free0 (_data_->_id);
					}
				}
				(_data_->_node_collection == NULL) ? NULL : (_data_->_node_collection = (g_list_free (_data_->_node_collection), NULL));
			}
			_data_->_tmp95_ = _data_->parser;
			_data_->_tmp96_ = json_parser_get_root (_data_->_tmp95_);
			_data_->_tmp97_ = json_node_get_object (_data_->_tmp96_);
			_data_->_tmp98_ = json_object_get_array_member (_data_->_tmp97_, SERVICES_TODOIST_PROJECTS_COLLECTION);
			_data_->projects = _data_->_tmp98_;
			_data_->_tmp99_ = _data_->projects;
			_data_->_tmp100_ = json_array_get_elements (_data_->_tmp99_);
			{
				_data_->_vala1__node_collection = _data_->_tmp100_;
				for (_data_->_vala1__node_it = _data_->_vala1__node_collection; _data_->_vala1__node_it != NULL; _data_->_vala1__node_it = _data_->_vala1__node_it->next) {
					_data_->_vala1__node = (JsonNode*) _data_->_vala1__node_it->data;
					{
						_data_->_tmp101_ = services_store_instance ();
						_data_->_tmp102_ = _data_->_vala1__node;
						_data_->_tmp103_ = json_node_get_object (_data_->_tmp102_);
						_data_->_tmp104_ = json_object_get_string_member (_data_->_tmp103_, "id");
						_data_->_tmp105_ = services_store_get_project (_data_->_tmp101_, _data_->_tmp104_);
						_data_->project = _data_->_tmp105_;
						_data_->_tmp106_ = _data_->project;
						if (_data_->_tmp106_ != NULL) {
							_data_->_tmp107_ = _data_->_vala1__node;
							_data_->_tmp108_ = json_node_get_object (_data_->_tmp107_);
							if (json_object_get_boolean_member (_data_->_tmp108_, "is_deleted")) {
								_data_->_tmp109_ = services_store_instance ();
								_data_->_tmp110_ = _data_->project;
								services_store_delete_project (_data_->_tmp109_, _data_->_tmp110_, NULL, NULL);
							} else {
								_data_->_tmp111_ = _data_->project;
								_data_->_tmp112_ = objects_project_get_parent_id (_data_->_tmp111_);
								_data_->_tmp113_ = _data_->_tmp112_;
								_data_->_tmp114_ = g_strdup (_data_->_tmp113_);
								_data_->old_parent_id = _data_->_tmp114_;
								_data_->_tmp115_ = _data_->project;
								_data_->_tmp116_ = objects_project_get_is_favorite (_data_->_tmp115_);
								_data_->_tmp117_ = _data_->_tmp116_;
								_data_->old_is_favorite = _data_->_tmp117_;
								_data_->_tmp118_ = _data_->project;
								_data_->_tmp119_ = _data_->_vala1__node;
								objects_project_update_from_json (_data_->_tmp118_, _data_->_tmp119_);
								_data_->_tmp120_ = services_store_instance ();
								_data_->_tmp121_ = _data_->project;
								services_store_update_project (_data_->_tmp120_, _data_->_tmp121_);
								_data_->_tmp122_ = _data_->project;
								_data_->_tmp123_ = objects_project_get_parent_id (_data_->_tmp122_);
								_data_->_tmp124_ = _data_->_tmp123_;
								_data_->_tmp125_ = _data_->old_parent_id;
								if (g_strcmp0 (_data_->_tmp124_, _data_->_tmp125_) != 0) {
									_data_->_tmp126_ = services_event_bus_get_default ();
									_data_->_tmp127_ = _data_->_tmp126_;
									_data_->_tmp128_ = _data_->project;
									_data_->_tmp129_ = _data_->old_parent_id;
									g_signal_emit_by_name (_data_->_tmp127_, "project-parent-changed", _data_->_tmp128_, _data_->_tmp129_, FALSE);
									_g_object_unref0 (_data_->_tmp127_);
								}
								_data_->_tmp130_ = _data_->project;
								_data_->_tmp131_ = objects_project_get_is_favorite (_data_->_tmp130_);
								_data_->_tmp132_ = _data_->_tmp131_;
								if (_data_->_tmp132_ != _data_->old_is_favorite) {
									_data_->_tmp133_ = services_event_bus_get_default ();
									_data_->_tmp134_ = _data_->_tmp133_;
									_data_->_tmp135_ = _data_->project;
									g_signal_emit_by_name (_data_->_tmp134_, "favorite-toggled", _data_->_tmp135_);
									_g_object_unref0 (_data_->_tmp134_);
								}
								_g_free0 (_data_->old_parent_id);
							}
						} else {
							_data_->_tmp136_ = _data_->_vala1__node;
							_data_->_tmp137_ = objects_project_new_from_json (_data_->_tmp136_);
							_data_->_project = _data_->_tmp137_;
							_data_->_tmp138_ = _data_->_project;
							_data_->_tmp139_ = objects_base_object_get_id ((ObjectsBaseObject*) _data_->source);
							_data_->_tmp140_ = _data_->_tmp139_;
							objects_project_set_source_id (_data_->_tmp138_, _data_->_tmp140_);
							_data_->_tmp141_ = services_store_instance ();
							_data_->_tmp142_ = _data_->_project;
							services_store_insert_project (_data_->_tmp141_, _data_->_tmp142_);
							_g_object_unref0 (_data_->_project);
						}
						_g_object_unref0 (_data_->project);
					}
				}
				(_data_->_vala1__node_collection == NULL) ? NULL : (_data_->_vala1__node_collection = (g_list_free (_data_->_vala1__node_collection), NULL));
			}
			{
				_data_->_tmp143_ = services_store_instance ();
				_data_->_tmp144_ = objects_base_object_get_id ((ObjectsBaseObject*) _data_->source);
				_data_->_tmp145_ = _data_->_tmp144_;
				_data_->_tmp146_ = services_store_get_projects_by_source (_data_->_tmp143_, _data_->_tmp145_);
				_data_->_project_list = _data_->_tmp146_;
				_data_->_tmp147_ = _data_->_project_list;
				_data_->_tmp148_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp147_);
				_data_->_tmp149_ = _data_->_tmp148_;
				_data_->_project_size = _data_->_tmp149_;
				_data_->_project_index = -1;
				while (TRUE) {
					_data_->_project_index = _data_->_project_index + 1;
					_data_->_tmp150_ = _data_->_project_index;
					_data_->_tmp151_ = _data_->_project_size;
					if (!(_data_->_tmp150_ < _data_->_tmp151_)) {
						break;
					}
					_data_->_tmp152_ = _data_->_project_list;
					_data_->_tmp153_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp152_, _data_->_project_index);
					_data_->_vala1_project = (ObjectsProject*) _data_->_tmp153_;
					_data_->_tmp154_ = _data_->_vala1_project;
					objects_project_set_freeze_update (_data_->_tmp154_, TRUE);
					_g_object_unref0 (_data_->_vala1_project);
				}
				_g_object_unref0 (_data_->_project_list);
			}
			_data_->_tmp155_ = _data_->parser;
			_data_->_tmp156_ = json_parser_get_root (_data_->_tmp155_);
			_data_->_tmp157_ = json_node_get_object (_data_->_tmp156_);
			_data_->_tmp158_ = json_object_get_array_member (_data_->_tmp157_, SERVICES_TODOIST_SECTIONS_COLLECTION);
			_data_->sections = _data_->_tmp158_;
			_data_->_tmp159_ = _data_->sections;
			_data_->_tmp160_ = json_array_get_elements (_data_->_tmp159_);
			{
				_data_->_vala2__node_collection = _data_->_tmp160_;
				for (_data_->_vala2__node_it = _data_->_vala2__node_collection; _data_->_vala2__node_it != NULL; _data_->_vala2__node_it = _data_->_vala2__node_it->next) {
					_data_->_vala2__node = (JsonNode*) _data_->_vala2__node_it->data;
					{
						_data_->_tmp161_ = services_store_instance ();
						_data_->_tmp162_ = _data_->_vala2__node;
						_data_->_tmp163_ = json_node_get_object (_data_->_tmp162_);
						_data_->_tmp164_ = json_object_get_string_member (_data_->_tmp163_, "id");
						_data_->_tmp165_ = services_store_get_section (_data_->_tmp161_, _data_->_tmp164_);
						_data_->section = _data_->_tmp165_;
						_data_->_tmp166_ = _data_->section;
						if (_data_->_tmp166_ != NULL) {
							_data_->_tmp167_ = _data_->_vala2__node;
							_data_->_tmp168_ = json_node_get_object (_data_->_tmp167_);
							if (json_object_get_boolean_member (_data_->_tmp168_, "is_deleted")) {
								_data_->_tmp169_ = services_store_instance ();
								_data_->_tmp170_ = _data_->section;
								services_store_delete_section (_data_->_tmp169_, _data_->_tmp170_);
							} else {
								_data_->_tmp171_ = _data_->section;
								_data_->_tmp172_ = _data_->_vala2__node;
								objects_section_update_from_json (_data_->_tmp171_, _data_->_tmp172_);
								_data_->_tmp173_ = services_store_instance ();
								_data_->_tmp174_ = _data_->section;
								services_store_update_section (_data_->_tmp173_, _data_->_tmp174_);
							}
						} else {
							_data_->_tmp175_ = _data_->_vala2__node;
							services_todoist_add_section_if_not_exists (_data_->self, _data_->_tmp175_);
						}
						_g_object_unref0 (_data_->section);
					}
				}
				(_data_->_vala2__node_collection == NULL) ? NULL : (_data_->_vala2__node_collection = (g_list_free (_data_->_vala2__node_collection), NULL));
			}
			_data_->_tmp176_ = _data_->parser;
			_data_->_tmp177_ = json_parser_get_root (_data_->_tmp176_);
			_data_->_tmp178_ = json_node_get_object (_data_->_tmp177_);
			_data_->_tmp179_ = json_object_get_array_member (_data_->_tmp178_, SERVICES_TODOIST_ITEMS_COLLECTION);
			_data_->items = _data_->_tmp179_;
			_data_->_tmp180_ = _data_->items;
			_data_->_tmp181_ = json_array_get_elements (_data_->_tmp180_);
			{
				_data_->_vala3__node_collection = _data_->_tmp181_;
				for (_data_->_vala3__node_it = _data_->_vala3__node_collection; _data_->_vala3__node_it != NULL; _data_->_vala3__node_it = _data_->_vala3__node_it->next) {
					_data_->_vala3__node = (JsonNode*) _data_->_vala3__node_it->data;
					{
						_data_->_tmp182_ = _data_->_vala3__node;
						services_todoist_process_item_node (_data_->self, _data_->_tmp182_);
					}
				}
				(_data_->_vala3__node_collection == NULL) ? NULL : (_data_->_vala3__node_collection = (g_list_free (_data_->_vala3__node_collection), NULL));
			}
			_data_->_tmp183_ = _data_->parser;
			_data_->_tmp184_ = json_parser_get_root (_data_->_tmp183_);
			_data_->_tmp185_ = json_node_get_object (_data_->_tmp184_);
			_data_->_tmp186_ = json_object_get_array_member (_data_->_tmp185_, SERVICES_TODOIST_REMINDERS_COLLECTION);
			_data_->reminders = _data_->_tmp186_;
			_data_->_tmp187_ = _data_->reminders;
			_data_->_tmp188_ = json_array_get_elements (_data_->_tmp187_);
			{
				_data_->_vala4__node_collection = _data_->_tmp188_;
				for (_data_->_vala4__node_it = _data_->_vala4__node_collection; _data_->_vala4__node_it != NULL; _data_->_vala4__node_it = _data_->_vala4__node_it->next) {
					_data_->_vala4__node = (JsonNode*) _data_->_vala4__node_it->data;
					{
						_data_->_tmp189_ = services_store_instance ();
						_data_->_tmp190_ = _data_->_vala4__node;
						_data_->_tmp191_ = json_node_get_object (_data_->_tmp190_);
						_data_->_tmp192_ = json_object_get_string_member (_data_->_tmp191_, "id");
						_data_->_tmp193_ = services_store_get_reminder (_data_->_tmp189_, _data_->_tmp192_);
						_data_->reminder = _data_->_tmp193_;
						_data_->_tmp194_ = _data_->reminder;
						if (_data_->_tmp194_ != NULL) {
							_data_->_tmp195_ = _data_->_vala4__node;
							_data_->_tmp196_ = json_node_get_object (_data_->_tmp195_);
							if (json_object_get_boolean_member (_data_->_tmp196_, "is_deleted")) {
								_data_->_tmp197_ = services_store_instance ();
								_data_->_tmp198_ = _data_->reminder;
								services_store_delete_reminder (_data_->_tmp197_, _data_->_tmp198_);
							}
						} else {
							_data_->_tmp199_ = _data_->_vala4__node;
							_data_->_tmp200_ = objects_reminder_new_from_json (_data_->_tmp199_);
							_g_object_unref0 (_data_->reminder);
							_data_->reminder = _data_->_tmp200_;
							_data_->_tmp201_ = services_store_instance ();
							_data_->_tmp202_ = _data_->reminder;
							_data_->_tmp203_ = objects_reminder_get_item_id (_data_->_tmp202_);
							_data_->_tmp204_ = _data_->_tmp203_;
							_data_->_tmp205_ = services_store_get_item (_data_->_tmp201_, _data_->_tmp204_);
							_data_->item = _data_->_tmp205_;
							_data_->_tmp206_ = _data_->item;
							if (_data_->_tmp206_ != NULL) {
								_data_->_tmp207_ = _data_->item;
								_data_->_tmp208_ = _data_->reminder;
								_data_->_tmp209_ = objects_item_add_reminder_if_not_exists (_data_->_tmp207_, _data_->_tmp208_, TRUE);
								_data_->_tmp210_ = _data_->_tmp209_;
								_g_object_unref0 (_data_->_tmp210_);
							}
							_g_object_unref0 (_data_->item);
						}
						_g_object_unref0 (_data_->reminder);
					}
				}
				(_data_->_vala4__node_collection == NULL) ? NULL : (_data_->_vala4__node_collection = (g_list_free (_data_->_vala4__node_collection), NULL));
			}
			_data_->_state_ = 2;
			services_todoist_queue (_data_->self, _data_->source, services_todoist_sync_ready, _data_);
			return FALSE;
			_state_2:
			services_todoist_queue_finish (_data_->self, _data_->_res_);
		}
		_g_object_unref0 (_data_->parser);
		_g_bytes_unref0 (_data_->stream);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp211_ = services_log_service_get_default ();
		_data_->_tmp212_ = _data_->_tmp211_;
		_data_->_tmp213_ = _data_->e;
		_data_->_tmp214_ = _data_->_tmp213_->message;
		_data_->_tmp215_ = g_strdup_printf ("Failed to sync: %s", _data_->_tmp214_);
		_data_->_tmp216_ = _data_->_tmp215_;
		services_log_service_error (_data_->_tmp212_, "Todoist", _data_->_tmp216_);
		_g_free0 (_data_->_tmp216_);
		_g_object_unref0 (_data_->_tmp212_);
		g_signal_emit_by_name (_data_->source, "sync-failed", NULL);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_free0 (_data_->form_data);
		_g_object_unref0 (_data_->message);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp217_ = g_date_time_new_now_local ();
	_data_->_tmp218_ = _data_->_tmp217_;
	_data_->_tmp219_ = g_date_time_to_string (_data_->_tmp218_);
	_data_->_tmp220_ = _data_->_tmp219_;
	objects_source_set_last_sync (_data_->source, _data_->_tmp220_);
	_g_free0 (_data_->_tmp220_);
	_g_date_time_unref0 (_data_->_tmp218_);
	{
		_data_->_tmp221_ = services_store_instance ();
		_data_->_tmp222_ = objects_base_object_get_id ((ObjectsBaseObject*) _data_->source);
		_data_->_tmp223_ = _data_->_tmp222_;
		_data_->_tmp224_ = services_store_get_projects_by_source (_data_->_tmp221_, _data_->_tmp223_);
		_data_->_vala1__project_list = _data_->_tmp224_;
		_data_->_tmp225_ = _data_->_vala1__project_list;
		_data_->_tmp226_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp225_);
		_data_->_tmp227_ = _data_->_tmp226_;
		_data_->_vala1__project_size = _data_->_tmp227_;
		_data_->_vala1__project_index = -1;
		while (TRUE) {
			_data_->_vala1__project_index = _data_->_vala1__project_index + 1;
			_data_->_tmp228_ = _data_->_vala1__project_index;
			_data_->_tmp229_ = _data_->_vala1__project_size;
			if (!(_data_->_tmp228_ < _data_->_tmp229_)) {
				break;
			}
			_data_->_tmp230_ = _data_->_vala1__project_list;
			_data_->_tmp231_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp230_, _data_->_vala1__project_index);
			_data_->_vala2_project = (ObjectsProject*) _data_->_tmp231_;
			_data_->_tmp232_ = _data_->_vala2_project;
			objects_project_set_freeze_update (_data_->_tmp232_, FALSE);
			_data_->_tmp233_ = _data_->_vala2_project;
			objects_base_object_count_update ((ObjectsBaseObject*) _data_->_tmp233_);
			_data_->_tmp234_ = services_store_instance ();
			_data_->_tmp235_ = _data_->_vala2_project;
			services_store_update_project (_data_->_tmp234_, _data_->_tmp235_);
			_g_object_unref0 (_data_->_vala2_project);
		}
		_g_object_unref0 (_data_->_vala1__project_list);
	}
	g_signal_emit_by_name (_data_->source, "sync-finished");
	_g_free0 (_data_->form_data);
	_g_object_unref0 (_data_->message);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_queue_data_free (gpointer _data)
{
	ServicesTodoistQueueData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistQueueData, _data_);
}

void
services_todoist_queue (ServicesTodoist* self,
                        ObjectsSource* source,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_)
{
	ServicesTodoistQueueData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsSource* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (source != NULL);
	_data_ = g_slice_new0 (ServicesTodoistQueueData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_queue_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (_data_->source);
	_data_->source = _tmp1_;
	services_todoist_queue_co (_data_);
}

void
services_todoist_queue_finish (ServicesTodoist* self,
                               GAsyncResult* _res_)
{
	ServicesTodoistQueueData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
services_todoist_queue_ready (GObject* source_object,
                              GAsyncResult* _res_,
                              gpointer _user_data_)
{
	ServicesTodoistQueueData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_queue_co (_data_);
}

static JsonNode*
_vala_JsonNode_copy (JsonNode* self)
{
	return g_boxed_copy (json_node_get_type (), self);
}

static gpointer
__vala_JsonNode_copy0 (gpointer self)
{
	return self ? _vala_JsonNode_copy (self) : NULL;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gboolean
services_todoist_queue_co (ServicesTodoistQueueData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->_queue_running) {
		_data_->_tmp0_ = services_log_service_get_default ();
		_data_->_tmp1_ = _data_->_tmp0_;
		services_log_service_debug (_data_->_tmp1_, "Todoist", "Queue already running, skipping");
		_g_object_unref0 (_data_->_tmp1_);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->_queue_running = TRUE;
	_data_->_tmp2_ = services_database_get_default ();
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = objects_base_object_get_id ((ObjectsBaseObject*) _data_->source);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = services_database_get_all_queue (_data_->_tmp3_, _data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_g_object_unref0 (_data_->_tmp3_);
	_data_->queue_collection = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->queue_collection;
	_data_->_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	if (_data_->_tmp10_ <= 0) {
		_data_->self->priv->_queue_running = FALSE;
		_g_object_unref0 (_data_->queue_collection);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp11_ = _data_->queue_collection;
	_data_->_tmp12_ = objects_source_get_todoist_data (_data_->source);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = objects_source_todoist_data_get_sync_token (_data_->_tmp13_);
	_data_->_tmp15_ = _data_->_tmp14_;
	_data_->_tmp16_ = services_todoist_get_queue_json (_data_->self, _data_->_tmp11_, _data_->_tmp15_);
	_data_->json = _data_->_tmp16_;
	_data_->_tmp17_ = services_log_service_get_default ();
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = _data_->queue_collection;
	_data_->_tmp20_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp19_);
	_data_->_tmp21_ = _data_->_tmp20_;
	_data_->_tmp22_ = g_strdup_printf ("Flushing queue: %d items", _data_->_tmp21_);
	_data_->_tmp23_ = _data_->_tmp22_;
	services_log_service_info (_data_->_tmp18_, "Todoist", _data_->_tmp23_);
	_g_free0 (_data_->_tmp23_);
	_g_object_unref0 (_data_->_tmp18_);
	_data_->_tmp24_ = services_log_service_get_default ();
	_data_->_tmp25_ = _data_->_tmp24_;
	_data_->_tmp26_ = _data_->json;
	_data_->_tmp27_ = g_strdup_printf ("Queue JSON: %s", _data_->_tmp26_);
	_data_->_tmp28_ = _data_->_tmp27_;
	services_log_service_debug (_data_->_tmp25_, "Todoist", _data_->_tmp28_);
	_g_free0 (_data_->_tmp28_);
	_g_object_unref0 (_data_->_tmp25_);
	_data_->_tmp29_ = soup_message_new ("POST", SERVICES_TODOIST_TODOIST_SYNC_URL);
	_data_->message = _data_->_tmp29_;
	_data_->_tmp30_ = _data_->message;
	_data_->_tmp31_ = soup_message_get_request_headers (_data_->_tmp30_);
	_data_->_tmp32_ = _data_->_tmp31_;
	_data_->_tmp33_ = objects_source_get_todoist_data (_data_->source);
	_data_->_tmp34_ = _data_->_tmp33_;
	_data_->_tmp35_ = objects_source_todoist_data_get_access_token (_data_->_tmp34_);
	_data_->_tmp36_ = _data_->_tmp35_;
	_data_->_tmp37_ = g_strdup_printf ("Bearer %s", _data_->_tmp36_);
	_data_->_tmp38_ = _data_->_tmp37_;
	soup_message_headers_append (_data_->_tmp32_, "Authorization", _data_->_tmp38_);
	_g_free0 (_data_->_tmp38_);
	_data_->_tmp39_ = _data_->message;
	_data_->_tmp40_ = _data_->json;
	_data_->_tmp42_ = 0;
	_data_->_tmp41_ = string_get_data (_data_->_tmp40_, &_data_->_tmp42_);
	_data_->_tmp41__length1 = _data_->_tmp42_;
	_data_->_tmp43_ = _data_->_tmp41_;
	_data_->_tmp43__length1 = _data_->_tmp41__length1;
	_data_->_tmp44_ = g_bytes_new (_data_->_tmp43_, _data_->_tmp43__length1);
	_data_->_tmp45_ = _data_->_tmp44_;
	soup_message_set_request_body_from_bytes (_data_->_tmp39_, "application/json", _data_->_tmp45_);
	_g_bytes_unref0 (_data_->_tmp45_);
	{
		_data_->_tmp46_ = _data_->self->priv->session;
		_data_->_tmp47_ = _data_->message;
		_data_->_state_ = 1;
		soup_session_send_and_read_async (_data_->_tmp46_, _data_->_tmp47_, G_PRIORITY_LOW, NULL, services_todoist_queue_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp48_ = soup_session_send_and_read_finish (_data_->_tmp46_, _data_->_res_, &_data_->_inner_error0_);
		_data_->stream = _data_->_tmp48_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp49_ = json_parser_new ();
		_data_->parser = _data_->_tmp49_;
		_data_->_tmp50_ = _data_->parser;
		_data_->_tmp51_ = _data_->stream;
		_data_->_tmp52_ = 0;
		_data_->_tmp53_ = g_bytes_get_data (_data_->_tmp51_, &_data_->_tmp52_);
		json_parser_load_from_data (_data_->_tmp50_, (const gchar*) _data_->_tmp53_, (gssize) -1, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->parser);
			_g_bytes_unref0 (_data_->stream);
			goto __catch0_g_error;
		}
		_data_->_tmp54_ = _data_->parser;
		_data_->_tmp55_ = json_parser_get_root (_data_->_tmp54_);
		_data_->_tmp56_ = json_node_get_object (_data_->_tmp55_);
		_data_->_tmp57_ = _json_object_ref0 (_data_->_tmp56_);
		_data_->node = _data_->_tmp57_;
		_data_->_tmp58_ = objects_source_get_todoist_data (_data_->source);
		_data_->_tmp59_ = _data_->_tmp58_;
		_data_->_tmp60_ = _data_->node;
		_data_->_tmp61_ = json_object_get_string_member (_data_->_tmp60_, "sync_token");
		objects_source_todoist_data_set_sync_token (_data_->_tmp59_, _data_->_tmp61_);
		{
			_data_->_tmp62_ = _data_->queue_collection;
			_data_->_q_list = _data_->_tmp62_;
			_data_->_tmp63_ = _data_->_q_list;
			_data_->_tmp64_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp63_);
			_data_->_tmp65_ = _data_->_tmp64_;
			_data_->_q_size = _data_->_tmp65_;
			_data_->_q_index = -1;
			while (TRUE) {
				_data_->_q_index = _data_->_q_index + 1;
				_data_->_tmp66_ = _data_->_q_index;
				_data_->_tmp67_ = _data_->_q_size;
				if (!(_data_->_tmp66_ < _data_->_tmp67_)) {
					break;
				}
				_data_->_tmp68_ = _data_->_q_list;
				_data_->_tmp69_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp68_, _data_->_q_index);
				_data_->q = (ObjectsQueue*) _data_->_tmp69_;
				_data_->_tmp70_ = _data_->node;
				_data_->_tmp71_ = json_object_get_object_member (_data_->_tmp70_, "sync_status");
				_data_->_tmp72_ = _data_->q;
				_data_->_tmp73_ = objects_queue_get_uuid (_data_->_tmp72_);
				_data_->_tmp74_ = _data_->_tmp73_;
				_data_->_tmp75_ = json_object_get_member (_data_->_tmp71_, _data_->_tmp74_);
				_data_->_tmp76_ = __vala_JsonNode_copy0 (_data_->_tmp75_);
				_data_->uuid_member = _data_->_tmp76_;
				_data_->_tmp77_ = services_log_service_get_default ();
				_data_->_tmp78_ = _data_->_tmp77_;
				_data_->_tmp79_ = _data_->q;
				_data_->_tmp80_ = objects_queue_get_query (_data_->_tmp79_);
				_data_->_tmp81_ = _data_->_tmp80_;
				_data_->_tmp82_ = _data_->q;
				_data_->_tmp83_ = objects_queue_get_uuid (_data_->_tmp82_);
				_data_->_tmp84_ = _data_->_tmp83_;
				_data_->_tmp85_ = _data_->q;
				_data_->_tmp86_ = objects_queue_get_object_id (_data_->_tmp85_);
				_data_->_tmp87_ = _data_->_tmp86_;
				_data_->_tmp88_ = g_strdup_printf ("Processing queue item — query: %s, uuid: %s, object_id: %s", _data_->_tmp81_, _data_->_tmp84_, _data_->_tmp87_);
				_data_->_tmp89_ = _data_->_tmp88_;
				services_log_service_debug (_data_->_tmp78_, "Todoist", _data_->_tmp89_);
				_g_free0 (_data_->_tmp89_);
				_g_object_unref0 (_data_->_tmp78_);
				_data_->_tmp90_ = _data_->uuid_member;
				if (json_node_get_node_type (_data_->_tmp90_) == JSON_NODE_VALUE) {
					_data_->_tmp91_ = _data_->node;
					_data_->_tmp92_ = json_object_get_object_member (_data_->_tmp91_, "temp_id_mapping");
					_data_->_tmp93_ = _json_object_ref0 (_data_->_tmp92_);
					_data_->temp_id_mapping = _data_->_tmp93_;
					_data_->success = TRUE;
					_data_->_tmp94_ = _data_->q;
					_data_->_tmp95_ = objects_queue_get_query (_data_->_tmp94_);
					_data_->_tmp96_ = _data_->_tmp95_;
					if (g_strcmp0 (_data_->_tmp96_, "project_add") == 0) {
						_data_->_tmp97_ = _data_->temp_id_mapping;
						_data_->_tmp98_ = _data_->q;
						_data_->_tmp99_ = objects_queue_get_temp_id (_data_->_tmp98_);
						_data_->_tmp100_ = _data_->_tmp99_;
						if (json_object_has_member (_data_->_tmp97_, _data_->_tmp100_)) {
							_data_->_tmp101_ = _data_->temp_id_mapping;
							_data_->_tmp102_ = _data_->q;
							_data_->_tmp103_ = objects_queue_get_temp_id (_data_->_tmp102_);
							_data_->_tmp104_ = _data_->_tmp103_;
							_data_->_tmp105_ = json_object_get_string_member (_data_->_tmp101_, _data_->_tmp104_);
							_data_->_tmp106_ = g_strdup (_data_->_tmp105_);
							_data_->id = _data_->_tmp106_;
							_data_->_tmp107_ = services_store_instance ();
							_data_->_tmp108_ = _data_->q;
							_data_->_tmp109_ = objects_queue_get_object_id (_data_->_tmp108_);
							_data_->_tmp110_ = _data_->_tmp109_;
							_data_->_tmp111_ = _data_->id;
							services_store_update_project_id (_data_->_tmp107_, _data_->_tmp110_, _data_->_tmp111_);
							_data_->_tmp112_ = services_database_get_default ();
							_data_->_tmp113_ = _data_->_tmp112_;
							_data_->_tmp114_ = _data_->q;
							_data_->_tmp115_ = objects_queue_get_object_id (_data_->_tmp114_);
							_data_->_tmp116_ = _data_->_tmp115_;
							services_database_remove_CurTempIds (_data_->_tmp113_, _data_->_tmp116_);
							_g_object_unref0 (_data_->_tmp113_);
							_g_free0 (_data_->id);
						} else {
							_data_->_tmp117_ = services_log_service_get_default ();
							_data_->_tmp118_ = _data_->_tmp117_;
							_data_->_tmp119_ = _data_->q;
							_data_->_tmp120_ = objects_queue_get_temp_id (_data_->_tmp119_);
							_data_->_tmp121_ = _data_->_tmp120_;
							_data_->_tmp122_ = g_strdup_printf ("temp_id_mapping missing for project_add: %s", _data_->_tmp121_);
							_data_->_tmp123_ = _data_->_tmp122_;
							services_log_service_warn (_data_->_tmp118_, "Todoist", _data_->_tmp123_);
							_g_free0 (_data_->_tmp123_);
							_g_object_unref0 (_data_->_tmp118_);
							_data_->success = FALSE;
						}
					}
					_data_->_tmp124_ = _data_->q;
					_data_->_tmp125_ = objects_queue_get_query (_data_->_tmp124_);
					_data_->_tmp126_ = _data_->_tmp125_;
					if (g_strcmp0 (_data_->_tmp126_, "section_add") == 0) {
						_data_->_tmp127_ = _data_->temp_id_mapping;
						_data_->_tmp128_ = _data_->q;
						_data_->_tmp129_ = objects_queue_get_temp_id (_data_->_tmp128_);
						_data_->_tmp130_ = _data_->_tmp129_;
						if (json_object_has_member (_data_->_tmp127_, _data_->_tmp130_)) {
							_data_->_tmp131_ = _data_->temp_id_mapping;
							_data_->_tmp132_ = _data_->q;
							_data_->_tmp133_ = objects_queue_get_temp_id (_data_->_tmp132_);
							_data_->_tmp134_ = _data_->_tmp133_;
							_data_->_tmp135_ = json_object_get_string_member (_data_->_tmp131_, _data_->_tmp134_);
							_data_->_tmp136_ = g_strdup (_data_->_tmp135_);
							_data_->_vala1_id = _data_->_tmp136_;
							_data_->_tmp137_ = services_store_instance ();
							_data_->_tmp138_ = _data_->q;
							_data_->_tmp139_ = objects_queue_get_object_id (_data_->_tmp138_);
							_data_->_tmp140_ = _data_->_tmp139_;
							_data_->_tmp141_ = _data_->_vala1_id;
							services_store_update_section_id (_data_->_tmp137_, _data_->_tmp140_, _data_->_tmp141_);
							_data_->_tmp142_ = services_database_get_default ();
							_data_->_tmp143_ = _data_->_tmp142_;
							_data_->_tmp144_ = _data_->q;
							_data_->_tmp145_ = objects_queue_get_object_id (_data_->_tmp144_);
							_data_->_tmp146_ = _data_->_tmp145_;
							services_database_remove_CurTempIds (_data_->_tmp143_, _data_->_tmp146_);
							_g_object_unref0 (_data_->_tmp143_);
							_g_free0 (_data_->_vala1_id);
						} else {
							_data_->_tmp147_ = services_log_service_get_default ();
							_data_->_tmp148_ = _data_->_tmp147_;
							_data_->_tmp149_ = _data_->q;
							_data_->_tmp150_ = objects_queue_get_temp_id (_data_->_tmp149_);
							_data_->_tmp151_ = _data_->_tmp150_;
							_data_->_tmp152_ = g_strdup_printf ("temp_id_mapping missing for section_add: %s", _data_->_tmp151_);
							_data_->_tmp153_ = _data_->_tmp152_;
							services_log_service_warn (_data_->_tmp148_, "Todoist", _data_->_tmp153_);
							_g_free0 (_data_->_tmp153_);
							_g_object_unref0 (_data_->_tmp148_);
							_data_->success = FALSE;
						}
					}
					_data_->_tmp154_ = _data_->q;
					_data_->_tmp155_ = objects_queue_get_query (_data_->_tmp154_);
					_data_->_tmp156_ = _data_->_tmp155_;
					if (g_strcmp0 (_data_->_tmp156_, "item_add") == 0) {
						_data_->_tmp157_ = _data_->temp_id_mapping;
						_data_->_tmp158_ = _data_->q;
						_data_->_tmp159_ = objects_queue_get_temp_id (_data_->_tmp158_);
						_data_->_tmp160_ = _data_->_tmp159_;
						if (json_object_has_member (_data_->_tmp157_, _data_->_tmp160_)) {
							_data_->_tmp161_ = _data_->temp_id_mapping;
							_data_->_tmp162_ = _data_->q;
							_data_->_tmp163_ = objects_queue_get_temp_id (_data_->_tmp162_);
							_data_->_tmp164_ = _data_->_tmp163_;
							_data_->_tmp165_ = json_object_get_string_member (_data_->_tmp161_, _data_->_tmp164_);
							_data_->_tmp166_ = g_strdup (_data_->_tmp165_);
							_data_->_vala2_id = _data_->_tmp166_;
							_data_->_tmp167_ = services_store_instance ();
							_data_->_tmp168_ = _data_->q;
							_data_->_tmp169_ = objects_queue_get_object_id (_data_->_tmp168_);
							_data_->_tmp170_ = _data_->_tmp169_;
							_data_->_tmp171_ = _data_->_vala2_id;
							services_store_update_item_id (_data_->_tmp167_, _data_->_tmp170_, _data_->_tmp171_);
							_data_->_tmp172_ = services_database_get_default ();
							_data_->_tmp173_ = _data_->_tmp172_;
							_data_->_tmp174_ = _data_->q;
							_data_->_tmp175_ = objects_queue_get_object_id (_data_->_tmp174_);
							_data_->_tmp176_ = _data_->_tmp175_;
							services_database_remove_CurTempIds (_data_->_tmp173_, _data_->_tmp176_);
							_g_object_unref0 (_data_->_tmp173_);
							_g_free0 (_data_->_vala2_id);
						} else {
							_data_->_tmp177_ = services_log_service_get_default ();
							_data_->_tmp178_ = _data_->_tmp177_;
							_data_->_tmp179_ = _data_->q;
							_data_->_tmp180_ = objects_queue_get_temp_id (_data_->_tmp179_);
							_data_->_tmp181_ = _data_->_tmp180_;
							_data_->_tmp182_ = g_strdup_printf ("temp_id_mapping missing for item_add: %s", _data_->_tmp181_);
							_data_->_tmp183_ = _data_->_tmp182_;
							services_log_service_warn (_data_->_tmp178_, "Todoist", _data_->_tmp183_);
							_g_free0 (_data_->_tmp183_);
							_g_object_unref0 (_data_->_tmp178_);
							_data_->success = FALSE;
						}
					}
					if (_data_->success) {
						_data_->_tmp184_ = services_database_get_default ();
						_data_->_tmp185_ = _data_->_tmp184_;
						_data_->_tmp186_ = _data_->q;
						_data_->_tmp187_ = objects_queue_get_uuid (_data_->_tmp186_);
						_data_->_tmp188_ = _data_->_tmp187_;
						services_database_remove_queue (_data_->_tmp185_, _data_->_tmp188_);
						_g_object_unref0 (_data_->_tmp185_);
					}
					_json_object_unref0 (_data_->temp_id_mapping);
				} else {
					_data_->_tmp189_ = _data_->node;
					_data_->_tmp190_ = json_object_get_object_member (_data_->_tmp189_, "sync_status");
					_data_->_tmp191_ = _json_object_ref0 (_data_->_tmp190_);
					_data_->sync_status = _data_->_tmp191_;
					_data_->_tmp192_ = _data_->sync_status;
					_data_->_tmp193_ = _data_->q;
					_data_->_tmp194_ = objects_queue_get_uuid (_data_->_tmp193_);
					_data_->_tmp195_ = _data_->_tmp194_;
					if (json_object_has_member (_data_->_tmp192_, _data_->_tmp195_)) {
						_data_->_tmp196_ = _data_->sync_status;
						_data_->_tmp197_ = _data_->q;
						_data_->_tmp198_ = objects_queue_get_uuid (_data_->_tmp197_);
						_data_->_tmp199_ = _data_->_tmp198_;
						_data_->_tmp200_ = json_object_get_object_member (_data_->_tmp196_, _data_->_tmp199_);
						_data_->_tmp201_ = _json_object_ref0 (_data_->_tmp200_);
						_data_->error_obj = _data_->_tmp201_;
						_data_->_tmp202_ = services_log_service_get_default ();
						_data_->_tmp203_ = _data_->_tmp202_;
						_data_->_tmp204_ = _data_->q;
						_data_->_tmp205_ = objects_queue_get_query (_data_->_tmp204_);
						_data_->_tmp206_ = _data_->_tmp205_;
						_data_->_tmp207_ = _data_->error_obj;
						_data_->_tmp208_ = json_object_get_string_member (_data_->_tmp207_, "error");
						_data_->_tmp209_ = g_strdup_printf ("Queue item failed — query: %s, error: %s", _data_->_tmp206_, _data_->_tmp208_);
						_data_->_tmp210_ = _data_->_tmp209_;
						services_log_service_warn (_data_->_tmp203_, "Todoist", _data_->_tmp210_);
						_g_free0 (_data_->_tmp210_);
						_g_object_unref0 (_data_->_tmp203_);
						_json_object_unref0 (_data_->error_obj);
					}
					_data_->_tmp211_ = services_database_get_default ();
					_data_->_tmp212_ = _data_->_tmp211_;
					_data_->_tmp213_ = _data_->q;
					_data_->_tmp214_ = objects_queue_get_uuid (_data_->_tmp213_);
					_data_->_tmp215_ = _data_->_tmp214_;
					services_database_remove_queue (_data_->_tmp212_, _data_->_tmp215_);
					_g_object_unref0 (_data_->_tmp212_);
					_json_object_unref0 (_data_->sync_status);
				}
				__vala_JsonNode_free0 (_data_->uuid_member);
				_g_object_unref0 (_data_->q);
			}
		}
		_data_->_tmp216_ = _data_->node;
		if (json_object_has_member (_data_->_tmp216_, "items")) {
			_data_->_tmp217_ = _data_->node;
			_data_->_tmp218_ = json_object_get_array_member (_data_->_tmp217_, "items");
			_data_->_tmp219_ = json_array_get_elements (_data_->_tmp218_);
			{
				_data_->_node_collection = _data_->_tmp219_;
				for (_data_->_node_it = _data_->_node_collection; _data_->_node_it != NULL; _data_->_node_it = _data_->_node_it->next) {
					_data_->_node = (JsonNode*) _data_->_node_it->data;
					{
						_data_->_tmp220_ = _data_->_node;
						services_todoist_process_item_node (_data_->self, _data_->_tmp220_);
					}
				}
				(_data_->_node_collection == NULL) ? NULL : (_data_->_node_collection = (g_list_free (_data_->_node_collection), NULL));
			}
		}
		_json_object_unref0 (_data_->node);
		_g_object_unref0 (_data_->parser);
		_g_bytes_unref0 (_data_->stream);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp221_ = _data_->e;
		_data_->_tmp222_ = _data_->_tmp221_->message;
		g_debug ("Todoist.vala:342: %s", _data_->_tmp222_);
		_g_error_free0 (_data_->e);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->message);
		_g_free0 (_data_->json);
		_g_object_unref0 (_data_->queue_collection);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->_queue_running = FALSE;
	_g_object_unref0 (_data_->message);
	_g_free0 (_data_->json);
	_g_object_unref0 (_data_->queue_collection);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gchar*
services_todoist_resolve_id (ServicesTodoist* self,
                             const gchar* id)
{
	ServicesDatabase* _tmp0_;
	ServicesDatabase* _tmp1_;
	gboolean _tmp2_;
	gchar* _tmp7_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	_tmp0_ = services_database_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = services_database_curTempIds_exists (_tmp1_, id);
	_g_object_unref0 (_tmp1_);
	if (_tmp2_) {
		ServicesDatabase* _tmp3_;
		ServicesDatabase* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp3_ = services_database_get_default ();
		_tmp4_ = _tmp3_;
		_tmp5_ = services_database_get_temp_id (_tmp4_, id);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		result = _tmp6_;
		return result;
	}
	_tmp7_ = g_strdup (id);
	result = _tmp7_;
	return result;
}

static void
services_todoist_begin_command (ServicesTodoist* self,
                                JsonBuilder* builder,
                                const gchar* type,
                                const gchar* uuid,
                                const gchar* temp_id)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (builder != NULL);
	g_return_if_fail (type != NULL);
	g_return_if_fail (uuid != NULL);
	json_builder_begin_object (builder);
	json_builder_set_member_name (builder, "type");
	json_builder_add_string_value (builder, type);
	json_builder_set_member_name (builder, "uuid");
	json_builder_add_string_value (builder, uuid);
	if (temp_id != NULL) {
		json_builder_set_member_name (builder, "temp_id");
		json_builder_add_string_value (builder, temp_id);
	}
	json_builder_set_member_name (builder, "args");
	json_builder_begin_object (builder);
}

static void
services_todoist_end_command (ServicesTodoist* self,
                              JsonBuilder* builder)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (builder != NULL);
	json_builder_end_object (builder);
	json_builder_end_object (builder);
}

gchar*
services_todoist_get_queue_json (ServicesTodoist* self,
                                 GeeArrayList* queue,
                                 const gchar* sync_token)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	JsonBuilder* _tmp2_;
	JsonBuilder* _tmp3_;
	JsonBuilder* _tmp4_;
	JsonBuilder* _tmp5_;
	JsonBuilder* _tmp6_;
	JsonBuilder* _tmp7_;
	JsonBuilder* _tmp8_;
	JsonBuilder* _tmp9_;
	JsonBuilder* _tmp413_;
	JsonBuilder* _tmp414_;
	JsonGenerator* generator = NULL;
	JsonGenerator* _tmp415_;
	JsonBuilder* _tmp416_;
	JsonNode* _tmp417_;
	JsonNode* _tmp418_;
	gchar* _tmp419_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (queue != NULL, NULL);
	g_return_val_if_fail (sync_token != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	_tmp1_ = builder;
	json_builder_begin_object (_tmp1_);
	_tmp2_ = builder;
	json_builder_set_member_name (_tmp2_, "sync_token");
	_tmp3_ = builder;
	json_builder_add_string_value (_tmp3_, sync_token);
	_tmp4_ = builder;
	json_builder_set_member_name (_tmp4_, "resource_types");
	_tmp5_ = builder;
	json_builder_begin_array (_tmp5_);
	_tmp6_ = builder;
	json_builder_add_string_value (_tmp6_, "items");
	_tmp7_ = builder;
	json_builder_end_array (_tmp7_);
	_tmp8_ = builder;
	json_builder_set_member_name (_tmp8_, "commands");
	_tmp9_ = builder;
	json_builder_begin_array (_tmp9_);
	{
		GeeArrayList* _q_list = NULL;
		gint _q_size = 0;
		GeeArrayList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		gint _q_index = 0;
		_q_list = queue;
		_tmp10_ = _q_list;
		_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_q_size = _tmp12_;
		_q_index = -1;
		while (TRUE) {
			gint _tmp13_;
			gint _tmp14_;
			ObjectsQueue* q = NULL;
			GeeArrayList* _tmp15_;
			gpointer _tmp16_;
			ObjectsQueue* _tmp17_;
			const gchar* _tmp18_;
			const gchar* _tmp19_;
			_q_index = _q_index + 1;
			_tmp13_ = _q_index;
			_tmp14_ = _q_size;
			if (!(_tmp13_ < _tmp14_)) {
				break;
			}
			_tmp15_ = _q_list;
			_tmp16_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, _q_index);
			q = (ObjectsQueue*) _tmp16_;
			_tmp17_ = q;
			_tmp18_ = objects_queue_get_query (_tmp17_);
			_tmp19_ = _tmp18_;
			if (g_strcmp0 (_tmp19_, "project_add") == 0) {
				JsonBuilder* _tmp20_;
				ObjectsQueue* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				ObjectsQueue* _tmp24_;
				const gchar* _tmp25_;
				const gchar* _tmp26_;
				JsonBuilder* _tmp27_;
				JsonBuilder* _tmp28_;
				ObjectsQueue* _tmp29_;
				const gchar* _tmp30_;
				const gchar* _tmp31_;
				gchar* _tmp32_;
				gchar* _tmp33_;
				JsonBuilder* _tmp34_;
				JsonBuilder* _tmp35_;
				ObjectsQueue* _tmp36_;
				const gchar* _tmp37_;
				const gchar* _tmp38_;
				gchar* _tmp39_;
				gchar* _tmp40_;
				JsonBuilder* _tmp41_;
				_tmp20_ = builder;
				_tmp21_ = q;
				_tmp22_ = objects_queue_get_uuid (_tmp21_);
				_tmp23_ = _tmp22_;
				_tmp24_ = q;
				_tmp25_ = objects_queue_get_temp_id (_tmp24_);
				_tmp26_ = _tmp25_;
				services_todoist_begin_command (self, _tmp20_, "project_add", _tmp23_, _tmp26_);
				_tmp27_ = builder;
				json_builder_set_member_name (_tmp27_, "name");
				_tmp28_ = builder;
				_tmp29_ = q;
				_tmp30_ = objects_queue_get_args (_tmp29_);
				_tmp31_ = _tmp30_;
				_tmp32_ = utils_json_utils_get_string (_tmp31_, "name");
				_tmp33_ = _tmp32_;
				json_builder_add_string_value (_tmp28_, _tmp33_);
				_g_free0 (_tmp33_);
				_tmp34_ = builder;
				json_builder_set_member_name (_tmp34_, "color");
				_tmp35_ = builder;
				_tmp36_ = q;
				_tmp37_ = objects_queue_get_args (_tmp36_);
				_tmp38_ = _tmp37_;
				_tmp39_ = utils_json_utils_get_string (_tmp38_, "color");
				_tmp40_ = _tmp39_;
				json_builder_add_string_value (_tmp35_, _tmp40_);
				_g_free0 (_tmp40_);
				_tmp41_ = builder;
				services_todoist_end_command (self, _tmp41_);
			} else {
				ObjectsQueue* _tmp42_;
				const gchar* _tmp43_;
				const gchar* _tmp44_;
				_tmp42_ = q;
				_tmp43_ = objects_queue_get_query (_tmp42_);
				_tmp44_ = _tmp43_;
				if (g_strcmp0 (_tmp44_, "project_update") == 0) {
					JsonBuilder* _tmp45_;
					ObjectsQueue* _tmp46_;
					const gchar* _tmp47_;
					const gchar* _tmp48_;
					JsonBuilder* _tmp49_;
					JsonBuilder* _tmp50_;
					ObjectsQueue* _tmp51_;
					const gchar* _tmp52_;
					const gchar* _tmp53_;
					gchar* _tmp54_;
					gchar* _tmp55_;
					JsonBuilder* _tmp56_;
					JsonBuilder* _tmp57_;
					ObjectsQueue* _tmp58_;
					const gchar* _tmp59_;
					const gchar* _tmp60_;
					gchar* _tmp61_;
					gchar* _tmp62_;
					JsonBuilder* _tmp63_;
					JsonBuilder* _tmp64_;
					ObjectsQueue* _tmp65_;
					const gchar* _tmp66_;
					const gchar* _tmp67_;
					gchar* _tmp68_;
					gchar* _tmp69_;
					JsonBuilder* _tmp70_;
					_tmp45_ = builder;
					_tmp46_ = q;
					_tmp47_ = objects_queue_get_uuid (_tmp46_);
					_tmp48_ = _tmp47_;
					services_todoist_begin_command (self, _tmp45_, "project_update", _tmp48_, NULL);
					_tmp49_ = builder;
					json_builder_set_member_name (_tmp49_, "id");
					_tmp50_ = builder;
					_tmp51_ = q;
					_tmp52_ = objects_queue_get_args (_tmp51_);
					_tmp53_ = _tmp52_;
					_tmp54_ = utils_json_utils_get_string (_tmp53_, "id");
					_tmp55_ = _tmp54_;
					json_builder_add_string_value (_tmp50_, _tmp55_);
					_g_free0 (_tmp55_);
					_tmp56_ = builder;
					json_builder_set_member_name (_tmp56_, "name");
					_tmp57_ = builder;
					_tmp58_ = q;
					_tmp59_ = objects_queue_get_args (_tmp58_);
					_tmp60_ = _tmp59_;
					_tmp61_ = utils_json_utils_get_string (_tmp60_, "name");
					_tmp62_ = _tmp61_;
					json_builder_add_string_value (_tmp57_, _tmp62_);
					_g_free0 (_tmp62_);
					_tmp63_ = builder;
					json_builder_set_member_name (_tmp63_, "color");
					_tmp64_ = builder;
					_tmp65_ = q;
					_tmp66_ = objects_queue_get_args (_tmp65_);
					_tmp67_ = _tmp66_;
					_tmp68_ = utils_json_utils_get_string (_tmp67_, "color");
					_tmp69_ = _tmp68_;
					json_builder_add_string_value (_tmp64_, _tmp69_);
					_g_free0 (_tmp69_);
					_tmp70_ = builder;
					services_todoist_end_command (self, _tmp70_);
				} else {
					ObjectsQueue* _tmp71_;
					const gchar* _tmp72_;
					const gchar* _tmp73_;
					_tmp71_ = q;
					_tmp72_ = objects_queue_get_query (_tmp71_);
					_tmp73_ = _tmp72_;
					if (g_strcmp0 (_tmp73_, "project_delete") == 0) {
						JsonBuilder* _tmp74_;
						ObjectsQueue* _tmp75_;
						const gchar* _tmp76_;
						const gchar* _tmp77_;
						JsonBuilder* _tmp78_;
						JsonBuilder* _tmp79_;
						ObjectsQueue* _tmp80_;
						const gchar* _tmp81_;
						const gchar* _tmp82_;
						gchar* _tmp83_;
						gchar* _tmp84_;
						JsonBuilder* _tmp85_;
						_tmp74_ = builder;
						_tmp75_ = q;
						_tmp76_ = objects_queue_get_uuid (_tmp75_);
						_tmp77_ = _tmp76_;
						services_todoist_begin_command (self, _tmp74_, "project_delete", _tmp77_, NULL);
						_tmp78_ = builder;
						json_builder_set_member_name (_tmp78_, "id");
						_tmp79_ = builder;
						_tmp80_ = q;
						_tmp81_ = objects_queue_get_args (_tmp80_);
						_tmp82_ = _tmp81_;
						_tmp83_ = utils_json_utils_get_string (_tmp82_, "id");
						_tmp84_ = _tmp83_;
						json_builder_add_string_value (_tmp79_, _tmp84_);
						_g_free0 (_tmp84_);
						_tmp85_ = builder;
						services_todoist_end_command (self, _tmp85_);
					} else {
						ObjectsQueue* _tmp86_;
						const gchar* _tmp87_;
						const gchar* _tmp88_;
						_tmp86_ = q;
						_tmp87_ = objects_queue_get_query (_tmp86_);
						_tmp88_ = _tmp87_;
						if (g_strcmp0 (_tmp88_, "section_add") == 0) {
							JsonBuilder* _tmp89_;
							ObjectsQueue* _tmp90_;
							const gchar* _tmp91_;
							const gchar* _tmp92_;
							ObjectsQueue* _tmp93_;
							const gchar* _tmp94_;
							const gchar* _tmp95_;
							JsonBuilder* _tmp96_;
							JsonBuilder* _tmp97_;
							ObjectsQueue* _tmp98_;
							const gchar* _tmp99_;
							const gchar* _tmp100_;
							gchar* _tmp101_;
							gchar* _tmp102_;
							JsonBuilder* _tmp103_;
							JsonBuilder* _tmp104_;
							ObjectsQueue* _tmp105_;
							const gchar* _tmp106_;
							const gchar* _tmp107_;
							gchar* _tmp108_;
							gchar* _tmp109_;
							gchar* _tmp110_;
							gchar* _tmp111_;
							JsonBuilder* _tmp112_;
							_tmp89_ = builder;
							_tmp90_ = q;
							_tmp91_ = objects_queue_get_uuid (_tmp90_);
							_tmp92_ = _tmp91_;
							_tmp93_ = q;
							_tmp94_ = objects_queue_get_temp_id (_tmp93_);
							_tmp95_ = _tmp94_;
							services_todoist_begin_command (self, _tmp89_, "section_add", _tmp92_, _tmp95_);
							_tmp96_ = builder;
							json_builder_set_member_name (_tmp96_, "name");
							_tmp97_ = builder;
							_tmp98_ = q;
							_tmp99_ = objects_queue_get_args (_tmp98_);
							_tmp100_ = _tmp99_;
							_tmp101_ = utils_json_utils_get_string (_tmp100_, "name");
							_tmp102_ = _tmp101_;
							json_builder_add_string_value (_tmp97_, _tmp102_);
							_g_free0 (_tmp102_);
							_tmp103_ = builder;
							json_builder_set_member_name (_tmp103_, "project_id");
							_tmp104_ = builder;
							_tmp105_ = q;
							_tmp106_ = objects_queue_get_args (_tmp105_);
							_tmp107_ = _tmp106_;
							_tmp108_ = utils_json_utils_get_string (_tmp107_, "project_id");
							_tmp109_ = _tmp108_;
							_tmp110_ = services_todoist_resolve_id (self, _tmp109_);
							_tmp111_ = _tmp110_;
							json_builder_add_string_value (_tmp104_, _tmp111_);
							_g_free0 (_tmp111_);
							_g_free0 (_tmp109_);
							_tmp112_ = builder;
							services_todoist_end_command (self, _tmp112_);
						} else {
							ObjectsQueue* _tmp113_;
							const gchar* _tmp114_;
							const gchar* _tmp115_;
							_tmp113_ = q;
							_tmp114_ = objects_queue_get_query (_tmp113_);
							_tmp115_ = _tmp114_;
							if (g_strcmp0 (_tmp115_, "section_update") == 0) {
								JsonBuilder* _tmp116_;
								ObjectsQueue* _tmp117_;
								const gchar* _tmp118_;
								const gchar* _tmp119_;
								JsonBuilder* _tmp120_;
								JsonBuilder* _tmp121_;
								ObjectsQueue* _tmp122_;
								const gchar* _tmp123_;
								const gchar* _tmp124_;
								gchar* _tmp125_;
								gchar* _tmp126_;
								JsonBuilder* _tmp127_;
								JsonBuilder* _tmp128_;
								ObjectsQueue* _tmp129_;
								const gchar* _tmp130_;
								const gchar* _tmp131_;
								gchar* _tmp132_;
								gchar* _tmp133_;
								JsonBuilder* _tmp134_;
								_tmp116_ = builder;
								_tmp117_ = q;
								_tmp118_ = objects_queue_get_uuid (_tmp117_);
								_tmp119_ = _tmp118_;
								services_todoist_begin_command (self, _tmp116_, "section_update", _tmp119_, NULL);
								_tmp120_ = builder;
								json_builder_set_member_name (_tmp120_, "id");
								_tmp121_ = builder;
								_tmp122_ = q;
								_tmp123_ = objects_queue_get_args (_tmp122_);
								_tmp124_ = _tmp123_;
								_tmp125_ = utils_json_utils_get_string (_tmp124_, "id");
								_tmp126_ = _tmp125_;
								json_builder_add_string_value (_tmp121_, _tmp126_);
								_g_free0 (_tmp126_);
								_tmp127_ = builder;
								json_builder_set_member_name (_tmp127_, "name");
								_tmp128_ = builder;
								_tmp129_ = q;
								_tmp130_ = objects_queue_get_args (_tmp129_);
								_tmp131_ = _tmp130_;
								_tmp132_ = utils_json_utils_get_string (_tmp131_, "name");
								_tmp133_ = _tmp132_;
								json_builder_add_string_value (_tmp128_, _tmp133_);
								_g_free0 (_tmp133_);
								_tmp134_ = builder;
								services_todoist_end_command (self, _tmp134_);
							} else {
								ObjectsQueue* _tmp135_;
								const gchar* _tmp136_;
								const gchar* _tmp137_;
								_tmp135_ = q;
								_tmp136_ = objects_queue_get_query (_tmp135_);
								_tmp137_ = _tmp136_;
								if (g_strcmp0 (_tmp137_, "section_delete") == 0) {
									JsonBuilder* _tmp138_;
									ObjectsQueue* _tmp139_;
									const gchar* _tmp140_;
									const gchar* _tmp141_;
									JsonBuilder* _tmp142_;
									JsonBuilder* _tmp143_;
									ObjectsQueue* _tmp144_;
									const gchar* _tmp145_;
									const gchar* _tmp146_;
									gchar* _tmp147_;
									gchar* _tmp148_;
									JsonBuilder* _tmp149_;
									_tmp138_ = builder;
									_tmp139_ = q;
									_tmp140_ = objects_queue_get_uuid (_tmp139_);
									_tmp141_ = _tmp140_;
									services_todoist_begin_command (self, _tmp138_, "section_delete", _tmp141_, NULL);
									_tmp142_ = builder;
									json_builder_set_member_name (_tmp142_, "id");
									_tmp143_ = builder;
									_tmp144_ = q;
									_tmp145_ = objects_queue_get_args (_tmp144_);
									_tmp146_ = _tmp145_;
									_tmp147_ = utils_json_utils_get_string (_tmp146_, "id");
									_tmp148_ = _tmp147_;
									json_builder_add_string_value (_tmp143_, _tmp148_);
									_g_free0 (_tmp148_);
									_tmp149_ = builder;
									services_todoist_end_command (self, _tmp149_);
								} else {
									ObjectsQueue* _tmp150_;
									const gchar* _tmp151_;
									const gchar* _tmp152_;
									_tmp150_ = q;
									_tmp151_ = objects_queue_get_query (_tmp150_);
									_tmp152_ = _tmp151_;
									if (g_strcmp0 (_tmp152_, "section_move") == 0) {
										JsonBuilder* _tmp153_;
										ObjectsQueue* _tmp154_;
										const gchar* _tmp155_;
										const gchar* _tmp156_;
										JsonBuilder* _tmp157_;
										JsonBuilder* _tmp158_;
										ObjectsQueue* _tmp159_;
										const gchar* _tmp160_;
										const gchar* _tmp161_;
										gchar* _tmp162_;
										gchar* _tmp163_;
										JsonBuilder* _tmp164_;
										JsonBuilder* _tmp165_;
										ObjectsQueue* _tmp166_;
										const gchar* _tmp167_;
										const gchar* _tmp168_;
										gchar* _tmp169_;
										gchar* _tmp170_;
										JsonBuilder* _tmp171_;
										_tmp153_ = builder;
										_tmp154_ = q;
										_tmp155_ = objects_queue_get_uuid (_tmp154_);
										_tmp156_ = _tmp155_;
										services_todoist_begin_command (self, _tmp153_, "section_move", _tmp156_, NULL);
										_tmp157_ = builder;
										json_builder_set_member_name (_tmp157_, "id");
										_tmp158_ = builder;
										_tmp159_ = q;
										_tmp160_ = objects_queue_get_args (_tmp159_);
										_tmp161_ = _tmp160_;
										_tmp162_ = utils_json_utils_get_string (_tmp161_, "id");
										_tmp163_ = _tmp162_;
										json_builder_add_string_value (_tmp158_, _tmp163_);
										_g_free0 (_tmp163_);
										_tmp164_ = builder;
										json_builder_set_member_name (_tmp164_, "project_id");
										_tmp165_ = builder;
										_tmp166_ = q;
										_tmp167_ = objects_queue_get_args (_tmp166_);
										_tmp168_ = _tmp167_;
										_tmp169_ = utils_json_utils_get_string (_tmp168_, "project_id");
										_tmp170_ = _tmp169_;
										json_builder_add_string_value (_tmp165_, _tmp170_);
										_g_free0 (_tmp170_);
										_tmp171_ = builder;
										services_todoist_end_command (self, _tmp171_);
									} else {
										ObjectsQueue* _tmp172_;
										const gchar* _tmp173_;
										const gchar* _tmp174_;
										_tmp172_ = q;
										_tmp173_ = objects_queue_get_query (_tmp172_);
										_tmp174_ = _tmp173_;
										if (g_strcmp0 (_tmp174_, "project_move") == 0) {
											JsonBuilder* _tmp175_;
											ObjectsQueue* _tmp176_;
											const gchar* _tmp177_;
											const gchar* _tmp178_;
											JsonBuilder* _tmp179_;
											JsonBuilder* _tmp180_;
											ObjectsQueue* _tmp181_;
											const gchar* _tmp182_;
											const gchar* _tmp183_;
											gchar* _tmp184_;
											gchar* _tmp185_;
											JsonBuilder* _tmp186_;
											JsonBuilder* _tmp187_;
											ObjectsQueue* _tmp188_;
											const gchar* _tmp189_;
											const gchar* _tmp190_;
											gchar* _tmp191_;
											gchar* _tmp192_;
											JsonBuilder* _tmp193_;
											_tmp175_ = builder;
											_tmp176_ = q;
											_tmp177_ = objects_queue_get_uuid (_tmp176_);
											_tmp178_ = _tmp177_;
											services_todoist_begin_command (self, _tmp175_, "project_move", _tmp178_, NULL);
											_tmp179_ = builder;
											json_builder_set_member_name (_tmp179_, "id");
											_tmp180_ = builder;
											_tmp181_ = q;
											_tmp182_ = objects_queue_get_args (_tmp181_);
											_tmp183_ = _tmp182_;
											_tmp184_ = utils_json_utils_get_string (_tmp183_, "id");
											_tmp185_ = _tmp184_;
											json_builder_add_string_value (_tmp180_, _tmp185_);
											_g_free0 (_tmp185_);
											_tmp186_ = builder;
											json_builder_set_member_name (_tmp186_, "parent_id");
											_tmp187_ = builder;
											_tmp188_ = q;
											_tmp189_ = objects_queue_get_args (_tmp188_);
											_tmp190_ = _tmp189_;
											_tmp191_ = utils_json_utils_get_string (_tmp190_, "parent_id");
											_tmp192_ = _tmp191_;
											json_builder_add_string_value (_tmp187_, _tmp192_);
											_g_free0 (_tmp192_);
											_tmp193_ = builder;
											services_todoist_end_command (self, _tmp193_);
										} else {
											ObjectsQueue* _tmp194_;
											const gchar* _tmp195_;
											const gchar* _tmp196_;
											_tmp194_ = q;
											_tmp195_ = objects_queue_get_query (_tmp194_);
											_tmp196_ = _tmp195_;
											if (g_strcmp0 (_tmp196_, "item_add") == 0) {
												JsonBuilder* _tmp197_;
												ObjectsQueue* _tmp198_;
												const gchar* _tmp199_;
												const gchar* _tmp200_;
												ObjectsQueue* _tmp201_;
												const gchar* _tmp202_;
												const gchar* _tmp203_;
												JsonBuilder* _tmp204_;
												JsonBuilder* _tmp205_;
												ObjectsQueue* _tmp206_;
												const gchar* _tmp207_;
												const gchar* _tmp208_;
												gchar* _tmp209_;
												gchar* _tmp210_;
												JsonBuilder* _tmp211_;
												JsonBuilder* _tmp212_;
												ObjectsQueue* _tmp213_;
												const gchar* _tmp214_;
												const gchar* _tmp215_;
												gchar* _tmp216_;
												gchar* _tmp217_;
												JsonBuilder* _tmp218_;
												JsonBuilder* _tmp219_;
												ObjectsQueue* _tmp220_;
												const gchar* _tmp221_;
												const gchar* _tmp222_;
												gchar* item_project_id = NULL;
												ObjectsQueue* _tmp223_;
												const gchar* _tmp224_;
												const gchar* _tmp225_;
												gchar* _tmp226_;
												gchar* _tmp227_;
												gchar* _tmp228_;
												gchar* _tmp229_;
												JsonBuilder* _tmp230_;
												JsonBuilder* _tmp231_;
												const gchar* _tmp232_;
												gchar* section_id = NULL;
												ObjectsQueue* _tmp233_;
												const gchar* _tmp234_;
												const gchar* _tmp235_;
												gchar* _tmp236_;
												const gchar* _tmp237_;
												gchar* parent_id = NULL;
												ObjectsQueue* _tmp243_;
												const gchar* _tmp244_;
												const gchar* _tmp245_;
												gchar* _tmp246_;
												const gchar* _tmp247_;
												ObjectsQueue* _tmp251_;
												const gchar* _tmp252_;
												const gchar* _tmp253_;
												JsonBuilder* _tmp275_;
												_tmp197_ = builder;
												_tmp198_ = q;
												_tmp199_ = objects_queue_get_uuid (_tmp198_);
												_tmp200_ = _tmp199_;
												_tmp201_ = q;
												_tmp202_ = objects_queue_get_temp_id (_tmp201_);
												_tmp203_ = _tmp202_;
												services_todoist_begin_command (self, _tmp197_, "item_add", _tmp200_, _tmp203_);
												_tmp204_ = builder;
												json_builder_set_member_name (_tmp204_, "content");
												_tmp205_ = builder;
												_tmp206_ = q;
												_tmp207_ = objects_queue_get_args (_tmp206_);
												_tmp208_ = _tmp207_;
												_tmp209_ = utils_json_utils_get_string (_tmp208_, "content");
												_tmp210_ = _tmp209_;
												json_builder_add_string_value (_tmp205_, _tmp210_);
												_g_free0 (_tmp210_);
												_tmp211_ = builder;
												json_builder_set_member_name (_tmp211_, "description");
												_tmp212_ = builder;
												_tmp213_ = q;
												_tmp214_ = objects_queue_get_args (_tmp213_);
												_tmp215_ = _tmp214_;
												_tmp216_ = utils_json_utils_get_string (_tmp215_, "description");
												_tmp217_ = _tmp216_;
												json_builder_add_string_value (_tmp212_, _tmp217_);
												_g_free0 (_tmp217_);
												_tmp218_ = builder;
												json_builder_set_member_name (_tmp218_, "priority");
												_tmp219_ = builder;
												_tmp220_ = q;
												_tmp221_ = objects_queue_get_args (_tmp220_);
												_tmp222_ = _tmp221_;
												json_builder_add_int_value (_tmp219_, utils_json_utils_get_int (_tmp222_, "priority"));
												_tmp223_ = q;
												_tmp224_ = objects_queue_get_args (_tmp223_);
												_tmp225_ = _tmp224_;
												_tmp226_ = utils_json_utils_get_string (_tmp225_, "project_id");
												_tmp227_ = _tmp226_;
												_tmp228_ = services_todoist_resolve_id (self, _tmp227_);
												_tmp229_ = _tmp228_;
												_g_free0 (_tmp227_);
												item_project_id = _tmp229_;
												_tmp230_ = builder;
												json_builder_set_member_name (_tmp230_, "project_id");
												_tmp231_ = builder;
												_tmp232_ = item_project_id;
												json_builder_add_string_value (_tmp231_, _tmp232_);
												_tmp233_ = q;
												_tmp234_ = objects_queue_get_args (_tmp233_);
												_tmp235_ = _tmp234_;
												_tmp236_ = utils_json_utils_get_string (_tmp235_, "section_id");
												section_id = _tmp236_;
												_tmp237_ = section_id;
												if (g_strcmp0 (_tmp237_, "") != 0) {
													JsonBuilder* _tmp238_;
													JsonBuilder* _tmp239_;
													const gchar* _tmp240_;
													gchar* _tmp241_;
													gchar* _tmp242_;
													_tmp238_ = builder;
													json_builder_set_member_name (_tmp238_, "section_id");
													_tmp239_ = builder;
													_tmp240_ = section_id;
													_tmp241_ = services_todoist_resolve_id (self, _tmp240_);
													_tmp242_ = _tmp241_;
													json_builder_add_string_value (_tmp239_, _tmp242_);
													_g_free0 (_tmp242_);
												}
												_tmp243_ = q;
												_tmp244_ = objects_queue_get_args (_tmp243_);
												_tmp245_ = _tmp244_;
												_tmp246_ = utils_json_utils_get_string (_tmp245_, "parent_id");
												parent_id = _tmp246_;
												_tmp247_ = parent_id;
												if (g_strcmp0 (_tmp247_, "") != 0) {
													JsonBuilder* _tmp248_;
													JsonBuilder* _tmp249_;
													const gchar* _tmp250_;
													_tmp248_ = builder;
													json_builder_set_member_name (_tmp248_, "parent_id");
													_tmp249_ = builder;
													_tmp250_ = parent_id;
													json_builder_add_string_value (_tmp249_, _tmp250_);
												}
												_tmp251_ = q;
												_tmp252_ = objects_queue_get_args (_tmp251_);
												_tmp253_ = _tmp252_;
												if (utils_json_utils_is_null_member (_tmp253_, "due")) {
													JsonBuilder* _tmp254_;
													JsonBuilder* _tmp255_;
													_tmp254_ = builder;
													json_builder_set_member_name (_tmp254_, "due");
													_tmp255_ = builder;
													json_builder_add_null_value (_tmp255_);
												} else {
													JsonBuilder* _tmp256_;
													JsonBuilder* _tmp257_;
													JsonBuilder* _tmp258_;
													JsonBuilder* _tmp259_;
													ObjectsQueue* _tmp260_;
													const gchar* _tmp261_;
													const gchar* _tmp262_;
													JsonObject* _tmp263_;
													JsonObject* _tmp264_;
													const gchar* _tmp265_;
													JsonBuilder* _tmp266_;
													JsonBuilder* _tmp267_;
													ObjectsQueue* _tmp268_;
													const gchar* _tmp269_;
													const gchar* _tmp270_;
													JsonObject* _tmp271_;
													JsonObject* _tmp272_;
													const gchar* _tmp273_;
													JsonBuilder* _tmp274_;
													_tmp256_ = builder;
													json_builder_set_member_name (_tmp256_, "due");
													_tmp257_ = builder;
													json_builder_begin_object (_tmp257_);
													_tmp258_ = builder;
													json_builder_set_member_name (_tmp258_, "date");
													_tmp259_ = builder;
													_tmp260_ = q;
													_tmp261_ = objects_queue_get_args (_tmp260_);
													_tmp262_ = _tmp261_;
													_tmp263_ = utils_json_utils_get_object_member (_tmp262_, "due");
													_tmp264_ = _tmp263_;
													_tmp265_ = json_object_get_string_member (_tmp264_, "date");
													json_builder_add_string_value (_tmp259_, _tmp265_);
													_json_object_unref0 (_tmp264_);
													_tmp266_ = builder;
													json_builder_set_member_name (_tmp266_, "string");
													_tmp267_ = builder;
													_tmp268_ = q;
													_tmp269_ = objects_queue_get_args (_tmp268_);
													_tmp270_ = _tmp269_;
													_tmp271_ = utils_json_utils_get_object_member (_tmp270_, "due");
													_tmp272_ = _tmp271_;
													_tmp273_ = json_object_get_string_member (_tmp272_, "string");
													json_builder_add_string_value (_tmp267_, _tmp273_);
													_json_object_unref0 (_tmp272_);
													_tmp274_ = builder;
													json_builder_end_object (_tmp274_);
												}
												_tmp275_ = builder;
												services_todoist_end_command (self, _tmp275_);
												_g_free0 (parent_id);
												_g_free0 (section_id);
												_g_free0 (item_project_id);
											} else {
												ObjectsQueue* _tmp276_;
												const gchar* _tmp277_;
												const gchar* _tmp278_;
												_tmp276_ = q;
												_tmp277_ = objects_queue_get_query (_tmp276_);
												_tmp278_ = _tmp277_;
												if (g_strcmp0 (_tmp278_, "item_update") == 0) {
													JsonBuilder* _tmp279_;
													ObjectsQueue* _tmp280_;
													const gchar* _tmp281_;
													const gchar* _tmp282_;
													JsonBuilder* _tmp283_;
													JsonBuilder* _tmp284_;
													ObjectsQueue* _tmp285_;
													const gchar* _tmp286_;
													const gchar* _tmp287_;
													gchar* _tmp288_;
													gchar* _tmp289_;
													gchar* _tmp290_;
													gchar* _tmp291_;
													JsonBuilder* _tmp292_;
													JsonBuilder* _tmp293_;
													ObjectsQueue* _tmp294_;
													const gchar* _tmp295_;
													const gchar* _tmp296_;
													gchar* _tmp297_;
													gchar* _tmp298_;
													JsonBuilder* _tmp299_;
													JsonBuilder* _tmp300_;
													ObjectsQueue* _tmp301_;
													const gchar* _tmp302_;
													const gchar* _tmp303_;
													gchar* _tmp304_;
													gchar* _tmp305_;
													JsonBuilder* _tmp306_;
													JsonBuilder* _tmp307_;
													ObjectsQueue* _tmp308_;
													const gchar* _tmp309_;
													const gchar* _tmp310_;
													ObjectsQueue* _tmp311_;
													const gchar* _tmp312_;
													const gchar* _tmp313_;
													JsonBuilder* _tmp335_;
													_tmp279_ = builder;
													_tmp280_ = q;
													_tmp281_ = objects_queue_get_uuid (_tmp280_);
													_tmp282_ = _tmp281_;
													services_todoist_begin_command (self, _tmp279_, "item_update", _tmp282_, NULL);
													_tmp283_ = builder;
													json_builder_set_member_name (_tmp283_, "id");
													_tmp284_ = builder;
													_tmp285_ = q;
													_tmp286_ = objects_queue_get_args (_tmp285_);
													_tmp287_ = _tmp286_;
													_tmp288_ = utils_json_utils_get_string (_tmp287_, "id");
													_tmp289_ = _tmp288_;
													_tmp290_ = services_todoist_resolve_id (self, _tmp289_);
													_tmp291_ = _tmp290_;
													json_builder_add_string_value (_tmp284_, _tmp291_);
													_g_free0 (_tmp291_);
													_g_free0 (_tmp289_);
													_tmp292_ = builder;
													json_builder_set_member_name (_tmp292_, "content");
													_tmp293_ = builder;
													_tmp294_ = q;
													_tmp295_ = objects_queue_get_args (_tmp294_);
													_tmp296_ = _tmp295_;
													_tmp297_ = utils_json_utils_get_string (_tmp296_, "content");
													_tmp298_ = _tmp297_;
													json_builder_add_string_value (_tmp293_, _tmp298_);
													_g_free0 (_tmp298_);
													_tmp299_ = builder;
													json_builder_set_member_name (_tmp299_, "description");
													_tmp300_ = builder;
													_tmp301_ = q;
													_tmp302_ = objects_queue_get_args (_tmp301_);
													_tmp303_ = _tmp302_;
													_tmp304_ = utils_json_utils_get_string (_tmp303_, "description");
													_tmp305_ = _tmp304_;
													json_builder_add_string_value (_tmp300_, _tmp305_);
													_g_free0 (_tmp305_);
													_tmp306_ = builder;
													json_builder_set_member_name (_tmp306_, "priority");
													_tmp307_ = builder;
													_tmp308_ = q;
													_tmp309_ = objects_queue_get_args (_tmp308_);
													_tmp310_ = _tmp309_;
													json_builder_add_int_value (_tmp307_, utils_json_utils_get_int (_tmp310_, "priority"));
													_tmp311_ = q;
													_tmp312_ = objects_queue_get_args (_tmp311_);
													_tmp313_ = _tmp312_;
													if (utils_json_utils_is_null_member (_tmp313_, "due")) {
														JsonBuilder* _tmp314_;
														JsonBuilder* _tmp315_;
														_tmp314_ = builder;
														json_builder_set_member_name (_tmp314_, "due");
														_tmp315_ = builder;
														json_builder_add_null_value (_tmp315_);
													} else {
														JsonBuilder* _tmp316_;
														JsonBuilder* _tmp317_;
														JsonBuilder* _tmp318_;
														JsonBuilder* _tmp319_;
														ObjectsQueue* _tmp320_;
														const gchar* _tmp321_;
														const gchar* _tmp322_;
														JsonObject* _tmp323_;
														JsonObject* _tmp324_;
														const gchar* _tmp325_;
														JsonBuilder* _tmp326_;
														JsonBuilder* _tmp327_;
														ObjectsQueue* _tmp328_;
														const gchar* _tmp329_;
														const gchar* _tmp330_;
														JsonObject* _tmp331_;
														JsonObject* _tmp332_;
														const gchar* _tmp333_;
														JsonBuilder* _tmp334_;
														_tmp316_ = builder;
														json_builder_set_member_name (_tmp316_, "due");
														_tmp317_ = builder;
														json_builder_begin_object (_tmp317_);
														_tmp318_ = builder;
														json_builder_set_member_name (_tmp318_, "date");
														_tmp319_ = builder;
														_tmp320_ = q;
														_tmp321_ = objects_queue_get_args (_tmp320_);
														_tmp322_ = _tmp321_;
														_tmp323_ = utils_json_utils_get_object_member (_tmp322_, "due");
														_tmp324_ = _tmp323_;
														_tmp325_ = json_object_get_string_member (_tmp324_, "date");
														json_builder_add_string_value (_tmp319_, _tmp325_);
														_json_object_unref0 (_tmp324_);
														_tmp326_ = builder;
														json_builder_set_member_name (_tmp326_, "string");
														_tmp327_ = builder;
														_tmp328_ = q;
														_tmp329_ = objects_queue_get_args (_tmp328_);
														_tmp330_ = _tmp329_;
														_tmp331_ = utils_json_utils_get_object_member (_tmp330_, "due");
														_tmp332_ = _tmp331_;
														_tmp333_ = json_object_get_string_member (_tmp332_, "string");
														json_builder_add_string_value (_tmp327_, _tmp333_);
														_json_object_unref0 (_tmp332_);
														_tmp334_ = builder;
														json_builder_end_object (_tmp334_);
													}
													_tmp335_ = builder;
													services_todoist_end_command (self, _tmp335_);
												} else {
													ObjectsQueue* _tmp336_;
													const gchar* _tmp337_;
													const gchar* _tmp338_;
													_tmp336_ = q;
													_tmp337_ = objects_queue_get_query (_tmp336_);
													_tmp338_ = _tmp337_;
													if (g_strcmp0 (_tmp338_, "item_delete") == 0) {
														JsonBuilder* _tmp339_;
														ObjectsQueue* _tmp340_;
														const gchar* _tmp341_;
														const gchar* _tmp342_;
														JsonBuilder* _tmp343_;
														JsonBuilder* _tmp344_;
														ObjectsQueue* _tmp345_;
														const gchar* _tmp346_;
														const gchar* _tmp347_;
														gchar* _tmp348_;
														gchar* _tmp349_;
														gchar* _tmp350_;
														gchar* _tmp351_;
														JsonBuilder* _tmp352_;
														_tmp339_ = builder;
														_tmp340_ = q;
														_tmp341_ = objects_queue_get_uuid (_tmp340_);
														_tmp342_ = _tmp341_;
														services_todoist_begin_command (self, _tmp339_, "item_delete", _tmp342_, NULL);
														_tmp343_ = builder;
														json_builder_set_member_name (_tmp343_, "id");
														_tmp344_ = builder;
														_tmp345_ = q;
														_tmp346_ = objects_queue_get_args (_tmp345_);
														_tmp347_ = _tmp346_;
														_tmp348_ = utils_json_utils_get_string (_tmp347_, "id");
														_tmp349_ = _tmp348_;
														_tmp350_ = services_todoist_resolve_id (self, _tmp349_);
														_tmp351_ = _tmp350_;
														json_builder_add_string_value (_tmp344_, _tmp351_);
														_g_free0 (_tmp351_);
														_g_free0 (_tmp349_);
														_tmp352_ = builder;
														services_todoist_end_command (self, _tmp352_);
													} else {
														ObjectsQueue* _tmp353_;
														const gchar* _tmp354_;
														const gchar* _tmp355_;
														_tmp353_ = q;
														_tmp354_ = objects_queue_get_query (_tmp353_);
														_tmp355_ = _tmp354_;
														if (g_strcmp0 (_tmp355_, "item_move") == 0) {
															JsonBuilder* _tmp356_;
															ObjectsQueue* _tmp357_;
															const gchar* _tmp358_;
															const gchar* _tmp359_;
															JsonBuilder* _tmp360_;
															JsonBuilder* _tmp361_;
															ObjectsQueue* _tmp362_;
															const gchar* _tmp363_;
															const gchar* _tmp364_;
															gchar* _tmp365_;
															gchar* _tmp366_;
															gchar* _tmp367_;
															gchar* _tmp368_;
															gchar* move_type = NULL;
															ObjectsQueue* _tmp369_;
															const gchar* _tmp370_;
															const gchar* _tmp371_;
															gchar* _tmp372_;
															JsonBuilder* _tmp373_;
															const gchar* _tmp374_;
															JsonBuilder* _tmp375_;
															ObjectsQueue* _tmp376_;
															const gchar* _tmp377_;
															const gchar* _tmp378_;
															const gchar* _tmp379_;
															gchar* _tmp380_;
															gchar* _tmp381_;
															gchar* _tmp382_;
															gchar* _tmp383_;
															JsonBuilder* _tmp384_;
															_tmp356_ = builder;
															_tmp357_ = q;
															_tmp358_ = objects_queue_get_uuid (_tmp357_);
															_tmp359_ = _tmp358_;
															services_todoist_begin_command (self, _tmp356_, "item_move", _tmp359_, NULL);
															_tmp360_ = builder;
															json_builder_set_member_name (_tmp360_, "id");
															_tmp361_ = builder;
															_tmp362_ = q;
															_tmp363_ = objects_queue_get_args (_tmp362_);
															_tmp364_ = _tmp363_;
															_tmp365_ = utils_json_utils_get_string (_tmp364_, "id");
															_tmp366_ = _tmp365_;
															_tmp367_ = services_todoist_resolve_id (self, _tmp366_);
															_tmp368_ = _tmp367_;
															json_builder_add_string_value (_tmp361_, _tmp368_);
															_g_free0 (_tmp368_);
															_g_free0 (_tmp366_);
															_tmp369_ = q;
															_tmp370_ = objects_queue_get_args (_tmp369_);
															_tmp371_ = _tmp370_;
															_tmp372_ = utils_json_utils_get_string (_tmp371_, "type");
															move_type = _tmp372_;
															_tmp373_ = builder;
															_tmp374_ = move_type;
															json_builder_set_member_name (_tmp373_, _tmp374_);
															_tmp375_ = builder;
															_tmp376_ = q;
															_tmp377_ = objects_queue_get_args (_tmp376_);
															_tmp378_ = _tmp377_;
															_tmp379_ = move_type;
															_tmp380_ = utils_json_utils_get_string (_tmp378_, _tmp379_);
															_tmp381_ = _tmp380_;
															_tmp382_ = services_todoist_resolve_id (self, _tmp381_);
															_tmp383_ = _tmp382_;
															json_builder_add_string_value (_tmp375_, _tmp383_);
															_g_free0 (_tmp383_);
															_g_free0 (_tmp381_);
															_tmp384_ = builder;
															services_todoist_end_command (self, _tmp384_);
															_g_free0 (move_type);
														} else {
															gboolean _tmp385_ = FALSE;
															gboolean _tmp386_ = FALSE;
															ObjectsQueue* _tmp387_;
															const gchar* _tmp388_;
															const gchar* _tmp389_;
															_tmp387_ = q;
															_tmp388_ = objects_queue_get_query (_tmp387_);
															_tmp389_ = _tmp388_;
															if (g_strcmp0 (_tmp389_, "item_complete") == 0) {
																_tmp386_ = TRUE;
															} else {
																ObjectsQueue* _tmp390_;
																const gchar* _tmp391_;
																const gchar* _tmp392_;
																_tmp390_ = q;
																_tmp391_ = objects_queue_get_query (_tmp390_);
																_tmp392_ = _tmp391_;
																_tmp386_ = g_strcmp0 (_tmp392_, "item_uncomplete") == 0;
															}
															if (_tmp386_) {
																_tmp385_ = TRUE;
															} else {
																ObjectsQueue* _tmp393_;
																const gchar* _tmp394_;
																const gchar* _tmp395_;
																_tmp393_ = q;
																_tmp394_ = objects_queue_get_query (_tmp393_);
																_tmp395_ = _tmp394_;
																_tmp385_ = g_strcmp0 (_tmp395_, "item_close") == 0;
															}
															if (_tmp385_) {
																JsonBuilder* _tmp396_;
																ObjectsQueue* _tmp397_;
																const gchar* _tmp398_;
																const gchar* _tmp399_;
																ObjectsQueue* _tmp400_;
																const gchar* _tmp401_;
																const gchar* _tmp402_;
																JsonBuilder* _tmp403_;
																JsonBuilder* _tmp404_;
																ObjectsQueue* _tmp405_;
																const gchar* _tmp406_;
																const gchar* _tmp407_;
																gchar* _tmp408_;
																gchar* _tmp409_;
																gchar* _tmp410_;
																gchar* _tmp411_;
																JsonBuilder* _tmp412_;
																_tmp396_ = builder;
																_tmp397_ = q;
																_tmp398_ = objects_queue_get_query (_tmp397_);
																_tmp399_ = _tmp398_;
																_tmp400_ = q;
																_tmp401_ = objects_queue_get_uuid (_tmp400_);
																_tmp402_ = _tmp401_;
																services_todoist_begin_command (self, _tmp396_, _tmp399_, _tmp402_, NULL);
																_tmp403_ = builder;
																json_builder_set_member_name (_tmp403_, "id");
																_tmp404_ = builder;
																_tmp405_ = q;
																_tmp406_ = objects_queue_get_args (_tmp405_);
																_tmp407_ = _tmp406_;
																_tmp408_ = utils_json_utils_get_string (_tmp407_, "id");
																_tmp409_ = _tmp408_;
																_tmp410_ = services_todoist_resolve_id (self, _tmp409_);
																_tmp411_ = _tmp410_;
																json_builder_add_string_value (_tmp404_, _tmp411_);
																_g_free0 (_tmp411_);
																_g_free0 (_tmp409_);
																_tmp412_ = builder;
																services_todoist_end_command (self, _tmp412_);
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
			}
			_g_object_unref0 (q);
		}
	}
	_tmp413_ = builder;
	json_builder_end_array (_tmp413_);
	_tmp414_ = builder;
	json_builder_end_object (_tmp414_);
	_tmp415_ = json_generator_new ();
	generator = _tmp415_;
	_tmp416_ = builder;
	_tmp417_ = json_builder_get_root (_tmp416_);
	_tmp418_ = _tmp417_;
	json_generator_set_root (generator, _tmp418_);
	__vala_JsonNode_free0 (_tmp418_);
	_tmp419_ = json_generator_to_data (generator, NULL);
	result = _tmp419_;
	_g_object_unref0 (generator);
	_g_object_unref0 (builder);
	return result;
}

gchar*
services_todoist_get_delete_json (ServicesTodoist* self,
                                  const gchar* id,
                                  const gchar* type,
                                  const gchar* uuid)
{
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	JsonGenerator* generator = NULL;
	JsonGenerator* _tmp1_;
	JsonNode* _tmp2_;
	JsonNode* _tmp3_;
	gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (type != NULL, NULL);
	g_return_val_if_fail (uuid != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	json_builder_begin_object (builder);
	json_builder_set_member_name (builder, "commands");
	json_builder_begin_array (builder);
	services_todoist_begin_command (self, builder, type, uuid, NULL);
	json_builder_set_member_name (builder, "id");
	json_builder_add_string_value (builder, id);
	services_todoist_end_command (self, builder);
	json_builder_end_array (builder);
	json_builder_end_object (builder);
	_tmp1_ = json_generator_new ();
	generator = _tmp1_;
	_tmp2_ = json_builder_get_root (builder);
	_tmp3_ = _tmp2_;
	json_generator_set_root (generator, _tmp3_);
	__vala_JsonNode_free0 (_tmp3_);
	_tmp4_ = json_generator_to_data (generator, NULL);
	result = _tmp4_;
	_g_object_unref0 (generator);
	_g_object_unref0 (builder);
	return result;
}

static void
services_todoist_add_data_free (gpointer _data)
{
	ServicesTodoistAddData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistAddData, _data_);
}

void
services_todoist_add (ServicesTodoist* self,
                      ObjectsBaseObject* object,
                      GAsyncReadyCallback _callback_,
                      gpointer _user_data_)
{
	ServicesTodoistAddData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsBaseObject* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_data_ = g_slice_new0 (ServicesTodoistAddData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_add_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (object);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp1_;
	services_todoist_add_co (_data_);
}

HttpResponse*
services_todoist_add_finish (ServicesTodoist* self,
                             GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistAddData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_add_ready (GObject* source_object,
                            GAsyncResult* _res_,
                            gpointer _user_data_)
{
	ServicesTodoistAddData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_add_co (_data_);
}

static gboolean
services_todoist_add_co (ServicesTodoistAddData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_add (_data_->_tmp0_, _data_->object, services_todoist_add_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_items_add_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_update_data_free (gpointer _data)
{
	ServicesTodoistUpdateData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistUpdateData, _data_);
}

void
services_todoist_update (ServicesTodoist* self,
                         ObjectsBaseObject* object,
                         GAsyncReadyCallback _callback_,
                         gpointer _user_data_)
{
	ServicesTodoistUpdateData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsBaseObject* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_data_ = g_slice_new0 (ServicesTodoistUpdateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_update_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (object);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp1_;
	services_todoist_update_co (_data_);
}

HttpResponse*
services_todoist_update_finish (ServicesTodoist* self,
                                GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistUpdateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_update_ready (GObject* source_object,
                               GAsyncResult* _res_,
                               gpointer _user_data_)
{
	ServicesTodoistUpdateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_update_co (_data_);
}

static gboolean
services_todoist_update_co (ServicesTodoistUpdateData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_update (_data_->_tmp0_, _data_->object, services_todoist_update_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_items_update_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_delete_data_free (gpointer _data)
{
	ServicesTodoistDeleteData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistDeleteData, _data_);
}

void
services_todoist_delete (ServicesTodoist* self,
                         ObjectsBaseObject* object,
                         GAsyncReadyCallback _callback_,
                         gpointer _user_data_)
{
	ServicesTodoistDeleteData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsBaseObject* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_data_ = g_slice_new0 (ServicesTodoistDeleteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_delete_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (object);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp1_;
	services_todoist_delete_co (_data_);
}

HttpResponse*
services_todoist_delete_finish (ServicesTodoist* self,
                                GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistDeleteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_delete_ready (GObject* source_object,
                               GAsyncResult* _res_,
                               gpointer _user_data_)
{
	ServicesTodoistDeleteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_delete_co (_data_);
}

static gboolean
services_todoist_delete_co (ServicesTodoistDeleteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_delete (_data_->_tmp0_, _data_->object, services_todoist_delete_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_items_delete_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_complete_item_data_free (gpointer _data)
{
	ServicesTodoistCompleteItemData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->item);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistCompleteItemData, _data_);
}

void
services_todoist_complete_item (ServicesTodoist* self,
                                ObjectsItem* item,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	ServicesTodoistCompleteItemData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsItem* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_data_ = g_slice_new0 (ServicesTodoistCompleteItemData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_complete_item_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (item);
	_g_object_unref0 (_data_->item);
	_data_->item = _tmp1_;
	services_todoist_complete_item_co (_data_);
}

HttpResponse*
services_todoist_complete_item_finish (ServicesTodoist* self,
                                       GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistCompleteItemData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_complete_item_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	ServicesTodoistCompleteItemData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_complete_item_co (_data_);
}

static gboolean
services_todoist_complete_item_co (ServicesTodoistCompleteItemData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_complete_item (_data_->_tmp0_, _data_->item, services_todoist_complete_item_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_items_complete_item_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_close_item_data_free (gpointer _data)
{
	ServicesTodoistCloseItemData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->item);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistCloseItemData, _data_);
}

void
services_todoist_close_item (ServicesTodoist* self,
                             ObjectsItem* item,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	ServicesTodoistCloseItemData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsItem* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_data_ = g_slice_new0 (ServicesTodoistCloseItemData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_close_item_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (item);
	_g_object_unref0 (_data_->item);
	_data_->item = _tmp1_;
	services_todoist_close_item_co (_data_);
}

HttpResponse*
services_todoist_close_item_finish (ServicesTodoist* self,
                                    GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistCloseItemData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_close_item_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_)
{
	ServicesTodoistCloseItemData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_close_item_co (_data_);
}

static gboolean
services_todoist_close_item_co (ServicesTodoistCloseItemData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_close_item (_data_->_tmp0_, _data_->item, services_todoist_close_item_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_items_close_item_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_move_item_data_free (gpointer _data)
{
	ServicesTodoistMoveItemData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->item);
	_g_free0 (_data_->type);
	_g_free0 (_data_->id);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistMoveItemData, _data_);
}

void
services_todoist_move_item (ServicesTodoist* self,
                            ObjectsItem* item,
                            const gchar* type,
                            const gchar* id,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	ServicesTodoistMoveItemData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsItem* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	g_return_if_fail (type != NULL);
	g_return_if_fail (id != NULL);
	_data_ = g_slice_new0 (ServicesTodoistMoveItemData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_move_item_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (item);
	_g_object_unref0 (_data_->item);
	_data_->item = _tmp1_;
	_tmp2_ = g_strdup (type);
	_g_free0 (_data_->type);
	_data_->type = _tmp2_;
	_tmp3_ = g_strdup (id);
	_g_free0 (_data_->id);
	_data_->id = _tmp3_;
	services_todoist_move_item_co (_data_);
}

HttpResponse*
services_todoist_move_item_finish (ServicesTodoist* self,
                                   GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistMoveItemData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_move_item_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	ServicesTodoistMoveItemData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_move_item_co (_data_);
}

static gboolean
services_todoist_move_item_co (ServicesTodoistMoveItemData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_move_item (_data_->_tmp0_, _data_->item, _data_->type, _data_->id, services_todoist_move_item_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_items_move_item_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_update_items_data_free (gpointer _data)
{
	ServicesTodoistUpdateItemsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->objects);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistUpdateItemsData, _data_);
}

void
services_todoist_update_items (ServicesTodoist* self,
                               GeeArrayList* objects,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	ServicesTodoistUpdateItemsData* _data_;
	ServicesTodoist* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (objects != NULL);
	_data_ = g_slice_new0 (ServicesTodoistUpdateItemsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_update_items_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (objects);
	_g_object_unref0 (_data_->objects);
	_data_->objects = _tmp1_;
	services_todoist_update_items_co (_data_);
}

void
services_todoist_update_items_finish (ServicesTodoist* self,
                                      GAsyncResult* _res_)
{
	ServicesTodoistUpdateItemsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
services_todoist_update_items_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	ServicesTodoistUpdateItemsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_update_items_co (_data_);
}

static gboolean
services_todoist_update_items_co (ServicesTodoistUpdateItemsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_items;
	_data_->_state_ = 1;
	services_todoist_items_update_items (_data_->_tmp0_, _data_->objects, services_todoist_update_items_ready, _data_);
	return FALSE;
	_state_1:
	services_todoist_items_update_items_finish (_data_->_tmp0_, _data_->_res_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_move_project_section_data_free (gpointer _data)
{
	ServicesTodoistMoveProjectSectionData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->base_object);
	_g_free0 (_data_->project_id);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistMoveProjectSectionData, _data_);
}

void
services_todoist_move_project_section (ServicesTodoist* self,
                                       ObjectsBaseObject* base_object,
                                       const gchar* project_id,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	ServicesTodoistMoveProjectSectionData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsBaseObject* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (base_object != NULL);
	g_return_if_fail (project_id != NULL);
	_data_ = g_slice_new0 (ServicesTodoistMoveProjectSectionData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_move_project_section_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (base_object);
	_g_object_unref0 (_data_->base_object);
	_data_->base_object = _tmp1_;
	_tmp2_ = g_strdup (project_id);
	_g_free0 (_data_->project_id);
	_data_->project_id = _tmp2_;
	services_todoist_move_project_section_co (_data_);
}

HttpResponse*
services_todoist_move_project_section_finish (ServicesTodoist* self,
                                              GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistMoveProjectSectionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_move_project_section_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	ServicesTodoistMoveProjectSectionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_move_project_section_co (_data_);
}

static gboolean
services_todoist_move_project_section_co (ServicesTodoistMoveProjectSectionData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_projects;
	_data_->_state_ = 1;
	services_todoist_projects_move_project_section (_data_->_tmp0_, _data_->base_object, _data_->project_id, services_todoist_move_project_section_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_projects_move_project_section_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
services_todoist_duplicate_project_data_free (gpointer _data)
{
	ServicesTodoistDuplicateProjectData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->project);
	_http_response_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ServicesTodoistDuplicateProjectData, _data_);
}

void
services_todoist_duplicate_project (ServicesTodoist* self,
                                    ObjectsProject* project,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	ServicesTodoistDuplicateProjectData* _data_;
	ServicesTodoist* _tmp0_;
	ObjectsProject* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (project != NULL);
	_data_ = g_slice_new0 (ServicesTodoistDuplicateProjectData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, services_todoist_duplicate_project_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (project);
	_g_object_unref0 (_data_->project);
	_data_->project = _tmp1_;
	services_todoist_duplicate_project_co (_data_);
}

HttpResponse*
services_todoist_duplicate_project_finish (ServicesTodoist* self,
                                           GAsyncResult* _res_)
{
	HttpResponse* result;
	ServicesTodoistDuplicateProjectData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
services_todoist_duplicate_project_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	ServicesTodoistDuplicateProjectData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	services_todoist_duplicate_project_co (_data_);
}

static gboolean
services_todoist_duplicate_project_co (ServicesTodoistDuplicateProjectData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_projects;
	_data_->_state_ = 1;
	services_todoist_projects_duplicate_project (_data_->_tmp0_, _data_->project, services_todoist_duplicate_project_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = services_todoist_projects_duplicate_project_finish (_data_->_tmp0_, _data_->_res_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
services_todoist_add_item_if_not_exists (ServicesTodoist* self,
                                         JsonNode* node)
{
	JsonObject* _tmp0_;
	JsonObject* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = json_node_get_object (node);
	if (!json_object_get_null_member (_tmp0_, "parent_id")) {
		ObjectsItem* item = NULL;
		ServicesStore* _tmp1_;
		JsonObject* _tmp2_;
		const gchar* _tmp3_;
		ObjectsItem* _tmp4_;
		ObjectsItem* _tmp5_;
		_tmp1_ = services_store_instance ();
		_tmp2_ = json_node_get_object (node);
		_tmp3_ = json_object_get_string_member (_tmp2_, "parent_id");
		_tmp4_ = services_store_get_item (_tmp1_, _tmp3_);
		item = _tmp4_;
		_tmp5_ = item;
		if (_tmp5_ != NULL) {
			ObjectsItem* _tmp6_;
			ObjectsItem* _tmp7_;
			ObjectsItem* _tmp8_;
			ObjectsItem* _tmp9_;
			ObjectsItem* _tmp10_;
			_tmp6_ = item;
			_tmp7_ = objects_item_new_from_json (node);
			_tmp8_ = _tmp7_;
			_tmp9_ = objects_item_add_item_if_not_exists (_tmp6_, _tmp8_, TRUE);
			_tmp10_ = _tmp9_;
			_g_object_unref0 (_tmp10_);
			_g_object_unref0 (_tmp8_);
		}
		_g_object_unref0 (item);
		return;
	}
	_tmp11_ = json_node_get_object (node);
	if (!json_object_get_null_member (_tmp11_, "section_id")) {
		ObjectsSection* section = NULL;
		ServicesStore* _tmp12_;
		JsonObject* _tmp13_;
		const gchar* _tmp14_;
		ObjectsSection* _tmp15_;
		ObjectsSection* _tmp16_;
		_tmp12_ = services_store_instance ();
		_tmp13_ = json_node_get_object (node);
		_tmp14_ = json_object_get_string_member (_tmp13_, "section_id");
		_tmp15_ = services_store_get_section (_tmp12_, _tmp14_);
		section = _tmp15_;
		_tmp16_ = section;
		if (_tmp16_ != NULL) {
			ObjectsSection* _tmp17_;
			ObjectsItem* _tmp18_;
			ObjectsItem* _tmp19_;
			ObjectsItem* _tmp20_;
			ObjectsItem* _tmp21_;
			_tmp17_ = section;
			_tmp18_ = objects_item_new_from_json (node);
			_tmp19_ = _tmp18_;
			_tmp20_ = objects_section_add_item_if_not_exists (_tmp17_, _tmp19_, TRUE);
			_tmp21_ = _tmp20_;
			_g_object_unref0 (_tmp21_);
			_g_object_unref0 (_tmp19_);
		}
		_g_object_unref0 (section);
	} else {
		ObjectsProject* project = NULL;
		ServicesStore* _tmp22_;
		JsonObject* _tmp23_;
		const gchar* _tmp24_;
		ObjectsProject* _tmp25_;
		ObjectsProject* _tmp26_;
		_tmp22_ = services_store_instance ();
		_tmp23_ = json_node_get_object (node);
		_tmp24_ = json_object_get_string_member (_tmp23_, "project_id");
		_tmp25_ = services_store_get_project (_tmp22_, _tmp24_);
		project = _tmp25_;
		_tmp26_ = project;
		if (_tmp26_ != NULL) {
			ObjectsProject* _tmp27_;
			ObjectsItem* _tmp28_;
			ObjectsItem* _tmp29_;
			ObjectsItem* _tmp30_;
			ObjectsItem* _tmp31_;
			_tmp27_ = project;
			_tmp28_ = objects_item_new_from_json (node);
			_tmp29_ = _tmp28_;
			_tmp30_ = objects_project_add_item_if_not_exists (_tmp27_, _tmp29_, TRUE);
			_tmp31_ = _tmp30_;
			_g_object_unref0 (_tmp31_);
			_g_object_unref0 (_tmp29_);
		}
		_g_object_unref0 (project);
	}
}

void
services_todoist_add_section_if_not_exists (ServicesTodoist* self,
                                            JsonNode* node)
{
	gchar* _id = NULL;
	JsonObject* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	ObjectsProject* project = NULL;
	ServicesStore* _tmp3_;
	const gchar* _tmp4_;
	ObjectsProject* _tmp5_;
	ObjectsProject* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_tmp0_ = json_node_get_object (node);
	_tmp1_ = json_object_get_string_member (_tmp0_, "project_id");
	_tmp2_ = g_strdup (_tmp1_);
	_id = _tmp2_;
	_tmp3_ = services_store_instance ();
	_tmp4_ = _id;
	_tmp5_ = services_store_get_project (_tmp3_, _tmp4_);
	project = _tmp5_;
	_tmp6_ = project;
	if (_tmp6_ != NULL) {
		ObjectsProject* _tmp7_;
		ObjectsSection* _tmp8_;
		ObjectsSection* _tmp9_;
		ObjectsSection* _tmp10_;
		ObjectsSection* _tmp11_;
		_tmp7_ = project;
		_tmp8_ = objects_section_new_from_json (node);
		_tmp9_ = _tmp8_;
		_tmp10_ = objects_project_add_section_if_not_exists (_tmp7_, _tmp9_);
		_tmp11_ = _tmp10_;
		_g_object_unref0 (_tmp11_);
		_g_object_unref0 (_tmp9_);
	}
	_g_object_unref0 (project);
	_g_free0 (_id);
}

gboolean
services_todoist_is_todoist_error (ServicesTodoist* self,
                                   guint status_code)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (status_code == ((guint) 400)) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = status_code == ((guint) 401);
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = status_code == ((guint) 403);
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		_tmp3_ = status_code == ((guint) 404);
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = status_code == ((guint) 429);
	}
	if (_tmp2_) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = status_code == ((guint) 500);
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = status_code == ((guint) 503);
	}
	result = _tmp0_;
	return result;
}

gchar*
services_todoist_get_todoist_error (ServicesTodoist* self,
                                    guint code)
{
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	switch (code) {
		case 400:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup (_ ("The request was incorrect."));
			result = _tmp0_;
			return result;
		}
		case 401:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup (_ ("Authentication is required, and has failed, or has not yet been provid" \
"ed."));
			result = _tmp1_;
			return result;
		}
		case 403:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup (_ ("The request was valid, but for something that is forbidden."));
			result = _tmp2_;
			return result;
		}
		case 404:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup (_ ("The requested resource could not be found."));
			result = _tmp3_;
			return result;
		}
		case 429:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup (_ ("The user has sent too many requests in a given amount of time."));
			result = _tmp4_;
			return result;
		}
		case 500:
		{
			gchar* _tmp5_;
			_tmp5_ = g_strdup (_ ("The request failed due to a server error."));
			result = _tmp5_;
			return result;
		}
		case 503:
		{
			gchar* _tmp6_;
			_tmp6_ = g_strdup (_ ("The server is currently unable to handle the request."));
			result = _tmp6_;
			return result;
		}
		default:
		{
			gchar* _tmp7_;
			_tmp7_ = g_strdup (_ ("Unknown error"));
			result = _tmp7_;
			return result;
		}
	}
}

static void
services_todoist_class_init (ServicesTodoistClass * klass,
                             gpointer klass_data)
{
	services_todoist_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ServicesTodoist_private_offset);
	G_OBJECT_CLASS (klass)->finalize = services_todoist_finalize;
}

static void
services_todoist_instance_init (ServicesTodoist * self,
                                gpointer klass)
{
	self->priv = services_todoist_get_instance_private (self);
	self->priv->_queue_running = FALSE;
}

static void
services_todoist_finalize (GObject * obj)
{
	ServicesTodoist * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SERVICES_TYPE_TODOIST, ServicesTodoist);
	_g_object_unref0 (self->priv->session);
	_g_object_unref0 (self->priv->_auth);
	_g_object_unref0 (self->priv->_items);
	_g_object_unref0 (self->priv->_projects);
	G_OBJECT_CLASS (services_todoist_parent_class)->finalize (obj);
}

static GType
services_todoist_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ServicesTodoistClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) services_todoist_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ServicesTodoist), 0, (GInstanceInitFunc) services_todoist_instance_init, NULL };
	GType services_todoist_type_id;
	services_todoist_type_id = g_type_register_static (G_TYPE_OBJECT, "ServicesTodoist", &g_define_type_info, 0);
	ServicesTodoist_private_offset = g_type_add_instance_private (services_todoist_type_id, sizeof (ServicesTodoistPrivate));
	return services_todoist_type_id;
}

GType
services_todoist_get_type (void)
{
	static volatile gsize services_todoist_type_id__once = 0;
	if (g_once_init_enter (&services_todoist_type_id__once)) {
		GType services_todoist_type_id;
		services_todoist_type_id = services_todoist_get_type_once ();
		g_once_init_leave (&services_todoist_type_id__once, services_todoist_type_id);
	}
	return services_todoist_type_id__once;
}

static inline gpointer
http_response_get_instance_private (HttpResponse* self)
{
	return G_STRUCT_MEMBER_P (self, HttpResponse_private_offset);
}

void
http_response_from_error_json (HttpResponse* self,
                               JsonNode* node)
{
	JsonObject* _tmp0_;
	JsonObject* _tmp1_;
	const gchar* _tmp2_;
	JsonObject* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	http_response_set_status (self, FALSE);
	_tmp0_ = json_node_get_object (node);
	http_response_set_error_code (self, (gint) json_object_get_int_member (_tmp0_, "error_code"));
	_tmp1_ = json_node_get_object (node);
	_tmp2_ = json_object_get_string_member (_tmp1_, "error");
	http_response_set_error (self, _tmp2_);
	_tmp3_ = json_node_get_object (node);
	http_response_set_http_code (self, (gint) json_object_get_int_member (_tmp3_, "http_code"));
}

void
http_response_from_error_xml (HttpResponse* self,
                              GXmlDomDocument* doc,
                              gint error_code)
{
	GXmlDomHTMLCollection* _tmp0_;
	GXmlDomHTMLCollection* _tmp1_;
	GXmlDomElement* _tmp2_;
	GXmlDomElement* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (doc != NULL);
	http_response_set_status (self, FALSE);
	http_response_set_error_code (self, error_code);
	http_response_set_http_code (self, error_code);
	_tmp0_ = gxml_dom_document_get_elements_by_tag_name (doc, "o:hint");
	_tmp1_ = _tmp0_;
	_tmp2_ = gxml_dom_html_collection_get_element (_tmp1_, 0);
	_tmp3_ = _tmp2_;
	_tmp4_ = gxml_dom_node_get_text_content ((GXmlDomNode*) _tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	http_response_set_error (self, _tmp6_);
	_g_free0 (_tmp6_);
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
}

HttpResponse*
http_response_construct (GType object_type)
{
	HttpResponse* self = NULL;
	self = (HttpResponse*) g_type_create_instance (object_type);
	return self;
}

HttpResponse*
http_response_new (void)
{
	return http_response_construct (TYPE_HTTP_RESPONSE);
}

gboolean
http_response_get_status (HttpResponse* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_status;
	return result;
}

void
http_response_set_status (HttpResponse* self,
                          gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_status = value;
}

const gchar*
http_response_get_error (HttpResponse* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_error;
	result = _tmp0_;
	return result;
}

void
http_response_set_error (HttpResponse* self,
                         const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_error);
	self->priv->_error = _tmp0_;
}

gint
http_response_get_error_code (HttpResponse* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_error_code;
	return result;
}

void
http_response_set_error_code (HttpResponse* self,
                              gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_error_code = value;
}

gint
http_response_get_http_code (HttpResponse* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_http_code;
	return result;
}

void
http_response_set_http_code (HttpResponse* self,
                             gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_http_code = value;
}

const gchar*
http_response_get_data (HttpResponse* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_data;
	result = _tmp0_;
	return result;
}

void
http_response_set_data (HttpResponse* self,
                        const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_data);
	self->priv->_data = _tmp0_;
}

void
http_response_get_data_object (HttpResponse* self,
                               GValue * result)
{
	GValue _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_data_object;
	*result = _tmp0_;
	return;
}

void
http_response_set_data_object (HttpResponse* self,
                               GValue * value)
{
	GValue _tmp0_;
	GValue _tmp1_;
	GValue _tmp2_ = {0};
	g_return_if_fail (self != NULL);
	_tmp0_ = *value;
	_tmp1_ = _tmp0_;
	if (G_IS_VALUE (&_tmp1_)) {
		g_value_init (&_tmp2_, G_VALUE_TYPE (&_tmp1_));
		g_value_copy (&_tmp1_, &_tmp2_);
	} else {
		_tmp2_ = _tmp1_;
	}
	G_IS_VALUE (&self->priv->_data_object) ? (g_value_unset (&self->priv->_data_object), NULL) : NULL;
	self->priv->_data_object = _tmp2_;
}

static void
value_http_response_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
value_http_response_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		http_response_unref (value->data[0].v_pointer);
	}
}

static void
value_http_response_copy_value (const GValue* src_value,
                                GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = http_response_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
value_http_response_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
value_http_response_collect_value (GValue* value,
                                   guint n_collect_values,
                                   GTypeCValue* collect_values,
                                   guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		HttpResponse * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = http_response_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
value_http_response_lcopy_value (const GValue* value,
                                 guint n_collect_values,
                                 GTypeCValue* collect_values,
                                 guint collect_flags)
{
	HttpResponse ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = http_response_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
param_spec_http_response (const gchar* name,
                          const gchar* nick,
                          const gchar* blurb,
                          GType object_type,
                          GParamFlags flags)
{
	ParamSpecHttpResponse* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TYPE_HTTP_RESPONSE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
value_get_http_response (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HTTP_RESPONSE), NULL);
	return value->data[0].v_pointer;
}

void
value_set_http_response (GValue* value,
                         gpointer v_object)
{
	HttpResponse * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HTTP_RESPONSE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HTTP_RESPONSE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		http_response_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		http_response_unref (old);
	}
}

void
value_take_http_response (GValue* value,
                          gpointer v_object)
{
	HttpResponse * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_HTTP_RESPONSE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_HTTP_RESPONSE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		http_response_unref (old);
	}
}

static void
http_response_class_init (HttpResponseClass * klass,
                          gpointer klass_data)
{
	http_response_parent_class = g_type_class_peek_parent (klass);
	((HttpResponseClass *) klass)->finalize = http_response_finalize;
	g_type_class_adjust_private_offset (klass, &HttpResponse_private_offset);
}

static void
http_response_instance_init (HttpResponse * self,
                             gpointer klass)
{
	gchar* _tmp0_;
	self->priv = http_response_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_error = _tmp0_;
	self->priv->_error_code = 0;
	self->priv->_http_code = 0;
	self->ref_count = 1;
}

static void
http_response_finalize (HttpResponse * obj)
{
	HttpResponse * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_HTTP_RESPONSE, HttpResponse);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_error);
	_g_free0 (self->priv->_data);
	G_IS_VALUE (&self->priv->_data_object) ? (g_value_unset (&self->priv->_data_object), NULL) : NULL;
}

static GType
http_response_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { value_http_response_init, value_http_response_free_value, value_http_response_copy_value, value_http_response_peek_pointer, "p", value_http_response_collect_value, "p", value_http_response_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (HttpResponseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) http_response_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (HttpResponse), 0, (GInstanceInitFunc) http_response_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType http_response_type_id;
	http_response_type_id = g_type_register_fundamental (g_type_fundamental_next (), "HttpResponse", &g_define_type_info, &g_define_type_fundamental_info, 0);
	HttpResponse_private_offset = g_type_add_instance_private (http_response_type_id, sizeof (HttpResponsePrivate));
	return http_response_type_id;
}

GType
http_response_get_type (void)
{
	static volatile gsize http_response_type_id__once = 0;
	if (g_once_init_enter (&http_response_type_id__once)) {
		GType http_response_type_id;
		http_response_type_id = http_response_get_type_once ();
		g_once_init_leave (&http_response_type_id__once, http_response_type_id);
	}
	return http_response_type_id__once;
}

gpointer
http_response_ref (gpointer instance)
{
	HttpResponse * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
http_response_unref (gpointer instance)
{
	HttpResponse * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		HTTP_RESPONSE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

