@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
1,110 lines • 125 kB
JavaScript
"use strict";
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.
// versions:
// protoc-gen-ts_proto v1.181.2
// protoc v3.21.12
// source: google/ads/googleads/v19/services/reach_plan_service.proto
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReachPlanServiceClient = exports.ReachPlanServiceService = exports.TargetFrequencySettings = exports.SurfaceTargeting = exports.SurfaceTargetingCombinations = exports.YouTubeSelectLineUp = exports.YouTubeSelectSettings = exports.AdvancedProductTargeting = exports.AudienceTargeting = exports.ForecastMetricOptions = exports.EffectiveFrequencyBreakdown = exports.OnTargetAudienceMetrics = exports.PlannedProductForecast = exports.PlannedProductReachForecast = exports.Forecast = exports.ReachForecast = exports.ReachCurve = exports.GenerateReachForecastResponse = exports.PlannedProduct = exports.CampaignDuration = exports.Targeting = exports.FrequencyCap = exports.EffectiveFrequencyLimit = exports.GenerateReachForecastRequest = exports.PlannableTargeting = exports.ProductMetadata = exports.ListPlannableProductsResponse = exports.ListPlannableProductsRequest = exports.PlannableLocation = exports.ListPlannableLocationsResponse = exports.ListPlannableLocationsRequest = void 0;
/* eslint-disable */
const grpc_js_1 = require("@grpc/grpc-js");
const long_1 = __importDefault(require("long"));
const minimal_js_1 = __importDefault(require("protobufjs/minimal.js"));
const criteria_js_1 = require("../common/criteria.js");
const dates_js_1 = require("../common/dates.js");
const frequency_cap_time_unit_js_1 = require("../enums/frequency_cap_time_unit.js");
const reach_plan_age_range_js_1 = require("../enums/reach_plan_age_range.js");
const reach_plan_network_js_1 = require("../enums/reach_plan_network.js");
const reach_plan_surface_js_1 = require("../enums/reach_plan_surface.js");
const target_frequency_time_unit_js_1 = require("../enums/target_frequency_time_unit.js");
function createBaseListPlannableLocationsRequest() {
return {};
}
exports.ListPlannableLocationsRequest = {
encode(_, writer = minimal_js_1.default.Writer.create()) {
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListPlannableLocationsRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(_) {
return {};
},
toJSON(_) {
const obj = {};
return obj;
},
create(base) {
return exports.ListPlannableLocationsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(_) {
const message = createBaseListPlannableLocationsRequest();
return message;
},
};
function createBaseListPlannableLocationsResponse() {
return { plannable_locations: [] };
}
exports.ListPlannableLocationsResponse = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.plannable_locations !== undefined && message.plannable_locations.length !== 0) {
for (const v of message.plannable_locations) {
exports.PlannableLocation.encode(v, writer.uint32(10).fork()).ldelim();
}
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListPlannableLocationsResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.plannable_locations.push(exports.PlannableLocation.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
plannable_locations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.plannable_locations)
? object.plannable_locations.map((e) => exports.PlannableLocation.fromJSON(e))
: [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.plannable_locations) === null || _a === void 0 ? void 0 : _a.length) {
obj.plannable_locations = message.plannable_locations.map((e) => exports.PlannableLocation.toJSON(e));
}
return obj;
},
create(base) {
return exports.ListPlannableLocationsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseListPlannableLocationsResponse();
message.plannable_locations = ((_a = object.plannable_locations) === null || _a === void 0 ? void 0 : _a.map((e) => exports.PlannableLocation.fromPartial(e))) || [];
return message;
},
};
function createBasePlannableLocation() {
return {
id: undefined,
name: undefined,
parent_country_id: undefined,
country_code: undefined,
location_type: undefined,
};
}
exports.PlannableLocation = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.id !== undefined) {
writer.uint32(34).string(message.id);
}
if (message.name !== undefined) {
writer.uint32(42).string(message.name);
}
if (message.parent_country_id !== undefined) {
writer.uint32(48).int64(message.parent_country_id);
}
if (message.country_code !== undefined) {
writer.uint32(58).string(message.country_code);
}
if (message.location_type !== undefined) {
writer.uint32(66).string(message.location_type);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePlannableLocation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 4:
if (tag !== 34) {
break;
}
message.id = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.name = reader.string();
continue;
case 6:
if (tag !== 48) {
break;
}
message.parent_country_id = longToString(reader.int64());
continue;
case 7:
if (tag !== 58) {
break;
}
message.country_code = reader.string();
continue;
case 8:
if (tag !== 66) {
break;
}
message.location_type = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
id: isSet(object.id) ? globalThis.String(object.id) : undefined,
name: isSet(object.name) ? globalThis.String(object.name) : undefined,
parent_country_id: isSet(object.parent_country_id) ? globalThis.String(object.parent_country_id) : undefined,
country_code: isSet(object.country_code) ? globalThis.String(object.country_code) : undefined,
location_type: isSet(object.location_type) ? globalThis.String(object.location_type) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.id !== undefined) {
obj.id = message.id;
}
if (message.name !== undefined) {
obj.name = message.name;
}
if (message.parent_country_id !== undefined) {
obj.parent_country_id = message.parent_country_id;
}
if (message.country_code !== undefined) {
obj.country_code = message.country_code;
}
if (message.location_type !== undefined) {
obj.location_type = message.location_type;
}
return obj;
},
create(base) {
return exports.PlannableLocation.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = createBasePlannableLocation();
message.id = (_a = object.id) !== null && _a !== void 0 ? _a : undefined;
message.name = (_b = object.name) !== null && _b !== void 0 ? _b : undefined;
message.parent_country_id = (_c = object.parent_country_id) !== null && _c !== void 0 ? _c : undefined;
message.country_code = (_d = object.country_code) !== null && _d !== void 0 ? _d : undefined;
message.location_type = (_e = object.location_type) !== null && _e !== void 0 ? _e : undefined;
return message;
},
};
function createBaseListPlannableProductsRequest() {
return { plannable_location_id: "" };
}
exports.ListPlannableProductsRequest = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.plannable_location_id !== undefined && message.plannable_location_id !== "") {
writer.uint32(18).string(message.plannable_location_id);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListPlannableProductsRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 2:
if (tag !== 18) {
break;
}
message.plannable_location_id = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
plannable_location_id: isSet(object.plannable_location_id) ? globalThis.String(object.plannable_location_id) : "",
};
},
toJSON(message) {
const obj = {};
if (message.plannable_location_id !== undefined && message.plannable_location_id !== "") {
obj.plannable_location_id = message.plannable_location_id;
}
return obj;
},
create(base) {
return exports.ListPlannableProductsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseListPlannableProductsRequest();
message.plannable_location_id = (_a = object.plannable_location_id) !== null && _a !== void 0 ? _a : "";
return message;
},
};
function createBaseListPlannableProductsResponse() {
return { product_metadata: [] };
}
exports.ListPlannableProductsResponse = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.product_metadata !== undefined && message.product_metadata.length !== 0) {
for (const v of message.product_metadata) {
exports.ProductMetadata.encode(v, writer.uint32(10).fork()).ldelim();
}
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListPlannableProductsResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.product_metadata.push(exports.ProductMetadata.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
product_metadata: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.product_metadata)
? object.product_metadata.map((e) => exports.ProductMetadata.fromJSON(e))
: [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.product_metadata) === null || _a === void 0 ? void 0 : _a.length) {
obj.product_metadata = message.product_metadata.map((e) => exports.ProductMetadata.toJSON(e));
}
return obj;
},
create(base) {
return exports.ListPlannableProductsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseListPlannableProductsResponse();
message.product_metadata = ((_a = object.product_metadata) === null || _a === void 0 ? void 0 : _a.map((e) => exports.ProductMetadata.fromPartial(e))) || [];
return message;
},
};
function createBaseProductMetadata() {
return { plannable_product_code: undefined, plannable_product_name: "", plannable_targeting: undefined };
}
exports.ProductMetadata = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.plannable_product_code !== undefined) {
writer.uint32(34).string(message.plannable_product_code);
}
if (message.plannable_product_name !== undefined && message.plannable_product_name !== "") {
writer.uint32(26).string(message.plannable_product_name);
}
if (message.plannable_targeting !== undefined) {
exports.PlannableTargeting.encode(message.plannable_targeting, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseProductMetadata();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 4:
if (tag !== 34) {
break;
}
message.plannable_product_code = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.plannable_product_name = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.plannable_targeting = exports.PlannableTargeting.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
plannable_product_code: isSet(object.plannable_product_code)
? globalThis.String(object.plannable_product_code)
: undefined,
plannable_product_name: isSet(object.plannable_product_name)
? globalThis.String(object.plannable_product_name)
: "",
plannable_targeting: isSet(object.plannable_targeting)
? exports.PlannableTargeting.fromJSON(object.plannable_targeting)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.plannable_product_code !== undefined) {
obj.plannable_product_code = message.plannable_product_code;
}
if (message.plannable_product_name !== undefined && message.plannable_product_name !== "") {
obj.plannable_product_name = message.plannable_product_name;
}
if (message.plannable_targeting !== undefined) {
obj.plannable_targeting = exports.PlannableTargeting.toJSON(message.plannable_targeting);
}
return obj;
},
create(base) {
return exports.ProductMetadata.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseProductMetadata();
message.plannable_product_code = (_a = object.plannable_product_code) !== null && _a !== void 0 ? _a : undefined;
message.plannable_product_name = (_b = object.plannable_product_name) !== null && _b !== void 0 ? _b : "";
message.plannable_targeting = (object.plannable_targeting !== undefined && object.plannable_targeting !== null)
? exports.PlannableTargeting.fromPartial(object.plannable_targeting)
: undefined;
return message;
},
};
function createBasePlannableTargeting() {
return {
age_ranges: [],
genders: [],
devices: [],
networks: [],
youtube_select_lineups: [],
surface_targeting: undefined,
};
}
exports.PlannableTargeting = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.age_ranges !== undefined && message.age_ranges.length !== 0) {
writer.uint32(10).fork();
for (const v of message.age_ranges) {
writer.int32(v);
}
writer.ldelim();
}
if (message.genders !== undefined && message.genders.length !== 0) {
for (const v of message.genders) {
criteria_js_1.GenderInfo.encode(v, writer.uint32(18).fork()).ldelim();
}
}
if (message.devices !== undefined && message.devices.length !== 0) {
for (const v of message.devices) {
criteria_js_1.DeviceInfo.encode(v, writer.uint32(26).fork()).ldelim();
}
}
if (message.networks !== undefined && message.networks.length !== 0) {
writer.uint32(34).fork();
for (const v of message.networks) {
writer.int32(v);
}
writer.ldelim();
}
if (message.youtube_select_lineups !== undefined && message.youtube_select_lineups.length !== 0) {
for (const v of message.youtube_select_lineups) {
exports.YouTubeSelectLineUp.encode(v, writer.uint32(42).fork()).ldelim();
}
}
if (message.surface_targeting !== undefined) {
exports.SurfaceTargetingCombinations.encode(message.surface_targeting, writer.uint32(50).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBasePlannableTargeting();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag === 8) {
message.age_ranges.push(reader.int32());
continue;
}
if (tag === 10) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.age_ranges.push(reader.int32());
}
continue;
}
break;
case 2:
if (tag !== 18) {
break;
}
message.genders.push(criteria_js_1.GenderInfo.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 26) {
break;
}
message.devices.push(criteria_js_1.DeviceInfo.decode(reader, reader.uint32()));
continue;
case 4:
if (tag === 32) {
message.networks.push(reader.int32());
continue;
}
if (tag === 34) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.networks.push(reader.int32());
}
continue;
}
break;
case 5:
if (tag !== 42) {
break;
}
message.youtube_select_lineups.push(exports.YouTubeSelectLineUp.decode(reader, reader.uint32()));
continue;
case 6:
if (tag !== 50) {
break;
}
message.surface_targeting = exports.SurfaceTargetingCombinations.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
age_ranges: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.age_ranges)
? object.age_ranges.map((e) => (0, reach_plan_age_range_js_1.reachPlanAgeRangeEnum_ReachPlanAgeRangeFromJSON)(e))
: [],
genders: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.genders) ? object.genders.map((e) => criteria_js_1.GenderInfo.fromJSON(e)) : [],
devices: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.devices) ? object.devices.map((e) => criteria_js_1.DeviceInfo.fromJSON(e)) : [],
networks: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.networks)
? object.networks.map((e) => (0, reach_plan_network_js_1.reachPlanNetworkEnum_ReachPlanNetworkFromJSON)(e))
: [],
youtube_select_lineups: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.youtube_select_lineups)
? object.youtube_select_lineups.map((e) => exports.YouTubeSelectLineUp.fromJSON(e))
: [],
surface_targeting: isSet(object.surface_targeting)
? exports.SurfaceTargetingCombinations.fromJSON(object.surface_targeting)
: undefined,
};
},
toJSON(message) {
var _a, _b, _c, _d, _e;
const obj = {};
if ((_a = message.age_ranges) === null || _a === void 0 ? void 0 : _a.length) {
obj.age_ranges = message.age_ranges.map((e) => (0, reach_plan_age_range_js_1.reachPlanAgeRangeEnum_ReachPlanAgeRangeToJSON)(e));
}
if ((_b = message.genders) === null || _b === void 0 ? void 0 : _b.length) {
obj.genders = message.genders.map((e) => criteria_js_1.GenderInfo.toJSON(e));
}
if ((_c = message.devices) === null || _c === void 0 ? void 0 : _c.length) {
obj.devices = message.devices.map((e) => criteria_js_1.DeviceInfo.toJSON(e));
}
if ((_d = message.networks) === null || _d === void 0 ? void 0 : _d.length) {
obj.networks = message.networks.map((e) => (0, reach_plan_network_js_1.reachPlanNetworkEnum_ReachPlanNetworkToJSON)(e));
}
if ((_e = message.youtube_select_lineups) === null || _e === void 0 ? void 0 : _e.length) {
obj.youtube_select_lineups = message.youtube_select_lineups.map((e) => exports.YouTubeSelectLineUp.toJSON(e));
}
if (message.surface_targeting !== undefined) {
obj.surface_targeting = exports.SurfaceTargetingCombinations.toJSON(message.surface_targeting);
}
return obj;
},
create(base) {
return exports.PlannableTargeting.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = createBasePlannableTargeting();
message.age_ranges = ((_a = object.age_ranges) === null || _a === void 0 ? void 0 : _a.map((e) => e)) || [];
message.genders = ((_b = object.genders) === null || _b === void 0 ? void 0 : _b.map((e) => criteria_js_1.GenderInfo.fromPartial(e))) || [];
message.devices = ((_c = object.devices) === null || _c === void 0 ? void 0 : _c.map((e) => criteria_js_1.DeviceInfo.fromPartial(e))) || [];
message.networks = ((_d = object.networks) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || [];
message.youtube_select_lineups = ((_e = object.youtube_select_lineups) === null || _e === void 0 ? void 0 : _e.map((e) => exports.YouTubeSelectLineUp.fromPartial(e))) ||
[];
message.surface_targeting = (object.surface_targeting !== undefined && object.surface_targeting !== null)
? exports.SurfaceTargetingCombinations.fromPartial(object.surface_targeting)
: undefined;
return message;
},
};
function createBaseGenerateReachForecastRequest() {
return {
customer_id: "",
currency_code: undefined,
campaign_duration: undefined,
cookie_frequency_cap: undefined,
cookie_frequency_cap_setting: undefined,
min_effective_frequency: undefined,
effective_frequency_limit: undefined,
targeting: undefined,
planned_products: [],
forecast_metric_options: undefined,
customer_reach_group: undefined,
};
}
exports.GenerateReachForecastRequest = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.currency_code !== undefined) {
writer.uint32(74).string(message.currency_code);
}
if (message.campaign_duration !== undefined) {
exports.CampaignDuration.encode(message.campaign_duration, writer.uint32(26).fork()).ldelim();
}
if (message.cookie_frequency_cap !== undefined) {
writer.uint32(80).int32(message.cookie_frequency_cap);
}
if (message.cookie_frequency_cap_setting !== undefined) {
exports.FrequencyCap.encode(message.cookie_frequency_cap_setting, writer.uint32(66).fork()).ldelim();
}
if (message.min_effective_frequency !== undefined) {
writer.uint32(88).int32(message.min_effective_frequency);
}
if (message.effective_frequency_limit !== undefined) {
exports.EffectiveFrequencyLimit.encode(message.effective_frequency_limit, writer.uint32(98).fork()).ldelim();
}
if (message.targeting !== undefined) {
exports.Targeting.encode(message.targeting, writer.uint32(50).fork()).ldelim();
}
if (message.planned_products !== undefined && message.planned_products.length !== 0) {
for (const v of message.planned_products) {
exports.PlannedProduct.encode(v, writer.uint32(58).fork()).ldelim();
}
}
if (message.forecast_metric_options !== undefined) {
exports.ForecastMetricOptions.encode(message.forecast_metric_options, writer.uint32(106).fork()).ldelim();
}
if (message.customer_reach_group !== undefined) {
writer.uint32(114).string(message.customer_reach_group);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateReachForecastRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.customer_id = reader.string();
continue;
case 9:
if (tag !== 74) {
break;
}
message.currency_code = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.campaign_duration = exports.CampaignDuration.decode(reader, reader.uint32());
continue;
case 10:
if (tag !== 80) {
break;
}
message.cookie_frequency_cap = reader.int32();
continue;
case 8:
if (tag !== 66) {
break;
}
message.cookie_frequency_cap_setting = exports.FrequencyCap.decode(reader, reader.uint32());
continue;
case 11:
if (tag !== 88) {
break;
}
message.min_effective_frequency = reader.int32();
continue;
case 12:
if (tag !== 98) {
break;
}
message.effective_frequency_limit = exports.EffectiveFrequencyLimit.decode(reader, reader.uint32());
continue;
case 6:
if (tag !== 50) {
break;
}
message.targeting = exports.Targeting.decode(reader, reader.uint32());
continue;
case 7:
if (tag !== 58) {
break;
}
message.planned_products.push(exports.PlannedProduct.decode(reader, reader.uint32()));
continue;
case 13:
if (tag !== 106) {
break;
}
message.forecast_metric_options = exports.ForecastMetricOptions.decode(reader, reader.uint32());
continue;
case 14:
if (tag !== 114) {
break;
}
message.customer_reach_group = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
customer_id: isSet(object.customer_id) ? globalThis.String(object.customer_id) : "",
currency_code: isSet(object.currency_code) ? globalThis.String(object.currency_code) : undefined,
campaign_duration: isSet(object.campaign_duration)
? exports.CampaignDuration.fromJSON(object.campaign_duration)
: undefined,
cookie_frequency_cap: isSet(object.cookie_frequency_cap)
? globalThis.Number(object.cookie_frequency_cap)
: undefined,
cookie_frequency_cap_setting: isSet(object.cookie_frequency_cap_setting)
? exports.FrequencyCap.fromJSON(object.cookie_frequency_cap_setting)
: undefined,
min_effective_frequency: isSet(object.min_effective_frequency)
? globalThis.Number(object.min_effective_frequency)
: undefined,
effective_frequency_limit: isSet(object.effective_frequency_limit)
? exports.EffectiveFrequencyLimit.fromJSON(object.effective_frequency_limit)
: undefined,
targeting: isSet(object.targeting) ? exports.Targeting.fromJSON(object.targeting) : undefined,
planned_products: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.planned_products)
? object.planned_products.map((e) => exports.PlannedProduct.fromJSON(e))
: [],
forecast_metric_options: isSet(object.forecast_metric_options)
? exports.ForecastMetricOptions.fromJSON(object.forecast_metric_options)
: undefined,
customer_reach_group: isSet(object.customer_reach_group)
? globalThis.String(object.customer_reach_group)
: undefined,
};
},
toJSON(message) {
var _a;
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if (message.currency_code !== undefined) {
obj.currency_code = message.currency_code;
}
if (message.campaign_duration !== undefined) {
obj.campaign_duration = exports.CampaignDuration.toJSON(message.campaign_duration);
}
if (message.cookie_frequency_cap !== undefined) {
obj.cookie_frequency_cap = Math.round(message.cookie_frequency_cap);
}
if (message.cookie_frequency_cap_setting !== undefined) {
obj.cookie_frequency_cap_setting = exports.FrequencyCap.toJSON(message.cookie_frequency_cap_setting);
}
if (message.min_effective_frequency !== undefined) {
obj.min_effective_frequency = Math.round(message.min_effective_frequency);
}
if (message.effective_frequency_limit !== undefined) {
obj.effective_frequency_limit = exports.EffectiveFrequencyLimit.toJSON(message.effective_frequency_limit);
}
if (message.targeting !== undefined) {
obj.targeting = exports.Targeting.toJSON(message.targeting);
}
if ((_a = message.planned_products) === null || _a === void 0 ? void 0 : _a.length) {
obj.planned_products = message.planned_products.map((e) => exports.PlannedProduct.toJSON(e));
}
if (message.forecast_metric_options !== undefined) {
obj.forecast_metric_options = exports.ForecastMetricOptions.toJSON(message.forecast_metric_options);
}
if (message.customer_reach_group !== undefined) {
obj.customer_reach_group = message.customer_reach_group;
}
return obj;
},
create(base) {
return exports.GenerateReachForecastRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f;
const message = createBaseGenerateReachForecastRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.currency_code = (_b = object.currency_code) !== null && _b !== void 0 ? _b : undefined;
message.campaign_duration = (object.campaign_duration !== undefined && object.campaign_duration !== null)
? exports.CampaignDuration.fromPartial(object.campaign_duration)
: undefined;
message.cookie_frequency_cap = (_c = object.cookie_frequency_cap) !== null && _c !== void 0 ? _c : undefined;
message.cookie_frequency_cap_setting =
(object.cookie_frequency_cap_setting !== undefined && object.cookie_frequency_cap_setting !== null)
? exports.FrequencyCap.fromPartial(object.cookie_frequency_cap_setting)
: undefined;
message.min_effective_frequency = (_d = object.min_effective_frequency) !== null && _d !== void 0 ? _d : undefined;
message.effective_frequency_limit =
(object.effective_frequency_limit !== undefined && object.effective_frequency_limit !== null)
? exports.EffectiveFrequencyLimit.fromPartial(object.effective_frequency_limit)
: undefined;
message.targeting = (object.targeting !== undefined && object.targeting !== null)
? exports.Targeting.fromPartial(object.targeting)
: undefined;
message.planned_products = ((_e = object.planned_products) === null || _e === void 0 ? void 0 : _e.map((e) => exports.PlannedProduct.fromPartial(e))) || [];
message.forecast_metric_options =
(object.forecast_metric_options !== undefined && object.forecast_metric_options !== null)
? exports.ForecastMetricOptions.fromPartial(object.forecast_metric_options)
: undefined;
message.customer_reach_group = (_f = object.customer_reach_group) !== null && _f !== void 0 ? _f : undefined;
return message;
},
};
function createBaseEffectiveFrequencyLimit() {
return { effective_frequency_breakdown_limit: 0 };
}
exports.EffectiveFrequencyLimit = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.effective_frequency_breakdown_limit !== undefined && message.effective_frequency_breakdown_limit !== 0) {
writer.uint32(8).int32(message.effective_frequency_breakdown_limit);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseEffectiveFrequencyLimit();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 8) {
break;
}
message.effective_frequency_breakdown_limit = reader.int32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
effective_frequency_breakdown_limit: isSet(object.effective_frequency_breakdown_limit)
? globalThis.Number(object.effective_frequency_breakdown_limit)
: 0,
};
},
toJSON(message) {
const obj = {};
if (message.effective_frequency_breakdown_limit !== undefined && message.effective_frequency_breakdown_limit !== 0) {
obj.effective_frequency_breakdown_limit = Math.round(message.effective_frequency_breakdown_limit);
}
return obj;
},
create(base) {
return exports.EffectiveFrequencyLimit.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseEffectiveFrequencyLimit();
message.effective_frequency_breakdown_limit = (_a = object.effective_frequency_breakdown_limit) !== null && _a !== void 0 ? _a : 0;
return message;
},
};
function createBaseFrequencyCap() {
return { impressions: 0, time_unit: 0 };
}
exports.FrequencyCap = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.impressions !== undefined && message.impressions !== 0) {
writer.uint32(24).int32(message.impressions);
}
if (message.time_unit !== undefined && message.time_unit !== 0) {
writer.uint32(16).int32(message.time_unit);
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseFrequencyCap();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 3:
if (tag !== 24) {
break;
}
message.impressions = reader.int32();
continue;
case 2:
if (tag !== 16) {
break;
}
message.time_unit = reader.int32();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
impressions: isSet(object.impressions) ? globalThis.Number(object.impressions) : 0,
time_unit: isSet(object.time_unit) ? (0, frequency_cap_time_unit_js_1.frequencyCapTimeUnitEnum_FrequencyCapTimeUnitFromJSON)(object.time_unit) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.impressions !== undefined && message.impressions !== 0) {
obj.impressions = Math.round(message.impressions);
}
if (message.time_unit !== undefined && message.time_unit !== 0) {
obj.time_unit = (0, frequency_cap_time_unit_js_1.frequencyCapTimeUnitEnum_FrequencyCapTimeUnitToJSON)(message.time_unit);
}
return obj;
},
create(base) {
return exports.FrequencyCap.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseFrequencyCap();
message.impressions = (_a = object.impressions) !== null && _a !== void 0 ? _a : 0;
message.time_unit = (_b = object.time_unit) !== null && _b !== void 0 ? _b : 0;
return message;
},
};
function createBaseTargeting() {
return {
plannable_location_id: undefined,
plannable_location_ids: [],
age_range: 0,
genders: [],
devices: [],
network: 0,
audience_targeting: undefined,
};
}
exports.Targeting = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.plannable_location_id !== undefined) {
writer.uint32(50).string(message.plannable_location_id);
}
if (message.plannable_location_ids !== undefined && message.plannable_location_ids.length !== 0) {
for (const v of message.plannable_location_ids) {
writer.uint32(66).string(v);
}
}
if (message.age_range !== undefined && message.age_range !== 0) {
writer.uint32(16).int32(message.age_range);
}
if (message.genders !== undefined && message.genders.length !== 0) {
for (const v of message.genders) {
criteria_js_1.GenderInfo.encode(v, writer.uint32(26).fork()).ldelim();
}
}
if (message.devices !== undefined && message.devices.length !== 0) {
for (const v of message.devices) {
criteria_js_1.DeviceInfo.encode(v, writer.uint32(34).fork()).ldelim();
}
}
if (message.network !== undefined && message.network !== 0) {
writer.uint32(40).int32(message.network);
}
if (message.audience_targeting !== undefined) {
exports.AudienceTargeting.encode(message.audience_targeting, writer.uint32(58).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof minimal_js_1.default.Reader ? input : minimal_js_1.default.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseTargeting();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 6:
if (tag !== 50) {
break;
}
message.plannable_location_id = reader.string();
continue;
case 8:
if (tag !== 66) {
break;
}
message.plannable_location_ids.push(reader.string());
continue;
case 2:
if (tag !== 16) {
break;
}
message.age_range = reader.int32();
continue;
case 3:
if (tag !== 26) {
break;
}
message.genders.push(criteria_js_1.GenderInfo.decode(reader, reader.uint32()));
continue;
case 4:
if (tag !== 34) {
break;
}
message.devices.push(criteria_js_1.DeviceInfo.decode(reader, reader.uint32()));
continue;
case 5:
if (tag !== 40) {
break;
}
message.network = reader.int32();
continue;
case 7:
if (tag !== 58) {
break;
}
message.audience_targeting = exports.AudienceTargeting.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
plannable_location_id: isSet(object.plannable_location_id)
? globalThis.String(object.plannable_location_id)
: undefined,
plannable_location_ids: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.plannable_location_ids)
? object.plannable_location_ids.map((e) => globalThis.String(e))
: [],
age_range: isSet(object.age_range) ? (0, reach_plan_age_range_js_1.reachPlanAgeRangeEnum_ReachPlanAgeRangeFromJSON)(object.age_range) : 0,
genders: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.genders) ? object.genders.map((e) => criteria_js_1.GenderInfo.fromJSON(e)) : [],
devices: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.devices) ? object.devices.map((e) => criteria_js_1.DeviceInfo.fromJSON(e)) : [],
network: isSet(object.network) ? (0, reach_plan_network_js_1.reachPlanNetworkEnum_ReachPlanNetworkFromJSON)(object.network) : 0,
audience_targeting: isSet(object.audience_targeting)
? exports.AudienceTargeting.fromJSON(object.audience_targeting)
: undefined,
};
},
toJSON(message) {
var _a, _b, _c;
const obj = {};
if (message.plannable_location_id !== undefined) {
obj.plannable_location_id = message.plannable_location_id;
}
if ((_a = message.plannable_location_ids) === null || _a === void 0 ? void 0 : _a.length) {
obj.plannable_location_ids = message.plannable_location_ids;
}
if (message.age_range !== undefined && message.age_range !== 0) {
obj.age_range = (0, reach_plan_age_range_js_1.reachPlanAgeRangeEnum_ReachPlanAgeRangeToJSON)(message.age_range);
}
if ((_b = message.genders) === null || _b === void 0 ? void 0 : _b.length) {
obj.genders = message.genders.map((e) => criteria_js_1.GenderInfo.toJSON(e));
}
if ((_c = message.devices) === null || _c === void 0 ? void 0 : _c.length) {
obj.devices = message.devices.map((e) => criteria_js_1.DeviceInfo.toJSON(e));
}
if (message.network !== undefined && message.network !== 0) {
obj.network = (0, reach_plan_network_js_1.reachPlanNetworkEnum_ReachPlanNetworkToJSON)(message.network);
}
if (message.audience_targeting !== undefined) {
obj.audience_targeting = exports.AudienceTargeting.toJSON(message.audience_targeting);
}
return obj;
},
create(base) {
return exports.Targeting.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f;
const message = createBaseTargeting();
message.plannable_location_id = (_a