UNPKG

revenuecat

Version:

Revenuecat Rest API for Node.js and TypeScript (Unofficial)

2 lines 1.91 kB
"use strict";var c=Object.create;var o=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=(r,t)=>{for(var e in t)o(r,e,{get:t[e],enumerable:!0})},n=(r,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of d(t))!h.call(r,s)&&s!==e&&o(r,s,{get:()=>t[s],enumerable:!(i=u(t,s))||i.enumerable});return r};var x=(r,t,e)=>(e=r!=null?c(f(r)):{},n(t||!r||!r.__esModule?o(e,"default",{value:r,enumerable:!0}):e,r)),l=r=>n(o({},"__esModule",{value:!0}),r);var g={};y(g,{Revenuecat:()=>a,default:()=>m});module.exports=l(g);var p=x(require("axios")),a=class{secretKey;iosKey;androidKey;url="https://api.revenuecat.com/v1";axios;constructor({secretKey:t,iosKey:e,androidKey:i}){this.secretKey=t,this.iosKey=e,this.androidKey=i,this.axios=p.default.create({baseURL:this.url})}createAuthorizationHeader(t){switch(t){case"ios":return`Bearer ${this.iosKey}`;case"android":return`Bearer ${this.androidKey}`;default:return`Bearer ${this.secretKey}`}}getSubscriptions=async({userId:t,platform:e})=>{let i={"Content-Type":"application/json",Authorization:this.createAuthorizationHeader(e)};e&&(i=Object.assign(i,{"x-platform":e}));let{data:s}=await this.axios.get(`/subscribers/${t}`,{headers:i});return s};postSubscriptionsAttributes=async({userId:t,data:e})=>{let i={"Content-Type":"application/json",Authorization:this.createAuthorizationHeader(),app_user_id:t},{data:s}=await this.axios.post(`/subscribers/${t}/attributes`,e,{headers:i});return s};getOfferings=async({userId:t,platform:e})=>{let i={"Content-Type":"application/json",Authorization:this.createAuthorizationHeader(e),app_user_id:t};e&&(i=Object.assign(i,{"x-platform":e}));let{data:s}=await this.axios.get(`/subscribers/${t}/offerings`,{headers:i});return s}};var m=a;0&&(module.exports={Revenuecat}); //# sourceMappingURL=index.js.map