@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
196 lines (195 loc) • 8.21 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/invoice_service.proto
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InvoiceServiceClient = exports.InvoiceServiceService = exports.ListInvoicesResponse = exports.ListInvoicesRequest = void 0;
/* eslint-disable */
const grpc_js_1 = require("@grpc/grpc-js");
const minimal_js_1 = __importDefault(require("protobufjs/minimal.js"));
const month_of_year_js_1 = require("../enums/month_of_year.js");
const invoice_js_1 = require("../resources/invoice.js");
function createBaseListInvoicesRequest() {
return { customer_id: "", billing_setup: "", issue_year: "", issue_month: 0 };
}
exports.ListInvoicesRequest = {
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.billing_setup !== undefined && message.billing_setup !== "") {
writer.uint32(18).string(message.billing_setup);
}
if (message.issue_year !== undefined && message.issue_year !== "") {
writer.uint32(26).string(message.issue_year);
}
if (message.issue_month !== undefined && message.issue_month !== 0) {
writer.uint32(32).int32(message.issue_month);
}
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 = createBaseListInvoicesRequest();
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.billing_setup = reader.string();
continue;
case 3:
if (tag !== 26) {
break;
}
message.issue_year = reader.string();
continue;
case 4:
if (tag !== 32) {
break;
}
message.issue_month = 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) : "",
billing_setup: isSet(object.billing_setup) ? globalThis.String(object.billing_setup) : "",
issue_year: isSet(object.issue_year) ? globalThis.String(object.issue_year) : "",
issue_month: isSet(object.issue_month) ? (0, month_of_year_js_1.monthOfYearEnum_MonthOfYearFromJSON)(object.issue_month) : 0,
};
},
toJSON(message) {
const obj = {};
if (message.customer_id !== undefined && message.customer_id !== "") {
obj.customer_id = message.customer_id;
}
if (message.billing_setup !== undefined && message.billing_setup !== "") {
obj.billing_setup = message.billing_setup;
}
if (message.issue_year !== undefined && message.issue_year !== "") {
obj.issue_year = message.issue_year;
}
if (message.issue_month !== undefined && message.issue_month !== 0) {
obj.issue_month = (0, month_of_year_js_1.monthOfYearEnum_MonthOfYearToJSON)(message.issue_month);
}
return obj;
},
create(base) {
return exports.ListInvoicesRequest.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c, _d;
const message = createBaseListInvoicesRequest();
message.customer_id = (_a = object.customer_id) !== null && _a !== void 0 ? _a : "";
message.billing_setup = (_b = object.billing_setup) !== null && _b !== void 0 ? _b : "";
message.issue_year = (_c = object.issue_year) !== null && _c !== void 0 ? _c : "";
message.issue_month = (_d = object.issue_month) !== null && _d !== void 0 ? _d : 0;
return message;
},
};
function createBaseListInvoicesResponse() {
return { invoices: [] };
}
exports.ListInvoicesResponse = {
encode(message, writer = minimal_js_1.default.Writer.create()) {
if (message.invoices !== undefined && message.invoices.length !== 0) {
for (const v of message.invoices) {
invoice_js_1.Invoice.encode(v, 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 = createBaseListInvoicesResponse();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.invoices.push(invoice_js_1.Invoice.decode(reader, reader.uint32()));
continue;
}
if ((tag & 7) === 4 || tag === 0) {
break;
}
reader.skipType(tag & 7);
}
return message;
},
fromJSON(object) {
return {
invoices: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.invoices) ? object.invoices.map((e) => invoice_js_1.Invoice.fromJSON(e)) : [],
};
},
toJSON(message) {
var _a;
const obj = {};
if ((_a = message.invoices) === null || _a === void 0 ? void 0 : _a.length) {
obj.invoices = message.invoices.map((e) => invoice_js_1.Invoice.toJSON(e));
}
return obj;
},
create(base) {
return exports.ListInvoicesResponse.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a;
const message = createBaseListInvoicesResponse();
message.invoices = ((_a = object.invoices) === null || _a === void 0 ? void 0 : _a.map((e) => invoice_js_1.Invoice.fromPartial(e))) || [];
return message;
},
};
exports.InvoiceServiceService = {
/**
* Returns all invoices associated with a billing setup, for a given month.
*
* List of thrown errors:
* [AuthenticationError]()
* [AuthorizationError]()
* [FieldError]()
* [HeaderError]()
* [InternalError]()
* [InvoiceError]()
* [QuotaError]()
* [RequestError]()
*/
listInvoices: {
path: "/google.ads.googleads.v21.services.InvoiceService/ListInvoices",
requestStream: false,
responseStream: false,
requestSerialize: (value) => Buffer.from(exports.ListInvoicesRequest.encode(value).finish()),
requestDeserialize: (value) => exports.ListInvoicesRequest.decode(value),
responseSerialize: (value) => Buffer.from(exports.ListInvoicesResponse.encode(value).finish()),
responseDeserialize: (value) => exports.ListInvoicesResponse.decode(value),
},
};
exports.InvoiceServiceClient = (0, grpc_js_1.makeGenericClientConstructor)(exports.InvoiceServiceService, "google.ads.googleads.v21.services.InvoiceService");
function isSet(value) {
return value !== null && value !== undefined;
}