UNPKG

tgsnake

Version:

Telegram MTProto framework for nodejs.

111 lines (110 loc) 3.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PreCheckoutQuery = exports.ShippingQuery = exports.OrderInfo = exports.ShippingAddress = void 0; const TL_js_1 = require("../TL.js"); const User_js_1 = require("../Advanced/User.js"); class ShippingAddress extends TL_js_1.TLObject { countryCode; state; city; streetLine1; streetLine2; postCode; constructor({ countryCode, state, city, streetLine1, streetLine2, postCode }, client) { super(client); this.countryCode = countryCode; this.state = state; this.city = city; this.streetLine1 = streetLine1; this.streetLine2 = streetLine2; this.postCode = postCode; } static parse(client, address) { return new ShippingAddress({ countryCode: address.countryIso2, state: address.state, city: address.city, streetLine1: address.streetLine1, streetLine2: address.streetLine2, postCode: address.postCode, }, client); } } exports.ShippingAddress = ShippingAddress; class OrderInfo extends TL_js_1.TLObject { name; phoneNumber; email; shippingAddress; constructor({ name, phoneNumber, email, shippingAddress }, client) { super(client); this.name = name; this.phoneNumber = phoneNumber; this.email = email; this.shippingAddress = shippingAddress; } static parse(client, info) { return new OrderInfo({ name: info.name, phoneNumber: info.phone, email: info.email, shippingAddress: info.shippingAddress ? ShippingAddress.parse(client, info.shippingAddress) : undefined, }, client); } } exports.OrderInfo = OrderInfo; class ShippingQuery extends TL_js_1.TLObject { id; invoicePayload; shippingAddress; from; constructor({ id, invoicePayload, shippingAddress, from }, client) { super(client); this.id = id; this.invoicePayload = invoicePayload; this.shippingAddress = shippingAddress; this.from = from; } static parse(client, update, users) { return new ShippingQuery({ id: String(update.queryId), invoicePayload: update.payload.toString(), shippingAddress: ShippingAddress.parse(client, update.shippingAddress), from: User_js_1.User.parse(client, users.find((user) => user.id === update.userId)), }, client); } } exports.ShippingQuery = ShippingQuery; class PreCheckoutQuery extends TL_js_1.TLObject { id; currency; totalAmount; invoicePayload; shippingOptionId; orderInfo; from; constructor({ id, currency, totalAmount, invoicePayload, shippingOptionId, orderInfo, from, }, client) { super(client); this.id = id; this.currency = currency; this.totalAmount = totalAmount; this.invoicePayload = invoicePayload; this.shippingOptionId = shippingOptionId; this.orderInfo = orderInfo; this.from = from; } static parse(client, update, users) { return new PreCheckoutQuery({ id: String(update.queryId), currency: update.currency, totalAmount: update.totalAmount, invoicePayload: update.payload.toString(), shippingOptionId: update.shippingOptionId, orderInfo: update.info ? OrderInfo.parse(client, update.info) : undefined, from: User_js_1.User.parse(client, users.find((user) => user.id === update.userId)), }, client); } } exports.PreCheckoutQuery = PreCheckoutQuery;