Compare commits
No commits in common. "3429b10896abcbd02703fb98c47b026c17e11465" and "c21e34cc07b9a3c36e75870656e4d11f76dbaee2" have entirely different histories.
3429b10896
...
c21e34cc07
9 changed files with 2 additions and 123 deletions
23
common.ts
23
common.ts
|
@ -40,26 +40,3 @@ export function paginacionToSearchParams(
|
||||||
searchParams.set("pageNumber", "1");
|
searchParams.set("pageNumber", "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface QueryCustomer {
|
|
||||||
type: TipoDeDocumento;
|
|
||||||
number: string;
|
|
||||||
}
|
|
||||||
export function queryCustomerToSearchParams(
|
|
||||||
cliente: QueryCustomer,
|
|
||||||
searchParams: URLSearchParams
|
|
||||||
) {
|
|
||||||
if (cliente) {
|
|
||||||
searchParams.set("documentType", cliente.type.toString());
|
|
||||||
searchParams.set("documentNumber", cliente.number);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum TipoDeDocumento {
|
|
||||||
CUIT = 80,
|
|
||||||
CUIL = 86,
|
|
||||||
CDI = 87,
|
|
||||||
LE = 89,
|
|
||||||
LC = 90,
|
|
||||||
DNI = 96,
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +1,12 @@
|
||||||
import {
|
import {
|
||||||
QueryCustomer,
|
|
||||||
HOST,
|
HOST,
|
||||||
Paginacion,
|
Paginacion,
|
||||||
paginacionToSearchParams,
|
paginacionToSearchParams,
|
||||||
Paging,
|
Paging,
|
||||||
queryCustomerToSearchParams,
|
|
||||||
TipoDeDocumento,
|
|
||||||
} from "./common.js";
|
} from "./common.js";
|
||||||
|
|
||||||
export interface CustomerQuery {
|
export interface CustomerQuery {
|
||||||
paginacion?: Paginacion;
|
paginacion?: Paginacion;
|
||||||
customer?: QueryCustomer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Customer {
|
export interface Customer {
|
||||||
|
@ -27,7 +23,7 @@ export interface Customer {
|
||||||
MobilePhoneNumber: string;
|
MobilePhoneNumber: string;
|
||||||
WebPage: string;
|
WebPage: string;
|
||||||
IvaCategoryCode: string;
|
IvaCategoryCode: string;
|
||||||
DocumentType: TipoDeDocumento;
|
DocumentType: string;
|
||||||
DocumentNumber: string;
|
DocumentNumber: string;
|
||||||
PriceListNumber: number;
|
PriceListNumber: number;
|
||||||
Discount: number;
|
Discount: number;
|
||||||
|
@ -83,9 +79,6 @@ export async function getCustomers(
|
||||||
): Promise<CustomerResponse> {
|
): Promise<CustomerResponse> {
|
||||||
let searchParams = new URLSearchParams();
|
let searchParams = new URLSearchParams();
|
||||||
paginacionToSearchParams(options.paginacion, searchParams);
|
paginacionToSearchParams(options.paginacion, searchParams);
|
||||||
if (options.customer) {
|
|
||||||
queryCustomerToSearchParams(options.customer, searchParams);
|
|
||||||
}
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${HOST}/api/Aperture/Customer?${searchParams.toString()}`,
|
`${HOST}/api/Aperture/Customer?${searchParams.toString()}`,
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
getPrices,
|
getPrices,
|
||||||
getPricesByCustomer,
|
getPricesByCustomer,
|
||||||
getCustomers,
|
getCustomers,
|
||||||
getPublications,
|
|
||||||
} from "../index.js";
|
} from "../index.js";
|
||||||
|
|
||||||
const tokenInput = document.querySelector<HTMLInputElement>("#token-input")!;
|
const tokenInput = document.querySelector<HTMLInputElement>("#token-input")!;
|
||||||
|
@ -78,7 +77,6 @@ setupForm("#save-token", async () => {
|
||||||
localStorage.token = token();
|
localStorage.token = token();
|
||||||
});
|
});
|
||||||
setupForm("#productos", () => getProductos(token(), {}));
|
setupForm("#productos", () => getProductos(token(), {}));
|
||||||
setupForm("#publicaciones", () => getPublications(token(), {}));
|
|
||||||
setupForm("#price", () => getPrices(token(), {}));
|
setupForm("#price", () => getPrices(token(), {}));
|
||||||
setupForm("#price-by-customer", (event) =>
|
setupForm("#price-by-customer", (event) =>
|
||||||
getPricesByCustomer(token(), { filter: (event.target! as any).filter.value })
|
getPricesByCustomer(token(), { filter: (event.target! as any).filter.value })
|
||||||
|
|
|
@ -38,11 +38,6 @@
|
||||||
<p class="status"></p>
|
<p class="status"></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form id="publicaciones">
|
|
||||||
<button>Conseguir publicaciones</button>
|
|
||||||
<p class="status"></p>
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form id="price">
|
<form id="price">
|
||||||
<button>Conseguir precios</button>
|
<button>Conseguir precios</button>
|
||||||
<p class="status"></p>
|
<p class="status"></p>
|
||||||
|
|
1
index.ts
1
index.ts
|
@ -5,4 +5,3 @@ export * from "./product.js";
|
||||||
export * from "./price.js";
|
export * from "./price.js";
|
||||||
export * from "./priceByCustomer.js";
|
export * from "./priceByCustomer.js";
|
||||||
export * from "./customer.js";
|
export * from "./customer.js";
|
||||||
export * from "./publications.js";
|
|
||||||
|
|
8
price.ts
8
price.ts
|
@ -7,8 +7,6 @@ import {
|
||||||
|
|
||||||
export interface PriceQuery {
|
export interface PriceQuery {
|
||||||
paginacion?: Paginacion;
|
paginacion?: Paginacion;
|
||||||
filter?: string;
|
|
||||||
SKUCode?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Price {
|
export interface Price {
|
||||||
|
@ -30,12 +28,6 @@ export async function getPrices(
|
||||||
): Promise<PriceResponse> {
|
): Promise<PriceResponse> {
|
||||||
let searchParams = new URLSearchParams();
|
let searchParams = new URLSearchParams();
|
||||||
paginacionToSearchParams(options.paginacion, searchParams);
|
paginacionToSearchParams(options.paginacion, searchParams);
|
||||||
if (options.filter) {
|
|
||||||
searchParams.set("filter", options.filter);
|
|
||||||
}
|
|
||||||
if (options.SKUCode) {
|
|
||||||
searchParams.set("SKUCode", options.SKUCode);
|
|
||||||
}
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${HOST}/api/Aperture/Price?${searchParams.toString()}`,
|
`${HOST}/api/Aperture/Price?${searchParams.toString()}`,
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import {
|
||||||
QueryCustomer,
|
|
||||||
queryCustomerToSearchParams,
|
|
||||||
HOST,
|
HOST,
|
||||||
Paginacion,
|
Paginacion,
|
||||||
paginacionToSearchParams,
|
paginacionToSearchParams,
|
||||||
|
@ -11,8 +9,6 @@ export interface PriceByCustomerQuery {
|
||||||
paginacion?: Paginacion;
|
paginacion?: Paginacion;
|
||||||
/// Filtro por el código del cliente ("Code" en Customer.)
|
/// Filtro por el código del cliente ("Code" en Customer.)
|
||||||
filter?: string;
|
filter?: string;
|
||||||
SKUCode?: string;
|
|
||||||
customer?: QueryCustomer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Precio {
|
export interface Precio {
|
||||||
|
@ -36,12 +32,6 @@ export async function getPricesByCustomer(
|
||||||
if (options.filter) {
|
if (options.filter) {
|
||||||
searchParams.set("filter", options.filter);
|
searchParams.set("filter", options.filter);
|
||||||
}
|
}
|
||||||
if (options.SKUCode) {
|
|
||||||
searchParams.set("SKUCode", options.SKUCode);
|
|
||||||
}
|
|
||||||
if (options.customer) {
|
|
||||||
queryCustomerToSearchParams(options.customer, searchParams);
|
|
||||||
}
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${HOST}/api/Aperture/PriceByCustomer?${searchParams.toString()}`,
|
`${HOST}/api/Aperture/PriceByCustomer?${searchParams.toString()}`,
|
||||||
{
|
{
|
||||||
|
|
|
@ -11,7 +11,6 @@ export interface ProductosQuery {
|
||||||
* Decide si solo traer los productos habilitados.
|
* Decide si solo traer los productos habilitados.
|
||||||
*/
|
*/
|
||||||
onlyEnabled?: boolean;
|
onlyEnabled?: boolean;
|
||||||
filter?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Producto {
|
export interface Producto {
|
||||||
|
@ -62,9 +61,6 @@ export async function getProductos(
|
||||||
if ("onlyEnabled" in options) {
|
if ("onlyEnabled" in options) {
|
||||||
searchParams.set("onlyEnabled", options.onlyEnabled ? "true" : "false");
|
searchParams.set("onlyEnabled", options.onlyEnabled ? "true" : "false");
|
||||||
}
|
}
|
||||||
if (options.filter) {
|
|
||||||
searchParams.set("filter", options.filter);
|
|
||||||
}
|
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`${HOST}/api/Aperture/Product?${searchParams.toString()}`,
|
`${HOST}/api/Aperture/Product?${searchParams.toString()}`,
|
||||||
{
|
{
|
||||||
|
@ -73,10 +69,7 @@ export async function getProductos(
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
const json = await res.json();
|
const json: ProductosResponse = await res.json();
|
||||||
console.debug(json);
|
console.debug(json);
|
||||||
if (json.Message) {
|
|
||||||
throw new Error(`Tango: ${json.Message}`);
|
|
||||||
}
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,58 +0,0 @@
|
||||||
import {
|
|
||||||
HOST,
|
|
||||||
Paginacion,
|
|
||||||
paginacionToSearchParams,
|
|
||||||
Paging,
|
|
||||||
} from "./common.js";
|
|
||||||
|
|
||||||
export interface PublicationsQuery {
|
|
||||||
paginacion?: Paginacion;
|
|
||||||
productCode?: string;
|
|
||||||
skuCode?: string;
|
|
||||||
variantCode?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Publication {
|
|
||||||
ProductCode: string;
|
|
||||||
Description: string;
|
|
||||||
VariantCode?: string;
|
|
||||||
VariantDescription?: string;
|
|
||||||
SkuCode: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PublicationsResponse {
|
|
||||||
Paging: Paging;
|
|
||||||
Data: Publication[];
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://github.com/TangoSoftware/ApiTiendas#art%C3%ADculos
|
|
||||||
export async function getPublications(
|
|
||||||
token: string,
|
|
||||||
options: PublicationsQuery
|
|
||||||
): Promise<PublicationsResponse> {
|
|
||||||
let searchParams = new URLSearchParams();
|
|
||||||
paginacionToSearchParams(options.paginacion, searchParams);
|
|
||||||
if (options.skuCode) {
|
|
||||||
searchParams.set("skuCode", options.skuCode);
|
|
||||||
}
|
|
||||||
if (options.productCode) {
|
|
||||||
searchParams.set("productCode", options.productCode);
|
|
||||||
}
|
|
||||||
if (options.variantCode) {
|
|
||||||
searchParams.set("variantCode", options.variantCode);
|
|
||||||
}
|
|
||||||
const res = await fetch(
|
|
||||||
`${HOST}/api/Aperture/Publications?${searchParams.toString()}`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
accesstoken: token,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const json = await res.json();
|
|
||||||
console.debug(json);
|
|
||||||
if (json.Message) {
|
|
||||||
throw new Error(`Tango: ${json.Message}`);
|
|
||||||
}
|
|
||||||
return json;
|
|
||||||
}
|
|
Loading…
Reference in a new issue