UNPKG

@htdangkhoa/google-ads

Version:
190 lines (189 loc) 7.63 kB
// 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 /* eslint-disable */ import { makeGenericClientConstructor, } from "@grpc/grpc-js"; import _m0 from "protobufjs/minimal.js"; import { monthOfYearEnum_MonthOfYearFromJSON, monthOfYearEnum_MonthOfYearToJSON, } from "../enums/month_of_year.js"; import { Invoice } from "../resources/invoice.js"; function createBaseListInvoicesRequest() { return { customer_id: "", billing_setup: "", issue_year: "", issue_month: 0 }; } export const ListInvoicesRequest = { encode(message, writer = _m0.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 _m0.Reader ? input : _m0.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) ? 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 = monthOfYearEnum_MonthOfYearToJSON(message.issue_month); } return obj; }, create(base) { return 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: [] }; } export const ListInvoicesResponse = { encode(message, writer = _m0.Writer.create()) { if (message.invoices !== undefined && message.invoices.length !== 0) { for (const v of message.invoices) { Invoice.encode(v, 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 = createBaseListInvoicesResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: if (tag !== 10) { break; } message.invoices.push(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.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.toJSON(e)); } return obj; }, create(base) { return 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.fromPartial(e))) || []; return message; }, }; export const 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(ListInvoicesRequest.encode(value).finish()), requestDeserialize: (value) => ListInvoicesRequest.decode(value), responseSerialize: (value) => Buffer.from(ListInvoicesResponse.encode(value).finish()), responseDeserialize: (value) => ListInvoicesResponse.decode(value), }, }; export const InvoiceServiceClient = makeGenericClientConstructor(InvoiceServiceService, "google.ads.googleads.v21.services.InvoiceService"); function isSet(value) { return value !== null && value !== undefined; }