UNPKG

@getoccasion/sdk

Version:

An SDK library that enables access to Occasion's application, providing a rich DSL for creating and managing bookings.

1 lines 29.6 kB
!function(root,factory){"function"==typeof define&&define.amd?define(["active-resource","axios","decimal.js-light","moment","underscore","underscore.string","moment-timezone"],function(a0,b1,c2,d3,e4,f5,g6){return root.Occasion=factory(a0,b1,c2,d3,e4,f5,g6)}):"object"==typeof module&&module.exports?module.exports=factory(require("active-resource"),require("axios"),require("decimal.js-light"),require("moment"),require("underscore"),require("underscore.string"),require("moment-timezone")):root.Occasion=factory(root["active-resource"],root.axios,root["decimal.js-light"],root.moment,root.underscore,root["underscore.string"],root["moment-timezone"])}(this,function(ActiveResource,axios,Decimal,moment,_,s){"use strict";function _possibleConstructorReturn(self,call){if(!self)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!call||"object"!=typeof call&&"function"!=typeof call?self:call}function _inherits(subClass,superClass){if("function"!=typeof superClass&&null!==superClass)throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:!1,writable:!0,configurable:!0}}),superClass&&(Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass)}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor))throw new TypeError("Cannot call a class as a function")}var _get=function get(object,property,receiver){null===object&&(object=Function.prototype);var desc=Object.getOwnPropertyDescriptor(object,property);if(void 0===desc){var parent=Object.getPrototypeOf(object);return null===parent?void 0:get(parent,property,receiver)}if("value"in desc)return desc.value;var getter=desc.get;return void 0===getter?void 0:getter.call(receiver)},_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||!1,descriptor.configurable=!0,"value"in descriptor&&(descriptor.writable=!0),Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){return protoProps&&defineProperties(Constructor.prototype,protoProps),staticProps&&defineProperties(Constructor,staticProps),Constructor}}();ActiveResource.Interfaces.JsonApi.contentType="application/json";var Occasion=function(){function Occasion(){_classCallCheck(this,Occasion)}return _createClass(Occasion,null,[{key:"Client",value:function(){var options=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},url=options.baseUrl||Occasion.baseUrl,token=options.token,secret=options.secret,immutable=options.immutable||!1;if(!_.isString(token))throw"Token must be of type string";if("undefined"==typeof window)var encodedToken=Buffer.from(unescape(encodeURIComponent([token,secret].join(":")))).toString("base64");else var encodedToken=window.btoa(unescape(encodeURIComponent([token,secret].join(":"))));var libraryOptions={headers:{Authorization:"Basic "+encodedToken},immutable:immutable,strictAttributes:!0},resourceLibrary=ActiveResource.createResourceLibrary(url,libraryOptions);return Occasion.Modules.each(function(initializeModule){initializeModule(resourceLibrary)}),resourceLibrary}}]),Occasion}();return Occasion.baseUrl="https://occ.sn/api/v1",Occasion.Modules=ActiveResource.prototype.Collection.build(),Occasion.__constructCalendar=function(month){var _ref=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},calendar=_ref.calendar,monthlyTimeSlotDaysBatchSize=_ref.monthlyTimeSlotDaysBatchSize,monthlyTimeSlotPreloadSize=_ref.monthlyTimeSlotPreloadSize,preload=_ref.preload,prevPagePromise=_ref.prevPagePromise,relation=_ref.relation,status=_ref.status,timeZone=_ref.timeZone,today=moment.tz(timeZone);status=status||"bookable";var lowerRange;lowerRange=month?month.tz(timeZone):today,lowerRange=lowerRange.startOf("month");var upperRange=lowerRange.clone().endOf("month"),numRequests=Math.ceil(upperRange.diff(lowerRange,"days")/monthlyTimeSlotDaysBatchSize);1>numRequests&&(numRequests=1);for(var i=0,requests=[],lower=lowerRange.clone(),upper=lowerRange.clone().add(monthlyTimeSlotDaysBatchSize,"days");numRequests>i;)i+1==numRequests&&(upper=upperRange.clone()),requests.push(relation.includes({product:"merchant"}).where({startsAt:{ge:lower.toDate(),le:upper.toDate()},status:status}).all()),lower.add(monthlyTimeSlotDaysBatchSize,"days"),upper.add(monthlyTimeSlotDaysBatchSize,"days"),i++;calendar=calendar||{},_.isUndefined(calendar.__currentPage)&&(calendar.__currentPage=0),_.isUndefined(calendar.__preloadedPages)&&(calendar.__preloadedPages=0),calendar.__preloading=!0;var currentPromise=Promise.all(requests).then(function(timeSlotsArray){for(var allTimeSlots=ActiveResource.Collection.build(timeSlotsArray).map(function(ts){return ts.toArray()}).flatten(),startDate=moment(lowerRange).startOf("month"),endDate=moment(lowerRange).endOf("month"),response=ActiveResource.CollectionResponse.build(),day=startDate;day.isSameOrBefore(endDate);)response.push({day:day,timeSlots:allTimeSlots.select(function(timeSlot){return timeSlot.startsAt.isSame(day,"day")})}),day=day.clone().add(1,"days");response.hasNextPage=function(){return!0};var commonPaginationOptions={calendar:calendar,monthlyTimeSlotDaysBatchSize:monthlyTimeSlotDaysBatchSize,monthlyTimeSlotPreloadSize:monthlyTimeSlotPreloadSize,relation:relation,status:status,timeZone:timeZone};return response.nextPage=function(preloadCount){return this.nextPromise||(this.nextPromise=Occasion.__constructCalendar(moment(upperRange).add(1,"days").startOf("month"),_extends({},commonPaginationOptions,{preload:preloadCount,prevPagePromise:currentPromise}))),_.isUndefined(preloadCount)&&(calendar.__currentPage+=1,!calendar.__preloading&&calendar.__preloadedPages<=calendar.__currentPage+monthlyTimeSlotPreloadSize/2&&calendar.__lastPreloadedPage.nextPage(monthlyTimeSlotPreloadSize)),this.nextPromise},("bookable"!==status||month&&!month.isSame(today,"month"))&&(response.hasPrevPage=function(){return!0},response.prevPage=function(){return this.prevPromise=this.prevPromise||prevPagePromise||Occasion.__constructCalendar(moment(lowerRange).subtract(1,"months"),_extends({},commonPaginationOptions,{preload:0})),calendar.__currentPage-=1,this.prevPromise}),monthlyTimeSlotPreloadSize>0&&(_.isUndefined(preload)?response.nextPage(monthlyTimeSlotPreloadSize-1):preload>0?response.nextPage(--preload):calendar.__preloading=!1),calendar.__preloadedPages+=1,calendar.__lastPreloadedPage=response,response});return currentPromise},Occasion.Modules.push(function(library){library.Answer=function(_library$Base){function Answer(){return _classCallCheck(this,Answer),_possibleConstructorReturn(this,(Answer.__proto__||Object.getPrototypeOf(Answer)).apply(this,arguments))}return _inherits(Answer,_library$Base),_createClass(Answer,[{key:"valid",value:function(){switch(this.question().formControl){case"checkbox":case"waiver":return!(this.question().required||"waiver"==this.question().formControl)||"YES"==this.value||"NO"!=this.value&&this.value;default:return!this.question().required||this.question().optionable&&this.option()||!this.question().optionable&&this.value&&""!=this.value}}}]),Answer}(library.Base),library.Answer.className="Answer",library.Answer.queryName="answers",library.Answer.attributes("value"),library.Answer.belongsTo("question"),library.Answer.belongsTo("option"),library.Answer.belongsTo("order",{inverseOf:"answers"})}),Occasion.Modules.push(function(library){library.Attendee=function(_library$Base2){function Attendee(){return _classCallCheck(this,Attendee),_possibleConstructorReturn(this,(Attendee.__proto__||Object.getPrototypeOf(Attendee)).apply(this,arguments))}return _inherits(Attendee,_library$Base2),_createClass(Attendee,[{key:"complete",value:function(){var _this4=this;return!this.order().product().attendeeQuestions.detect(function(question){return!_this4[question]||0==_this4[question].length})}}]),Attendee}(library.Base),library.Attendee.className="Attendee",library.Attendee.queryName="attendees",library.Attendee.attributes("address","age","allergies","city","country","email","firstName","gender","lastName","phone","state","zip"),library.Attendee.belongsTo("order",{inverseOf:"attendees"})}),Occasion.Modules.push(function(library){library.Country=function(_library$Base3){function Country(){return _classCallCheck(this,Country),_possibleConstructorReturn(this,(Country.__proto__||Object.getPrototypeOf(Country)).apply(this,arguments))}return _inherits(Country,_library$Base3),Country}(library.Base),library.Country.className="Country",library.Country.queryName="countries"}),Occasion.Modules.push(function(library){library.Coupon=function(_library$Base4){function Coupon(){return _classCallCheck(this,Coupon),_possibleConstructorReturn(this,(Coupon.__proto__||Object.getPrototypeOf(Coupon)).apply(this,arguments))}return _inherits(Coupon,_library$Base4),Coupon}(library.Base),library.Coupon.className="Coupon",library.Coupon.queryName="coupons",library.Coupon.belongsTo("merchant"),library.Coupon.hasMany("orders")}),Occasion.Modules.push(function(library){library.Currency=function(_library$Base5){function Currency(){return _classCallCheck(this,Currency),_possibleConstructorReturn(this,(Currency.__proto__||Object.getPrototypeOf(Currency)).apply(this,arguments))}return _inherits(Currency,_library$Base5),Currency}(library.Base),library.Currency.className="Currency",library.Currency.queryName="currencies",library.Currency.hasMany("merchants"),library.Currency.hasMany("orders")}),Occasion.Modules.push(function(library){library.Customer=function(_library$Base6){function Customer(){return _classCallCheck(this,Customer),_possibleConstructorReturn(this,(Customer.__proto__||Object.getPrototypeOf(Customer)).apply(this,arguments))}return _inherits(Customer,_library$Base6),_createClass(Customer,[{key:"ahoyEmailChanged",value:function(){}},{key:"complete",value:function(){return this.email&&this.firstName&&this.lastName&&this.email.length>0&&this.firstName.length>0&&this.lastName.length>0}}]),Customer}(library.Base),library.Customer.className="Customer",library.Customer.queryName="customers",library.Customer.attributes("email","firstName","lastName","zip","phone"),library.Customer.hasMany("orders",{inverseOf:"customer"}),library.Customer.afterBuild(function(){var lastEmail=null,watchEmail=_.bind(function(){lastEmail!=this.email&&(_.bind(this.ahoyEmailChanged,this)(),lastEmail=this.email),setTimeout(watchEmail,500)},this);setTimeout(watchEmail,500)})}),Occasion.Modules.push(function(library){library.Fulfillment=function(_library$Base7){function Fulfillment(){return _classCallCheck(this,Fulfillment),_possibleConstructorReturn(this,(Fulfillment.__proto__||Object.getPrototypeOf(Fulfillment)).apply(this,arguments))}return _inherits(Fulfillment,_library$Base7),Fulfillment}(library.Base),library.Fulfillment.className="Fulfillment",library.Fulfillment.queryName="fulfillments",library.Fulfillment.belongsTo("order",{inverseOf:"fulfillment"}),library.Fulfillment.hasOne("shipmentDetails",{autosave:!0,inverseOf:"fulfillment"}),library.Fulfillment.hasOne("pickupDetails",{autosave:!0,inverseOf:"fulfillment"}),library.Fulfillment.hasOne("recipient",{autosave:!0}),library.Fulfillment.attributes("fulfillmentType","triggerEvent")}),Occasion.Modules.push(function(library){library.Label=function(_library$Base8){function Label(){return _classCallCheck(this,Label),_possibleConstructorReturn(this,(Label.__proto__||Object.getPrototypeOf(Label)).apply(this,arguments))}return _inherits(Label,_library$Base8),Label}(library.Base),library.Label.className="Label",library.Label.queryName="labels",library.Label.belongsTo("product")}),Occasion.Modules.push(function(library){library.Merchant=function(_library$Base9){function Merchant(){return _classCallCheck(this,Merchant),_possibleConstructorReturn(this,(Merchant.__proto__||Object.getPrototypeOf(Merchant)).apply(this,arguments))}return _inherits(Merchant,_library$Base9),Merchant}(library.Base),library.Merchant.className="Merchant",library.Merchant.queryName="merchants",library.Merchant.belongsTo("currency"),library.Merchant.hasMany("products"),library.Merchant.hasMany("venues")}),Occasion.Modules.push(function(library){library.Option=function(_library$Base10){function Option(){return _classCallCheck(this,Option),_possibleConstructorReturn(this,(Option.__proto__||Object.getPrototypeOf(Option)).apply(this,arguments))}return _inherits(Option,_library$Base10),Option}(library.Base),library.Option.className="Option",library.Option.queryName="options",library.Option.belongsTo("answer"),library.Option.belongsTo("question")}),Occasion.Modules.push(function(library){library.Order=function(_library$Base11){function Order(){return _classCallCheck(this,Order),_possibleConstructorReturn(this,(Order.__proto__||Object.getPrototypeOf(Order)).apply(this,arguments))}return _inherits(Order,_library$Base11),_createClass(Order,[{key:"charge",value:function(paymentMethod,amount){return this.transactions().build({amount:amount,paymentMethod:paymentMethod})}},{key:"editCharge",value:function(paymentMethod,amount){var transaction=this.transactions().target().detect(function(t){return t.paymentMethod()==paymentMethod});transaction&&(transaction.amount=amount)}},{key:"removeCharge",value:function(paymentMethod){var transaction=this.transactions().target().detect(function(t){return t.paymentMethod()==paymentMethod});transaction&&this.transactions().target()["delete"](transaction)}},{key:"save",value:function(callback){if(this.association("fulfillment").loaded()&&this.fulfillment()){var fulfillment=this.fulfillment();"shipment"===fulfillment.fulfillmentType?fulfillment.association("pickupDetails").reset():fulfillment.association("shipmentDetails").reset(),["pickupDetails","shipmentDetails","recipient"].forEach(function(a){var association=fulfillment.association(a);association.loaded()&&association.target&&!association.target.changedFields().empty()&&(fulfillment.state="initialized")})}return _get(Order.prototype.__proto__||Object.getPrototypeOf(Order.prototype),"save",this).call(this,callback)}}],[{key:"construct",value:function(attributes){var order=this.includes("currency",{fulfillment:["recipient","pickupDetails","shipmentDetails"]}).build(attributes);order.sessionIdentifier=order.sessionIdentifier||Math.random().toString(36).substring(7)+"-"+Date.now(),order.upcomingEventsEmails=order.upcomingEventsEmails||!0,null==order.customer()&&order.buildCustomer({email:null,firstName:null,lastName:null,zip:null,phone:null}),order.product().fulfills&&null==order.fulfillment()&&order.buildFulfillment();var promises=[new Promise(function(resolve){resolve(order)})];null!=order.product()&&(promises.push(order.product().questions().includes("options").perPage(500).load()),order.product().requiresTimeSlotSelection||promises.push(order.product().timeSlots().includes({product:"merchant"}).where({status:"bookable"}).perPage(500).all()));var _this=this;return Promise.all(promises).then(function(args){order=args[0];var questions=args[1],timeSlots=args[2];return void 0!=questions&&questions.inject(order,_this.__constructAnswer),void 0!=timeSlots&&order.timeSlots().assign(timeSlots,!1),order})}},{key:"__constructAnswer",value:function(order,question){if("static"!=question.category){var answer=order.answers().build({question:question});switch(question.formControl){case"drop_down":case"option_list":answer.assignOption(question.options().target().detect(function(o){return o["default"]}));break;case"spin_button":answer.value=question.min}}return order}}]),Order}(library.Base),library.Order.className="Order",library.Order.queryName="orders",library.Order.attributes("sessionIdentifier","status","upcomingEventsEmails","referrerToken"),library.Order.attributes("buyerBookingFee","buyerDueTodayAfterGiftCards","buyerDueToday","buyerTotalWithoutGiftCards","couponAmount","dropInsDiscount","fulfillmentFee","giftCardAmount","outstandingBalance","paymentDueOnEvent","price","quantity","serviceFee","subtotal","tax","taxPercentage","totalDiscountsGiftCards","totalTaxesFees","total","totalDiscount",{readOnly:!0}),library.Order.belongsTo("coupon"),library.Order.belongsTo("currency"),library.Order.belongsTo("customer",{autosave:!0,inverseOf:"orders"}),library.Order.belongsTo("merchant"),library.Order.belongsTo("product"),library.Order.hasOne("fulfillment",{autosave:!0,inverseOf:"order"}),library.Order.hasMany("answers",{autosave:!0,inverseOf:"order"}),library.Order.hasMany("attendees",{autosave:!0,inverseOf:"order"}),library.Order.hasMany("timeSlots"),library.Order.hasMany("transactions",{autosave:!0,inverseOf:"order"}),library.Order.afterRequest(function(){var _this14=this;if(this.product()&&!this.product().attendeeQuestions.empty()){var diff=this.quantity-this.attendees().size();if(0!=diff)for(var i=0;i<Math.abs(diff);i++)diff>0?this.attendees().build():this.attendees().target().pop()}if(ActiveResource.Collection.build(["buyerBookingFee","buyerDueToday","buyerDueTodayAfterGiftCards","buyerTotalWithoutGiftCards","couponAmount","dropInsDiscount","fulfillmentFee","giftCardAmount","outstandingBalance","paymentDueOnEvent","price","quantity","serviceFee","subtotal","tax","taxPercentage","total","totalDiscount","totalDiscountsGiftCards","totalTaxesFees"]).select(function(attr){return _this14[attr]}).each(function(attr){_this14[attr]=new Decimal(_this14[attr])}),this.outstandingBalance&&!this.outstandingBalance.isZero()){var giftCardTransactions=this.transactions().target().select(function(t){return t.paymentMethod()&&t.paymentMethod().isA(library.GiftCard)}),remainingBalanceTransaction=this.transactions().target().detect(function(t){return!(t.paymentMethod()&&t.paymentMethod().isA(library.GiftCard))});this.outstandingBalance.isPositive()?giftCardTransactions.empty()||giftCardTransactions.each(function(t){if(!_this14.outstandingBalance.isZero()){var amount=new Decimal(t.amount),giftCardValue=new Decimal(t.paymentMethod().value),remainingGiftCardBalance=giftCardValue.minus(amount);remainingGiftCardBalance.isZero()||(remainingGiftCardBalance.greaterThanOrEqualTo(_this14.outstandingBalance)?(amount=amount.plus(_this14.outstandingBalance),_this14.outstandingBalance=new Decimal(0)):(amount=remainingGiftCardBalance,_this14.outstandingBalance=_this14.outstandingBalance.minus(remainingGiftCardBalance)),t.amount=amount.toString(),_this14.transactions().target()["delete"](t),t.__createClone({cloner:_this14}))}}):giftCardTransactions.empty()||ActiveResource.Collection.build(giftCardTransactions.toArray().reverse()).each(function(t){if(!_this14.outstandingBalance.isZero()){var amount=new Decimal(t.amount);if(!amount.greaterThan(_this14.outstandingBalance.abs()))return _this14.outstandingBalance=_this14.outstandingBalance.plus(amount),void _this14.removeCharge(t.paymentMethod());amount=amount.plus(_this14.outstandingBalance),_this14.outstandingBalance=new Decimal(0),t.amount=amount.toString(),_this14.transactions().target()["delete"](t),t.__createClone({cloner:_this14})}}),giftCardTransactions.empty()||(this.giftCardAmount=this.transactions().target().select(function(t){return t.paymentMethod()&&t.paymentMethod().isA(library.GiftCard)}).inject(new Decimal(0),function(total,transaction){return total.plus(transaction.amount)})),remainingBalanceTransaction&&(remainingBalanceTransaction.amount=this.outstandingBalance.toString(),this.transactions().target()["delete"](remainingBalanceTransaction),remainingBalanceTransaction.__createClone({cloner:this}))}});library.Order.prototype.save}),Occasion.Modules.push(function(library){library.PaymentMethod=function(_library$Base12){function PaymentMethod(){return _classCallCheck(this,PaymentMethod),_possibleConstructorReturn(this,(PaymentMethod.__proto__||Object.getPrototypeOf(PaymentMethod)).apply(this,arguments))}return _inherits(PaymentMethod,_library$Base12),PaymentMethod}(library.Base),library.PaymentMethod.className="PaymentMethod",library.PaymentMethod.queryName="payment_methods",library.PaymentMethod.hasMany("transactions",{as:"paymentMethod"})}),Occasion.Modules.push(function(library){library.PickupDetail=function(_library$Base13){function PickupDetail(){return _classCallCheck(this,PickupDetail),_possibleConstructorReturn(this,(PickupDetail.__proto__||Object.getPrototypeOf(PickupDetail)).apply(this,arguments))}return _inherits(PickupDetail,_library$Base13),PickupDetail}(library.Base),library.PickupDetail.className="PickupDetail",library.PickupDetail.queryName="pickup_details",library.PickupDetail.belongsTo("fulfillment",{inverseOf:"pickupDetails"}),library.PickupDetail.attributes("expiredAt","expiresAt","isCurbsidePickup","curbsideDetails","pickupAt","pickupWindowDuration","readyAt","scheduleType","placedAt","dropoffAt")}),Occasion.Modules.push(function(library){library.Product=function(_library$Base14){function Product(){return _classCallCheck(this,Product),_possibleConstructorReturn(this,(Product.__proto__||Object.getPrototypeOf(Product)).apply(this,arguments))}return _inherits(Product,_library$Base14),_createClass(Product,[{key:"constructCalendar",value:function(month){var options=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Occasion.__constructCalendar(month,_extends({monthlyTimeSlotDaysBatchSize:this.monthlyTimeSlotDaysBatchSize,monthlyTimeSlotPreloadSize:this.monthlyTimeSlotPreloadSize,relation:this.timeSlots(),timeZone:this.merchant().timeZone},options))}}]),Product}(library.Base),library.Product.className="Product",library.Product.queryName="products",library.Product.belongsTo("merchant"),library.Product.belongsTo("venue"),library.Product.hasMany("labels"),library.Product.hasMany("orders"),library.Product.hasMany("questions"),library.Product.hasMany("redeemables"),library.Product.hasMany("timeSlots"),library.Product.hasOne("firstTimeSlot",{className:"TimeSlot"}),library.Product.hasOne("lastTimeSlot",{className:"TimeSlot"}),library.Product.hasOne("firstFilteredTimeSlot",{className:"TimeSlot"}),library.Product.afterRequest(function(){if(this.attendeeQuestions=ActiveResource.Collection.build(this.attendeeQuestions).map(function(q){return s.camelize(q,!0)}),this.firstTimeSlotStartsAt){if(!this.merchant())throw"Product has timeslots - but merchant.timeZone is not available; include merchant in response.";this.firstTimeSlotStartsAt=moment.tz(this.firstTimeSlotStartsAt,this.merchant().timeZone)}})}),Occasion.Modules.push(function(library){library.Question=function(_library$Base15){function Question(){return _classCallCheck(this,Question),_possibleConstructorReturn(this,(Question.__proto__||Object.getPrototypeOf(Question)).apply(this,arguments))}return _inherits(Question,_library$Base15),Question}(library.Base),library.Question.className="Question",library.Question.queryName="questions",library.Question.belongsTo("product"),library.Question.hasMany("answers"),library.Question.hasMany("options")}),Occasion.Modules.push(function(library){library.Rate=function(_library$Base16){function Rate(){return _classCallCheck(this,Rate),_possibleConstructorReturn(this,(Rate.__proto__||Object.getPrototypeOf(Rate)).apply(this,arguments))}return _inherits(Rate,_library$Base16),Rate}(library.Base),library.Rate.className="Rate",library.Rate.queryName="rates",library.Rate.attributes("fulfillment_uid","fee","eta","carrier","service","expires_at")}),Occasion.Modules.push(function(library){library.Recipient=function(_library$Base17){function Recipient(){return _classCallCheck(this,Recipient),_possibleConstructorReturn(this,(Recipient.__proto__||Object.getPrototypeOf(Recipient)).apply(this,arguments))}return _inherits(Recipient,_library$Base17),Recipient}(library.Base),library.Recipient.className="Recipient",library.Recipient.queryName="recipients",library.Recipient.attributes("addressLine1","addressLine2","addressLine3","administrativeDistrictLevel1","administrativeDistrictLevel2","administrativeDistrictLevel3","country","displayName","emailAddress","firstName","lastName","locality","organization","phoneNumber","postalCode","sublocality","sublocality2","sublocality3")}),Occasion.Modules.push(function(library){library.Redeemable=function(_library$Base18){function Redeemable(){return _classCallCheck(this,Redeemable),_possibleConstructorReturn(this,(Redeemable.__proto__||Object.getPrototypeOf(Redeemable)).apply(this,arguments))}return _inherits(Redeemable,_library$Base18),Redeemable}(library.Base),library.Redeemable.className="Redeemable",library.Redeemable.queryName="redeemables",library.Redeemable.belongsTo("product")}),Occasion.Modules.push(function(library){library.ShipmentDetail=function(_library$Base19){function ShipmentDetail(){return _classCallCheck(this,ShipmentDetail),_possibleConstructorReturn(this,(ShipmentDetail.__proto__||Object.getPrototypeOf(ShipmentDetail)).apply(this,arguments))}return _inherits(ShipmentDetail,_library$Base19),ShipmentDetail}(library.Base),library.ShipmentDetail.className="ShipmentDetail",library.ShipmentDetail.queryName="shipment_details",library.ShipmentDetail.belongsTo("fulfillment",{inverseOf:"shipmentDetails"}),library.ShipmentDetail.hasMany("rates"),library.ShipmentDetail.attributes("carrier","shippingNote","shippingType","easyPostRateUid")}),Occasion.Modules.push(function(library){library.State=function(_library$Base20){function State(){return _classCallCheck(this,State),_possibleConstructorReturn(this,(State.__proto__||Object.getPrototypeOf(State)).apply(this,arguments))}return _inherits(State,_library$Base20),State}(library.Base),library.State.className="State",library.State.queryName="states"}),Occasion.Modules.push(function(library){var _class,_temp;library.TimeSlot=(_temp=_class=function(_library$Base21){function TimeSlot(){return _classCallCheck(this,TimeSlot),_possibleConstructorReturn(this,(TimeSlot.__proto__||Object.getPrototypeOf(TimeSlot)).apply(this,arguments))}return _inherits(TimeSlot,_library$Base21),_createClass(TimeSlot,[{key:"toString",value:function(format){var output;if(this.showTimeSlotDuration){var durationFormat,durationTimeSlot=this.endsAt;durationFormat=durationTimeSlot.isSame(this.startsAt,"day")?"LT":"LLLL",output=this.startsAt.format(format),output+=" - ",output+=durationTimeSlot.format(durationFormat)}else output=this.startsAt.format(format);return output}},{key:"toDateString",value:function(){return this.startsAt.format("ddd ll")}}]),TimeSlot}(library.Base),_class.constructCalendar=function(){var month=void 0,options=void 0;return moment.isMoment(arguments[0])?(month=arguments[0],options=arguments[1]||{}):options=arguments[0]||{},Occasion.__constructCalendar(month,_extends({monthlyTimeSlotDaysBatchSize:7,monthlyTimeSlotPreloadSize:4,relation:this},options))},_temp),library.TimeSlot.className="TimeSlot",library.TimeSlot.queryName="time_slots",library.TimeSlot.belongsTo("order"),library.TimeSlot.belongsTo("product"),library.TimeSlot.belongsTo("venue"),library.TimeSlot.afterRequest(function(){this.startsAt=moment.tz(this.startsAt,this.timeZone),this.duration=moment.duration(this.duration,"minutes"),this.endsAt=moment.tz(this.startsAt.clone().add(this.duration),this.timeZone)})}),Occasion.Modules.push(function(library){library.Transaction=function(_library$Base22){function Transaction(){return _classCallCheck(this,Transaction),_possibleConstructorReturn(this,(Transaction.__proto__||Object.getPrototypeOf(Transaction)).apply(this,arguments))}return _inherits(Transaction,_library$Base22),Transaction}(library.Base),library.Transaction.className="Transaction",library.Transaction.queryName="transactions",library.Transaction.attributes("amount"),library.Transaction.belongsTo("order",{inverseOf:"transactions"}),library.Transaction.belongsTo("paymentMethod",{polymorphic:!0})}),Occasion.Modules.push(function(library){library.Venue=function(_library$Base23){function Venue(){return _classCallCheck(this,Venue),_possibleConstructorReturn(this,(Venue.__proto__||Object.getPrototypeOf(Venue)).apply(this,arguments))}return _inherits(Venue,_library$Base23),Venue}(library.Base),library.Venue.className="Venue",library.Venue.queryName="venues",library.Venue.belongsTo("merchant"),library.Venue.belongsTo("state"),library.Venue.belongsTo("country"),library.Venue.hasMany("products")}),Occasion.Modules.push(function(library){library.CreditCard=function(_library$PaymentMetho){function CreditCard(){return _classCallCheck(this,CreditCard),_possibleConstructorReturn(this,(CreditCard.__proto__||Object.getPrototypeOf(CreditCard)).apply(this,arguments))}return _inherits(CreditCard,_library$PaymentMetho),CreditCard}(library.PaymentMethod),library.CreditCard.className="CreditCard",library.CreditCard.queryName="credit_cards",library.CreditCard.hasMany("transactions",{as:"paymentMethod"})}),Occasion.Modules.push(function(library){library.GiftCard=function(_library$PaymentMetho2){function GiftCard(){return _classCallCheck(this,GiftCard),_possibleConstructorReturn(this,(GiftCard.__proto__||Object.getPrototypeOf(GiftCard)).apply(this,arguments))}return _inherits(GiftCard,_library$PaymentMetho2),GiftCard}(library.PaymentMethod),library.GiftCard.className="GiftCard",library.GiftCard.queryName="gift_cards",library.GiftCard.belongsTo("customer"),library.GiftCard.hasMany("transactions",{as:"paymentMethod"})}),Occasion});