hyperpop.js/order.ts

133 lines
3.3 KiB
TypeScript
Raw Permalink Normal View History

2021-11-15 21:48:48 +00:00
export interface OrderDto {
SituacionOrden?: null | string;
Date: string;
Total: number;
TotalDiscount?: number;
PaidTotal?: number;
FinancialSurcharge?: number;
WarehouseCode?: null | string;
SellerCode?: null | string;
TransportCode?: null | string;
SaleConditionCode?: number;
InvoiceCounterfoil?: number;
PriceListNumber?: number;
AgreedWithSeller?: boolean;
IvaIncluded?: boolean;
InternalTaxIncluded?: boolean;
OrderID: string;
OrderNumber: string;
ValidateTotalWithPaidTotal?: boolean;
Comment?: null | string;
Customer: CustomerDto;
CancelOrder?: boolean;
OrderItems: OrderItemDto[];
Shipping?: null | ShippingDto;
CashPayment?: null | CashPaymentDto;
CashPayments?: CashPaymentDto[] | null;
Payments?: PaymentDto[] | null;
}
export interface CustomerDto {
CustomerID: number;
Code?: null | string;
DocumentType?: null | string;
DocumentNumber?: null | string;
IVACategoryCode: string;
PayInternalTax?: boolean;
User: string;
Email: string;
FirstName?: null | string;
LastName?: null | string;
BusinessName?: null | string;
Street?: null | string;
HouseNumber?: null | string;
Floor?: null | string;
Apartment?: null | string;
City?: null | string;
ProvinceCode: string;
PostalCode?: null | string;
PhoneNumber1?: null | string;
PhoneNumber2?: null | string;
Bonus?: number;
MobilePhoneNumber?: null | string;
WebPage?: null | string;
BusinessAddress?: null | string;
Comments?: null | string;
NumberListPrice?: number;
Removed?: boolean;
DateUpdate?: string;
Disable?: string;
}
export interface OrderItemDto {
ProductCode: string;
SKUCode?: null | string;
VariantCode?: null | string;
Description: string;
VariantDescription?: null | string;
Quantity: number;
UnitPrice: number;
DiscountPercentage?: number;
}
export interface ShippingDto {
ShippingID: number;
ShippingCode?: null | string;
Street?: null | string;
HouseNumber?: null | string;
Floor?: null | string;
Apartment?: null | string;
City?: null | string;
ProvinceCode?: null | string;
PostalCode?: null | string;
PhoneNumber1?: null | string;
PhoneNumber2?: null | string;
ShippingCost?: number;
DeliversMonday?: null | string;
DeliversTuesday?: null | string;
DeliversWednesday?: null | string;
DeliversThursday?: null | string;
DeliversFriday?: null | string;
DeliversSaturday?: null | string;
DeliversSunday?: null | string;
DeliveryHours?: null | string;
}
export interface CashPaymentDto {
PaymentID?: number;
PaymentMethod: string;
PaymentTotal?: number;
}
export interface PaymentDto {
PaymentId: number;
TransactionDate: string;
AuthorizationCode?: null | string;
TransactionNumber?: null | string;
Installments: number;
InstallmentAmount: number;
Total: number;
CardCode: string;
CardPlanCode: string;
VoucherNo: number;
CardPromotionCode?: null | string;
}
export interface OrderResponse {}
export async function order(
2021-11-15 21:57:36 +00:00
host: string,
2021-11-15 21:48:48 +00:00
token: string,
order: OrderDto
): Promise<OrderResponse> {
2021-11-15 21:57:36 +00:00
const res = await fetch(`${host}/api/Aperture/order`, {
2021-11-15 21:48:48 +00:00
method: "POST",
headers: {
accesstoken: token,
"content-type": "application/json",
},
body: JSON.stringify(order),
});
const json = await res.json();
console.debug(json);
if (!json.isOk) {
throw new Error(`Tango: ${json.Message}`);
}
return json;
}