UNPKG

@htdangkhoa/google-ads

Version:
427 lines (426 loc) 18.3 kB
"use strict"; // 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/ad_service.proto var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.AdServiceClient = exports.AdServiceService = exports.MutateAdResult = exports.MutateAdsResponse = exports.AdOperation = exports.MutateAdsRequest = void 0; /* eslint-disable */ const grpc_js_1 = require("@grpc/grpc-js"); const minimal_js_1 = __importDefault(require("protobufjs/minimal.js")); const field_mask_js_1 = require("../../../../protobuf/field_mask.js"); const status_js_1 = require("../../../../rpc/status.js"); const policy_js_1 = require("../common/policy.js"); const response_content_type_js_1 = require("../enums/response_content_type.js"); const ad_js_1 = require("../resources/ad.js"); function createBaseMutateAdsRequest() { return { customer_id: "", operations: [], partial_failure: false, response_content_type: 0, validate_only: false }; } exports.MutateAdsRequest = { encode(message, writer = minimal_js_1.default.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) { exports.AdOperation.encode(v, writer.uint32(18).fork()).ldelim(); } } if (message.partial_failure !== undefined && message.partial_failure !== false) { writer.uint32(32).bool(message.partial_failure); } if (message.response_content_type !== undefined && message.response_content_type !== 0) { writer.uint32(40).int32(message.response_content_type); } if (message.validate_only !== undefined && message.validate_only !== false) { writer.uint32(24).bool(message.validate_only); } 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 = createBaseMutateAdsRequest(); 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(exports.AdOperation.decode(reader, reader.uint32())); continue; case 4: if (tag !== 32) { break; } message.partial_failure = reader.bool(); continue; case 5: if (tag !== 40) { break; } message.response_content_type = reader.int32(); continue; case 3: if (tag !== 24) { 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) => exports.AdOperation.fromJSON(e)) : [], partial_failure: isSet(object.partial_failure) ? globalThis.Boolean(object.partial_failure) : false, response_content_type: isSet(object.response_content_type) ? (0, response_content_type_js_1.responseContentTypeEnum_ResponseContentTypeFromJSON)(object.response_content_type) : 0, 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) => exports.AdOperation.toJSON(e)); } if (message.partial_failure !== undefined && message.partial_failure !== false) { obj.partial_failure = message.partial_failure; } if (message.response_content_type !== undefined && message.response_content_type !== 0) { obj.response_content_type = (0, response_content_type_js_1.responseContentTypeEnum_ResponseContentTypeToJSON)(message.response_content_type); } if (message.validate_only !== undefined && message.validate_only !== false) { obj.validate_only = message.validate_only; } return obj; }, create(base) { return exports.MutateAdsRequest.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a, _b, _c, _d, _e; const message = createBaseMutateAdsRequest(); 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) => exports.AdOperation.fromPartial(e))) || []; message.partial_failure = (_c = object.partial_failure) !== null && _c !== void 0 ? _c : false; message.response_content_type = (_d = object.response_content_type) !== null && _d !== void 0 ? _d : 0; message.validate_only = (_e = object.validate_only) !== null && _e !== void 0 ? _e : false; return message; }, }; function createBaseAdOperation() { return { update_mask: undefined, policy_validation_parameter: undefined, update: undefined }; } exports.AdOperation = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.update_mask !== undefined) { field_mask_js_1.FieldMask.encode(field_mask_js_1.FieldMask.wrap(message.update_mask), writer.uint32(18).fork()).ldelim(); } if (message.policy_validation_parameter !== undefined) { policy_js_1.PolicyValidationParameter.encode(message.policy_validation_parameter, writer.uint32(26).fork()).ldelim(); } if (message.update !== undefined) { ad_js_1.Ad.encode(message.update, writer.uint32(10).fork()).ldelim(); } 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 = createBaseAdOperation(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 2: if (tag !== 18) { break; } message.update_mask = field_mask_js_1.FieldMask.unwrap(field_mask_js_1.FieldMask.decode(reader, reader.uint32())); continue; case 3: if (tag !== 26) { break; } message.policy_validation_parameter = policy_js_1.PolicyValidationParameter.decode(reader, reader.uint32()); continue; case 1: if (tag !== 10) { break; } message.update = ad_js_1.Ad.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) ? field_mask_js_1.FieldMask.unwrap(field_mask_js_1.FieldMask.fromJSON(object.update_mask)) : undefined, policy_validation_parameter: isSet(object.policy_validation_parameter) ? policy_js_1.PolicyValidationParameter.fromJSON(object.policy_validation_parameter) : undefined, update: isSet(object.update) ? ad_js_1.Ad.fromJSON(object.update) : undefined, }; }, toJSON(message) { const obj = {}; if (message.update_mask !== undefined) { obj.update_mask = field_mask_js_1.FieldMask.toJSON(field_mask_js_1.FieldMask.wrap(message.update_mask)); } if (message.policy_validation_parameter !== undefined) { obj.policy_validation_parameter = policy_js_1.PolicyValidationParameter.toJSON(message.policy_validation_parameter); } if (message.update !== undefined) { obj.update = ad_js_1.Ad.toJSON(message.update); } return obj; }, create(base) { return exports.AdOperation.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a; const message = createBaseAdOperation(); message.update_mask = (_a = object.update_mask) !== null && _a !== void 0 ? _a : undefined; message.policy_validation_parameter = (object.policy_validation_parameter !== undefined && object.policy_validation_parameter !== null) ? policy_js_1.PolicyValidationParameter.fromPartial(object.policy_validation_parameter) : undefined; message.update = (object.update !== undefined && object.update !== null) ? ad_js_1.Ad.fromPartial(object.update) : undefined; return message; }, }; function createBaseMutateAdsResponse() { return { partial_failure_error: undefined, results: [] }; } exports.MutateAdsResponse = { encode(message, writer = minimal_js_1.default.Writer.create()) { if (message.partial_failure_error !== undefined) { status_js_1.Status.encode(message.partial_failure_error, writer.uint32(26).fork()).ldelim(); } if (message.results !== undefined && message.results.length !== 0) { for (const v of message.results) { exports.MutateAdResult.encode(v, writer.uint32(18).fork()).ldelim(); } } 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 = createBaseMutateAdsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 3: if (tag !== 26) { break; } message.partial_failure_error = status_js_1.Status.decode(reader, reader.uint32()); continue; case 2: if (tag !== 18) { break; } message.results.push(exports.MutateAdResult.decode(reader, reader.uint32())); continue; } if ((tag & 7) === 4 || tag === 0) { break; } reader.skipType(tag & 7); } return message; }, fromJSON(object) { return { partial_failure_error: isSet(object.partial_failure_error) ? status_js_1.Status.fromJSON(object.partial_failure_error) : undefined, results: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.results) ? object.results.map((e) => exports.MutateAdResult.fromJSON(e)) : [], }; }, toJSON(message) { var _a; const obj = {}; if (message.partial_failure_error !== undefined) { obj.partial_failure_error = status_js_1.Status.toJSON(message.partial_failure_error); } if ((_a = message.results) === null || _a === void 0 ? void 0 : _a.length) { obj.results = message.results.map((e) => exports.MutateAdResult.toJSON(e)); } return obj; }, create(base) { return exports.MutateAdsResponse.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a; const message = createBaseMutateAdsResponse(); message.partial_failure_error = (object.partial_failure_error !== undefined && object.partial_failure_error !== null) ? status_js_1.Status.fromPartial(object.partial_failure_error) : undefined; message.results = ((_a = object.results) === null || _a === void 0 ? void 0 : _a.map((e) => exports.MutateAdResult.fromPartial(e))) || []; return message; }, }; function createBaseMutateAdResult() { return { resource_name: "", ad: undefined }; } exports.MutateAdResult = { 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.ad !== undefined) { ad_js_1.Ad.encode(message.ad, writer.uint32(18).fork()).ldelim(); } 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 = createBaseMutateAdResult(); 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.ad = ad_js_1.Ad.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) : "", ad: isSet(object.ad) ? ad_js_1.Ad.fromJSON(object.ad) : undefined, }; }, toJSON(message) { const obj = {}; if (message.resource_name !== undefined && message.resource_name !== "") { obj.resource_name = message.resource_name; } if (message.ad !== undefined) { obj.ad = ad_js_1.Ad.toJSON(message.ad); } return obj; }, create(base) { return exports.MutateAdResult.fromPartial(base !== null && base !== void 0 ? base : {}); }, fromPartial(object) { var _a; const message = createBaseMutateAdResult(); message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : ""; message.ad = (object.ad !== undefined && object.ad !== null) ? ad_js_1.Ad.fromPartial(object.ad) : undefined; return message; }, }; exports.AdServiceService = { /** * Updates ads. Operation statuses are returned. Updating ads is not supported * for TextAd, ExpandedDynamicSearchAd, GmailAd and ImageAd. * * List of thrown errors: * [AdCustomizerError]() * [AdError]() * [AdSharingError]() * [AdxError]() * [AssetError]() * [AssetLinkError]() * [AuthenticationError]() * [AuthorizationError]() * [CollectionSizeError]() * [DatabaseError]() * [DateError]() * [DistinctError]() * [FeedAttributeReferenceError]() * [FieldError]() * [FieldMaskError]() * [FunctionError]() * [FunctionParsingError]() * [HeaderError]() * [IdError]() * [ImageError]() * [InternalError]() * [ListOperationError]() * [MediaBundleError]() * [MediaFileError]() * [MutateError]() * [NewResourceCreationError]() * [NotEmptyError]() * [NullError]() * [OperatorError]() * [PolicyFindingError]() * [PolicyViolationError]() * [QuotaError]() * [RangeError]() * [RequestError]() * [SizeLimitError]() * [StringFormatError]() * [StringLengthError]() * [UrlFieldError]() */ mutateAds: { path: "/google.ads.googleads.v21.services.AdService/MutateAds", requestStream: false, responseStream: false, requestSerialize: (value) => Buffer.from(exports.MutateAdsRequest.encode(value).finish()), requestDeserialize: (value) => exports.MutateAdsRequest.decode(value), responseSerialize: (value) => Buffer.from(exports.MutateAdsResponse.encode(value).finish()), responseDeserialize: (value) => exports.MutateAdsResponse.decode(value), }, }; exports.AdServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.AdServiceService, "google.ads.googleads.v21.services.AdService"); function isSet(value) { return value !== null && value !== undefined; }