diff --git a/accounts/linx.ts b/accounts/linx.ts new file mode 100644 index 00000000..ec6d6ff9 --- /dev/null +++ b/accounts/linx.ts @@ -0,0 +1 @@ +export { default } from "deco-sites/std/packs/linx/accounts/linx.ts"; diff --git a/doccache.zst b/doccache.zst index d1f4c029..a9239a94 100644 Binary files a/doccache.zst and b/doccache.zst differ diff --git a/live.gen.ts b/live.gen.ts index 6b478d5d..f723be5a 100644 --- a/live.gen.ts +++ b/live.gen.ts @@ -33,9 +33,10 @@ import * as $$1 from "./accounts/linxImpulse.ts"; import * as $$2 from "./accounts/vnda.ts"; import * as $$3 from "./accounts/nuvemShop.ts"; import * as $$4 from "./accounts/yourViews.ts"; -import * as $$5 from "./accounts/vtex.ts"; -import * as $$6 from "./accounts/shopify.ts"; -import * as $$7 from "./accounts/occ.ts"; +import * as $$5 from "./accounts/linx.ts"; +import * as $$6 from "./accounts/vtex.ts"; +import * as $$7 from "./accounts/shopify.ts"; +import * as $$8 from "./accounts/occ.ts"; import * as $$$0 from "./loaders/linxImpulse/products/similarItems.ts"; import * as $$$1 from "./loaders/linxImpulse/search.ts"; import * as $$$2 from "./loaders/linxImpulse/autocompletes/popular.ts"; @@ -173,12 +174,13 @@ const manifest = { }, "accounts": { "deco-sites/std/accounts/butterCMS.ts": $$0, + "deco-sites/std/accounts/linx.ts": $$5, "deco-sites/std/accounts/linxImpulse.ts": $$1, "deco-sites/std/accounts/nuvemShop.ts": $$3, - "deco-sites/std/accounts/occ.ts": $$7, - "deco-sites/std/accounts/shopify.ts": $$6, + "deco-sites/std/accounts/occ.ts": $$8, + "deco-sites/std/accounts/shopify.ts": $$7, "deco-sites/std/accounts/vnda.ts": $$2, - "deco-sites/std/accounts/vtex.ts": $$5, + "deco-sites/std/accounts/vtex.ts": $$6, "deco-sites/std/accounts/yourViews.ts": $$4, }, "loaders": { diff --git a/packs/linx/accounts/linx.ts b/packs/linx/accounts/linx.ts new file mode 100644 index 00000000..c82ec6af --- /dev/null +++ b/packs/linx/accounts/linx.ts @@ -0,0 +1,44 @@ +import type { Account as AccountBlock } from "$live/blocks/account.ts"; +import type { FnContext } from "$live/types.ts"; +import type { Manifest } from "deco-sites/std/live.gen.ts"; + +export interface Account extends AccountBlock { + /** + * @description LINX Account name. For more info, read here: https://help.linx.com/en/tutorial/o-que-e-account-name--i0mIGLcg3QyEy8OCicEoC. + */ + account: string; + + /** + * @title Public store URL + * @description Domain that is registered on License Manager (e.g: www.mystore.com.br) + */ + publicUrl?: string; + + /** + * @description Locale used for LINX Intelligent Search client. + */ + defaultLocale: string; + + /** + * @description Default price currency. + * @default USD + */ + defaultPriceCurrency: string; + + /** + * @description LINX sales channel. This will be the default sales channel your site. For more info, read here: https://help.linx.com/tutorial/how-trade-policies-work--6Xef8PZiFm40kg2STrMkMV + */ + defaultSalesChannel: string; + defaultRegionId?: string; + defaultHideUnavailableItems?: boolean; +} + +export type Context = FnContext<{ + configLINX?: Account; +}, Manifest>; + +function account(acc: Account) { + return acc; +} + +export default account; diff --git a/packs/linx/utils/path.ts b/packs/linx/utils/path.ts new file mode 100644 index 00000000..ec1064ac --- /dev/null +++ b/packs/linx/utils/path.ts @@ -0,0 +1,70 @@ +import { Account } from "../accounts/linx.ts"; + +export const paths = ({ account }: Account) => { + const base = `https://${account}.core.dcg.com.br/web-api/v1`; + const href = (path: string) => new URL(path, base).href; + + return { + catalog: { + brandList: { + brandID: (brandID: number) => + href(`/Catalog/Products/Brand/${brandID}`), + }, + categoryList: { + categoryID: (categoryID: number, catalogID: number) => + href(`/Catalog/Products/Brand/${categoryID}?catalogID=${catalogID}`), + }, + datasourceList: { + datasourceID: (datasourceID: number) => + href(`/Catalog/Products/Datasource/${datasourceID}`), + }, + searchList: { + term: (term: string) => href(`/Catalog/Products/Search/${term}`), + }, + productDetail: { + productID: (productID: number) => + href(`/Catalog/Products/Get/${productID}`), + }, + }, + profile: { + orderList: href(`/Profile/AccountOrder/List`), + orderDetail: href(`/Profile/AccountOrder/Get`), + login: href(`/Profile/Account/Login`), + register: href(`/Profile/Account/Register`), + logout: href(`/Profile/Account/Logout`), + accountUpdate: href(`/Profile/Account/Update`), + changePassword: href(`/Profile/Account/ChangePassword`), + isAuth: href(`/Profile/Account/IsAuthenticated`), + adressList: href(`/Profile/AccountAddress/List`), + adressDetail: href(`/Profile/AccountAddress/Get`), + adressUpdate: href(`/Profile/AccountAddress/Save`), + adressDelete: href(`/Profile/AccountAddress/Delete`), + adressForm: href(`/Profile/AccountAddress/GetForm`), + gift: href(`/Profile/AccountGiftCertificate/List`), + }, + shopping: { + deliveryList: href(`/Shopping/Delivery/Get`), + getPrice: href(`/Shopping/Price/Get`), + getPriceB2B: href(`/Shopping/PriceMatrix/Get`), + reviewsList: href(`/Shopping/Review/GetReviewers`), + reviewDetail: { + reviewID: (reviewID: string) => + href(`/Shopping/Review/Get/${reviewID}`), + }, + basketDetail: href(`/Shopping/Basket/Get`), + addProduct: href(`/Shopping/Basket/AddProduct`), + redirectCheckout: href(`/Shopping/Basket/CheckoutRedirect`), + removeBasketItem: href(`/Shopping/Basket/RemoveBasketItem`), + updateBasketItem: href(`/Shopping/Basket/UpdateBasketItem`), + clearBasket: href(`/Shopping/Basket/RemoveAll`), + addCupom: href(`/Shopping/Basket/AddCoupon`), + removeCupom: href(`/Shopping/Basket/RemoveCoupon`), + setCep: href(`/Shopping/Basket/SetPostalCode`), + setDelivery: href(`/Shopping/Basket/SetDeliveryOption`), + addMetadata: href(`/Shopping/Basket/AddCustomMetadata`), + removeMetadata: href(`/Shopping/Basket/RemoveCustomMetadata`), + addAdditional: href(`/Shopping/Basket/AddAdditionalProduct`), + removeAdditional: href(`/Shopping/Basket/RemoveAdditionalProduct`), + }, + }; +};