@beamimpact/web-sdk
Version:
The Beam SDK enables brands to connect with their customers over shared values, not transactional discounts, to build stronger loyalty. Our integration achieves this by allowing customers to (a) choose a nonprofit where the brand will donate part of their
3 lines (2 loc) • 2.57 kB
JavaScript
import"./promo-types-DKAOFHJr.esm.js";import{B as y,N as d}from"./beam-errors-Ci0d3926.esm.js";import{logger as p}from"../utils/logger.js";const l="https://api.beamimpact.com",O="https://production.beamimpactlogs.com",v={en:"en",fr:"fr",de:"de",es:"es",it:"it",pl:"pl",ja:"ja"},w={select_nonprofit:"select-nonprofit",redeem_transaction:"redeem-transaction",impact_overview:"impact-overview",community_impact:"community-impact",cumulative_impact:"cumulative-impact",product_details_page:"product-details-page",subscription_management:"subscription-management",subscription_impact:"subscription-impact",select_subscription_nonprofit:"select-subscription-nonprofit",social_share:"social-share"},C={cart_update:"cart_update"},L={NONPROFIT:"nonprofit",NONPROFIT_SELECTED_AT:"nonprofit_selected_at"};var A="1.55.8",R={"@shoelace-style/shoelace":"2.15.0","lucide-static":"0.292.0"};async function u(o,s){const c={method:"GET",...s,headers:{"Content-Type":"application/json",Accept:"application/json","X-Beam-Client":"WebSDK","X-Beam-Client-Version":A,...s?.headers},preflightContinue:!0,mode:s?.mode||"cors",body:s?.body!=null?s.body:void 0};let i;try{i=await fetch(o,c)}catch(e){const a=new y(`Network call failed (${c?.method.toUpperCase()} ${o})`);throw a.cause=e,p.error(a,o),a}let r,n;try{n=await i.text(),n&&(r=JSON.parse(n))}catch(e){let a=e;throw e instanceof SyntaxError&&(a=new d(i,r,`Response invalid. Expected JSON. Received: "${n}"`),a.cause=e),p.error(a),a}if(!i.ok){const e=new d(i,r,"Response was not OK");throw p.error(e),e}return r}const t=(o,s,c)=>({[o]:async function({headers:i={},baseUrl:r=l,apiRoot:n="/api/v3",pathParams:e={},queryParams:a={},requestBody:h}){const f=Object.entries(e).reduce((g,[E,N])=>g.replace(`{${E}}`,N),o),_=JSON.parse(JSON.stringify(a)),m=new URLSearchParams(_).toString(),S=r+n+f+(m&&`?${m}`),b={headers:i,method:s,body:JSON.stringify(h)};return u(S,b)}})[o];t("/chain/{chainId}/nonprofits","get");const T=t("/impact","get"),P=t("/chain/{chainId}/cumulativeImpact","get"),D=t("/selectNonprofit","post");t("/transaction","post"),t("/transaction/{transactionId}","put");const I=t("/cart","post"),U=t("/chain/findEligibleNonprofitsForCart","post"),F=t("/logs","post"),j=t("/experimentSession","post"),x=t("/subscriptions/updateSubscriptionNonprofit","post"),B=t("/subscriptions/findOrCreateSubscription","post"),G=t("/productDetailsPage","post");export{l as D,C as H,L,v as S,w as W,O as a,F as b,j as c,U as d,B as e,u as f,T as g,D as h,P as i,G as j,R as k,t as m,I as p,x as u};
//# sourceMappingURL=routes-BvX92EDq.esm.js.map