Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Cleaning depracated types
Browse files Browse the repository at this point in the history
  • Loading branch information
aplegatt committed Aug 2, 2022
1 parent a66800f commit 98021a0
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 292 deletions.
45 changes: 2 additions & 43 deletions src/interfaces/Account.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { IAddress } from './attributes/Address'
import type { JsonApiDocument, JsonApiListResponse, JsonApiSingleResponse } from './JsonApi'
import type { IQuery } from './Query'
import type { IRelationships } from './Relationships'
import type { ResultResponse } from './ResultResponse'
import type { WithCommonOptions } from './WithCommonOptions'
Expand All @@ -25,40 +24,6 @@ export interface IAccount extends JsonApiSingleResponse {

export interface IAccountResult extends ResultResponse<IAccount> {}

export interface IAccountConfirmation {
data: {
state: string
}
}

export interface IAccountConfirmationResult extends ResultResponse<IAccountConfirmation> {}

/**
* @deprecated Use {@link ForgotPasswordOptions} instead.
*/
export interface ForgotPasswordParams extends IQuery {
user: {
email: string
}
}

/**
* @deprecated Use {@link ResetPasswordOptions} instead.
*/
export interface ResetPasswordParams extends IQuery {
user: {
password: string
password_confirmation: string
}
}

/**
* @deprecated Use {@link CreateAddressOptions} instead.
*/
export interface AccountAddressParams extends IQuery {
address: IAddress
}

export interface AccountAddressAttr extends JsonApiDocument {
attributes: IAddress
}
Expand Down Expand Up @@ -118,12 +83,6 @@ export type CreateOptions = WithCommonOptions<
}
>

export type ConfirmOptions = WithCommonOptions<null, { confirmation_token: string }>

export type ForgotPasswordOptions = WithCommonOptions<null, ForgotPasswordParams>

export type ResetPasswordOptions = WithCommonOptions<null, ResetPasswordParams & { reset_password_token: string }>

export type UpdateOptions = WithCommonOptions<
{ suggestToken: true; onlyAccountToken: true },
{
Expand All @@ -148,12 +107,12 @@ export type ShowAddressOptions = WithCommonOptions<

export type CreateAddressOptions = WithCommonOptions<
{ suggestToken: true; onlyAccountToken: true; suggestQuery: true },
AccountAddressParams
{ address: IAddress }
>

export type RemoveAddressOptions = WithCommonOptions<{ suggestToken: true; onlyAccountToken: true }, { id: string }>

export type UpdateAddressOptions = WithCommonOptions<
{ suggestToken: true; onlyAccountToken: true },
AccountAddressParams & { id: string }
{ address: IAddress }
>
25 changes: 15 additions & 10 deletions src/interfaces/Cart.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { WithCommonOptions } from './WithCommonOptions'

import type * as RestCheckoutTypes from './endpoints/CartClass'

export * from './endpoints/CartClass'

export type ShowOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }>

export type CreateOptions = WithCommonOptions<{
Expand All @@ -18,7 +14,13 @@ export type AddItemOptions = WithCommonOptions<
suggestToken: true
suggestQuery: true
},
RestCheckoutTypes.AddItem
{
variant_id: string
quantity: number
options?: {
[key: string]: string
}
}
>

export type RemoveItemOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, { id: string }>
Expand All @@ -29,12 +31,15 @@ export type RemoveOptions = WithCommonOptions<{ suggestToken: true }>

export type SetQuantityOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.SetQuantity
{
line_item_id: string
quantity: number
}
>

export type ApplyCouponCodeOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.CouponCode
{ coupon_code: string }
>

export type RemoveCouponCodeOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, { code?: string }>
Expand All @@ -43,15 +48,15 @@ export type RemoveAllCouponsOptions = WithCommonOptions<{ suggestToken: true; su

export type EstimateShippingRatesOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.EstimateShippingRates
{ country_iso: string }
>

export type AssociateGuestCartOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.AssociateCart
{ guest_order_token: string }
>

export type ChangeCurrencyOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.ChangeCurrency
{ new_currency: string }
>
39 changes: 34 additions & 5 deletions src/interfaces/Checkout.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { WithCommonOptions } from './WithCommonOptions'

import type * as RestCheckoutTypes from './endpoints/CheckoutClass'

export * from './endpoints/CheckoutClass'
import { IAddress } from './attributes/Address'
import { IShipment } from './attributes/Shipment'

export type CreateStripeSessionOptions = WithCommonOptions<
{ suggestToken: true },
Expand All @@ -14,7 +13,17 @@ export type CreateStripeSessionOptions = WithCommonOptions<

export type AddPaymentOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.AddFullPayment & {
{
payment_method_id: string
source_attributes?: {
gateway_payment_profile_id: string
cc_type?: string
last_digits?: string
month?: string
year?: string
name: string
}
} & {
source_id?: string
amount?: number
}
Expand Down Expand Up @@ -47,7 +56,27 @@ export type AdvanceOptions = WithCommonOptions<{ suggestToken: true; suggestQuer

export type OrderUpdateOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
RestCheckoutTypes.OrderUpdate
{ order?: {
email?: string
special_instructions?: string
bill_address_attributes?: IAddress
ship_address_attributes?: IAddress
payments_attributes?: AddFullPayment[]
shipments_attributes?: IShipment[]
}
}
>

export type OrderNextOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }>

export interface AddFullPayment {
payment_method_id: string
source_attributes?: {
gateway_payment_profile_id: string
cc_type?: string
last_digits?: string
month?: string
year?: string
name: string
}
}
12 changes: 1 addition & 11 deletions src/interfaces/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ export interface MenuResult extends ResultResponse<Menu> {}

export interface MenusResult extends ResultResponse<Menus> {}

/**
* @deprecated Use {@link ListOptions} instead.
*/
export interface MenusList extends IQuery {
locale?: string
filter?: IQuery['filter'] & {
location?: string
}
}

export type ListOptions = WithCommonOptions<{ suggestQuery: true }, MenusList>
export type ListOptions = WithCommonOptions<{ suggestQuery: true }, { locale?: string; filter?: IQuery['filter'] & { location?: string } }>

export type ShowOptions = WithCommonOptions<{ suggestQuery: true }, { id: string }>
30 changes: 0 additions & 30 deletions src/interfaces/ShippingMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,6 @@ import { JsonApiDocument, JsonApiListResponse } from './JsonApi'
import { IRelationships } from './Relationships'
import { ResultResponse } from './ResultResponse'

/**
* @deprecated Use {@link ShippingRateAttr} instead.
*/
export interface ShippingMethodAttr extends JsonApiDocument {
type: string
id: string
attributes: {
number: string
free: boolean
final_price: string
display_final_price: string
tracking_url: string
state: string
shipped_at: Date
}
relationships: IRelationships
}

/**
* @deprecated Use {@link ShippingRates} instead.
*/
export interface IShippingMethods extends JsonApiListResponse {
data: ShippingMethodAttr[]
}

/**
* @deprecated Use {@link ShippingRatesResult} instead.
*/
export interface IShippingMethodsResult extends ResultResponse<IShippingMethods> {}

export interface ShippingRateAttr extends JsonApiDocument {
type: string
id: string
Expand Down
20 changes: 2 additions & 18 deletions src/interfaces/WishedItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { JsonApiDocument, JsonApiSingleResponse } from './JsonApi'
import type { IQuery } from './Query'
import type { IRelationships } from './Relationships'
import type { ResultResponse } from './ResultResponse'
import type { WithCommonOptions } from './WithCommonOptions'
Expand All @@ -20,29 +19,14 @@ export interface WishedItem extends JsonApiSingleResponse {

export interface WishedItemResult extends ResultResponse<WishedItem> {}

/**
* @deprecated Use {@link AddWishedItemOptions} instead.
*/
export interface WishlistsAddWishedItem extends IQuery {
variant_id: string
quantity: number
}

/**
* @deprecated Use {@link UpdateWishedItemOptions} instead.
*/
export interface WishlistsUpdateWishedItem extends IQuery {
quantity: number
}

export type AddWishedItemOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
{ wishlist_token: string } & WishlistsAddWishedItem
{ wishlist_token: string } & { variant_id: string; quantity: number }
>

export type UpdateWishedItemOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
{ wishlist_token: string; id: string } & WishlistsUpdateWishedItem
{ wishlist_token: string; id: string } & { quantity: number }
>

export type RemoveWishedItemOptions = WithCommonOptions<{ suggestToken: true }, { wishlist_token: string; id: string }>
50 changes: 5 additions & 45 deletions src/interfaces/Wishlist.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { JsonApiDocument, JsonApiListResponse, JsonApiSingleResponse } from './JsonApi'
import { IQuery } from './Query'
import { IRelationships } from './Relationships'
import { ResultResponse } from './ResultResponse'
import { WithCommonOptions } from './WithCommonOptions'
Expand Down Expand Up @@ -29,59 +28,20 @@ export interface WishlistResult extends ResultResponse<Wishlist> {}

export interface WishlistsResult extends ResultResponse<Wishlists> {}

/**
* @deprecated Use {@link ListOptions} instead.
*/
export interface WishlistsList extends IQuery {
is_variant_included?: string
}

/**
* @deprecated Use {@link ShowOptions} instead.
*/
export interface WishlistsShow extends IQuery {
is_variant_included?: string
}

/**
* @deprecated Use {@link DefaultOptions} instead.
*/
export interface WishlistsDefault extends IQuery {
is_variant_included?: string
}

/**
* @deprecated Use {@link CreateOptions} instead.
*/
export interface WishlistsCreate extends IQuery {
name: string
is_private?: boolean
is_default?: boolean
}

/**
* @deprecated Use {@link UpdateOptions} instead.
*/
export interface WishlistsUpdate extends IQuery {
name: string
is_private?: boolean
is_default?: boolean
}

export type ListOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, WishlistsList>
export type ListOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, { is_variant_included?: string }>

export type ShowOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
{ wishlist_token: string } & WishlistsShow
{ wishlist_token: string } & { is_variant_included?: string }
>

export type DefaultOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, WishlistsDefault>
export type DefaultOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, { is_variant_included?: string }>

export type CreateOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, WishlistsCreate>
export type CreateOptions = WithCommonOptions<{ suggestToken: true; suggestQuery: true }, { name: string; is_private?: boolean; is_default?: boolean}>

export type UpdateOptions = WithCommonOptions<
{ suggestToken: true; suggestQuery: true },
{ wishlist_token: string } & WishlistsUpdate
{ wishlist_token: string } & { name: string; is_private?: boolean; is_default?: boolean}
>

export type RemoveOptions = WithCommonOptions<{ suggestToken: true }, { wishlist_token: string }>
Loading

0 comments on commit 98021a0

Please sign in to comment.