oddular-storefront-js
Advanced tools
Comparing version 0.0.1 to 0.0.2
@@ -22,2 +22,22 @@ declare const request: (baseUrl?: string) => import("axios").AxiosInstance; | ||
declare const getProductDetails: (baseUrl: string, publicKey: string, productID: string) => Promise<ProductDetails>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; | ||
type OrderReceipt = { | ||
cart: any; | ||
id: string; | ||
payment_status: string; | ||
order_status: string; | ||
public_status: string; | ||
created: string; | ||
name: string; | ||
phone: string; | ||
user_email: string; | ||
total_net: string; | ||
total_tax: string; | ||
service_fee: string; | ||
total_gross: string; | ||
total_authorized: string; | ||
transaction_list: string; | ||
receipt_link: string; | ||
fulfillment: any; | ||
}; | ||
declare const getOrderReceipt: (baseUrl: string, publicKey: string, orderId: string) => Promise<OrderReceipt>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getOrderReceipt, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; |
@@ -22,2 +22,22 @@ declare const request: (baseUrl?: string) => import("axios").AxiosInstance; | ||
declare const getProductDetails: (baseUrl: string, publicKey: string, productID: string) => Promise<ProductDetails>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; | ||
type OrderReceipt = { | ||
cart: any; | ||
id: string; | ||
payment_status: string; | ||
order_status: string; | ||
public_status: string; | ||
created: string; | ||
name: string; | ||
phone: string; | ||
user_email: string; | ||
total_net: string; | ||
total_tax: string; | ||
service_fee: string; | ||
total_gross: string; | ||
total_authorized: string; | ||
transaction_list: string; | ||
receipt_link: string; | ||
fulfillment: any; | ||
}; | ||
declare const getOrderReceipt: (baseUrl: string, publicKey: string, orderId: string) => Promise<OrderReceipt>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getOrderReceipt, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; |
@@ -190,2 +190,12 @@ import axios from 'axios'; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; | ||
const RECEIPT_URL_PART = `/shop/public/receipt/`; | ||
const getOrderReceipt = async (baseUrl, publicKey, orderId) => { | ||
const response = await request(baseUrl).get(RECEIPT_URL_PART + orderId + '/', { | ||
params: { | ||
shop: publicKey | ||
} | ||
}); | ||
return response.data; | ||
}; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getOrderReceipt, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; |
@@ -196,2 +196,12 @@ 'use strict'; | ||
const RECEIPT_URL_PART = `/shop/public/receipt/`; | ||
const getOrderReceipt = async (baseUrl, publicKey, orderId) => { | ||
const response = await request(baseUrl).get(RECEIPT_URL_PART + orderId + '/', { | ||
params: { | ||
shop: publicKey | ||
} | ||
}); | ||
return response.data; | ||
}; | ||
exports.addItemToCart = addItemToCart; | ||
@@ -206,2 +216,3 @@ exports.adjustItemInCart = adjustItemInCart; | ||
exports.getCollectionDetails = getCollectionDetails; | ||
exports.getOrderReceipt = getOrderReceipt; | ||
exports.getProducts = getProducts; | ||
@@ -208,0 +219,0 @@ exports.getProductDetails = getProductDetails; |
@@ -22,2 +22,22 @@ declare const request: (baseUrl?: string) => import("axios").AxiosInstance; | ||
declare const getProductDetails: (baseUrl: string, publicKey: string, productID: string) => Promise<ProductDetails>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; | ||
type OrderReceipt = { | ||
cart: any; | ||
id: string; | ||
payment_status: string; | ||
order_status: string; | ||
public_status: string; | ||
created: string; | ||
name: string; | ||
phone: string; | ||
user_email: string; | ||
total_net: string; | ||
total_tax: string; | ||
service_fee: string; | ||
total_gross: string; | ||
total_authorized: string; | ||
transaction_list: string; | ||
receipt_link: string; | ||
fulfillment: any; | ||
}; | ||
declare const getOrderReceipt: (baseUrl: string, publicKey: string, orderId: string) => Promise<OrderReceipt>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getOrderReceipt, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; |
@@ -196,2 +196,12 @@ (function (global, factory) { | ||
const RECEIPT_URL_PART = `/shop/public/receipt/`; | ||
const getOrderReceipt = async (baseUrl, publicKey, orderId) => { | ||
const response = await request(baseUrl).get(RECEIPT_URL_PART + orderId + '/', { | ||
params: { | ||
shop: publicKey | ||
} | ||
}); | ||
return response.data; | ||
}; | ||
exports.addItemToCart = addItemToCart; | ||
@@ -206,2 +216,3 @@ exports.adjustItemInCart = adjustItemInCart; | ||
exports.getCollectionDetails = getCollectionDetails; | ||
exports.getOrderReceipt = getOrderReceipt; | ||
exports.getProducts = getProducts; | ||
@@ -208,0 +219,0 @@ exports.getProductDetails = getProductDetails; |
@@ -22,2 +22,22 @@ declare const request: (baseUrl?: string) => import("axios").AxiosInstance; | ||
declare const getProductDetails: (baseUrl: string, publicKey: string, productID: string) => Promise<ProductDetails>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; | ||
type OrderReceipt = { | ||
cart: any; | ||
id: string; | ||
payment_status: string; | ||
order_status: string; | ||
public_status: string; | ||
created: string; | ||
name: string; | ||
phone: string; | ||
user_email: string; | ||
total_net: string; | ||
total_tax: string; | ||
service_fee: string; | ||
total_gross: string; | ||
total_authorized: string; | ||
transaction_list: string; | ||
receipt_link: string; | ||
fulfillment: any; | ||
}; | ||
declare const getOrderReceipt: (baseUrl: string, publicKey: string, orderId: string) => Promise<OrderReceipt>; | ||
export { addItemToCart, adjustItemInCart, request, initCollectionCart, initCart, getCartCookie, getCollections, getCollectionCartCookie, getCollectionDetails, getOrderReceipt, getProducts, getProductDetails, processCheckout, removeItemFromCart, resetCart, resetCollectionCart, setCartCookie, setCollectionCartCookie, syncCart }; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("crypto")):"function"==typeof define&&define.amd?define(["exports","axios","crypto"],e):e(t.OddularStorefrontJS={},t.axios,t.crypto)}(this,(function(t,e,a){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,a=a&&a.hasOwnProperty("default")?a.default:a;const o=process.env.ODDULAR_BASE_URL||"https://api.oddular.com/",r=(process.env.ODDULAR_AUTH_URL,(t=o)=>e.create({baseURL:t,timeout:1e4})),s=new Uint8Array(256);let i=s.length;function c(){return i>s.length-16&&(a.randomFillSync(s),i=0),s.slice(i,i+=16)}var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).substr(1));function l(t,e=0){const a=(p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&n.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a}function d(t,e,a){const o=(t=t||{}).random||(t.rng||c)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e){a=a||0;for(let t=0;t<16;++t)e[a+t]=o[t];return e}return l(o)}const u=()=>d(),f=require("js-cookie"),h=t=>(f.set("_odd_cart",t,{expires:5,sameSite:"lax"}),t),g=()=>f.get("_odd_cart"),y=(t,e)=>(f.set("_odd_cart__"+t,e,{expires:5,sameSite:"lax"}),e),C=t=>f.get("_odd_cart__"+t);t.addItemToCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/add-item/",{...o,shop:e,cart:a})).data,t.adjustItemInCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/adjust-item/",{...o,shop:e,cart:a})).data,t.request=r,t.initCollectionCart=t=>{let e=C(t)||u();return y(t,e),e},t.initCart=()=>{let t=g()||u();return h(t),t},t.getCartCookie=g,t.getCollections=async(t,e,a=1,o=10)=>(await r(t).get("/shop/public/collection/",{params:{shop:e,page:a,page_size:o}})).data,t.getCollectionCartCookie=C,t.getCollectionDetails=async(t,e,a)=>(await r(t).get(`/shop/public/collection/${a}/`,{params:{shop:e}})).data,t.getProducts=async(t,e,a,o,s,i,c,n)=>(await r(t).get("/shop/public/product/",{params:{shop:e,page:a,page_size:o,ordering:s,search:i,categories:c,...n}})).data,t.getProductDetails=async(t,e,a)=>(await r(t).get(`/shop/public/product/${a}/`,{params:{shop:e}})).data,t.processCheckout=async(t,e,a,o,s,i,c)=>(await r(t).post("/shop/public/cart/process-checkout/",{shop:e,cart:a,email:o,phone:s,name:i,token:c})).data,t.removeItemFromCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/remove-item/",{...o,shop:e,cart:a})).data,t.resetCart=()=>{let t=u();return h(t),t},t.resetCollectionCart=t=>{let e=u();return y(t,e),e},t.setCartCookie=h,t.setCollectionCartCookie=y,t.syncCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/sync/",{shop:e,cart:a,session:f.get("_odd_s"),collection:o})).data,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("axios"),require("crypto")):"function"==typeof define&&define.amd?define(["exports","axios","crypto"],e):e(t.OddularStorefrontJS={},t.axios,t.crypto)}(this,(function(t,e,a){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e,a=a&&a.hasOwnProperty("default")?a.default:a;const o=process.env.ODDULAR_BASE_URL||"https://api.oddular.com/",r=(process.env.ODDULAR_AUTH_URL,(t=o)=>e.create({baseURL:t,timeout:1e4})),s=new Uint8Array(256);let i=s.length;function c(){return i>s.length-16&&(a.randomFillSync(s),i=0),s.slice(i,i+=16)}var n=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;const p=[];for(let t=0;t<256;++t)p.push((t+256).toString(16).substr(1));function l(t,e=0){const a=(p[t[e+0]]+p[t[e+1]]+p[t[e+2]]+p[t[e+3]]+"-"+p[t[e+4]]+p[t[e+5]]+"-"+p[t[e+6]]+p[t[e+7]]+"-"+p[t[e+8]]+p[t[e+9]]+"-"+p[t[e+10]]+p[t[e+11]]+p[t[e+12]]+p[t[e+13]]+p[t[e+14]]+p[t[e+15]]).toLowerCase();if(!function(t){return"string"==typeof t&&n.test(t)}(a))throw TypeError("Stringified UUID is invalid");return a}function d(t,e,a){const o=(t=t||{}).random||(t.rng||c)();if(o[6]=15&o[6]|64,o[8]=63&o[8]|128,e){a=a||0;for(let t=0;t<16;++t)e[a+t]=o[t];return e}return l(o)}const u=()=>d(),h=require("js-cookie"),f=t=>(h.set("_odd_cart",t,{expires:5,sameSite:"lax"}),t),g=()=>h.get("_odd_cart"),y=(t,e)=>(h.set("_odd_cart__"+t,e,{expires:5,sameSite:"lax"}),e),m=t=>h.get("_odd_cart__"+t);t.addItemToCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/add-item/",{...o,shop:e,cart:a})).data,t.adjustItemInCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/adjust-item/",{...o,shop:e,cart:a})).data,t.request=r,t.initCollectionCart=t=>{let e=m(t)||u();return y(t,e),e},t.initCart=()=>{let t=g()||u();return f(t),t},t.getCartCookie=g,t.getCollections=async(t,e,a=1,o=10)=>(await r(t).get("/shop/public/collection/",{params:{shop:e,page:a,page_size:o}})).data,t.getCollectionCartCookie=m,t.getCollectionDetails=async(t,e,a)=>(await r(t).get(`/shop/public/collection/${a}/`,{params:{shop:e}})).data,t.getOrderReceipt=async(t,e,a)=>(await r(t).get("/shop/public/receipt/"+a+"/",{params:{shop:e}})).data,t.getProducts=async(t,e,a,o,s,i,c,n)=>(await r(t).get("/shop/public/product/",{params:{shop:e,page:a,page_size:o,ordering:s,search:i,categories:c,...n}})).data,t.getProductDetails=async(t,e,a)=>(await r(t).get(`/shop/public/product/${a}/`,{params:{shop:e}})).data,t.processCheckout=async(t,e,a,o,s,i,c)=>(await r(t).post("/shop/public/cart/process-checkout/",{shop:e,cart:a,email:o,phone:s,name:i,token:c})).data,t.removeItemFromCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/remove-item/",{...o,shop:e,cart:a})).data,t.resetCart=()=>{let t=u();return f(t),t},t.resetCollectionCart=t=>{let e=u();return y(t,e),e},t.setCartCookie=f,t.setCollectionCartCookie=y,t.syncCart=async(t,e,a,o)=>(await r(t).post("/shop/public/cart/sync/",{shop:e,cart:a,session:h.get("_odd_s"),collection:o})).data,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "oddular-storefront-js", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Oddular Storefront JS", | ||
@@ -5,0 +5,0 @@ "keywords": [], |
@@ -23,2 +23,4 @@ import { request } from './api' | ||
import {getOrderReceipt} from './receipt' | ||
export { | ||
@@ -34,2 +36,3 @@ addItemToCart, | ||
getCollectionDetails, | ||
getOrderReceipt, | ||
getProducts, | ||
@@ -36,0 +39,0 @@ getProductDetails, |
@@ -26,3 +26,2 @@ import { request } from './api' | ||
export const getOrderReceipt = async ( | ||
token: string, | ||
baseUrl: string, | ||
@@ -32,3 +31,3 @@ publicKey: string, | ||
): Promise<OrderReceipt> => { | ||
const response = await request(token, baseUrl).get(RECEIPT_URL_PART + orderId + '/', { | ||
const response = await request(baseUrl).get(RECEIPT_URL_PART + orderId + '/', { | ||
params: { | ||
@@ -35,0 +34,0 @@ shop: publicKey |
77261
1483
27