Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linx #210

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

linx #210

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions accounts/linx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "deco-sites/std/packs/linx/accounts/linx.ts";
Binary file modified doccache.zst
Binary file not shown.
14 changes: 8 additions & 6 deletions live.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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": {
Expand Down
44 changes: 44 additions & 0 deletions packs/linx/accounts/linx.ts
Original file line number Diff line number Diff line change
@@ -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;
70 changes: 70 additions & 0 deletions packs/linx/utils/path.ts
Original file line number Diff line number Diff line change
@@ -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`),
},
};
};