@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
213 lines (212 loc) • 10.1 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/resources/campaign_asset.proto
/* eslint-disable */
import _m0 from "protobufjs/minimal.js";
import { AssetLinkPrimaryStatusDetails } from "../common/asset_policy.js";
import { assetFieldTypeEnum_AssetFieldTypeFromJSON, assetFieldTypeEnum_AssetFieldTypeToJSON, } from "../enums/asset_field_type.js";
import { assetLinkPrimaryStatusEnum_AssetLinkPrimaryStatusFromJSON, assetLinkPrimaryStatusEnum_AssetLinkPrimaryStatusToJSON, } from "../enums/asset_link_primary_status.js";
import { assetLinkPrimaryStatusReasonEnum_AssetLinkPrimaryStatusReasonFromJSON, assetLinkPrimaryStatusReasonEnum_AssetLinkPrimaryStatusReasonToJSON, } from "../enums/asset_link_primary_status_reason.js";
import { assetLinkStatusEnum_AssetLinkStatusFromJSON, assetLinkStatusEnum_AssetLinkStatusToJSON, } from "../enums/asset_link_status.js";
import { assetSourceEnum_AssetSourceFromJSON, assetSourceEnum_AssetSourceToJSON, } from "../enums/asset_source.js";
function createBaseCampaignAsset() {
return {
resource_name: "",
campaign: undefined,
asset: undefined,
field_type: 0,
source: 0,
status: 0,
primary_status: 0,
primary_status_details: [],
primary_status_reasons: [],
};
}
export const CampaignAsset = {
encode(message, writer = _m0.Writer.create()) {
if (message.resource_name !== undefined && message.resource_name !== "") {
writer.uint32(10).string(message.resource_name);
}
if (message.campaign !== undefined) {
writer.uint32(50).string(message.campaign);
}
if (message.asset !== undefined) {
writer.uint32(58).string(message.asset);
}
if (message.field_type !== undefined && message.field_type !== 0) {
writer.uint32(32).int32(message.field_type);
}
if (message.source !== undefined && message.source !== 0) {
writer.uint32(64).int32(message.source);
}
if (message.status !== undefined && message.status !== 0) {
writer.uint32(40).int32(message.status);
}
if (message.primary_status !== undefined && message.primary_status !== 0) {
writer.uint32(72).int32(message.primary_status);
}
if (message.primary_status_details !== undefined && message.primary_status_details.length !== 0) {
for (const v of message.primary_status_details) {
AssetLinkPrimaryStatusDetails.encode(v, writer.uint32(82).fork()).ldelim();
}
}
if (message.primary_status_reasons !== undefined && message.primary_status_reasons.length !== 0) {
writer.uint32(90).fork();
for (const v of message.primary_status_reasons) {
writer.int32(v);
}
writer.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 = createBaseCampaignAsset();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resource_name = reader.string();
continue;
case 6:
if (tag !== 50) {
break;
}
message.campaign = reader.string();
continue;
case 7:
if (tag !== 58) {
break;
}
message.asset = reader.string();
continue;
case 4:
if (tag !== 32) {
break;
}
message.field_type = reader.int32();
continue;
case 8:
if (tag !== 64) {
break;
}
message.source = reader.int32();
continue;
case 5:
if (tag !== 40) {
break;
}
message.status = reader.int32();
continue;
case 9:
if (tag !== 72) {
break;
}
message.primary_status = reader.int32();
continue;
case 10:
if (tag !== 82) {
break;
}
message.primary_status_details.push(AssetLinkPrimaryStatusDetails.decode(reader, reader.uint32()));
continue;
case 11:
if (tag === 88) {
message.primary_status_reasons.push(reader.int32());
continue;
}
if (tag === 90) {
const end2 = reader.uint32() + reader.pos;
while (reader.pos < end2) {
message.primary_status_reasons.push(reader.int32());
}
continue;
}
break;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
resource_name: isSet(object.resource_name) ? globalThis.String(object.resource_name) : "",
campaign: isSet(object.campaign) ? globalThis.String(object.campaign) : undefined,
asset: isSet(object.asset) ? globalThis.String(object.asset) : undefined,
field_type: isSet(object.field_type) ? assetFieldTypeEnum_AssetFieldTypeFromJSON(object.field_type) : 0,
source: isSet(object.source) ? assetSourceEnum_AssetSourceFromJSON(object.source) : 0,
status: isSet(object.status) ? assetLinkStatusEnum_AssetLinkStatusFromJSON(object.status) : 0,
primary_status: isSet(object.primary_status)
? assetLinkPrimaryStatusEnum_AssetLinkPrimaryStatusFromJSON(object.primary_status)
: 0,
primary_status_details: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.primary_status_details)
? object.primary_status_details.map((e) => AssetLinkPrimaryStatusDetails.fromJSON(e))
: [],
primary_status_reasons: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.primary_status_reasons)
? object.primary_status_reasons.map((e) => assetLinkPrimaryStatusReasonEnum_AssetLinkPrimaryStatusReasonFromJSON(e))
: [],
};
},
toJSON(message) {
var _a, _b;
const obj = {};
if (message.resource_name !== undefined && message.resource_name !== "") {
obj.resource_name = message.resource_name;
}
if (message.campaign !== undefined) {
obj.campaign = message.campaign;
}
if (message.asset !== undefined) {
obj.asset = message.asset;
}
if (message.field_type !== undefined && message.field_type !== 0) {
obj.field_type = assetFieldTypeEnum_AssetFieldTypeToJSON(message.field_type);
}
if (message.source !== undefined && message.source !== 0) {
obj.source = assetSourceEnum_AssetSourceToJSON(message.source);
}
if (message.status !== undefined && message.status !== 0) {
obj.status = assetLinkStatusEnum_AssetLinkStatusToJSON(message.status);
}
if (message.primary_status !== undefined && message.primary_status !== 0) {
obj.primary_status = assetLinkPrimaryStatusEnum_AssetLinkPrimaryStatusToJSON(message.primary_status);
}
if ((_a = message.primary_status_details) === null || _a === void 0 ? void 0 : _a.length) {
obj.primary_status_details = message.primary_status_details.map((e) => AssetLinkPrimaryStatusDetails.toJSON(e));
}
if ((_b = message.primary_status_reasons) === null || _b === void 0 ? void 0 : _b.length) {
obj.primary_status_reasons = message.primary_status_reasons.map((e) => assetLinkPrimaryStatusReasonEnum_AssetLinkPrimaryStatusReasonToJSON(e));
}
return obj;
},
create(base) {
return CampaignAsset.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
const message = createBaseCampaignAsset();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
message.campaign = (_b = object.campaign) !== null && _b !== void 0 ? _b : undefined;
message.asset = (_c = object.asset) !== null && _c !== void 0 ? _c : undefined;
message.field_type = (_d = object.field_type) !== null && _d !== void 0 ? _d : 0;
message.source = (_e = object.source) !== null && _e !== void 0 ? _e : 0;
message.status = (_f = object.status) !== null && _f !== void 0 ? _f : 0;
message.primary_status = (_g = object.primary_status) !== null && _g !== void 0 ? _g : 0;
message.primary_status_details =
((_h = object.primary_status_details) === null || _h === void 0 ? void 0 : _h.map((e) => AssetLinkPrimaryStatusDetails.fromPartial(e))) || [];
message.primary_status_reasons = ((_j = object.primary_status_reasons) === null || _j === void 0 ? void 0 : _j.map((e) => e)) || [];
return message;
},
};
function isSet(value) {
return value !== null && value !== undefined;
}