finish yadisk_get_disk

This commit is contained in:
2023-12-01 11:05:18 +03:00
parent b0cdcabe1a
commit db89e0e129
3 changed files with 100 additions and 7 deletions

View File

@@ -39,6 +39,40 @@ yadisk_code yadisk_get_disk(yadisk_api_client* client, yadisk_disk_info* info)
GET_JSON_STRING(root, "reg_time", &(info->reg_time));
GET_JSON_BOOL(root, "is_paid", &(info->is_paid));
json_object *user_object;
if (!json_object_object_get_ex(root, "user", &user_object))
THROW_PARSE_JSON_ERROR
GET_JSON_STRING(user_object, "reg_time", &(info->user.reg_time));
GET_JSON_STRING(user_object, "display_name", &(info->user.display_name));
GET_JSON_STRING(user_object, "uid", &(info->user.uid));
GET_JSON_STRING(user_object, "country", &(info->user.country));
GET_JSON_BOOL(user_object, "is_child", &(info->user.is_child));
GET_JSON_STRING(user_object, "login", &(info->user.login));
json_object *system_folders;
if (!json_object_object_get_ex(root, "system_folders", &system_folders))
THROW_PARSE_JSON_ERROR
GET_JSON_STRING(system_folders, "odnoklassniki", &(info->system_folders.odnoklassniki));
GET_JSON_STRING(system_folders, "google", &(info->system_folders.google));
GET_JSON_STRING(system_folders, "instagram", &(info->system_folders.instagram));
GET_JSON_STRING(system_folders, "vkontakte", &(info->system_folders.vkontakte));
GET_JSON_STRING(system_folders, "attach", &(info->system_folders.attach));
GET_JSON_STRING(system_folders, "mailru", &(info->system_folders.mailru));
GET_JSON_STRING(system_folders, "downloads", &(info->system_folders.downloads));
GET_JSON_STRING(system_folders, "applications", &(info->system_folders.applications));
GET_JSON_STRING(system_folders, "facebook", &(info->system_folders.facebook));
GET_JSON_STRING(system_folders, "social", &(info->system_folders.social));
GET_JSON_STRING(system_folders, "messenger", &(info->system_folders.messenger));
GET_JSON_STRING(system_folders, "calendar", &(info->system_folders.calendar));
GET_JSON_STRING(system_folders, "photostream", &(info->system_folders.photostream));
GET_JSON_STRING(system_folders, "screenshots", &(info->system_folders.screenshots));
GET_JSON_STRING(system_folders, "scans", &(info->system_folders.scans));
GET_JSON_BOOL(root, "unlimited_autoupload_enabled", &(info->unlimited_autoupload_enabled));
GET_JSON_UINT64(root, "revision", &(info->revision));
json_object_put(root);

View File

@@ -24,12 +24,43 @@
#include "yadisk_shared.h"
typedef struct {
const char* reg_time;
const char* display_name;
const char* uid;
const char* country;
int is_child;
const char* login;
} yadisk_user_info;
typedef struct {
const char* odnoklassniki;
const char* google;
const char* instagram;
const char* vkontakte;
const char* attach;
const char* mailru;
const char* downloads;
const char* applications;
const char* facebook;
const char* social;
const char* messenger;
const char* calendar;
const char* photostream;
const char* screenshots;
const char* scans;
} yadisk_system_folders;
typedef struct yadisk_disk_info {
unsigned long total_space;
unsigned long trash_size;
unsigned long used_space;
int is_paid;
const char* reg_time;
yadisk_system_folders system_folders;
yadisk_user_info user;
int unlimited_autoupload_enabled;
unsigned long revision;
} yadisk_disk_info;
yadisk_code yadisk_get_disk(yadisk_api_client* client, yadisk_disk_info* info);