@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
1,105 lines (1,104 loc) • 127 kB
JavaScript
// 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/v21/services/audience_insights_service.proto
/* eslint-disable */
import { makeGenericClientConstructor, } from "@grpc/grpc-js";
import Long from "long";
import _m0 from "protobufjs/minimal.js";
import { AdditionalApplicationInfo } from "../common/additional_application_info.js";
import { AudienceInsightsAttribute, AudienceInsightsAttributeMetadata, AudienceInsightsAttributeMetadataGroup, AudienceInsightsLineup, AudienceInsightsTopic, } from "../common/audience_insights_attribute.js";
import { AgeRangeInfo, GenderInfo, IncomeRangeInfo, LocationInfo, ParentalStatusInfo, UserInterestInfo, UserListInfo, } from "../common/criteria.js";
import { DateRange } from "../common/dates.js";
import { audienceInsightsDimensionEnum_AudienceInsightsDimensionFromJSON, audienceInsightsDimensionEnum_AudienceInsightsDimensionToJSON, } from "../enums/audience_insights_dimension.js";
import { audienceInsightsMarketingObjectiveEnum_AudienceInsightsMarketingObjectiveFromJSON, audienceInsightsMarketingObjectiveEnum_AudienceInsightsMarketingObjectiveToJSON, } from "../enums/audience_insights_marketing_objective.js";
function createBaseGenerateInsightsFinderReportRequest() {
return {
customer_id: "",
baseline_audience: undefined,
specific_audience: undefined,
customer_insights_group: "",
insights_application_info: undefined,
};
}
export const GenerateInsightsFinderReportRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.baseline_audience !== undefined) {
BasicInsightsAudience.encode(message.baseline_audience, writer.uint32(18).fork()).ldelim();
}
if (message.specific_audience !== undefined) {
BasicInsightsAudience.encode(message.specific_audience, writer.uint32(26).fork()).ldelim();
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
writer.uint32(34).string(message.customer_insights_group);
}
if (message.insights_application_info !== undefined) {
AdditionalApplicationInfo.encode(message.insights_application_info, writer.uint32(42).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateInsightsFinderReportRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.customer_id = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.baseline_audience = BasicInsightsAudience.decode(reader, reader.uint32());
continue;
case 3:
if (tag !== 26) {
break;
}
message.specific_audience = BasicInsightsAudience.decode(reader, reader.uint32());
continue;
case 4:
if (tag !== 34) {
break;
}
message.customer_insights_group = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.insights_application_info = AdditionalApplicationInfo.decode(reader, reader.uint32());
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) : "",
baseline_audience: isSet(object.baseline_audience)
? BasicInsightsAudience.fromJSON(object.baseline_audience)
: undefined,
specific_audience: isSet(object.specific_audience)
? BasicInsightsAudience.fromJSON(object.specific_audience)
: undefined,
customer_insights_group: isSet(object.customer_insights_group)
? globalThis.String(object.customer_insights_group)
: "",
insights_application_info: isSet(object.insights_application_info)
? AdditionalApplicationInfo.fromJSON(object.insights_application_info)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if (message.baseline_audience !== undefined) {
obj.baseline_audience = BasicInsightsAudience.toJSON(message.baseline_audience);
}
if (message.specific_audience !== undefined) {
obj.specific_audience = BasicInsightsAudience.toJSON(message.specific_audience);
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
obj.customer_insights_group = message.customer_insights_group;
}
if (message.insights_application_info !== undefined) {
obj.insights_application_info = AdditionalApplicationInfo.toJSON(message.insights_application_info);
}
return obj;
},
create(base) {
return GenerateInsightsFinderReportRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseGenerateInsightsFinderReportRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.baseline_audience = (object.baseline_audience !== undefined && object.baseline_audience !== null)
? BasicInsightsAudience.fromPartial(object.baseline_audience)
: undefined;
message.specific_audience = (object.specific_audience !== undefined && object.specific_audience !== null)
? BasicInsightsAudience.fromPartial(object.specific_audience)
: undefined;
message.customer_insights_group = (_b = object.customer_insights_group) !== null && _b !== void 0 ? _b : "";
message.insights_application_info =
(object.insights_application_info !== undefined && object.insights_application_info !== null)
? AdditionalApplicationInfo.fromPartial(object.insights_application_info)
: undefined;
return message;
},
};
function createBaseGenerateInsightsFinderReportResponse() {
return { saved_report_url: "" };
}
export const GenerateInsightsFinderReportResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.saved_report_url !== undefined && message.saved_report_url !== "") {
writer.uint32(10).string(message.saved_report_url);
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateInsightsFinderReportResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.saved_report_url = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return { saved_report_url: isSet(object.saved_report_url) ? globalThis.String(object.saved_report_url) : "" };
},
toJSON(message) {
const obj = {};
if (message.saved_report_url !== undefined && message.saved_report_url !== "") {
obj.saved_report_url = message.saved_report_url;
}
return obj;
},
create(base) {
return GenerateInsightsFinderReportResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseGenerateInsightsFinderReportResponse();
message.saved_report_url = (_a = object.saved_report_url) !== null && _a !== void 0 ? _a : "";
return message;
},
};
function createBaseGenerateAudienceCompositionInsightsRequest() {
return {
customer_id: "",
audience: undefined,
baseline_audience: undefined,
data_month: "",
dimensions: [],
customer_insights_group: "",
insights_application_info: undefined,
};
}
export const GenerateAudienceCompositionInsightsRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.audience !== undefined) {
InsightsAudience.encode(message.audience, writer.uint32(18).fork()).ldelim();
}
if (message.baseline_audience !== undefined) {
InsightsAudience.encode(message.baseline_audience, writer.uint32(50).fork()).ldelim();
}
if (message.data_month !== undefined && message.data_month !== "") {
writer.uint32(26).string(message.data_month);
}
if (message.dimensions !== undefined && message.dimensions.length !== 0) {
writer.uint32(34).fork();
for (const v of message.dimensions) {
writer.int32(v);
}
writer.ldelim();
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
writer.uint32(42).string(message.customer_insights_group);
}
if (message.insights_application_info !== undefined) {
AdditionalApplicationInfo.encode(message.insights_application_info, writer.uint32(58).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateAudienceCompositionInsightsRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.customer_id = reader.string();
continue;
case 2:
if (tag !== 18) {
break;
}
message.audience = InsightsAudience.decode(reader, reader.uint32());
continue;
case 6:
if (tag !== 50) {
break;
}
message.baseline_audience = InsightsAudience.decode(reader, reader.uint32());
continue;
case 3:
if (tag !== 26) {
break;
}
message.data_month = reader.string();
continue;
case 4:
if (tag === 32) {
message.dimensions.push(reader.int32());
continue;
}
if (tag === 34) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.dimensions.push(reader.int32());
}
continue;
}
break;
case 5:
if (tag !== 42) {
break;
}
message.customer_insights_group = reader.string();
continue;
case 7:
if (tag !== 58) {
break;
}
message.insights_application_info = AdditionalApplicationInfo.decode(reader, reader.uint32());
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) : "",
audience: isSet(object.audience) ? InsightsAudience.fromJSON(object.audience) : undefined,
baseline_audience: isSet(object.baseline_audience)
? InsightsAudience.fromJSON(object.baseline_audience)
: undefined,
data_month: isSet(object.data_month) ? globalThis.String(object.data_month) : "",
dimensions: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.dimensions)
? object.dimensions.map((e) => audienceInsightsDimensionEnum_AudienceInsightsDimensionFromJSON(e))
: [],
customer_insights_group: isSet(object.customer_insights_group)
? globalThis.String(object.customer_insights_group)
: "",
insights_application_info: isSet(object.insights_application_info)
? AdditionalApplicationInfo.fromJSON(object.insights_application_info)
: undefined,
};
},
toJSON(message) {
var _a;
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if (message.audience !== undefined) {
obj.audience = InsightsAudience.toJSON(message.audience);
}
if (message.baseline_audience !== undefined) {
obj.baseline_audience = InsightsAudience.toJSON(message.baseline_audience);
}
if (message.data_month !== undefined && message.data_month !== "") {
obj.data_month = message.data_month;
}
if ((_a = message.dimensions) === null || _a === void 0 ? void 0 : _a.length) {
obj.dimensions = message.dimensions.map((e) => audienceInsightsDimensionEnum_AudienceInsightsDimensionToJSON(e));
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
obj.customer_insights_group = message.customer_insights_group;
}
if (message.insights_application_info !== undefined) {
obj.insights_application_info = AdditionalApplicationInfo.toJSON(message.insights_application_info);
}
return obj;
},
create(base) {
return GenerateAudienceCompositionInsightsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d;
const message = createBaseGenerateAudienceCompositionInsightsRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.audience = (object.audience !== undefined && object.audience !== null)
? InsightsAudience.fromPartial(object.audience)
: undefined;
message.baseline_audience = (object.baseline_audience !== undefined && object.baseline_audience !== null)
? InsightsAudience.fromPartial(object.baseline_audience)
: undefined;
message.data_month = (_b = object.data_month) !== null && _b !== void 0 ? _b : "";
message.dimensions = ((_c = object.dimensions) === null || _c === void 0 ? void 0 : _c.map((e) => e)) || [];
message.customer_insights_group = (_d = object.customer_insights_group) !== null && _d !== void 0 ? _d : "";
message.insights_application_info =
(object.insights_application_info !== undefined && object.insights_application_info !== null)
? AdditionalApplicationInfo.fromPartial(object.insights_application_info)
: undefined;
return message;
},
};
function createBaseGenerateAudienceCompositionInsightsResponse() {
return { sections: [] };
}
export const GenerateAudienceCompositionInsightsResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.sections !== undefined && message.sections.length !== 0) {
for (const v of message.sections) {
AudienceCompositionSection.encode(v, writer.uint32(10).fork()).ldelim();
}
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateAudienceCompositionInsightsResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.sections.push(AudienceCompositionSection.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
sections: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.sections)
? object.sections.map((e) => AudienceCompositionSection.fromJSON(e))
: [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.sections) === null || _a === void 0 ? void 0 : _a.length) {
obj.sections = message.sections.map((e) => AudienceCompositionSection.toJSON(e));
}
return obj;
},
create(base) {
return GenerateAudienceCompositionInsightsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseGenerateAudienceCompositionInsightsResponse();
message.sections = ((_a = object.sections) === null || _a === void 0 ? void 0 : _a.map((e) => AudienceCompositionSection.fromPartial(e))) || [];
return message;
},
};
function createBaseGenerateSuggestedTargetingInsightsRequest() {
return {
customer_id: "",
customer_insights_group: "",
insights_application_info: undefined,
audience_definition: undefined,
audience_description: undefined,
};
}
export const GenerateSuggestedTargetingInsightsRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
writer.uint32(42).string(message.customer_insights_group);
}
if (message.insights_application_info !== undefined) {
AdditionalApplicationInfo.encode(message.insights_application_info, writer.uint32(66).fork()).ldelim();
}
if (message.audience_definition !== undefined) {
InsightsAudienceDefinition.encode(message.audience_definition, writer.uint32(50).fork()).ldelim();
}
if (message.audience_description !== undefined) {
InsightsAudienceDescription.encode(message.audience_description, writer.uint32(58).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateSuggestedTargetingInsightsRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.customer_id = reader.string();
continue;
case 5:
if (tag !== 42) {
break;
}
message.customer_insights_group = reader.string();
continue;
case 8:
if (tag !== 66) {
break;
}
message.insights_application_info = AdditionalApplicationInfo.decode(reader, reader.uint32());
continue;
case 6:
if (tag !== 50) {
break;
}
message.audience_definition = InsightsAudienceDefinition.decode(reader, reader.uint32());
continue;
case 7:
if (tag !== 58) {
break;
}
message.audience_description = InsightsAudienceDescription.decode(reader, reader.uint32());
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) : "",
customer_insights_group: isSet(object.customer_insights_group)
? globalThis.String(object.customer_insights_group)
: "",
insights_application_info: isSet(object.insights_application_info)
? AdditionalApplicationInfo.fromJSON(object.insights_application_info)
: undefined,
audience_definition: isSet(object.audience_definition)
? InsightsAudienceDefinition.fromJSON(object.audience_definition)
: undefined,
audience_description: isSet(object.audience_description)
? InsightsAudienceDescription.fromJSON(object.audience_description)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
obj.customer_insights_group = message.customer_insights_group;
}
if (message.insights_application_info !== undefined) {
obj.insights_application_info = AdditionalApplicationInfo.toJSON(message.insights_application_info);
}
if (message.audience_definition !== undefined) {
obj.audience_definition = InsightsAudienceDefinition.toJSON(message.audience_definition);
}
if (message.audience_description !== undefined) {
obj.audience_description = InsightsAudienceDescription.toJSON(message.audience_description);
}
return obj;
},
create(base) {
return GenerateSuggestedTargetingInsightsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseGenerateSuggestedTargetingInsightsRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.customer_insights_group = (_b = object.customer_insights_group) !== null && _b !== void 0 ? _b : "";
message.insights_application_info =
(object.insights_application_info !== undefined && object.insights_application_info !== null)
? AdditionalApplicationInfo.fromPartial(object.insights_application_info)
: undefined;
message.audience_definition = (object.audience_definition !== undefined && object.audience_definition !== null)
? InsightsAudienceDefinition.fromPartial(object.audience_definition)
: undefined;
message.audience_description = (object.audience_description !== undefined && object.audience_description !== null)
? InsightsAudienceDescription.fromPartial(object.audience_description)
: undefined;
return message;
},
};
function createBaseGenerateSuggestedTargetingInsightsResponse() {
return { suggestions: [] };
}
export const GenerateSuggestedTargetingInsightsResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.suggestions !== undefined && message.suggestions.length !== 0) {
for (const v of message.suggestions) {
TargetingSuggestionMetrics.encode(v, writer.uint32(10).fork()).ldelim();
}
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseGenerateSuggestedTargetingInsightsResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.suggestions.push(TargetingSuggestionMetrics.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
suggestions: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.suggestions)
? object.suggestions.map((e) => TargetingSuggestionMetrics.fromJSON(e))
: [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.suggestions) === null || _a === void 0 ? void 0 : _a.length) {
obj.suggestions = message.suggestions.map((e) => TargetingSuggestionMetrics.toJSON(e));
}
return obj;
},
create(base) {
return GenerateSuggestedTargetingInsightsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseGenerateSuggestedTargetingInsightsResponse();
message.suggestions = ((_a = object.suggestions) === null || _a === void 0 ? void 0 : _a.map((e) => TargetingSuggestionMetrics.fromPartial(e))) || [];
return message;
},
};
function createBaseTargetingSuggestionMetrics() {
return {
locations: [],
age_ranges: [],
gender: undefined,
parental_status: undefined,
user_interests: [],
coverage: 0,
index: 0,
potential_youtube_reach: "0",
};
}
export const TargetingSuggestionMetrics = {
encode(message, writer = _m0.Writer.create()) {
if (message.locations !== undefined && message.locations.length !== 0) {
for (const v of message.locations) {
AudienceInsightsAttributeMetadata.encode(v, writer.uint32(74).fork()).ldelim();
}
}
if (message.age_ranges !== undefined && message.age_ranges.length !== 0) {
for (const v of message.age_ranges) {
AgeRangeInfo.encode(v, writer.uint32(18).fork()).ldelim();
}
}
if (message.gender !== undefined) {
GenderInfo.encode(message.gender, writer.uint32(26).fork()).ldelim();
}
if (message.parental_status !== undefined) {
ParentalStatusInfo.encode(message.parental_status, writer.uint32(66).fork()).ldelim();
}
if (message.user_interests !== undefined && message.user_interests.length !== 0) {
for (const v of message.user_interests) {
AudienceInsightsAttributeMetadataGroup.encode(v, writer.uint32(90).fork()).ldelim();
}
}
if (message.coverage !== undefined && message.coverage !== 0) {
writer.uint32(41).double(message.coverage);
}
if (message.index !== undefined && message.index !== 0) {
writer.uint32(49).double(message.index);
}
if (message.potential_youtube_reach !== undefined && message.potential_youtube_reach !== "0") {
writer.uint32(56).int64(message.potential_youtube_reach);
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseTargetingSuggestionMetrics();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 9:
if (tag !== 74) {
break;
}
message.locations.push(AudienceInsightsAttributeMetadata.decode(reader, reader.uint32()));
continue;
case 2:
if (tag !== 18) {
break;
}
message.age_ranges.push(AgeRangeInfo.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 26) {
break;
}
message.gender = GenderInfo.decode(reader, reader.uint32());
continue;
case 8:
if (tag !== 66) {
break;
}
message.parental_status = ParentalStatusInfo.decode(reader, reader.uint32());
continue;
case 11:
if (tag !== 90) {
break;
}
message.user_interests.push(AudienceInsightsAttributeMetadataGroup.decode(reader, reader.uint32()));
continue;
case 5:
if (tag !== 41) {
break;
}
message.coverage = reader.double();
continue;
case 6:
if (tag !== 49) {
break;
}
message.index = reader.double();
continue;
case 7:
if (tag !== 56) {
break;
}
message.potential_youtube_reach = longToString(reader.int64());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
locations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.locations)
? object.locations.map((e) => AudienceInsightsAttributeMetadata.fromJSON(e))
: [],
age_ranges: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.age_ranges)
? object.age_ranges.map((e) => AgeRangeInfo.fromJSON(e))
: [],
gender: isSet(object.gender) ? GenderInfo.fromJSON(object.gender) : undefined,
parental_status: isSet(object.parental_status) ? ParentalStatusInfo.fromJSON(object.parental_status) : undefined,
user_interests: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.user_interests)
? object.user_interests.map((e) => AudienceInsightsAttributeMetadataGroup.fromJSON(e))
: [],
coverage: isSet(object.coverage) ? globalThis.Number(object.coverage) : 0,
index: isSet(object.index) ? globalThis.Number(object.index) : 0,
potential_youtube_reach: isSet(object.potential_youtube_reach)
? globalThis.String(object.potential_youtube_reach)
: "0",
};
},
toJSON(message) {
var _a, _b, _c;
const obj = {};
if ((_a = message.locations) === null || _a === void 0 ? void 0 : _a.length) {
obj.locations = message.locations.map((e) => AudienceInsightsAttributeMetadata.toJSON(e));
}
if ((_b = message.age_ranges) === null || _b === void 0 ? void 0 : _b.length) {
obj.age_ranges = message.age_ranges.map((e) => AgeRangeInfo.toJSON(e));
}
if (message.gender !== undefined) {
obj.gender = GenderInfo.toJSON(message.gender);
}
if (message.parental_status !== undefined) {
obj.parental_status = ParentalStatusInfo.toJSON(message.parental_status);
}
if ((_c = message.user_interests) === null || _c === void 0 ? void 0 : _c.length) {
obj.user_interests = message.user_interests.map((e) => AudienceInsightsAttributeMetadataGroup.toJSON(e));
}
if (message.coverage !== undefined && message.coverage !== 0) {
obj.coverage = message.coverage;
}
if (message.index !== undefined && message.index !== 0) {
obj.index = message.index;
}
if (message.potential_youtube_reach !== undefined && message.potential_youtube_reach !== "0") {
obj.potential_youtube_reach = message.potential_youtube_reach;
}
return obj;
},
create(base) {
return TargetingSuggestionMetrics.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f;
const message = createBaseTargetingSuggestionMetrics();
message.locations = ((_a = object.locations) === null || _a === void 0 ? void 0 : _a.map((e) => AudienceInsightsAttributeMetadata.fromPartial(e))) || [];
message.age_ranges = ((_b = object.age_ranges) === null || _b === void 0 ? void 0 : _b.map((e) => AgeRangeInfo.fromPartial(e))) || [];
message.gender = (object.gender !== undefined && object.gender !== null)
? GenderInfo.fromPartial(object.gender)
: undefined;
message.parental_status = (object.parental_status !== undefined && object.parental_status !== null)
? ParentalStatusInfo.fromPartial(object.parental_status)
: undefined;
message.user_interests = ((_c = object.user_interests) === null || _c === void 0 ? void 0 : _c.map((e) => AudienceInsightsAttributeMetadataGroup.fromPartial(e))) ||
[];
message.coverage = (_d = object.coverage) !== null && _d !== void 0 ? _d : 0;
message.index = (_e = object.index) !== null && _e !== void 0 ? _e : 0;
message.potential_youtube_reach = (_f = object.potential_youtube_reach) !== null && _f !== void 0 ? _f : "0";
return message;
},
};
function createBaseListAudienceInsightsAttributesRequest() {
return {
customer_id: "",
dimensions: [],
query_text: "",
customer_insights_group: "",
insights_application_info: undefined,
location_country_filters: [],
youtube_reach_location: undefined,
};
}
export const ListAudienceInsightsAttributesRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.dimensions !== undefined && message.dimensions.length !== 0) {
writer.uint32(18).fork();
for (const v of message.dimensions) {
writer.int32(v);
}
writer.ldelim();
}
if (message.query_text !== undefined && message.query_text !== "") {
writer.uint32(26).string(message.query_text);
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
writer.uint32(34).string(message.customer_insights_group);
}
if (message.insights_application_info !== undefined) {
AdditionalApplicationInfo.encode(message.insights_application_info, writer.uint32(58).fork()).ldelim();
}
if (message.location_country_filters !== undefined && message.location_country_filters.length !== 0) {
for (const v of message.location_country_filters) {
LocationInfo.encode(v, writer.uint32(42).fork()).ldelim();
}
}
if (message.youtube_reach_location !== undefined) {
LocationInfo.encode(message.youtube_reach_location, writer.uint32(50).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListAudienceInsightsAttributesRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.customer_id = reader.string();
continue;
case 2:
if (tag === 16) {
message.dimensions.push(reader.int32());
continue;
}
if (tag === 18) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.dimensions.push(reader.int32());
}
continue;
}
break;
case 3:
if (tag !== 26) {
break;
}
message.query_text = reader.string();
continue;
case 4:
if (tag !== 34) {
break;
}
message.customer_insights_group = reader.string();
continue;
case 7:
if (tag !== 58) {
break;
}
message.insights_application_info = AdditionalApplicationInfo.decode(reader, reader.uint32());
continue;
case 5:
if (tag !== 42) {
break;
}
message.location_country_filters.push(LocationInfo.decode(reader, reader.uint32()));
continue;
case 6:
if (tag !== 50) {
break;
}
message.youtube_reach_location = LocationInfo.decode(reader, reader.uint32());
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) : "",
dimensions: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.dimensions)
? object.dimensions.map((e) => audienceInsightsDimensionEnum_AudienceInsightsDimensionFromJSON(e))
: [],
query_text: isSet(object.query_text) ? globalThis.String(object.query_text) : "",
customer_insights_group: isSet(object.customer_insights_group)
? globalThis.String(object.customer_insights_group)
: "",
insights_application_info: isSet(object.insights_application_info)
? AdditionalApplicationInfo.fromJSON(object.insights_application_info)
: undefined,
location_country_filters: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.location_country_filters)
? object.location_country_filters.map((e) => LocationInfo.fromJSON(e))
: [],
youtube_reach_location: isSet(object.youtube_reach_location)
? LocationInfo.fromJSON(object.youtube_reach_location)
: undefined,
};
},
toJSON(message) {
var _a, _b;
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if ((_a = message.dimensions) === null || _a === void 0 ? void 0 : _a.length) {
obj.dimensions = message.dimensions.map((e) => audienceInsightsDimensionEnum_AudienceInsightsDimensionToJSON(e));
}
if (message.query_text !== undefined && message.query_text !== "") {
obj.query_text = message.query_text;
}
if (message.customer_insights_group !== undefined && message.customer_insights_group !== "") {
obj.customer_insights_group = message.customer_insights_group;
}
if (message.insights_application_info !== undefined) {
obj.insights_application_info = AdditionalApplicationInfo.toJSON(message.insights_application_info);
}
if ((_b = message.location_country_filters) === null || _b === void 0 ? void 0 : _b.length) {
obj.location_country_filters = message.location_country_filters.map((e) => LocationInfo.toJSON(e));
}
if (message.youtube_reach_location !== undefined) {
obj.youtube_reach_location = LocationInfo.toJSON(message.youtube_reach_location);
}
return obj;
},
create(base) {
return ListAudienceInsightsAttributesRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = createBaseListAudienceInsightsAttributesRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.dimensions = ((_b = object.dimensions) === null || _b === void 0 ? void 0 : _b.map((e) => e)) || [];
message.query_text = (_c = object.query_text) !== null && _c !== void 0 ? _c : "";
message.customer_insights_group = (_d = object.customer_insights_group) !== null && _d !== void 0 ? _d : "";
message.insights_application_info =
(object.insights_application_info !== undefined && object.insights_application_info !== null)
? AdditionalApplicationInfo.fromPartial(object.insights_application_info)
: undefined;
message.location_country_filters = ((_e = object.location_country_filters) === null || _e === void 0 ? void 0 : _e.map((e) => LocationInfo.fromPartial(e))) || [];
message.youtube_reach_location =
(object.youtube_reach_location !== undefined && object.youtube_reach_location !== null)
? LocationInfo.fromPartial(object.youtube_reach_location)
: undefined;
return message;
},
};
function createBaseListAudienceInsightsAttributesResponse() {
return { attributes: [] };
}
export const ListAudienceInsightsAttributesResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.attributes !== undefined && message.attributes.length !== 0) {
for (const v of message.attributes) {
AudienceInsightsAttributeMetadata.encode(v, writer.uint32(18).fork()).ldelim();
}
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListAudienceInsightsAttributesResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 2:
if (tag !== 18) {
break;
}
message.attributes.push(AudienceInsightsAttributeMetadata.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
attributes: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.attributes)
? object.attributes.map((e) => AudienceInsightsAttributeMetadata.fromJSON(e))
: [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.attributes) === null || _a === void 0 ? void 0 : _a.length) {
obj.attributes = message.attributes.map((e) => AudienceInsightsAttributeMetadata.toJSON(e));
}
return obj;
},
create(base) {
return ListAudienceInsightsAttributesResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseListAudienceInsightsAttributesResponse();
message.attributes = ((_a = object.attributes) === null || _a === void 0 ? void 0 : _a.map((e) => AudienceInsightsAttributeMetadata.fromPartial(e))) || [];
return message;
},
};
function createBaseListInsightsEligibleDatesRequest() {
return { insights_application_info: undefined };
}
export const ListInsightsEligibleDatesRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.insights_application_info !== undefined) {
AdditionalApplicationInfo.encode(message.insights_application_info, writer.uint32(10).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListInsightsEligibleDatesRequest();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.insights_application_info = AdditionalApplicationInfo.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
insights_application_info: isSet(object.insights_application_info)
? AdditionalApplicationInfo.fromJSON(object.insights_application_info)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.insights_application_info !== undefined) {
obj.insights_application_info = AdditionalApplicationInfo.toJSON(message.insights_application_info);
}
return obj;
},
create(base) {
return ListInsightsEligibleDatesRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
const message = createBaseListInsightsEligibleDatesRequest();
message.insights_application_info =
(object.insights_application_info !== undefined && object.insights_application_info !== null)
? AdditionalApplicationInfo.fromPartial(object.insights_application_info)
: undefined;
return message;
},
};
function createBaseListInsightsEligibleDatesResponse() {
return { data_months: [], last_thirty_days: undefined };
}
export const ListInsightsEligibleDatesResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.data_months !== undefined && message.data_months.length !== 0) {
for (const v of message.data_months) {
writer.uint32(10).string(v);
}
}
if (message.last_thirty_days !== undefined) {
DateRange.encode(message.last_thirty_days, writer.uint32(18).fork()).ldelim();
}
return writer;
},
decode(input, length) {
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseListInsightsEligibleDatesResponse();
while (reader.pos < end) {