@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
159 lines (158 loc) • 6.84 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/v24/resources/goal.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal.js";
import { GoalSetting_RetentionGoal } from "../common/goal_setting.js";
import { goalOptimizationEligibilityEnum_GoalOptimizationEligibilityFromJSON, goalOptimizationEligibilityEnum_GoalOptimizationEligibilityToJSON, } from "../enums/goal_optimization_eligibility.js";
import { goalTypeEnum_GoalTypeFromJSON, goalTypeEnum_GoalTypeToJSON, } from "../enums/goal_type.js";
function createBaseGoal() {
return {
resource_name: "",
goal_id: undefined,
goal_type: 0,
owner_customer: undefined,
optimization_eligibility: 0,
retention_goal_settings: undefined,
};
}
export const Goal = {
encode(message, writer = _m0.Writer.create()) {
if (message.resource_name !== undefined && message.resource_name !== "") {
writer.uint32(10).string(message.resource_name);
}
if (message.goal_id !== undefined) {
writer.uint32(16).int64(message.goal_id);
}
if (message.goal_type !== undefined && message.goal_type !== 0) {
writer.uint32(24).int32(message.goal_type);
}
if (message.owner_customer !== undefined) {
writer.uint32(34).string(message.owner_customer);
}
if (message.optimization_eligibility !== undefined && message.optimization_eligibility !== 0) {
writer.uint32(48).int32(message.optimization_eligibility);
}
if (message.retention_goal_settings !== undefined) {
GoalSetting_RetentionGoal.encode(message.retention_goal_settings, 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 = createBaseGoal();
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.goal_id = longToString(reader.int64());
continue;
case 3:
if (tag !== 24) {
break;
}
message.goal_type = reader.int32();
continue;
case 4:
if (tag !== 34) {
break;
}
message.owner_customer = reader.string();
continue;
case 6:
if (tag !== 48) {
break;
}
message.optimization_eligibility = reader.int32();
continue;
case 7:
if (tag !== 58) {
break;
}
message.retention_goal_settings = GoalSetting_RetentionGoal.decode(reader, reader.uint32());
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) : "",
goal_id: isSet(object.goal_id) ? globalThis.String(object.goal_id) : undefined,
goal_type: isSet(object.goal_type) ? goalTypeEnum_GoalTypeFromJSON(object.goal_type) : 0,
owner_customer: isSet(object.owner_customer) ? globalThis.String(object.owner_customer) : undefined,
optimization_eligibility: isSet(object.optimization_eligibility)
? goalOptimizationEligibilityEnum_GoalOptimizationEligibilityFromJSON(object.optimization_eligibility)
: 0,
retention_goal_settings: isSet(object.retention_goal_settings)
? GoalSetting_RetentionGoal.fromJSON(object.retention_goal_settings)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.resource_name !== undefined && message.resource_name !== "") {
obj.resource_name = message.resource_name;
}
if (message.goal_id !== undefined) {
obj.goal_id = message.goal_id;
}
if (message.goal_type !== undefined && message.goal_type !== 0) {
obj.goal_type = goalTypeEnum_GoalTypeToJSON(message.goal_type);
}
if (message.owner_customer !== undefined) {
obj.owner_customer = message.owner_customer;
}
if (message.optimization_eligibility !== undefined && message.optimization_eligibility !== 0) {
obj.optimization_eligibility = goalOptimizationEligibilityEnum_GoalOptimizationEligibilityToJSON(message.optimization_eligibility);
}
if (message.retention_goal_settings !== undefined) {
obj.retention_goal_settings = GoalSetting_RetentionGoal.toJSON(message.retention_goal_settings);
}
return obj;
},
create(base) {
return Goal.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = createBaseGoal();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
message.goal_id = (_b = object.goal_id) !== null && _b !== void 0 ? _b : undefined;
message.goal_type = (_c = object.goal_type) !== null && _c !== void 0 ? _c : 0;
message.owner_customer = (_d = object.owner_customer) !== null && _d !== void 0 ? _d : undefined;
message.optimization_eligibility = (_e = object.optimization_eligibility) !== null && _e !== void 0 ? _e : 0;
message.retention_goal_settings =
(object.retention_goal_settings !== undefined && object.retention_goal_settings !== null)
? GoalSetting_RetentionGoal.fromPartial(object.retention_goal_settings)
: undefined;
return message;
},
};
function longToString(long) {
return long.toString();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long;
_m0.configure();
}
function isSet(value) {
return value !== null && value !== undefined;
}