@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
142 lines (141 loc) • 5.95 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/custom_conversion_goal.proto
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CustomConversionGoal = void 0;
/* eslint-disable */
const long_1 = __importDefault(require("long"));
const minimal_js_1 = __importDefault(require("protobufjs/minimal.js"));
const custom_conversion_goal_status_js_1 = require("../enums/custom_conversion_goal_status.js");
function createBaseCustomConversionGoal() {
return { resource_name: "", id: "0", name: "", conversion_actions: [], status: 0 };
}
exports.CustomConversionGoal = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.resource_name !== undefined && message.resource_name !== "") {
writer.uint32(10).string(message.resource_name);
}
if (message.id !== undefined && message.id !== "0") {
writer.uint32(16).int64(message.id);
}
if (message.name !== undefined && message.name !== "") {
writer.uint32(26).string(message.name);
}
if (message.conversion_actions !== undefined && message.conversion_actions.length !== 0) {
for (const v of message.conversion_actions) {
writer.uint32(34).string(v);
}
}
if (message.status !== undefined && message.status !== 0) {
writer.uint32(40).int32(message.status);
}
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 = createBaseCustomConversionGoal();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resource_name = reader.string();
continue;
case 2:
if (tag !== 16) {
break;
}
message.id = longToString(reader.int64());
continue;
case 3:
if (tag !== 26) {
break;
}
message.name = reader.string();
continue;
case 4:
if (tag !== 34) {
break;
}
message.conversion_actions.push(reader.string());
continue;
case 5:
if (tag !== 40) {
break;
}
message.status = reader.int32();
continue;
}
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) : "",
id: isSet(object.id) ? globalThis.String(object.id) : "0",
name: isSet(object.name) ? globalThis.String(object.name) : "",
conversion_actions: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.conversion_actions)
? object.conversion_actions.map((e) => globalThis.String(e))
: [],
status: isSet(object.status)
? (0, custom_conversion_goal_status_js_1.customConversionGoalStatusEnum_CustomConversionGoalStatusFromJSON)(object.status)
: 0,
};
},
toJSON(message) {
var _a;
const obj = {};
if (message.resource_name !== undefined && message.resource_name !== "") {
obj.resource_name = message.resource_name;
}
if (message.id !== undefined && message.id !== "0") {
obj.id = message.id;
}
if (message.name !== undefined && message.name !== "") {
obj.name = message.name;
}
if ((_a = message.conversion_actions) === null || _a === void 0 ? void 0 : _a.length) {
obj.conversion_actions = message.conversion_actions;
}
if (message.status !== undefined && message.status !== 0) {
obj.status = (0, custom_conversion_goal_status_js_1.customConversionGoalStatusEnum_CustomConversionGoalStatusToJSON)(message.status);
}
return obj;
},
create(base) {
return exports.CustomConversionGoal.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = createBaseCustomConversionGoal();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
message.id = (_b = object.id) !== null && _b !== void 0 ? _b : "0";
message.name = (_c = object.name) !== null && _c !== void 0 ? _c : "";
message.conversion_actions = ((_d = object.conversion_actions) === null || _d === void 0 ? void 0 : _d.map((e) => e)) || [];
message.status = (_e = object.status) !== null && _e !== void 0 ? _e : 0;
return message;
},
};
function longToString(long) {
return long.toString();
}
if (minimal_js_1.default.util.Long !== long_1.default) {
minimal_js_1.default.util.Long = long_1.default;
minimal_js_1.default.configure();
}
function isSet(value) {
return value !== null && value !== undefined;
}