@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
281 lines (280 loc) • 10.5 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/billing_setup_service.proto
/* eslint-disable */
import { makeGenericClientConstructor, } from "@grpc/grpc-js";
import _m0 from "protobufjs/minimal.js";
import { BillingSetup } from "../resources/billing_setup.js";
function createBaseMutateBillingSetupRequest() {
return { customer_id: "", operation: undefined };
}
export const MutateBillingSetupRequest = {
encode(message, writer = _m0.Writer.create()) {
if (message.customer_id !== undefined && message.customer_id !== "") {
writer.uint32(10).string(message.customer_id);
}
if (message.operation !== undefined) {
BillingSetupOperation.encode(message.operation, 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 = createBaseMutateBillingSetupRequest();
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.operation = BillingSetupOperation.decode(reader, reader.uint32());
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) : "",
operation: isSet(object.operation) ? BillingSetupOperation.fromJSON(object.operation) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if (message.operation !== undefined) {
obj.operation = BillingSetupOperation.toJSON(message.operation);
}
return obj;
},
create(base) {
return MutateBillingSetupRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseMutateBillingSetupRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.operation = (object.operation !== undefined && object.operation !== null)
? BillingSetupOperation.fromPartial(object.operation)
: undefined;
return message;
},
};
function createBaseBillingSetupOperation() {
return { create: undefined, remove: undefined };
}
export const BillingSetupOperation = {
encode(message, writer = _m0.Writer.create()) {
if (message.create !== undefined) {
BillingSetup.encode(message.create, writer.uint32(18).fork()).ldelim();
}
if (message.remove !== undefined) {
writer.uint32(10).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 = createBaseBillingSetupOperation();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 2:
if (tag !== 18) {
break;
}
message.create = BillingSetup.decode(reader, reader.uint32());
continue;
case 1:
if (tag !== 10) {
break;
}
message.remove = reader.string();
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
create: isSet(object.create) ? BillingSetup.fromJSON(object.create) : undefined,
remove: isSet(object.remove) ? globalThis.String(object.remove) : undefined,
};
},
toJSON(message) {
const obj = {};
if (message.create !== undefined) {
obj.create = BillingSetup.toJSON(message.create);
}
if (message.remove !== undefined) {
obj.remove = message.remove;
}
return obj;
},
create(base) {
return BillingSetupOperation.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseBillingSetupOperation();
message.create = (object.create !== undefined && object.create !== null)
? BillingSetup.fromPartial(object.create)
: undefined;
message.remove = (_a = object.remove) !== null && _a !== void 0 ? _a : undefined;
return message;
},
};
function createBaseMutateBillingSetupResponse() {
return { result: undefined };
}
export const MutateBillingSetupResponse = {
encode(message, writer = _m0.Writer.create()) {
if (message.result !== undefined) {
MutateBillingSetupResult.encode(message.result, writer.uint32(10).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 = createBaseMutateBillingSetupResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.result = MutateBillingSetupResult.decode(reader, reader.uint32());
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return { result: isSet(object.result) ? MutateBillingSetupResult.fromJSON(object.result) : undefined };
},
toJSON(message) {
const obj = {};
if (message.result !== undefined) {
obj.result = MutateBillingSetupResult.toJSON(message.result);
}
return obj;
},
create(base) {
return MutateBillingSetupResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
const message = createBaseMutateBillingSetupResponse();
message.result = (object.result !== undefined && object.result !== null)
? MutateBillingSetupResult.fromPartial(object.result)
: undefined;
return message;
},
};
function createBaseMutateBillingSetupResult() {
return { resource_name: "" };
}
export const MutateBillingSetupResult = {
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 = createBaseMutateBillingSetupResult();
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 MutateBillingSetupResult.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseMutateBillingSetupResult();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
return message;
},
};
export const BillingSetupServiceService = {
/**
* Creates a billing setup, or cancels an existing billing setup.
*
* List of thrown errors:
* [AuthenticationError]()
* [AuthorizationError]()
* [BillingSetupError]()
* [DateError]()
* [FieldError]()
* [HeaderError]()
* [InternalError]()
* [MutateError]()
* [QuotaError]()
* [RequestError]()
*/
mutateBillingSetup: {
path: "/google.ads.googleads.v21.services.BillingSetupService/MutateBillingSetup",
requestStream: false,
responseStream: false,
requestSerialize: (value) => Buffer.from(MutateBillingSetupRequest.encode(value).finish()),
requestDeserialize: (value) => MutateBillingSetupRequest.decode(value),
responseSerialize: (value) => Buffer.from(MutateBillingSetupResponse.encode(value).finish()),
responseDeserialize: (value) => MutateBillingSetupResponse.decode(value),
},
};
export const BillingSetupServiceClient = makeGenericClientConstructor(BillingSetupServiceService, "google.ads.googleads.v21.services.BillingSetupService");
function isSet(value) {
return value !== null && value !== undefined;
}