Commit fd8c08d2 authored by Paweł Wegner's avatar Paweł Wegner

PCloud: implemented getGeneralData.

parent dcc6c40c
......@@ -100,6 +100,15 @@ IItem::Pointer PCloud::uploadFileResponse(const IItem&, const std::string&,
return toItem(util::json::from_stream(response)["metadata"][0]);
}
GeneralData PCloud::getGeneralDataResponse(std::istream& response) const {
auto json = util::json::from_stream(response);
GeneralData data;
data.space_total_ = json["quota"].asUInt64();
data.space_used_ = json["usedquota"].asUInt64();
data.username_ = json["email"].asString();
return data;
}
IHttpRequest::Pointer PCloud::listDirectoryRequest(const IItem& item,
const std::string&,
std::ostream&) const {
......@@ -187,6 +196,10 @@ IHttpRequest::Pointer PCloud::renameItemRequest(const IItem& item,
}
}
IHttpRequest::Pointer PCloud::getGeneralDataRequest(std::ostream&) const {
return http()->create(endpoint() + "/userinfo");
}
std::vector<IItem::Pointer> PCloud::listDirectoryResponse(
const IItem&, std::istream& response, std::string&) const {
auto json = util::json::from_stream(response);
......
......@@ -63,6 +63,7 @@ class PCloud : 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;
std::vector<IItem::Pointer> listDirectoryResponse(
const IItem&, std::istream&, std::string& next_page_token) const override;
......@@ -73,6 +74,7 @@ class PCloud : public CloudProvider {
IItem::Pointer uploadFileResponse(const IItem& parent,
const std::string& filename, uint64_t,
std::istream& response) const override;
GeneralData getGeneralDataResponse(std::istream& response) const override;
IItem::Pointer toItem(const Json::Value&) const;
......
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