0.14.8 • Published 8 months ago

apirocket v0.14.8

Weekly downloads
3
License
ISC
Repository
-
Last release
8 months ago

Uso

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apirocket@_VERSION_/dist/ecommerce.css">
<script src="https://cdn.jsdelivr.net/npm/apirocket@_VERSION/dist/ecommerce.js" defer></script>

Inicializar el ecommerce

    document.addEventListener('apirocket.ecommerce.ready', (event: EcommerceReadyEvent) => {

        event.ecommerce.config (EcommerceConfig)
    });

Actions

  • cart-add-item
  • cart-open
  • customer-account
  • checkout-open
  • sales-account

EcommerceReadyEvent

interface EcommerceReadyEvent extends Event {
    ecommerce: PublicEcommerceService
}

PublicEcommerceService

type PublicEcommerceService = {
    customer: CustomerService,
    cart: any,
    config: (value: EcommerceConfig) => void
}

EcommerceConfig

type EcommerceConfig = {
    countryIso?: string;
    debug?: DebugType | Array <DebugType> = '';
    customerFilterType: '' | 'B2B' | 'B2C' = '';
    ecommerceId: string;
    logo?: string;
    legalLinks?: LegalLinks;
    pricesTaxIncluded?: boolean = true;
    stage?: Stage = 'production';
}

Eventos

  • apirocket.ecommerce.updateEvents

DebugType

type DebugType = 'all' | 'analytics'

LegalLinks

type LegalLinks = {
    refundPolicy?:  LegalLink,
    privacyPolicy?: LegalLink,
    termsAndConditions?: LegalLink
}

type LegalLink = {
    label?: string;
    link?: string;
}

CustomerService

interface ReadOnly <CustomerService> {
    acceptEmailMarketing: boolean;
    email: string;
    firstName: string;
    id: number;
    lastName: string;
    phone: string;
    type: 'B2B' | 'B2C';
    isLogged: boolean;

    countries: () => Promise <Array <Countries>>;
    createBillingAddress: (input: Omit <BillingAddress, 'id'>) => Promise <BillingAddress>;
    createShippingAddress: (input: Omit <ShippingAddress, 'id'>) => Promise <ShippingAddress>;
    deleteShippingAddress: (id: number) => Promise <boolean>;
    myAccount: () => Promise <CustomerAccount>;
    price: (productId: number) => Promise <ProductPrice>;
    orders: (filter: OrdersFilter = {}) => Promise <Array <Order>>;
    order: (id: number) => Promise <Order>;
    states: (countryId: number) => Promise <Array <State>>;
    subscribe: (cb: (customer: CustomerService) => void);
    updateMyAccount: (input: InputUpdateAccount) => Promise <boolean>;
    updatePassword: (oldPassword: string, newPassword: string) => Promise <boolean>;
    updateBillingAddress: (input: BillingAddress) => Promise <BillingAddress>;
    updateShippingAddress: (input: ShippingAddress) => Promise <ShippingAddress>;
}

Tipos

type ShippingAddress {
    address: string;
    address2?: string;
    city: string;
    country: { id: number; name?: string; iso?: string };
    description: string;
    firstName: string;
    id: number;
    lastName: string;
    phone: string;
    postalCode?: string;
    state: State
}
type State = {
    name?: string;
    id: number;
}
type InputUpdateAccount = {
    acceptEmailMarketing: boolean;
    firstName: string;
    lastName: string;
    phone: string;
}
interface CustomerAccount {
    acceptEmailMarketing?: boolean;
    billingAddress?: BillingAddress;
    custom?: any;
    email?: string
    firstName?: string;
    lastName?: string;
    phone?: string;
    shippingAddress?: Array <AccountShippingAddress>;
}
interface BillingAddress {
    address: string;
    address2: string;
    city: string;
    country: Country
    default: boolean;
    description: string;
    id: number;
    name: string;
    phone: string;
    postalCode: string;
    state: State;
    taxCode: string;
}
interface AccountShippingAddress {
    address: string;
    address2: string;
    city: string;
    country: Country;
    default: boolean;
    description: string;
    firstName: string;
    id: number;
    lastName: string;
    name: string;
    phone: string;
    postalCode: string;
    state: {
        name: string;
        id: number;
    }
}
interface ProductPrice {
    comparePrice: number;
    comparePriceTaxBase: number;
    comparePriceTaxAmmount: number;
    taxAmount: number;
    taxBase: number;
    taxes: Array <any>;
}
interface Order extends CustomerOrder {
    billingAddres; OrderBillingAddress;
    cartTaxAmount: number;
    cartTaxBase: number;
    customer: OrderCustomer;
    customerOrder: string;
    date: string;
    discount: Array <OrderDiscount>;
    geolocation: OrderGeolocation;
    id: number;
    items: Array <OrderItem>;
    notes: string;
    number: string;
    payment: OrderPayment;
    pricesTaxIncluded: boolean;
    shippingAddress: OrderShippingAddress;
    shippingMethod: OrderShippingMethod;
    status: OrderStatus;
    totalTaxAmount: number;
    totalTaxBase: number;
    total: number;
}
interface OrderBillindAddress {
    address?: string;
    address2?: string;
    city?: string;
    country?: Country;
    description?: string;
    id?: number;
    name?: string;
    phone?: string;
    postalCode?: string;
    state?: { id: number; name: string };
    taxCode?: string
}
interface  OrderCustomer {
    code: string;
    email: string;
    id: number;
    isLogged: boolean;
    name: string;
    phone: string;
    priceList: { id: number; name: string }
    type: 'B2B' | 'B2C';
}
interface OrderDiscount {
    codes: Array <any>;
    taxAmount: number;
    taxBase: number;
    total: number;
}
interface OrderGeolocation {
    browser: { name: string, version: string };
    city: string;
    continent: string;
    country: string;
    device: { type: string; model: string; vendor: string };
    ip: string;
    lat: number;
    lon: number;
    os: { name: string; version: string };
    postalCode: string;
    region: string;
    remoteAddress: string;
    timeZone: string;
    userAgent: string;
    userIsp: string;
}
interface OrderItem {
    id: number;
    price: number;
    priceTaxAmount: number;
    priceTaxBase: number;
    product: OrderProduct;
    quantity: number;
    taxes: any;
}
type OrderPayment = {
    authorization: string;
    method: {
        id: number;
        name: string;
        type: PaymentType;
        notes: string;
        description: string;
    }
    total: number;
}
interface OrderProduct {
    barcode: string;
    category: {
        id: number,
        name: string
    },
    description: string;
    id: number;
    image: string;
    name: string;
    noShippingCost: boolean,
    sku: string,
    stockManagement: boolean,
    url?: string;
    weight: number;
}
type OrdersFilter = {
    page?: number;
    perPage?: number;
}
interface OrderShippingAddress {
    address?: string;
    address2?: string;
    city?: string;
    country?: Country;
    description?: string;
    email?: string;
    firstName?: string;
    id?: number;
    lastName?: string;
    phone?: string;
    postalCode?: string;
    state?: { id: number; name: string };
}
interface OrderShippingMethod {
    description: string;
    id: number;
    name: string;
    taxAmount: number;
    taxBase: number;
    taxes: Array <any>;
    total: number;
}
type OrderStatus = {
    id: number;
    name: string;
    color: string;
}

Ejemplo

document.addEventListener('apirocket.ecommerce.ready', (event: EcommerceReadyEvent) => {

    event.ecommerce.config ({
        ecommerceId: 'ECOMMERCE_ID',
        debug: 'all',
    })
});
0.14.7

8 months ago

0.14.8

8 months ago

0.14.6

8 months ago

0.13.6

10 months ago

0.13.7

10 months ago

0.13.3

10 months ago

0.13.4

10 months ago

0.13.5

10 months ago

0.14.5

9 months ago

0.14.0

10 months ago

0.14.1

10 months ago

0.14.2

10 months ago

0.14.3

9 months ago

0.14.4

9 months ago

0.11.0

10 months ago

0.11.1

10 months ago

0.13.0

10 months ago

0.11.2

10 months ago

0.13.1

10 months ago

0.11.3

10 months ago

0.13.2

10 months ago

0.11.4

10 months ago

0.12.0

10 months ago

0.12.1

10 months ago

0.12.2

10 months ago

0.12.3

10 months ago

0.12.4

10 months ago

0.10.4

11 months ago

0.10.2

12 months ago

0.10.3

12 months ago

0.9.7

1 year ago

0.10.1

1 year ago

0.10.0

1 year ago

0.9.6

1 year ago

0.9.5

1 year ago

0.9.4

1 year ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.0

1 year ago

0.9.1

1 year ago

0.8.2

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.7.5

1 year ago

0.7.4

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.3

1 year ago

0.7.0

1 year ago

0.6.10

1 year ago

0.6.9

1 year ago

0.6.8

1 year ago

0.6.7

1 year ago

0.6.6

1 year ago

0.6.5

1 year ago

0.6.4

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.5.7

2 years ago

0.5.4

2 years ago

0.5.6

2 years ago

0.5.5

2 years ago

0.5.3

2 years ago

0.5.0

2 years ago

0.5.2

2 years ago

0.5.1

2 years ago

0.4.3

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.4.2

2 years ago

0.3.0

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.2.2

3 years ago

0.0.20

3 years ago

0.1.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.3

3 years ago

0.0.15

3 years ago

0.0.16

3 years ago

0.0.17

3 years ago

0.0.18

3 years ago

0.0.19

3 years ago

0.0.10

3 years ago

0.0.11

3 years ago

0.0.12

3 years ago

0.0.13

3 years ago

0.0.14

3 years ago

0.0.9

3 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.1

4 years ago