@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
379 lines (378 loc) • 16.7 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/v19/services/customizer_attribute_service.proto
/* eslint-disable */
import { makeGenericClientConstructor, } from "@grpc/grpc-js";
import _m0 from "protobufjs/minimal.js";
import { FieldMask } from "../../../../protobuf/field_mask.js";
import { Status } from "../../../../rpc/status.js";
import { responseContentTypeEnum_ResponseContentTypeFromJSON, responseContentTypeEnum_ResponseContentTypeToJSON, } from "../enums/response_content_type.js";
import { CustomizerAttribute } from "../resources/customizer_attribute.js";
function createBaseMutateCustomizerAttributesRequest() {
return { customer_id: "", operations: [], partial_failure: false, validate_only: false, response_content_type: 0 };
}
export const MutateCustomizerAttributesRequest = {
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) {
CustomizerAttributeOperation.encode(v, writer.uint32(18).fork()).ldelim();
}
}
if (message.partial_failure !== undefined && message.partial_failure !== false) {
writer.uint32(24).bool(message.partial_failure);
}
if (message.validate_only !== undefined && message.validate_only !== false) {
writer.uint32(32).bool(message.validate_only);
}
if (message.response_content_type !== undefined && message.response_content_type !== 0) {
writer.uint32(40).int32(message.response_content_type);
}
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 = createBaseMutateCustomizerAttributesRequest();
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(CustomizerAttributeOperation.decode(reader, reader.uint32()));
continue;
case 3:
if (tag !== 24) {
break;
}
message.partial_failure = reader.bool();
continue;
case 4:
if (tag !== 32) {
break;
}
message.validate_only = reader.bool();
continue;
case 5:
if (tag !== 40) {
break;
}
message.response_content_type = reader.int32();
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) => CustomizerAttributeOperation.fromJSON(e))
: [],
partial_failure: isSet(object.partial_failure) ? globalThis.Boolean(object.partial_failure) : false,
validate_only: isSet(object.validate_only) ? globalThis.Boolean(object.validate_only) : false,
response_content_type: isSet(object.response_content_type)
? responseContentTypeEnum_ResponseContentTypeFromJSON(object.response_content_type)
: 0,
};
},
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) => CustomizerAttributeOperation.toJSON(e));
}
if (message.partial_failure !== undefined && message.partial_failure !== false) {
obj.partial_failure = message.partial_failure;
}
if (message.validate_only !== undefined && message.validate_only !== false) {
obj.validate_only = message.validate_only;
}
if (message.response_content_type !== undefined && message.response_content_type !== 0) {
obj.response_content_type = responseContentTypeEnum_ResponseContentTypeToJSON(message.response_content_type);
}
return obj;
},
create(base) {
return MutateCustomizerAttributesRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d, _e;
const message = createBaseMutateCustomizerAttributesRequest();
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) => CustomizerAttributeOperation.fromPartial(e))) || [];
message.partial_failure = (_c = object.partial_failure) !== null && _c !== void 0 ? _c : false;
message.validate_only = (_d = object.validate_only) !== null && _d !== void 0 ? _d : false;
message.response_content_type = (_e = object.response_content_type) !== null && _e !== void 0 ? _e : 0;
return message;
},
};
function createBaseCustomizerAttributeOperation() {
return { update_mask: undefined, create: undefined, remove: undefined };
}
export const CustomizerAttributeOperation = {
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) {
CustomizerAttribute.encode(message.create, writer.uint32(10).fork()).ldelim();
}
if (message.remove !== undefined) {
writer.uint32(18).string(message.remove);
}
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 = createBaseCustomizerAttributeOperation();
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 = CustomizerAttribute.decode(reader, reader.uint32());
continue;
case 2:
if (tag !== 18) {
break;
}
message.remove = reader.string();
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) ? CustomizerAttribute.fromJSON(object.create) : undefined,
remove: isSet(object.remove) ? globalThis.String(object.remove) : 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 = CustomizerAttribute.toJSON(message.create);
}
if (message.remove !== undefined) {
obj.remove = message.remove;
}
return obj;
},
create(base) {
return CustomizerAttributeOperation.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b;
const message = createBaseCustomizerAttributeOperation();
message.update_mask = (_a = object.update_mask) !== null && _a !== void 0 ? _a : undefined;
message.create = (object.create !== undefined && object.create !== null)
? CustomizerAttribute.fromPartial(object.create)
: undefined;
message.remove = (_b = object.remove) !== null && _b !== void 0 ? _b : undefined;
return message;
},
};
function createBaseMutateCustomizerAttributesResponse() {
return { results: [], partial_failure_error: undefined };
}
export const MutateCustomizerAttributesResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.results !== undefined && message.results.length !== 0) {
for (const v of message.results) {
MutateCustomizerAttributeResult.encode(v, writer.uint32(10).fork()).ldelim();
}
}
if (message.partial_failure_error !== undefined) {
Status.encode(message.partial_failure_error, 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 = createBaseMutateCustomizerAttributesResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.results.push(MutateCustomizerAttributeResult.decode(reader, reader.uint32()));
continue;
case 2:
if (tag !== 18) {
break;
}
message.partial_failure_error = Status.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) => MutateCustomizerAttributeResult.fromJSON(e))
: [],
partial_failure_error: isSet(object.partial_failure_error)
? Status.fromJSON(object.partial_failure_error)
: undefined,
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.results) === null || _a === void 0 ? void 0 : _a.length) {
obj.results = message.results.map((e) => MutateCustomizerAttributeResult.toJSON(e));
}
if (message.partial_failure_error !== undefined) {
obj.partial_failure_error = Status.toJSON(message.partial_failure_error);
}
return obj;
},
create(base) {
return MutateCustomizerAttributesResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseMutateCustomizerAttributesResponse();
message.results = ((_a = object.results) === null || _a === void 0 ? void 0 : _a.map((e) => MutateCustomizerAttributeResult.fromPartial(e))) || [];
message.partial_failure_error =
(object.partial_failure_error !== undefined && object.partial_failure_error !== null)
? Status.fromPartial(object.partial_failure_error)
: undefined;
return message;
},
};
function createBaseMutateCustomizerAttributeResult() {
return { resource_name: "", customizer_attribute: undefined };
}
export const MutateCustomizerAttributeResult = {
encode(message, writer = _m0.Writer.create()) {
if (message.resource_name !== undefined && message.resource_name !== "") {
writer.uint32(10).string(message.resource_name);
}
if (message.customizer_attribute !== undefined) {
CustomizerAttribute.encode(message.customizer_attribute, 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 = createBaseMutateCustomizerAttributeResult();
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 !== 18) {
break;
}
message.customizer_attribute = CustomizerAttribute.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) : "",
customizer_attribute: isSet(object.customizer_attribute)
? CustomizerAttribute.fromJSON(object.customizer_attribute)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.resource_name !== undefined && message.resource_name !== "") {
obj.resource_name = message.resource_name;
}
if (message.customizer_attribute !== undefined) {
obj.customizer_attribute = CustomizerAttribute.toJSON(message.customizer_attribute);
}
return obj;
},
create(base) {
return MutateCustomizerAttributeResult.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseMutateCustomizerAttributeResult();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
message.customizer_attribute = (object.customizer_attribute !== undefined && object.customizer_attribute !== null)
? CustomizerAttribute.fromPartial(object.customizer_attribute)
: undefined;
return message;
},
};
export const CustomizerAttributeServiceService = {
/**
* Creates, updates or removes customizer attributes. Operation statuses are
* returned.
*/
mutateCustomizerAttributes: {
path: "/google.ads.googleads.v19.services.CustomizerAttributeService/MutateCustomizerAttributes",
requestStream: false,
responseStream: false,
requestSerialize: (value) => Buffer.from(MutateCustomizerAttributesRequest.encode(value).finish()),
requestDeserialize: (value) => MutateCustomizerAttributesRequest.decode(value),
responseSerialize: (value) => Buffer.from(MutateCustomizerAttributesResponse.encode(value).finish()),
responseDeserialize: (value) => MutateCustomizerAttributesResponse.decode(value),
},
};
export const CustomizerAttributeServiceClient = makeGenericClientConstructor(CustomizerAttributeServiceService, "google.ads.googleads.v19.services.CustomizerAttributeService");
function isSet(value) {
return value !== null && value !== undefined;
}