orders

package
v0.1.4-beta Latest Latest
Warning

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

Go to latest
Published: May 15, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectionIn = iota
	DirectionOut
)
View Source
const (
	ShippingAreaInternational = "I"
	ShippingAreaDomestic      = "D"
	ShippingAreaBoth          = "B"
)

Variables

View Source
var ProblemReasonIDs map[int]string = map[int]string{
	6:   "Buyer did not respond to emails",
	7:   "Buyer email address bounced",
	8:   "Seller did not receive payment",
	9:   "Buyer found items elsewhere",
	10:  "Buyer no longer wants to purchase items",
	11:  "Buyer does not have enough funds to pay",
	12:  "Buyer did not comply with store policies",
	13:  "Buyer submitted a bogus orders",
	16:  "Buyer demanded a lower price on items",
	57:  "Package returned with incorrect address",
	60:  "Seller did not have items after orders was submitted",
	63:  "Buyer is underage",
	70:  "System Problem",
	72:  "Buyer is no longer registered",
	97:  "Package cannot be delivered to buyer's address",
	100: "Buyer did not pay for orders",
	107: "Mutual agreement between buyer and seller to cancel",
}

Functions

This section is empty.

Types

type Direction

type Direction int

Direction defines the directionality of the resource. It is used for feedback and orders. out = from this user in = to this user

func (Direction) String

func (dir Direction) String() string

type Feedback

type Feedback struct {
	ID        int         `json:"feedback_id, omitempty"`
	OrderID   int         `json:"order_id"`
	From      string      `json:"from,omitempty"`
	To        string      `json:"to,omitempty"`
	DateRated time.Time   `json:"date_rated,omitempty"`
	Rating    util.Rating `json:"rating"`
	Rater     string      `json:"rating_of_bs,omitempty"` // rating of buyer or seller (B or S)
	Comment   string      `json:"comment"`
	Reply     string      `json:"reply,omitempty"`
}

Feedback represents a feedback resource.

func (*Feedback) Label

func (f *Feedback) Label() entity.Label

func (*Feedback) PrimaryKey

func (f *Feedback) PrimaryKey() int
type Header struct {
	ID                int        `json:"order_id,omitempty"`
	DateOrdered       *time.Time `json:"date_ordered,omitempty"`
	DateStatusChanged *time.Time `json:"date_status_changed,omitempty"`
	SellerName        string     `json:"seller_name,omitempty"`
	StoreName         string     `json:"store_name,omitempty"`
	BuyerName         string     `json:"buyer_name,omitempty"`
	BuyerEmail        string     `json:"buyer_email,omitempty"`
	RequireInsurance  *bool      `json:"require_insurance,omitempty"`
	Status            string     `json:"status,omitempty"`
	IsInvoiced        *bool      `json:"is_invoiced,omitempty"`
	Remarks           string     `json:"remarks"`
	TotalCount        int        `json:"total_count,omitempty"`
	UniqueCount       int        `json:"unique_count,omitempty"`
	TotalWeight       string     `json:"total_weight,omitempty"`
	BuyerOrderCount   int        `json:"buyer_order_count,omitempty"`
	IsFiled           *bool      `json:"is_filed,omitempty"`
	DriveThruSent     *bool      `json:"drive_thru_sent,omitempty"`
	Payment           struct {
		Method       string     `json:"method,omitempty"`
		CurrencyCode string     `json:"currency_code,omitempty"`
		DatePaid     *time.Time `json:"date_paid,omitempty"`
		Status       string     `json:"status,omitempty"`
	} `json:"payment,omitempty"`
	Shipping struct {
		MethodID     int        `json:"method_id,omitempty"`
		Method       string     `json:"method,omitempty"`
		TrackingLink string     `json:"tracking_link,omitempty"`
		TrackingNo   string     `json:"tracking_no,omitempty"`
		DateShipped  *time.Time `json:"date_shipped,omitempty"`
		Address      *struct {
			Name struct {
				Full string `json:"full,omitempty"`
			} `json:"name,omitempty"`
			Full        string `json:"full,omitempty"`
			CountryCode string `json:"country_code,omitempty"`
		} `json:"address,omitempty"`
	} `json:"shipping,omitempty"`
	Cost struct {
		CurrencyCode string `json:"currency_code,omitempty"`
		Subtotal     string `json:"subtotal,omitempty"`
		GrandTotal   string `json:"grand_total,omitempty"`
		Etc1         string `json:"etc1,omitempty"`
		Etc2         string `json:"etc2,omitempty"`
		Insurance    string `json:"insurance,omitempty"`
		Shipping     string `json:"shipping,omitempty"`
		Credit       string `json:"credit,omitempty"`
		Coupon       string `json:"coupon,omitempty"`
		VatRate      string `json:"vat_rate,omitempty"`
		VatAmount    string `json:"vat_amount,omitempty"`
	} `json:"cost,omitempty"`
	DispCost struct {
		CurrencyCode string `json:"currency_code,omitempty"`
		Subtotal     string `json:"subtotal,omitempty"`
		GrandTotal   string `json:"grand_total,omitempty"`
		Etc1         string `json:"etc1,omitempty"`
		Etc2         string `json:"etc2,omitempty"`
		Insurance    string `json:"insurance,omitempty"`
		Shipping     string `json:"shipping,omitempty"`
		Credit       string `json:"credit,omitempty"`
		Coupon       string `json:"coupon,omitempty"`
		VatRate      string `json:"vat_rate,omitempty"`
		VatAmount    string `json:"vat_amount,omitempty"`
	} `json:"disp_cost,omitempty"`
}

func (Header) Label

func (h Header) Label() entity.Label

func (Header) PrimaryKey

func (h Header) PrimaryKey() int

type Item

type Item struct {
	BatchID            int            `json:"-"`
	InventoryID        int            `json:"inventory_id"`
	Item               reference.Item `json:"item"`
	ColorID            int            `json:"color_id"`
	Quantity           int            `json:"quantity"`
	NewOrUsed          string         `json:"new_or_used"`
	Completeness       string         `json:"completeness"`
	UnitPrice          string         `json:"unit_price"`
	UnitPriceFinal     string         `json:"unit_price_final"`
	DispUnitPrice      string         `json:"disp_unit_price"`
	DispUnitPriceFinal string         `json:"disp_unit_price_final"`
	CurrencyCode       string         `json:"currency_code"`
	DispCurrencyCode   string         `json:"disp_currency_code"`
	Description        string         `json:"description"`
	Remarks            string         `json:"remarks"`
	Weight             string         `json:"weight"`
}

func (Item) Label

func (it Item) Label() entity.Label

func (Item) PrimaryKey

func (it Item) PrimaryKey() int

type Member

type Member struct {
	UserName string
	Ratings  []Feedback
	Note     Note
}

Member represents a Bricklink member.

func (*Member) Label

func (m *Member) Label() entity.Label

func (*Member) PrimaryKey

func (m *Member) PrimaryKey() int

type MemberRating

type MemberRating struct {
	UserName string `json:"user_name"`

	Rating struct {
		Complaints int `json:"COMPLAINT"`
		Neutrals   int `json:"NEUTRAL"`
		Praises    int `json:"PRAISE"`
	} `json:"rating"`
}

MemberRating represents a Bricklink user.

type Message

type Message struct {
	Subject  string    `json:"subject"`
	Body     string    `json:"body"`
	From     string    `json:"from"`
	To       string    `json:"to"`
	DateSent time.Time `json:"dateSent"`
}

func (*Message) Label

func (m *Message) Label() entity.Label

func (*Message) PrimaryKey

func (m *Message) PrimaryKey() int

type Note

type Note struct {
	ID        int        `json:"note_id,omitempty"`
	UserName  string     `json:"user_name"`
	Note      string     `json:"note_text"`
	DateNoted *time.Time `json:"date_noted,omitempty"`
}

Note represents a note about a member.

func (*Note) Label

func (n *Note) Label() entity.Label

func (*Note) PrimaryKey

func (n *Note) PrimaryKey() int

type Order

type Order struct {
	Header
	Items            []Item
	Messages         []Message
	FeedbackSent     Feedback
	FeedbackReceived Feedback
}

func (Order) Label

func (o Order) Label() entity.Label

func (Order) PrimaryKey

func (o Order) PrimaryKey() int

type OrderStatus

type OrderStatus int

OrderStatus represents the status of an order. The lifetime of a transaction is defined by its status. The below outlines each status an order can have: Statuses can be set by the seller, the buyer, or by the system. N?? statuses prevent buyers from placing additional orders until the issue is resolved. Buyers can add to orders in pending, updated, processing, or ready statuses.

const (
	StatusUndefined OrderStatus = iota // System
	StatusPending
	StatusUpdated    // System
	StatusProcessing // Seller
	StatusReady      // Seller
	StatusPaid       // Seller or System
	StatusPacked     // Seller
	StatusShipped    // Seller
	StatusReceived   // Buyer
	StatusCompleted  // Buyer or Seller
	StatusOCR        // System
	StatusNPB        // System
	StatusNPX        // System
	StatusNRS        // System
	StatusNSS        // System
	StatusCancelled  // System
	StatusPurged
)

func (OrderStatus) String

func (s OrderStatus) String() string

type Orders

type Orders struct {
	bl.Bricklink

	ShippingMethods map[int]ShippingMethod
}

func New

func New(b bl.Bricklink) (*Orders, error)

New creates a new Orders instance.

func (*Orders) DeleteMemberNote

func (o *Orders) DeleteMemberNote(name string) error

DeleteMemberNote deletes the member note.

func (*Orders) GetFeedback

func (o *Orders) GetFeedback(id int) (*Feedback, error)

GetFeedback returns the feedback for the given feedback ID.

func (*Orders) GetFeedbackList

func (o *Orders) GetFeedbackList(options ...RequestOption) ([]Feedback, error)

GetFeedbackList returns a list of feedback in the given direction.

func (*Orders) GetMemberNote

func (o *Orders) GetMemberNote(name string) (*Note, error)

GetMemberNote returns the note for a specific member.

func (*Orders) GetMemberRatings

func (o *Orders) GetMemberRatings(name string) (*MemberRating, error)

GetMemberRatings returns the details feedback ratings for a specific member.

func (Orders) GetOrder

func (o Orders) GetOrder(id int) (*Order, error)

GetOrder is a convenience method that returns everything about an order at once. If the first call succeeds, this method requires 4 API calls. Errors for messages, items, and feedback are logged as messages in the returned order. Errors will have 'Error' as the subject.

func (*Orders) GetOrderFeedback

func (o *Orders) GetOrderFeedback(id int) ([]Feedback, error)

GetOrderFeedback returns the feedback for an order.

func (*Orders) GetOrderHeader

func (o *Orders) GetOrderHeader(id int) (*Header, error)

GetOrderHeader retrieves the transactional data for a specific order. https://www.bricklink.com/v3/api.page?page=get-order

func (*Orders) GetOrderHeaders

func (o *Orders) GetOrderHeaders(options ...RequestOption) ([]Header, error)

GetOrderHeaders retrieves a list of orders you received or placed. It does not include order items, messages, or problems. Use GetOrders to retrieve the full order details. https://www.bricklink.com/v3/api.page?page=get-orders

func (*Orders) GetOrderItems

func (o *Orders) GetOrderItems(id int) ([]Item, error)

func (*Orders) GetOrderMessages

func (o *Orders) GetOrderMessages(id int) ([]Message, error)

func (*Orders) GetShippingMethod

func (o *Orders) GetShippingMethod(id int, options ...RequestOption) (*ShippingMethod, error)

GetShippingMethod returns a shipping method by id from the cache. If forceRefresh is true, the cache will be refreshed. The Get Shipping Method endpoint is unneeded since a single call gets the entire list. Therefore, we can serve the response without additional api calls.

func (*Orders) PostFeedback

func (o *Orders) PostFeedback(fb Feedback) (*Feedback, error)

PostFeedback posts feedback for an order. OrderID, Rating, and Comment must be set

func (*Orders) RefreshShippingMethods

func (o *Orders) RefreshShippingMethods() error

func (*Orders) ReplyFeedback

func (o *Orders) ReplyFeedback(fb Feedback) error

ReplyFeedback replies to feedback. Reply must be set.

func (*Orders) SendDriveThru

func (o *Orders) SendDriveThru(id int, options ...RequestOption) error

SendDriveThru issues a drive-thru message to the buyer for an order. https://www.bricklink.com/v3/api.page?page=send-drive-thru

func (*Orders) UpdateOrder

func (o *Orders) UpdateOrder(header Header) (*Header, error)

UpdateOrder updates the properties of a specific order header. It strips out values that are read-only before submitting the update. https://www.bricklink.com/v3/api.page?page=update-order

func (*Orders) UpdateOrderStatus

func (o *Orders) UpdateOrderStatus(id int, status OrderStatus) error

UpdateOrderStatus updates the order status for an order. https://www.bricklink.com/v3/api.page?page=update-order-status

func (*Orders) UpdatePaymentStatus

func (o *Orders) UpdatePaymentStatus(id int, status PaymentStatus) error

UpdatePaymentStatus updates the payment for an order. https://www.bricklink.com/v3/api.page?page=update-payment-status

func (*Orders) UpsertMemberNote

func (o *Orders) UpsertMemberNote(note Note) (*Note, error)

UpsertMemberNote creates or updates a note for the member.

type PaymentStatus

type PaymentStatus int
const (
	PaymentStatusUndefined PaymentStatus = iota
	PaymentStatusNone
	PaymentStatusSent
	PaymentStatusReceived
	PaymentStatusClearing
	PaymentStatusReturned
	PaymentStatusBounced
	PaymentStatusCompleted
)

func (PaymentStatus) String

func (ps PaymentStatus) String() string

type Problem

type Problem struct {
	Type     string `json:"type"`
	Message  string `json:"message"`
	ReasonID string `json:"reason_id"`
}

type RequestOption

type RequestOption func(opts *requestOptions)

func WithDirection

func WithDirection(dir Direction) RequestOption

func WithExcludeStatus

func WithExcludeStatus(status OrderStatus) RequestOption

func WithFiled

func WithFiled(b bool) RequestOption

func WithIncludeStatus

func WithIncludeStatus(status OrderStatus) RequestOption

func WithRefresh

func WithRefresh(b bool) RequestOption

type ShippingMethod

type ShippingMethod struct {
	ID          int    `json:"method_id"`
	Name        string `json:"name"`
	Note        string `json:"note"`
	Insurance   bool   `json:"insurance"`
	IsDefault   bool   `json:"is_default"`
	Area        string `json:"area"` // International, Domestic, Both (I/D/B)
	IsAvailable bool   `json:"is_available"`
}

func (ShippingMethod) Label

func (sm ShippingMethod) Label() entity.Label

func (ShippingMethod) PrimaryKey

func (sm ShippingMethod) PrimaryKey() int

Jump to

Keyboard shortcuts

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