2
* Copyright © 2016 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Gary Wang <gary.wang@canonical.com>
19
#include <onedrive/api/cloudfolder.h>
21
#include <json/json.h>
27
namespace json = Json;
29
using namespace onedrive::api;
32
class CloudFolder::Priv {
34
Priv(const json::Value &root) {
35
id_ = root["id"].asString();
36
updated_date_ = root["lastModifiedDateTime"].asString();
37
created_date_ = root["createdDateTime"].asString();
38
etag_ = root["eTag"].asString();
39
name_ = root["name"].asString();
40
owner_ = root["createdBy"]["user"]["displayName"].asString();
41
folder_id_ = root.isMember("parentReference") ?
42
root["parentReference"]["id"].asString() : "";
43
children_count_ = root["folder"]["childCount"].asInt();
45
for (const auto & thumbnail: root["thumbnails"]) {
46
thumbnails_.large_url = thumbnail["large"]["url"].asString();
47
thumbnails_.medium_url = thumbnail["medium"]["url"].asString();
48
thumbnails_.small_url = thumbnail["small"]["url"].asString();
51
cout << "id: " << id_ << " name: " << name_ << " etag: " << etag_ << endl;
73
thumbnail_set thumbnails_;
76
CloudFolder::CloudFolder(const json::Value &root)
80
CloudFolder::~CloudFolder() {
83
const string &CloudFolder::id() const {
87
const string &CloudFolder::name() const {
91
const string &CloudFolder::created_date() const {
92
return p->created_date_;
95
const string &CloudFolder::updated_date() const {
96
return p->updated_date_;
99
const string &CloudFolder::download_url() const {
100
return p->download_url_;
103
const string &CloudFolder::parent_folder_id() const {
104
return p->folder_id_;
107
int CloudFolder::children_count() const {
108
return p->children_count_;
111
const string &CloudFolder::etag() const {
115
const string &CloudFolder::owner() const {
119
CloudResource::Property CloudFolder::property() const {
120
return CloudResource::Property::Folder;
123
const CloudResource::thumbnail_set &CloudFolder::thumbnails() const {
124
return p->thumbnails_;