carts

package
v0.0.0-...-f55e261 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CartContext

type CartContext map[string]any

type CartItem

type CartItem struct {
	VariantId string `json:"variant_id,omitempty"`
	Quantity  int    `json:"quantity,omitempty"`
}

type CompleteData

type CompleteData struct {
	// The type of the data property.
	Type CompleteDataEnum `json:"type"`

	// Data will be one of order, cart and swap
	Data any `json:"data"`
}

type CompleteDataEnum

type CompleteDataEnum string
const (
	CompleteOrder CompleteDataEnum = "order"
	CompleteCart  CompleteDataEnum = "cart"
	CompleteSwap  CompleteDataEnum = "swap"
)

type CompleteResponse

type CompleteResponse struct {
	// Success response
	Data *CompleteData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

func Complete

func Complete(cartId string, config *medusa.Config) (*CompleteResponse, error)

type CreateCart

type CreateCart struct {
	RegionId       string      `json:"region_id,omitempty"`
	SalesChannelId string      `json:"sales_channel_id,omitempty"`
	CountryCode    string      `json:"country_code,omitempty"`
	Items          []*CartItem `json:"items,omitempty"`
	Context        CartContext `json:"context,omitempty"`
}

func NewCreateCart

func NewCreateCart() *CreateCart

func (*CreateCart) Create

func (c *CreateCart) Create(config *medusa.Config) (*CreateResponse, error)

func (*CreateCart) SetContext

func (c *CreateCart) SetContext(context CartContext) *CreateCart

func (*CreateCart) SetCountryCode

func (c *CreateCart) SetCountryCode(countryCode string) *CreateCart

func (*CreateCart) SetItems

func (c *CreateCart) SetItems(items []*CartItem) *CreateCart

func (*CreateCart) SetRegionId

func (c *CreateCart) SetRegionId(regionId string) *CreateCart

func (*CreateCart) SetSalesChannelId

func (c *CreateCart) SetSalesChannelId(salesChannelId string) *CreateCart

type CreateData

type CreateData struct {
	Cart *schema.Cart `json:"cart"`
}

type CreatePaymentSessionData

type CreatePaymentSessionData struct {
	Cart *schema.Cart `json:"cart"`
}

type CreatePaymentSessionResponse

type CreatePaymentSessionResponse struct {
	// Success response
	Data *CreatePaymentSessionData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

func CreatePaymentSession

func CreatePaymentSession(cartId string, config *medusa.Config) (*CreatePaymentSessionResponse, error)

type CreateResponse

type CreateResponse struct {
	// Success response
	Data *CreateData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

type DeleteDiscountData

type DeleteDiscountData struct {
	Cart *schema.Cart `json:"cart"`
}

type DeleteDiscountResponse

type DeleteDiscountResponse struct {
	// Success response
	Data *DeleteDiscountData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

func DeleteDiscount

func DeleteDiscount(cartId string, code string, config *medusa.Config) (*DeleteDiscountResponse, error)

type DeletePaymentSessionData

type DeletePaymentSessionData struct {
	Cart *schema.Cart `json:"cart"`
}

type DeletePaymentSessionResponse

type DeletePaymentSessionResponse struct {
	// Success response
	Data *DeletePaymentSessionData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

func DeletePaymentSession

func DeletePaymentSession(cartId, providerId string, config *medusa.Config) (*DeletePaymentSessionResponse, error)

type Discount

type Discount struct {
	Code string `json:"code"`
}

type GiftCard

type GiftCard struct {
	Code string `json:"code"`
}

type RefreshPaymentSessionData

type RefreshPaymentSessionData struct {
	Cart *schema.Cart `json:"cart"`
}

type RefreshPaymentSessionResponse

type RefreshPaymentSessionResponse struct {
	// Success response
	Data *RefreshPaymentSessionData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

func RefreshPaymentSession

func RefreshPaymentSession(cartId, providerId string, config *medusa.Config) (*RefreshPaymentSessionResponse, error)

Refreshes a Payment Session to ensure that it is in sync with the Cart - this is usually not necessary.

type RetrieveData

type RetrieveData struct {
	Cart *schema.Cart `json:"cart"`
}

type RetrieveResponse

type RetrieveResponse struct {
	// Success response
	Data *RetrieveData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

func Retrieve

func Retrieve(cartId string, config *medusa.Config) (*RetrieveResponse, error)

Retrieves a Cart.

type SelectPaymentSession

type SelectPaymentSession struct {
	ProviderId string `json:"provider_id"`
}

func NewSelectPaymentSession

func NewSelectPaymentSession() *SelectPaymentSession

func (*SelectPaymentSession) Select

Selects a Payment Session as the session intended to be used towards the completion of the Cart.

func (*SelectPaymentSession) SetProviderId

func (p *SelectPaymentSession) SetProviderId(providerId string) *SelectPaymentSession

type SelectPaymentSessionData

type SelectPaymentSessionData struct {
	Cart *schema.Cart `json:"cart"`
}

type SelectPaymentSessionResponse

type SelectPaymentSessionResponse struct {
	// Success response
	Data *SelectPaymentSessionData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

type ShippingMethod

type ShippingMethod struct {
	OptionId string         `json:"option_id"`
	Data     map[string]any `json:"data"`
}

func NewShippingMethod

func NewShippingMethod() *ShippingMethod

func (*ShippingMethod) Add

func (s *ShippingMethod) Add(cartId string, config *medusa.Config) (*ShippingMethodResponse, error)

Adds a Shipping Method to the Cart.

func (*ShippingMethod) SetData

func (s *ShippingMethod) SetData(data map[string]any) *ShippingMethod

func (*ShippingMethod) SetOptionId

func (s *ShippingMethod) SetOptionId(optionId string) *ShippingMethod

type ShippingMethodData

type ShippingMethodData struct {
	Cart *schema.Cart `json:"cart"`
}

type ShippingMethodResponse

type ShippingMethodResponse struct {
	// Success response
	Data *ShippingMethodData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

type UpdateCart

type UpdateCart struct {
	// The id of the Region to create the Cart in.
	RegionId string `json:"region_id"`

	// The 2 character ISO country code to create the Cart in.
	CountryCode string `json:"country_code"`

	// An email to be used on the Cart.
	Email string `json:"email"`

	// The ID of the Sales channel to update the Cart with.
	SalesChannelId string `json:"sales_channel_id"`

	// The Address to be used for billing purposes.
	BillingAddress any `json:"billing_address"`

	// The Address to be used for shipping.
	ShippingAddress any `json:"ipping_address"`

	// An array of Gift Card codes to add to the Cart.
	GiftCards []*GiftCard `json:"gift_cards"`

	// An array of Discount codes to add to the Cart.
	Discounts []*Discount `json:"discounts"`

	// The ID of the Customer to associate the Cart with.
	CustomerId string `json:"customer_id"`

	// An optional object to provide context to the Cart.
	Context map[string]any `json:"context"`
}

func NewUpdateCart

func NewUpdateCart() *UpdateCart

func (*UpdateCart) SetBillingAddress

func (u *UpdateCart) SetBillingAddress(address any) *UpdateCart

func (*UpdateCart) SetContext

func (u *UpdateCart) SetContext(context map[string]any) *UpdateCart

func (*UpdateCart) SetCountryCode

func (u *UpdateCart) SetCountryCode(countryCode string) *UpdateCart

func (*UpdateCart) SetCustomerId

func (u *UpdateCart) SetCustomerId(customerId string) *UpdateCart

func (*UpdateCart) SetDiscounts

func (u *UpdateCart) SetDiscounts(discounts []*Discount) *UpdateCart

func (*UpdateCart) SetEmail

func (u *UpdateCart) SetEmail(email string) *UpdateCart

func (*UpdateCart) SetGiftCards

func (u *UpdateCart) SetGiftCards(giftCards []*GiftCard) *UpdateCart

func (*UpdateCart) SetRegionId

func (u *UpdateCart) SetRegionId(regionId string) *UpdateCart

func (*UpdateCart) SetSalesChannelId

func (u *UpdateCart) SetSalesChannelId(salesChannelId string) *UpdateCart

func (*UpdateCart) SetShippingAddress

func (u *UpdateCart) SetShippingAddress(address any) *UpdateCart

func (*UpdateCart) Update

func (u *UpdateCart) Update(cartId string, config *medusa.Config) (*UpdateCartResponse, error)

Updates a Cart.

type UpdateCartData

type UpdateCartData struct {
	Cart *schema.Cart `json:"cart"`
}

type UpdateCartResponse

type UpdateCartResponse struct {
	// Success response
	Data *UpdateCartData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

type UpdatePaymentSession

type UpdatePaymentSession struct {
	Data map[string]any `json:"data"`
}

func NewUpdatePaymentSession

func NewUpdatePaymentSession() *UpdatePaymentSession

func (*UpdatePaymentSession) SetData

func (u *UpdatePaymentSession) SetData(data map[string]any) *UpdatePaymentSession

func (*UpdatePaymentSession) Update

func (u *UpdatePaymentSession) Update(cartId, providerId string, config *medusa.Config) (*UpdatePaymentSessionResponse, error)

type UpdatePaymentSessionData

type UpdatePaymentSessionData struct {
	Cart *schema.Cart `json:"cart"`
}

type UpdatePaymentSessionResponse

type UpdatePaymentSessionResponse struct {
	// Success response
	Data *UpdatePaymentSessionData

	// Error response
	Error *response.Error

	// Errors in case of multiple errors
	Errors *response.Errors
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL