import { HttpClient } from '@angular/common/http'; import { ReplaySubject, SubscriptionLike as ISubscription, Observable } from 'rxjs'; import { Config } from './config'; import { Product } from './product.service'; import { Order } from './order/order'; import { Shop } from './shop.service'; import { User, UserAddress, UserCard, DepositAddress, ShippingAddress } from './user.service'; import './es5'; import { CalendarService } from './calendar.service'; import * as i0 from "@angular/core"; export declare enum CartAction { ITEM_ADD = "ITEM_ADD", ITEM_UPDATE = "ITEM_UPDATE", ITEM_REMOVE = "ITEM_REMOVE", ITEM_MAX = "ITEM_MAX", ITEM_ALL = "ITEM_ALL", CART_INIT = "CART_INIT", CART_LOADED = "CART_LOADED", CART_LOAD_ERROR = "CART_LOAD_ERROR", CART_SAVE_ERROR = "CART_SAVE_ERROR", CART_ADDRESS = "CART_ADDRESS", CART_PAYMENT = "CART_PAYMENT", CART_SHIPPING = "CART_SHIPPING", CART_CLEARED = "CART_CLEARED", CART_SUBSCRIPTION = "CART_SUBSCRIPTION" } export declare class CartState { item?: CartItem; order?: Order; action: CartAction; data?: any; server?: CartItem[]; } export declare class CartItem { constructor(item: any | CartItem); shared?: boolean; deleted?: boolean; selected?: boolean; bundle?: boolean | "true" | "false"; frequency?: CartItemFrequency | string | boolean; active: boolean; timestamp: Date; timelimit?: number; lastMinute?: boolean; displayName?: string; email?: string; hub: string; title: string; sku: number; variant: string; thumb: string; price: number; finalprice: number; weight: number; error?: string; note?: string; audio?: string; category: { slug: string; name: string; }; vendor: { urlpath: string; name: string; weekdays: number[]; photo: string; discount: { threshold?: number; amount?: number; }; }; discount: boolean; part: string; quantity: number; stockLimit?: number; static fromContract(item: CartSubscriptionProductItem): CartItem; static fromProduct(product: Product, hub: string, variant?: string, quantity?: number): CartItem; equalItem(other: CartItem, variant?: string): boolean; toDEPRECATED(): { sku: number; title: string; variant: string; frequency: string | boolean | CartItemFrequency.ITEM_NONE; timelimit: number; categories: string; vendor: string; quantity: number; price: number; hub: string; part: string; note: string; audio: string; finalprice: number; }; } export interface CartItemsContext { address?: DepositAddress | UserAddress; forSubscription?: boolean | undefined; onSubscription?: boolean; lastMinute?: boolean; hub?: string; } export interface CartSubscriptionProductItem { unit_amount: number; currency: string; quantity: number; fees: number; sku: number | string; title: string; note: string; hub: string; part: string; variant?: string; error?: string; deleted?: boolean; audio?: string; selected?: boolean; updated?: boolean; } export interface CartSubscriptionServiceItem { unit_amount: number; quantity: number; fees: number; id: string; title?: string; } export declare enum CartSchedulerStatus { active = "active", paused = "paused", pending = "pending", incomplete = "incomplete", trialing = "trialing", cancel = "cancel" } export declare enum CartItemFrequency { ITEM_NONE = 0, ITEM_DAY = "day", ITEM_WEEK = "week", ITEM_2WEEKS = "2weeks", ITEM_MONTH = "month" } export interface CartSubscription { id: string; plan: string; customer: string; paymentId: string; paymentAlias: string; description: string; start: Date; nextInvoice: Date; pauseUntil: Date | 0; frequency: CartItemFrequency; dayOfWeek: number; status: string; issue?: string; latestPaymentIntent: { source: string; status: string; id: string; client_secret: string; }; shipping: ShippingAddress | DepositAddress | UserAddress; items: CartSubscriptionProductItem[]; services: CartSubscriptionServiceItem[]; patreon: CartSubscriptionServiceItem[]; errors?: any; } export interface CartSubscriptionParams { time?: number; dayOfWeek: number; frequency: CartItemFrequency | string; activeForm: boolean; } export interface CartSubscriptionData { dayOfWeek: number; frequency: CartItemFrequency | string; items: any[]; shipping: DepositAddress | UserAddress; payment: string; hub: string; } export declare class CartConfig { namespace: string; gateway: { fees: number; label: string; }; currency: string; shipping: any | { average: number; price: { hypercenter: number; periphery: number; others: number; }; priceA: number; priceB: number; discountA: number; discountB: number; periphery: string[]; others: string[]; }; constructor(); } export declare class CartModel { cid: string | [string]; items: CartItem[]; updated: Date; reset: Date; subscriptionParams: CartSubscriptionParams; subscriptions: string[]; constructor(); } export declare class CartService { private $http; private $calendar; private isReady; private headers; private currentHub; private currentUser; private currentShops; private currentPendingOrder; private vendorAmount; private itemsQtyMap; private itemsSubsMap; private defaultConfig; private cartConfig; private cache; private load$; SHIPPING_COLLECT: string; SHIPPING_CENTER: string; SHIPPING_PERIPHERY: string; SHIPPING_OTHER: string; DEFAULT_GATEWAY: any; cart$: ReplaySubject; subscription$: ReplaySubject; constructor($http: HttpClient, $calendar: CalendarService); subscriptionsGetAll(): Observable; subscriptionsGet(): Observable; subscriptionPause(subscription: CartSubscription, to: Date): Observable; subscriptionResume(subscription: CartSubscription): Observable; /** * Réinitialise le cycle de facturation (Admin only) * * @param subscription - L'abonnement à modifier * @param toDate - 'now' pour immédiat, ou une Date future (utilise trial_end) - REQUIRED * * COMPORTEMENT STRIPE (trial_end pour date future) : * > "Adding a trial → Stripe sets the anchor date to the end of the trial" * * @see https://stripe.com/docs/billing/subscriptions/billing-cycle#changing */ subscriptionResetBillingCycle(subscription: CartSubscription, toDate: Date | 'now'): Observable; subscriptionCancel(subscription: CartSubscription): Observable; subscriptionCreatePatreon(options: any): Observable; subscriptionCreate(params: CartSubscriptionData): Observable; subscriptionUpdate(sid: any, params: CartSubscriptionData): Observable; subscriptionUpdatePayment(hub: any, sid: any, payment: any): Observable; subscriptionPaymentConfirm(sid: any, intent: any): Observable; subscriptionGetPatreonProducts(): Observable; subscriptionSetParams(params: CartSubscriptionParams, quiet?: boolean): void; subscriptionGetParams(): CartSubscriptionParams; addAll(products: Product[] | CartItem[]): void; addOrUpdateNote(item: CartItem, variant?: string): void; add(product: Product | CartItem, variant?: string, quiet?: boolean): void; clearErrors(): void; clearAfterOrder(hub: string, order?: Order, contract?: CartSubscription): void; broadcastState(): void; checkIfReady(): void; computeItemsQtyMap(): void; computeSubsQtyMap(items: CartItem[]): void; computeVendorDiscount(): void; computeShippingFees(ctx: CartItemsContext): any; estimateShippingFeesWithoutReduction(ctx: any): { price: any; status: string; }; findBySku(sku: number, hub: string, frequency?: boolean): CartItem; findIndexBySku(sku: number, hub: string, frequency?: boolean): number; getCurrentGateway(): { fees: number; label: string; }; getItemsQtyMap(sku: number, hub: string, frequency?: any): any; getSubsQtyMap(sku: number): any; getItems(ctx: CartItemsContext): CartItem[]; getName(): string; getCID(): string | [string]; getShared(name: string): Observable; getCurrentShippingAddress(): UserAddress; getShippingDayForMultipleHUBs(): any; getCurrentShippingDay(): Date; getCurrentShippingTime(): number; isCurrentShippingLastMinute(): boolean; selectLastMinuteShipping(now?: Date): void; getCurrentShippingTimePrice(): any; getCurrentPaymentMethod(): UserCard; getVendorDiscount(item: CartItem): number; getTotalDiscount(hub: string): number; hasError(hub: string): boolean; hasPendingOrder(): Order; hasPotentialShippingReductionMultipleOrder(): boolean; hasShippingReductionMultipleOrder(address?: any): boolean; hasShippingReduction(ctx: CartItemsContext): { multiple: boolean; discountA: boolean; discountB: boolean; deposit: boolean; }; isCurrentShippingDayAvailable(shop: Shop): boolean; load(shared?: string): void; loadCache(shared?: string): void; internalLoad(shared?: string): void; removeAll(product: CartItem, variant?: string): void; remove(product: CartItem, variant?: string): void; save(state: CartState): void; private saveLocal; private saveServer; setShippingAddress(address: UserAddress | DepositAddress): boolean; setPaymentMethod(payment: UserCard): void; setShippingDay(newDate: Date, hours: number, options?: { lastMinute?: boolean; }): void; setContext(config: Config, user: User, shops?: Shop[], orders?: Order[]): void; setError(errors: any, hub: any): void; subTotal(ctx: CartItemsContext): number; /** * Subscribe to the user stream. */ subscribe(onNext: any, onThrow?: ((exception: any) => void) | null, onReturn?: (() => void) | null): ISubscription; total(ctx: CartItemsContext): number; totalHubFees(ctx: CartItemsContext): number; updateGatewayFees(): boolean; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; } //# sourceMappingURL=cart.service.d.ts.map