Last active
August 7, 2023 21:42
-
-
Save cjmosure/ee25623c74bc95266c3852cf59b4176b to your computer and use it in GitHub Desktop.
Shiping Elements Types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ButtonTheme { | |
backgroundColor?: string; | |
activeBackgroundColor?: string; | |
hoverColor?: string; | |
hoverBackgroundColor?: string; | |
color?: string; | |
borderRadius?: string; | |
borderColor?: string; | |
activeBorderColor?: string; | |
textTransform?: 'lowercase' | 'uppercase' | 'capitalize'; | |
disabledBackgroundColor?: string; | |
disabledBorderColor?: string; | |
disabledTextColor?: string; | |
noBoxShadow?: boolean; | |
} | |
export interface Theme { | |
elementId?: string; | |
title?: string; | |
style?: string; | |
height?: string; | |
width?: string; | |
primaryColor?: string; | |
container?: { | |
backgroundColor?: string; | |
}; | |
header?: { | |
backgroundColor?: string; | |
borderColor?: string; | |
color?: string; | |
hasBoxShadow?: boolean; | |
textAlign?: 'left' | 'right' | 'center'; | |
display?: boolean; | |
}; | |
footer?: { | |
backgroundColor?: string; | |
borderColor?: string; | |
hasBoxShadow?: boolean; | |
displayShippoLogo?: boolean; | |
}; | |
button?: { | |
primary: ButtonTheme; | |
secondary?: ButtonTheme; | |
error?: ButtonTheme; | |
}; | |
cards?: { | |
subHeaderColor?: string; | |
backgroundColor?: string; | |
borderRadius?: string; | |
borderColor?: string; | |
borderStyle?: string; | |
hoverBackgroundColor?: string; | |
activeBackgroundColor?: string; | |
}; | |
inputs?: { | |
borderColor?: string; | |
borderActive?: string; | |
hoverColor?: string; | |
}; | |
menu?: { | |
titleBackgroundColor?: string; | |
hoverColor?: string; | |
hoverBackgroundColor?: string; | |
}; | |
} | |
interface Callbacks { | |
[eventName: string]: [Callback]; | |
} | |
declare type Callback<Payload = unknown> = (payload: Payload, eventName?: string) => void; | |
declare class ShippoEventSystem { | |
static getInstance: () => ShippoEventSystem; | |
addCallback: (eventName: string, cb: Callback) => void; | |
addAnyCallback: (cb: Callback) => void; | |
removeCallback: (eventName: string, cb: Callback) => void; | |
searchAndFireCallbacks: (eventName: string, payload: string) => void; | |
removeAllEventsAndCallbacks: () => void; | |
removeEvent: (eventName: string) => void; | |
get accessReadOnlyCallbacks(): Callbacks; | |
} | |
export interface ProviderDetails { | |
name: string; | |
service_levels?: string[]; | |
} | |
export interface RateFilters { | |
providers?: ProviderDetails[]; | |
} | |
export interface ShippoSettings { | |
token: string; | |
org: string; | |
origin?: string; | |
theme?: Theme; | |
rateFilters?: RateFilters; | |
locale?: string; | |
tracking?: Record<string, unknown>; | |
} | |
export interface Address { | |
name: string; | |
company?: string; | |
street_no?: string; | |
street1: string; | |
street2?: string; | |
street3?: string; | |
city: string; | |
state: string; | |
zip: string; | |
country: string; | |
phone?: string; | |
email?: string; | |
} | |
export interface Item { | |
id?: number; | |
title: string; | |
sku?: string; | |
quantity: number; | |
currency: string; | |
unit_amount: string; | |
unit_weight: string; | |
weight_unit: string; | |
country_of_origin?: string; | |
} | |
export interface Shipment { | |
shipment_id?: string; | |
} | |
export interface OrderDetails { | |
address_from?: Address; | |
address_to: Address; | |
line_items: Item[]; | |
address_return?: Address; | |
object_id?: string; | |
order_number?: string; | |
order_status?: string; | |
placed_at?: string; | |
notes?: string; | |
shipment_date?: Date; | |
extras?: { | |
insurance?: { | |
amount: string; | |
currency: string; | |
}; | |
signature_confirmation?: string; | |
}; | |
} | |
declare type Platform = ''; | |
export declare class Shippo { | |
constructor(); | |
init(settings: ShippoSettings): void; | |
labelPurchase(element: string, orderDetails?: OrderDetails | OrderDetails[]): void; | |
showAccountConnectionError( | |
element: string, | |
platform: Platform, | |
theme: Theme, | |
next: string, | |
shouldRefresh: boolean, | |
): void; | |
on(eventName: string, callback: Callback): void; | |
off(eventName: string, callback: Callback): void; | |
onAny(callback: Callback): void; | |
destroy(): void; | |
getConfig(): ShippoSettings; | |
} | |
export {}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment