Commit 0adcbfd1 authored by Paweł Wegner's avatar Paweł Wegner

Box: implemented getGeneralData.

parent 8a620312
......@@ -115,6 +115,15 @@ IItem::Pointer Box::uploadFileResponse(const IItem&, const std::string&,
return toItem(util::json::from_stream(response)["entries"][0]);
}
GeneralData Box::getGeneralDataResponse(std::istream& response) const {
auto json = util::json::from_stream(response);
GeneralData data;
data.space_used_ = json["space_used"].asUInt64();
data.space_total_ = json["space_amount"].asUInt64();
data.username_ = json["login"].asString();
return data;
}
IHttpRequest::Pointer Box::downloadFileRequest(const IItem& item,
std::ostream&) const {
return http()->create(
......@@ -183,6 +192,10 @@ IHttpRequest::Pointer Box::renameItemRequest(const IItem& item,
return request;
}
IHttpRequest::Pointer Box::getGeneralDataRequest(std::ostream&) const {
return http()->create(endpoint() + "/2.0/users/me");
}
IItem::Pointer Box::getItemDataResponse(std::istream& stream) const {
return toItem(util::json::from_stream(stream));
}
......
......@@ -63,6 +63,7 @@ class Box : 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::vector<IItem::Pointer> listDirectoryResponse(
......@@ -73,6 +74,7 @@ class Box : 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