@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
322 lines (321 loc) • 12.9 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/custom_interest_service.proto
/* eslint-disable */
import { makeGenericClientConstructor, } from "@grpc/grpc-js";
import _m0 from "protobufjs/minimal.js";
import { FieldMask } from "../../../../protobuf/field_mask.js";
import { CustomInterest } from "../resources/custom_interest.js";
function createBaseMutateCustomInterestsRequest() {
return { customer_id: "", operations: [], validate_only: false };
}
export const MutateCustomInterestsRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.operations !== undefined && message.operations.length !== 0) {
for (const v of message.operations) {
CustomInterestOperation.encode(v, writer.uint32(18).fork()).ldelim();
}
}
if (message.validate_only !== undefined && message.validate_only !== false) {
writer.uint32(32).bool(message.validate_only);
}
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 = createBaseMutateCustomInterestsRequest();
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.operations.push(CustomInterestOperation.decode(reader, reader.uint32()));
continue;
case 4:
if (tag !== 32) {
break;
}
message.validate_only = reader.bool();
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) : "",
operations: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.operations)
? object.operations.map((e) => CustomInterestOperation.fromJSON(e))
: [],
validate_only: isSet(object.validate_only) ? globalThis.Boolean(object.validate_only) : false,
};
},
toJSON(message) {
var _a;
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if ((_a = message.operations) === null || _a === void 0 ? void 0 : _a.length) {
obj.operations = message.operations.map((e) => CustomInterestOperation.toJSON(e));
}
if (message.validate_only !== undefined && message.validate_only !== false) {
obj.validate_only = message.validate_only;
}
return obj;
},
create(base) {
return MutateCustomInterestsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c;
const message = createBaseMutateCustomInterestsRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.operations = ((_b = object.operations) === null || _b === void 0 ? void 0 : _b.map((e) => CustomInterestOperation.fromPartial(e))) || [];
message.validate_only = (_c = object.validate_only) !== null && _c !== void 0 ? _c : false;
return message;
},
};
function createBaseCustomInterestOperation() {
return { update_mask: undefined, create: undefined, update: undefined };
}
export const CustomInterestOperation = {
encode(message, writer = _m0.Writer.create()) {
if (message.update_mask !== undefined) {
FieldMask.encode(FieldMask.wrap(message.update_mask), writer.uint32(34).fork()).ldelim();
}
if (message.create !== undefined) {
CustomInterest.encode(message.create, writer.uint32(10).fork()).ldelim();
}
if (message.update !== undefined) {
CustomInterest.encode(message.update, 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 = createBaseCustomInterestOperation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 4:
if (tag !== 34) {
break;
}
message.update_mask = FieldMask.unwrap(FieldMask.decode(reader, reader.uint32()));
continue;
case 1:
if (tag !== 10) {
break;
}
message.create = CustomInterest.decode(reader, reader.uint32());
continue;
case 2:
if (tag !== 18) {
break;
}
message.update = CustomInterest.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
update_mask: isSet(object.update_mask) ? FieldMask.unwrap(FieldMask.fromJSON(object.update_mask)) : undefined,
create: isSet(object.create) ? CustomInterest.fromJSON(object.create) : undefined,
update: isSet(object.update) ? CustomInterest.fromJSON(object.update) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.update_mask !== undefined) {
obj.update_mask = FieldMask.toJSON(FieldMask.wrap(message.update_mask));
}
if (message.create !== undefined) {
obj.create = CustomInterest.toJSON(message.create);
}
if (message.update !== undefined) {
obj.update = CustomInterest.toJSON(message.update);
}
return obj;
},
create(base) {
return CustomInterestOperation.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseCustomInterestOperation();
message.update_mask = (_a = object.update_mask) !== null && _a !== void 0 ? _a : undefined;
message.create = (object.create !== undefined && object.create !== null)
? CustomInterest.fromPartial(object.create)
: undefined;
message.update = (object.update !== undefined && object.update !== null)
? CustomInterest.fromPartial(object.update)
: undefined;
return message;
},
};
function createBaseMutateCustomInterestsResponse() {
return { results: [] };
}
export const MutateCustomInterestsResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.results !== undefined && message.results.length !== 0) {
for (const v of message.results) {
MutateCustomInterestResult.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 = createBaseMutateCustomInterestsResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 2:
if (tag !== 18) {
break;
}
message.results.push(MutateCustomInterestResult.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
results: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.results)
? object.results.map((e) => MutateCustomInterestResult.fromJSON(e))
: [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.results) === null || _a === void 0 ? void 0 : _a.length) {
obj.results = message.results.map((e) => MutateCustomInterestResult.toJSON(e));
}
return obj;
},
create(base) {
return MutateCustomInterestsResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseMutateCustomInterestsResponse();
message.results = ((_a = object.results) === null || _a === void 0 ? void 0 : _a.map((e) => MutateCustomInterestResult.fromPartial(e))) || [];
return message;
},
};
function createBaseMutateCustomInterestResult() {
return { resource_name: "" };
}
export const MutateCustomInterestResult = {
encode(message, writer = _m0.Writer.create()) {
if (message.resource_name !== undefined && message.resource_name !== "") {
writer.uint32(10).string(message.resource_name);
}
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 = createBaseMutateCustomInterestResult();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resource_name = reader.string();
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) : "" };
},
toJSON(message) {
const obj = {};
if (message.resource_name !== undefined && message.resource_name !== "") {
obj.resource_name = message.resource_name;
}
return obj;
},
create(base) {
return MutateCustomInterestResult.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseMutateCustomInterestResult();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
return message;
},
};
export const CustomInterestServiceService = {
/**
* Creates or updates custom interests. Operation statuses are returned.
*
* List of thrown errors:
* [AuthenticationError]()
* [AuthorizationError]()
* [CriterionError]()
* [CustomInterestError]()
* [HeaderError]()
* [InternalError]()
* [MutateError]()
* [PolicyViolationError]()
* [QuotaError]()
* [RequestError]()
* [StringLengthError]()
*/
mutateCustomInterests: {
path: "/google.ads.googleads.v21.services.CustomInterestService/MutateCustomInterests",
requestStream: false,
responseStream: false,
requestSerialize: (value) => Buffer.from(MutateCustomInterestsRequest.encode(value).finish()),
requestDeserialize: (value) => MutateCustomInterestsRequest.decode(value),
responseSerialize: (value) => Buffer.from(MutateCustomInterestsResponse.encode(value).finish()),
responseDeserialize: (value) => MutateCustomInterestsResponse.decode(value),
},
};
export const CustomInterestServiceClient = makeGenericClientConstructor(CustomInterestServiceService, "google.ads.googleads.v21.services.CustomInterestService");
function isSet(value) {
return value !== null && value !== undefined;
}