Skip to content
Merged
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
118 changes: 118 additions & 0 deletions docs/openrpc/openrpc/discovery.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,124 @@
}
}
]
},
{
"name": "watchedV2",
"summary": "Notify the platform that content was partially or completely watched, returns whether the notification was accepted",
"tags": [
{
"name": "polymorphic-reducer"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:discovery:watched"
]
}
],
"params": [
{
"name": "entityId",
"required": true,
"schema": {
"type": "string"
},
"summary": "The entity Id of the watched content."
},
{
"name": "progress",
"summary": "How much of the content has been watched (percentage as (0-0.999) for VOD, number of seconds for live)",
"schema": {
"type": "number",
"minimum": 0
}
},
{
"name": "completed",
"summary": "Whether or not this viewing is considered \"complete,\" per the app's definition thereof",
"schema": {
"type": "boolean"
}
},
{
"name": "watchedOn",
"summary": "Date/Time the content was watched, ISO 8601 Date/Time",
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "agePolicy",
"description": "The age policy associated with the watch event. The age policy describes the age groups to which content may be directed.",
"schema": {
"$ref": "https://meta.comcast.com/firebolt/policies#/definitions/AgePolicy"
}
}
],
"result": {
"name": "result",
"summary": "Whether the platform accepted the watched notification",
"schema": {
"type": "boolean"
}
},
"examples": [
{
"name": "Notify the platform of watched content (v2)",
"params": [
{
"name": "entityId",
"value": "partner.com/entity/123"
},
{
"name": "progress",
"value": 0.95
},
{
"name": "completed",
"value": true
},
{
"name": "watchedOn",
"value": "2021-04-23T18:25:43.511Z"
}
],
"result": {
"name": "result",
"value": true
}
},
{
"name": "Notify the platform that child-directed content was watched (v2)",
"params": [
{
"name": "entityId",
"value": "partner.com/entity/123"
},
{
"name": "progress",
"value": 0.95
},
{
"name": "completed",
"value": true
},
{
"name": "watchedOn",
"value": "2021-04-23T18:25:43.511Z"
},
{
"name": "agePolicy",
"value": "app:child"
}
],
"result": {
"name": "result",
"value": true
}
}
]
}
]
}
118 changes: 118 additions & 0 deletions docs/openrpc/the-spec/firebolt-open-rpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,124 @@
}
]
},
{
"name": "Discovery.watchedV2",
"summary": "Notify the platform that content was partially or completely watched, returns whether the notification was accepted",
"tags": [
{
"name": "polymorphic-reducer"
},
{
"name": "capabilities",
"x-uses": [
"xrn:firebolt:capability:discovery:watched"
]
}
],
"params": [
{
"name": "entityId",
"required": true,
"schema": {
"type": "string"
},
"summary": "The entity Id of the watched content."
},
{
"name": "progress",
"summary": "How much of the content has been watched (percentage as (0-0.999) for VOD, number of seconds for live)",
"schema": {
"type": "number",
"minimum": 0
}
},
{
"name": "completed",
"summary": "Whether or not this viewing is considered \"complete,\" per the app's definition thereof",
"schema": {
"type": "boolean"
}
},
{
"name": "watchedOn",
"summary": "Date/Time the content was watched, ISO 8601 Date/Time",
"schema": {
"type": "string",
"format": "date-time"
}
},
{
"name": "agePolicy",
"description": "The age policy associated with the watch event. The age policy describes the age groups to which content may be directed.",
"schema": {
"$ref": "#/x-schemas/Policies/AgePolicy"
}
}
],
"result": {
"name": "result",
"summary": "Whether the platform accepted the watched notification",
"schema": {
"type": "boolean"
}
},
"examples": [
{
"name": "Notify the platform of watched content (v2)",
"params": [
{
"name": "entityId",
"value": "partner.com/entity/123"
},
{
"name": "progress",
"value": 0.95
},
{
"name": "completed",
"value": true
},
{
"name": "watchedOn",
"value": "2021-04-23T18:25:43.511Z"
}
],
"result": {
"name": "result",
"value": true
}
},
{
"name": "Notify the platform that child-directed content was watched (v2)",
"params": [
{
"name": "entityId",
"value": "partner.com/entity/123"
},
{
"name": "progress",
"value": 0.95
},
{
"name": "completed",
"value": true
},
{
"name": "watchedOn",
"value": "2021-04-23T18:25:43.511Z"
},
{
"name": "agePolicy",
"value": "app:child"
}
],
"result": {
"name": "result",
"value": true
}
}
]
},
{
"name": "Display.edid",
"summary": "Returns the EDID (and extensions) of the connected or integral display, as a Base64 encoded string",
Expand Down
18 changes: 18 additions & 0 deletions include/firebolt/discovery.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,23 @@ class IDiscovery
virtual Result<void> watched(const std::string& entityId, std::optional<double> progress,
std::optional<bool> completed, std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const = 0;

/**
* @brief Notify the platform that content was partially or completely watched, returns whether the notification
* was accepted
*
* @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
* seconds for live)
* @param[in] completed : Whether or not this viewing is considered "complete" per the app's definition thereof
* @param[in] watchedOn : The ISO 8601 timestamp of when the content was watched
* @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
*/
virtual Result<bool> watchedV2(const std::string& entityId, std::optional<double> progress,
std::optional<bool> completed, std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const = 0;
};
} // namespace Firebolt::Discovery
26 changes: 26 additions & 0 deletions src/discovery_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,30 @@ Result<void> DiscoveryImpl::watched(const std::string& entityId, std::optional<d

return helper_.invoke("Discovery.watched", parameters);
}

Result<bool> 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
{
nlohmann::json parameters;
parameters["entityId"] = entityId;
if (progress)
{
parameters["progress"] = *progress;
}
if (completed)
{
parameters["completed"] = *completed;
}
if (watchedOn)
{
parameters["watchedOn"] = *watchedOn;
}
if (agePolicy)
{
parameters["agePolicy"] = Firebolt::JSON::toString(Firebolt::JsonData::AgePolicyEnum, *agePolicy);
}

return helper_.get<Firebolt::JSON::Boolean, bool>("Discovery.watchedV2", parameters);
}
} // namespace Firebolt::Discovery
4 changes: 4 additions & 0 deletions src/discovery_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ 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,
std::optional<std::string> watchedOn,
std::optional<Firebolt::AgePolicy> agePolicy) const override;

private:
Firebolt::Helpers::IHelper& helper_;
};
Expand Down
26 changes: 26 additions & 0 deletions test/api_test_app/apis/discoveryDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ DiscoveryDemo::DiscoveryDemo()
: DemoBase("Discovery")
{
methods_.push_back("Discovery.watched");
methods_.push_back("Discovery.watchedV2");
}

void DiscoveryDemo::runOption(const std::string& method)
Expand Down Expand Up @@ -64,4 +65,29 @@ void DiscoveryDemo::runOption(const std::string& method)
std::cout << "Discovery.watched: Success" << std::endl;
}
}
else if (method == "Discovery.watchedV2")
{
std::string entityId = paramFromConsole("entityId", "exampleEntityId");
std::optional<double> progress = 0.5;
try
{
progress = std::stod(
paramFromConsole("progress (percentage as (0-0.999) for VOD, number of seconds for live)", "0.5"));
}
catch (const std::exception&)
{
}
std::optional<bool> completed = paramFromConsole("completed (true/false)", "false") == "true";
std::string watchedOn = paramFromConsole("watchedOn (ISO 8601 timestamp)", "2024-01-01T00:00:00Z");

std::optional<Firebolt::AgePolicy> agePolicyOpt =
chooseEnumFromList(Firebolt::JsonData::AgePolicyEnum, "Choose an age policy for the watch event:");

auto r = Firebolt::IFireboltAccessor::Instance().DiscoveryInterface().watchedV2(entityId, progress, completed,
watchedOn, agePolicyOpt);
if (succeed(r))
{
std::cout << "Discovery.watchedV2: " << (*r ? "true" : "false") << std::endl;
}
}
}
13 changes: 13 additions & 0 deletions test/component/discoveryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@

#include "firebolt/discovery.h"
#include "firebolt/firebolt.h"
#include "json_engine.h"
#include <gtest/gtest.h>

class DiscoveryCTest : public ::testing::Test
{
protected:
JsonEngine jsonEngine;
};

TEST_F(DiscoveryCTest, Watched)
Expand All @@ -31,3 +34,13 @@ TEST_F(DiscoveryCTest, Watched)
Firebolt::AgePolicy::ADULT);
ASSERT_TRUE(result) << "Failed to call 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>());
}
Comment thread
swethasukumarr marked this conversation as resolved.
Loading
Loading