@htdangkhoa/google-ads
Version:
Google Ads API client for Node.js
105 lines (104 loc) • 4.09 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/resources/geographic_view.proto
/* eslint-disable */
import Long from "long";
import _m0 from "protobufjs/minimal.js";
import { geoTargetingTypeEnum_GeoTargetingTypeFromJSON, geoTargetingTypeEnum_GeoTargetingTypeToJSON, } from "../enums/geo_targeting_type.js";
function createBaseGeographicView() {
return { resource_name: "", location_type: 0, country_criterion_id: undefined };
}
export const GeographicView = {
encode(message, writer = _m0.Writer.create()) {
if (message.resource_name !== undefined && message.resource_name !== "") {
writer.uint32(10).string(message.resource_name);
}
if (message.location_type !== undefined && message.location_type !== 0) {
writer.uint32(24).int32(message.location_type);
}
if (message.country_criterion_id !== undefined) {
writer.uint32(40).int64(message.country_criterion_id);
}
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 = createBaseGeographicView();
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
if (tag !== 10) {
break;
}
message.resource_name = reader.string();
continue;
case 3:
if (tag !== 24) {
break;
}
message.location_type = reader.int32();
continue;
case 5:
if (tag !== 40) {
break;
}
message.country_criterion_id = longToString(reader.int64());
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) : "",
location_type: isSet(object.location_type)
? geoTargetingTypeEnum_GeoTargetingTypeFromJSON(object.location_type)
: 0,
country_criterion_id: isSet(object.country_criterion_id)
? globalThis.String(object.country_criterion_id)
: undefined,
};
},
toJSON(message) {
const obj = {};
if (message.resource_name !== undefined && message.resource_name !== "") {
obj.resource_name = message.resource_name;
}
if (message.location_type !== undefined && message.location_type !== 0) {
obj.location_type = geoTargetingTypeEnum_GeoTargetingTypeToJSON(message.location_type);
}
if (message.country_criterion_id !== undefined) {
obj.country_criterion_id = message.country_criterion_id;
}
return obj;
},
create(base) {
return GeographicView.fromPartial(base !== null && base !== void 0 ? base : {});
},
fromPartial(object) {
var _a, _b, _c;
const message = createBaseGeographicView();
message.resource_name = (_a = object.resource_name) !== null && _a !== void 0 ? _a : "";
message.location_type = (_b = object.location_type) !== null && _b !== void 0 ? _b : 0;
message.country_criterion_id = (_c = object.country_criterion_id) !== null && _c !== void 0 ? _c : undefined;
return message;
},
};
function longToString(long) {
return long.toString();
}
if (_m0.util.Long !== Long) {
_m0.util.Long = Long;
_m0.configure();
}
function isSet(value) {
return value !== null && value !== undefined;
}