Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions docs/openrpc/openrpc/discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
},
{
"name": "watchedV2",
"summary": "Notify the platform that content was partially or completely watched, returns whether the notification was accepted",
"summary": "Notify the platform that content was partially or completely watched",
"tags": [
{
"name": "polymorphic-reducer"
Expand Down Expand Up @@ -180,9 +180,8 @@
],
"result": {
"name": "result",
"summary": "Whether the platform accepted the watched notification",
"schema": {
"type": "boolean"
"type": "null"
}
Comment thread
swethasukumarr marked this conversation as resolved.
},
"examples": [
Expand All @@ -208,7 +207,7 @@
],
"result": {
"name": "result",
"value": true
"value": null
}
},
{
Expand Down Expand Up @@ -237,7 +236,7 @@
],
"result": {
"name": "result",
"value": true
"value": null
}
}
]
Expand Down
9 changes: 4 additions & 5 deletions docs/openrpc/the-spec/firebolt-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@
},
{
"name": "Discovery.watchedV2",
"summary": "Notify the platform that content was partially or completely watched, returns whether the notification was accepted",
"summary": "Notify the platform that content was partially or completely watched",
"tags": [
{
"name": "polymorphic-reducer"
Expand Down Expand Up @@ -701,9 +701,8 @@
],
"result": {
"name": "result",
"summary": "Whether the platform accepted the watched notification",
"schema": {
"type": "boolean"
"type": "null"
}
Comment thread
swethasukumarr marked this conversation as resolved.
},
"examples": [
Expand All @@ -729,7 +728,7 @@
],
"result": {
"name": "result",
"value": true
"value": null
}
},
{
Expand Down Expand Up @@ -758,7 +757,7 @@
],
"result": {
"name": "result",
"value": true
"value": null
}
}
]
Expand Down
7 changes: 3 additions & 4 deletions include/firebolt/discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ class IDiscovery
std::optional<Firebolt::AgePolicy> agePolicy) const = 0;

/**
* @brief Notify the platform that content was partially or completely watched, returns whether the notification
* was accepted
* @brief Notify the platform that content was partially or completely watched
*
* @param[in] entityId : The entity Id of the watched content
* @param[in] progress : How much of the content has been watched (percentage as (0-0.999) for VOD, number of
Expand All @@ -57,9 +56,9 @@ class IDiscovery
* @param[in] agePolicy : The age policy associated with the watch event. The age policy describes the age groups
* to which content may be directed
*
* @retval Whether the platform accepted the watched notification, or an error
* @retval An ok Result on success, or an error; no value is returned
*/
virtual Result<bool> watchedV2(const std::string& entityId, std::optional<double> progress,
virtual Result<void> watchedV2(const std::string& entityId, std::optional<double> progress,
Comment thread
swethasukumarr marked this conversation as resolved.
std::optional<bool> completed, std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const = 0;
};
Expand Down
4 changes: 2 additions & 2 deletions src/discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Result<bool> DiscoveryImpl::watched(const std::string& entityId, std::optional<d
return helper_.get<Firebolt::JSON::Boolean, bool>("Discovery.watched", parameters);
}

Result<bool> DiscoveryImpl::watchedV2(const std::string& entityId, std::optional<double> progress,
Result<void> DiscoveryImpl::watchedV2(const std::string& entityId, std::optional<double> progress,
std::optional<bool> completed, std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const
{
Expand All @@ -76,6 +76,6 @@ Result<bool> DiscoveryImpl::watchedV2(const std::string& entityId, std::optional
parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy);
}

return helper_.get<Firebolt::JSON::Boolean, bool>("Discovery.watchedV2", parameters);
return helper_.invoke("Discovery.watchedV2", parameters);
}
} // namespace Firebolt::Discovery
2 changes: 1 addition & 1 deletion src/discovery_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class DiscoveryImpl : public IDiscovery
std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const override;

Result<bool> watchedV2(const std::string& entityId, std::optional<double> progress, std::optional<bool> completed,
Result<void> watchedV2(const std::string& entityId, std::optional<double> progress, std::optional<bool> completed,
std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const override;

Expand Down
2 changes: 1 addition & 1 deletion test/api_test_app/apis/discoveryDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void DiscoveryDemo::runOption(const std::string& method)
watchedOn, agePolicyOpt);
if (succeed(r))
{
std::cout << "Discovery.watchedV2: " << (*r ? "true" : "false") << std::endl;
std::cout << "Discovery.watchedV2: Success" << std::endl;
}
}
}
2 changes: 0 additions & 2 deletions test/component/discoveryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ TEST_F(DiscoveryCTest, Watched)

TEST_F(DiscoveryCTest, WatchedV2)
{
auto expectedValue = jsonEngine.get_value("Discovery.watchedV2");
auto result = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watchedV2("entity123", 0.75f, true,
"2024-10-01T12:00:00Z",
Firebolt::AgePolicy::ADULT);
ASSERT_TRUE(result) << "Failed to call watchedV2";
EXPECT_EQ(*result, expectedValue.get<bool>());
}
8 changes: 3 additions & 5 deletions test/unit/discoveryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,14 @@ TEST_F(DiscoveryUTest, watched_payload)

TEST_F(DiscoveryUTest, watchedV2)
{
mock("Discovery.watchedV2");
mockInvoke("Discovery.watchedV2");
std::string entityId = "content123";
std::optional<double> progress = 0.75f;
std::optional<bool> completed = true;
std::optional<std::string> watchedOn = "2024-06-01T12:00:00Z";
std::optional<Firebolt::AgePolicy> agePolicy = Firebolt::AgePolicy::ADULT;
auto result = discoveryImpl_.watchedV2(entityId, progress, completed, watchedOn, agePolicy);
ASSERT_TRUE(result) << "Error on watchedV2";
EXPECT_TRUE(*result);
}

TEST_F(DiscoveryUTest, watchedV2_payload)
Expand All @@ -97,13 +96,13 @@ TEST_F(DiscoveryUTest, watchedV2_payload)
expected["completed"] = true;
expected["watchedOn"] = "2024-06-01T12:00:00Z";
expected["agePolicy"] = "app:adult";
EXPECT_CALL(mockHelper, getJson("Discovery.watchedV2", _))
EXPECT_CALL(mockHelper, invoke("Discovery.watchedV2", _))
.WillOnce(Invoke(
[&](const std::string& /* methodName */, const nlohmann::json& parameters)
{
EXPECT_EQ(parameters, expected) << "Parameters do not match expected payload: " << expected.dump()
<< " but got: " << parameters.dump();
return Firebolt::Result<nlohmann::json>{nlohmann::json(true)};
return Firebolt::Result<void>{Firebolt::Error::None};
}));
std::string entityId = "content123";
std::optional<double> progress = 0.75f;
Expand All @@ -112,5 +111,4 @@ TEST_F(DiscoveryUTest, watchedV2_payload)
std::optional<Firebolt::AgePolicy> agePolicy = Firebolt::AgePolicy::ADULT;
auto result = discoveryImpl_.watchedV2(entityId, progress, completed, watchedOn, agePolicy);
ASSERT_TRUE(result) << "Error on watchedV2";
EXPECT_TRUE(*result);
}
Loading