Help us shape the future of Go! Take the 2026 Go Developer Survey

neta

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MIT Imports: 5 Imported by: 0

README

Go-NETA is a client for the public NETA reserve-ahead API.

At this time only querying for products in the Brookline location is supported. For usage, see the tests.

There are constants for some product categories and filters, but not all of them. They are just strings, so if you need others, just get the strings you need by inspecting the reserve-ahead site's XHR calls.

Planned features:

  • Login
  • Add to Cart
  • Submit Reservation

I have no plans to support the Northampton location, but if you want to use this, feel free to send me a PR or just fork it.

Documentation

Index

Constants

View Source
const (
	CategoryConcentrates = "Concentrates"
	CategoryVapes        = "Vapes"
	CategoryFlower       = "Flower"
)

Valid values for Category

View Source
const (
	SubCategoryConcentratesOil     = "Oil"
	SubCategoryConcentratesWax     = "Wax"
	SubCategoryConcentratesShatter = "Shatter"
	SubCategoryVapesApex           = "Apex"
	SubCategoryVapesRubi           = "Rubi"
	SubCategoryVapesRempen         = "Rempen"
)

Valid values for SubCategory

View Source
const (
	FilterIndica = "Indica"
	FilterSativa = "Sativa"
	FilterHybrid = "Hybrid"
)

Valid values for Filter

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides access to the NETA reserve-ahead API

func NewClient

func NewClient() (*Client, error)

NewClient returns a Client ready to use

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

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 Response

type Response struct {
	Products []Product `json:"products"`
}

Response contains a slice of Products returned from the reserve-ahead API

Jump to

Keyboard shortcuts

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