Commit 8a620312 authored by Paweł Wegner's avatar Paweł Wegner

GoogleDrive: implemented getGeneralData.

parent e42b92af
......@@ -283,6 +283,12 @@ IHttpRequest::Pointer GoogleDrive::renameItemRequest(
return request;
}
IHttpRequest::Pointer GoogleDrive::getGeneralDataRequest(std::ostream&) const {
auto request = http()->create(endpoint() + "/drive/v3/about");
request->setParameter("fields", "user,storageQuota");
return request;
}
IItem::Pointer GoogleDrive::getItemDataResponse(std::istream& response) const {
return toItem(util::json::from_stream(response));
}
......@@ -303,6 +309,15 @@ std::vector<IItem::Pointer> GoogleDrive::listDirectoryResponse(
return result;
}
GeneralData GoogleDrive::getGeneralDataResponse(std::istream& response) const {
auto json = util::json::from_stream(response);
GeneralData data;
data.space_total_ = std::stoull(json["storageQuota"]["limit"].asString());
data.space_used_ = std::stoull(json["storageQuota"]["usage"].asString());
data.username_ = json["user"]["emailAddress"].asString();
return data;
}
IHttpRequest::Pointer GoogleDrive::upload(const IItem& f,
const std::string& url,
const std::string& method,
......
......@@ -65,6 +65,7 @@ class GoogleDrive : public CloudProvider {
std::ostream&) const override;
IHttpRequest::Pointer renameItemRequest(const IItem&, const std::string& name,
std::ostream&) const override;
IHttpRequest::Pointer getGeneralDataRequest(std::ostream&) const override;
IItem::Pointer getItemDataResponse(std::istream& response) const override;
std::string getItemUrlResponse(const IItem& item,
......@@ -72,6 +73,7 @@ class GoogleDrive : public CloudProvider {
std::istream& response) const override;
std::vector<IItem::Pointer> listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
GeneralData getGeneralDataResponse(std::istream& response) const override;
IHttpRequest::Pointer upload(const IItem& f, const std::string& url,
const std::string& method,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment