Documentation
¶
Index ¶
- Constants
- Variables
- type CartItem
- type Client
- func (c *Client) AddItem(productID, unitID, quantity int) error
- func (c *Client) Cookie() string
- func (c *Client) DeleteItem(productID, unitID int) error
- func (c *Client) GetCart() ([]CartItem, error)
- func (c *Client) Login(username, password string) error
- func (c *Client) Query() *QueryBuilder
- func (c *Client) Submit(unavailableItemPreference string) error
- type LabTest
- type Price
- type Product
- type QueryBuilder
- type QueryResponse
Constants ¶
const ( LabTestTHC = "thc" LabTestTAC = "tac" LabTestCBD = "cbd" LabTestCBN = "cbn" )
test name constants
const ( CategoryConcentrates = "Concentrates" CategoryVapes = "Vapes" CategoryFlower = "Flower" )
Valid values for Category
const ( SubCategoryConcentratesOil = "Oil" SubCategoryConcentratesWax = "Wax" SubCategoryConcentratesShatter = "Shatter" SubCategoryVapesApex = "Apex" SubCategoryVapesRubi = "Rubi" SubCategoryVapesRempen = "Rempen" )
Valid values for SubCategory
const ( FilterIndica = "Indica" FilterSativa = "Sativa" FilterHybrid = "Hybrid" )
Valid values for Filter
const ( )
Unavailable Item Preferences
Variables ¶
var (
ErrNoCookie = errors.New("failed to get cookie")
)
errors
Functions ¶
This section is empty.
Types ¶
type CartItem ¶ added in v0.2.0
type CartItem struct {
ProductID int `json:"product_id"`
UnitID int `json:"product_unit_id"`
Quantity int `json:"quantity"`
TopLine string `json:"top_line"`
BottomLine string `json:"bottom_line"`
}
CartItem is how the API represents an item in the cart
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides access to the NETA reserve-ahead API
func NewClientFromCookie ¶ added in v0.2.8
NewClientFromCookie constructs a new Client from a previously obtained cookie. No attempt is made to validate the cookie. Behavior with an invalid cookie is undefined.
func (*Client) DeleteItem ¶ added in v0.2.0
DeleteItem removes an item from the session's cart
func (*Client) Login ¶ added in v0.2.0
Login associates the Client with a previously-created user account
func (*Client) Query ¶
func (c *Client) Query() *QueryBuilder
Query returns a builder for a new query against the API
type LabTest ¶
type LabTest struct {
Name string `json:"lab_test_name"`
Value float64 `json:"lab_test_value"`
Unit string `json:"lab_test_unit"`
}
LabTest is a cannabinoid measurement for the Product
type Price ¶
type Price struct {
UnitID int `json:"product_unit_id"`
Quantity int `json:"quantity"`
RawPrice interface{} `json:"price"`
Price float64 `json:"-"`
TopLine string `json:"top_line"`
BottomLine string `json:"bottom_line"`
}
Price contains various representations of the price of the Product
type Product ¶
type Product struct {
ID int `json:"id"`
Name string `json:"name"`
Category string `json:"type_name"`
SubCategory string `json:"category"`
Type string `json:"type"`
LabTests []LabTest `json:"lab_tests"`
Description string `json:"description"`
Prices []Price `json:"prices"`
}
Product is a cannabis product available to reserve ahead
func (Product) CBD ¶ added in v0.2.3
CBD returns a formatted string with the Product's CBD content. If none, an empty string is returned.
func (Product) CBN ¶ added in v0.2.3
CBN returns a formatted string with the Product's CBN content. If none, an empty string is returned.
type QueryBuilder ¶
type QueryBuilder struct {
// contains filtered or unexported fields
}
QueryBuilder exposes methods for building a query against the API
func (*QueryBuilder) Category ¶
func (qb *QueryBuilder) Category(category string) *QueryBuilder
Category sets a category for the query
func (*QueryBuilder) Do ¶
func (qb *QueryBuilder) Do() ([]Product, error)
Do executes the query and returns the result as a slice of Products
func (*QueryBuilder) Filter ¶
func (qb *QueryBuilder) Filter(filter string) *QueryBuilder
Filter sets a filter for the query
func (*QueryBuilder) SubCategory ¶
func (qb *QueryBuilder) SubCategory(subCategory string) *QueryBuilder
SubCategory sets a sub-cateogry for the query
type QueryResponse ¶ added in v0.2.0
type QueryResponse struct {
Products []Product `json:"products"`
}
QueryResponse contains a slice of Products returned from the reserve-ahead API