diff --git a/docs/openrpc/openrpc/discovery.json b/docs/openrpc/openrpc/discovery.json index ac06280..bff6a97 100644 --- a/docs/openrpc/openrpc/discovery.json +++ b/docs/openrpc/openrpc/discovery.json @@ -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" @@ -180,9 +180,8 @@ ], "result": { "name": "result", - "summary": "Whether the platform accepted the watched notification", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -208,7 +207,7 @@ ], "result": { "name": "result", - "value": true + "value": null } }, { @@ -237,7 +236,7 @@ ], "result": { "name": "result", - "value": true + "value": null } } ] diff --git a/docs/openrpc/the-spec/firebolt-open-rpc.json b/docs/openrpc/the-spec/firebolt-open-rpc.json index 698d4f1..48e5e40 100644 --- a/docs/openrpc/the-spec/firebolt-open-rpc.json +++ b/docs/openrpc/the-spec/firebolt-open-rpc.json @@ -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" @@ -701,9 +701,8 @@ ], "result": { "name": "result", - "summary": "Whether the platform accepted the watched notification", "schema": { - "type": "boolean" + "type": "null" } }, "examples": [ @@ -729,7 +728,7 @@ ], "result": { "name": "result", - "value": true + "value": null } }, { @@ -758,7 +757,7 @@ ], "result": { "name": "result", - "value": true + "value": null } } ] diff --git a/include/firebolt/discovery.h b/include/firebolt/discovery.h index a3e9982..d9e2ae8 100644 --- a/include/firebolt/discovery.h +++ b/include/firebolt/discovery.h @@ -46,8 +46,7 @@ class IDiscovery std::optional 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 @@ -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 watchedV2(const std::string& entityId, std::optional progress, + virtual Result watchedV2(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, std::optional agePolicy) const = 0; }; diff --git a/src/discovery_impl.cpp b/src/discovery_impl.cpp index 67b0f5b..77095ca 100644 --- a/src/discovery_impl.cpp +++ b/src/discovery_impl.cpp @@ -53,7 +53,7 @@ Result DiscoveryImpl::watched(const std::string& entityId, std::optional("Discovery.watched", parameters); } -Result DiscoveryImpl::watchedV2(const std::string& entityId, std::optional progress, +Result DiscoveryImpl::watchedV2(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, std::optional agePolicy) const { @@ -76,6 +76,6 @@ Result DiscoveryImpl::watchedV2(const std::string& entityId, std::optional parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy); } - return helper_.get("Discovery.watchedV2", parameters); + return helper_.invoke("Discovery.watchedV2", parameters); } } // namespace Firebolt::Discovery diff --git a/src/discovery_impl.h b/src/discovery_impl.h index 7710e40..285186e 100644 --- a/src/discovery_impl.h +++ b/src/discovery_impl.h @@ -37,7 +37,7 @@ class DiscoveryImpl : public IDiscovery std::optional watchedOn, std::optional agePolicy) const override; - Result watchedV2(const std::string& entityId, std::optional progress, std::optional completed, + Result watchedV2(const std::string& entityId, std::optional progress, std::optional completed, std::optional watchedOn, std::optional agePolicy) const override; diff --git a/test/api_test_app/apis/discoveryDemo.cpp b/test/api_test_app/apis/discoveryDemo.cpp index 932785c..8c8d0ea 100644 --- a/test/api_test_app/apis/discoveryDemo.cpp +++ b/test/api_test_app/apis/discoveryDemo.cpp @@ -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; } } } diff --git a/test/component/discoveryTest.cpp b/test/component/discoveryTest.cpp index bdab3a5..8caf34f 100644 --- a/test/component/discoveryTest.cpp +++ b/test/component/discoveryTest.cpp @@ -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()); } diff --git a/test/unit/discoveryTest.cpp b/test/unit/discoveryTest.cpp index edba6d9..e16fe3a 100644 --- a/test/unit/discoveryTest.cpp +++ b/test/unit/discoveryTest.cpp @@ -78,7 +78,7 @@ TEST_F(DiscoveryUTest, watched_payload) TEST_F(DiscoveryUTest, watchedV2) { - mock("Discovery.watchedV2"); + mockInvoke("Discovery.watchedV2"); std::string entityId = "content123"; std::optional progress = 0.75f; std::optional completed = true; @@ -86,7 +86,6 @@ TEST_F(DiscoveryUTest, watchedV2) std::optional 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) @@ -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(true)}; + return Firebolt::Result{Firebolt::Error::None}; })); std::string entityId = "content123"; std::optional progress = 0.75f; @@ -112,5 +111,4 @@ TEST_F(DiscoveryUTest, watchedV2_payload) std::optional agePolicy = Firebolt::AgePolicy::ADULT; auto result = discoveryImpl_.watchedV2(entityId, progress, completed, watchedOn, agePolicy); ASSERT_TRUE(result) << "Error on watchedV2"; - EXPECT_TRUE(*result); }