Documentation ¶
Overview ¶
Package dawg (Dominos API Wrapper for Go) is a package that allows a go programmer to interact with the dominos web api.
The two main entry points in the package are the SignIn and NearestStore functions.
SignIn is used if you have an account with dominos.
user, err := dawg.SignIn(username, password) if err != nil { // handle error }
NearestStore should be used if you just want to make a one time order.
store, err := dawg.NearestStore(&address, dawg.Delivery) if err != nil { // handle error }
To order anything from dominos you need to find a store, create an order, then send that order.
Example (GetStore) ¶
package main import ( "fmt" "log" "github.com/harrybrwn/apizza/dawg" ) func main() { // This can be anything that satisfies the dawg.Address interface. var addr = dawg.StreetAddr{ Street: "600 Mountain Ave bldg 5", CityName: "New Providence", State: "NJ", Zipcode: "07974", AddrType: "Business", } store, err := dawg.NearestStore(&addr, dawg.Delivery) if err != nil { log.Fatal(err) } fmt.Println(store.WaitTime()) }
Output:
Index ¶
- Constants
- Variables
- func InitOrder(o *Order)
- func InitStore(id string, obj interface{}) error
- func IsFailure(err error) bool
- func IsOk(err error) bool
- func IsWarning(err error) bool
- func OrderToJSON(o *Order) string
- func ReadableOptions(item Item) map[string]string
- func ReadableToppings(item Item, m *Menu) map[string]string
- func ValidateCard(c Card) error
- func ValidateOrder(order *Order) error
- type Address
- type Card
- type CustomerLoyalty
- type DominosError
- type EasyOrder
- type Item
- type ItemCommon
- type ItemContainer
- type Menu
- type MenuCategory
- type Order
- func (o *Order) AddCard(c Card)
- func (o *Order) AddPayment(payment Payment)
- func (o *Order) AddProduct(item Item) error
- func (o *Order) AddProductQty(item Item, n int) error
- func (o *Order) Init()
- func (o *Order) Name() string
- func (o *Order) PlaceOrder() error
- func (o *Order) Price() (float64, error)
- func (o *Order) RemoveProduct(code string) error
- func (o *Order) SetName(name string)
- func (o *Order) Validate() error
- type OrderProduct
- type Params
- type Payment
- type PreConfiguredProduct
- type Product
- type Store
- func (s *Store) FindItem(code string) (Item, error)
- func (s *Store) GetProduct(code string) (*Product, error)
- func (s *Store) GetVariant(code string) (*Variant, error)
- func (s *Store) MakeOrder(firstname, lastname, email string) *Order
- func (s *Store) Menu() (*Menu, error)
- func (s *Store) NewOrder() *Order
- func (s *Store) WaitTime() (min int, max int)
- type StoreHours
- type StoreLocs
- type StreetAddr
- type Topping
- type URLParam
- type UserAddress
- type UserCard
- type UserProfile
- func (u *UserProfile) AddAddress(a Address)
- func (u *UserProfile) Cards() ([]*UserCard, error)
- func (u *UserProfile) DefaultAddress() *UserAddress
- func (u *UserProfile) GetEasyOrder() (*EasyOrder, error)
- func (u *UserProfile) Loyalty() (*CustomerLoyalty, error)
- func (u *UserProfile) NearestStore(service string) (*Store, error)
- func (u *UserProfile) NewOrder() (*Order, error)
- func (u *UserProfile) PreviousOrders(n int) ([]*EasyOrder, error)
- func (u *UserProfile) SetServiceMethod(service string) error
- func (u *UserProfile) SetStore(store *Store) error
- func (u *UserProfile) StoresNearMe() ([]*Store, error)
- type Variant
Examples ¶
Constants ¶
const ( // WarningStatus is the status code dominos serves use for a warning WarningStatus = 1 // FailureStatus is the status code dominos serves use for a failure FailureStatus = -1 // OkStatus is the status code dominos serves use to signify no problems OkStatus = 0 )
const ( // ToppingFull is the code sent to dominos to tell them you // want a topping that covers the whole pizza. ToppingFull = "1/1" // ToppingLeft is the code sent to dominos to tell them you // want a topping that covers the left side of the pizza ToppingLeft = "1/2" // ToppingRight is the code sent to dominos to tell them you // want a topping that covers the right side of the pizza ToppingRight = "2/2" )
const ( // Delivery is a dominos service method that will result // in a pizza delivery. Delivery = "Delivery" // Carryout is a dominos service method that // will require users to go and pickup their pizza. Carryout = "Carryout" // DefaultLang is the package language variable DefaultLang = "en" )
Variables ¶
var ( // ErrBadService is returned if a service is needed but the service validation failed. ErrBadService = errors.New("service must be either 'Delivery' or 'Carryout'") // ErrNoUserService is thrown when a user has no service method. ErrNoUserService = errors.New("UserProfile has no service method (use user.SetServiceMethod)") )
var BadExpiration = time.Date(0, 0, 0, 0, 0, 0, 0, time.UTC)
BadExpiration is a zero datetime object the is returned on error.
var ( // Warnings is a package switch for turning warnings on or off Warnings = false )
Functions ¶
func InitOrder ¶
func InitOrder(o *Order)
InitOrder will make sure that an order is initialized correctly. An order that is not initialized correctly cannot send itself to dominos.
func InitStore ¶
InitStore allows for the creation of arbitrary store objects. The main use-case is when data id needed that is not in the default Store object. The obj argument is anything that would be used to decode json data.
Use type '*map[string]interface{}' in the object argument for all the store data.
store := map[string]interface{}{} err := dawg.InitStore(id, &store)
This will allow all of the fields sent in the api to be viewed.
func IsFailure ¶
IsFailure will tell you if an error given by a function from the dawg package is an error thrown from dominos' servers.
func IsOk ¶
IsOk will tell you if the error returned does not contain any fatal errors or warnings from Dominos' servers. Will return true if the error is nil.
func IsWarning ¶
IsWarning will tell you if the error given contains a warning from the dominos server.
func OrderToJSON ¶
OrderToJSON converts an Order to the json string.
func ReadableOptions ¶
ReadableOptions gives an Item's options in a format meant for humans.
func ReadableToppings ¶
ReadableToppings is the same as ReadableOptions but it looks in the menu for the names of toppings instead outputting the topping code.
func ValidateCard ¶ added in v0.0.3
ValidateCard will return an error if the card given has any bad data.
func ValidateOrder ¶
ValidateOrder sends and order to the validation endpoint to be validated by Dominos' servers.
Types ¶
type Card ¶
type Card interface { // Number should return the card number. Num() string // ExpiresOn returns the date that the payment expires. ExpiresOn() time.Time // Code returns the security code or the cvv. Code() string }
Card is an interface representing a credit or debit card.
type CustomerLoyalty ¶ added in v0.0.3
type CustomerLoyalty struct { CustomerID string EnrollDate string LastActivityDate string BasePointExpirationDate string PendingPointBalance string AccountStatus string // VestedPointBalance is the points you have // saved up in order to get a free pizza. VestedPointBalance int // This is a list of possible coupons that a // customer can receive. LoyaltyCoupons []struct { CouponCode string PointValue int BaseCoupon bool LimitPerOrder string } }
CustomerLoyalty is a struct that holds account meta-data used by Dominos to keep track of customer rewards.
type DominosError ¶
type DominosError struct { Status int StatusItems []statusItem Order struct { Status int StatusItems []statusItem OrderID string } Msg string // contains filtered or unexported fields }
DominosError represents an error sent back by the dominos servers
func (*DominosError) Error ¶
func (err *DominosError) Error() string
type EasyOrder ¶ added in v0.0.3
type EasyOrder struct { AddressNickName string `json:"addressNickName"` OrderNickName string `json:"easyOrderNickName"` EasyOrder bool `json:"easyOrder"` ID string `json:"id"` DeliveryInstructions string `json:"deliveryInstructions"` Cards []struct { ID string `json:"id"` NickName string `json:"nickName"` } Store struct { Address *StreetAddr `json:"address"` CarryoutServiceHours string `json:"carryoutServiceHours"` DeliveryServiceHours string `json:"deliveryServiceHours"` } `json:"store"` Order previousOrder `json:"order"` }
EasyOrder is an easy order.
type Item ¶
type Item interface { // Options returns a map of the Item's options. Options() map[string]interface{} // AddToppings adds toppings to the item for when. AddTopping(string, string, string) error // get the Code from the object ItemCode() string // get the name of an item ItemName() string // Category returns the product category of the item. Category() string }
Item defines an interface for all objects that are items on the dominos menu.
type ItemCommon ¶ added in v0.0.3
type ItemCommon struct { Code string Name string Tags map[string]interface{} // Local will tell you if the item was made locally Local bool // contains filtered or unexported fields }
ItemCommon has the common fields between Product and Variant.
func (*ItemCommon) ItemCode ¶ added in v0.0.3
func (im *ItemCommon) ItemCode() string
ItemCode is a getter method for the Code field.
func (*ItemCommon) ItemName ¶ added in v0.0.3
func (im *ItemCommon) ItemName() string
ItemName gives the name of the item
type ItemContainer ¶
type ItemContainer interface { GetVariant(string) (*Variant, error) GetProduct(string) (*Product, error) }
ItemContainer defines an interface for objects that get Variants and Products.
type Menu ¶
type Menu struct { ID string Categorization struct { Food MenuCategory Coupons MenuCategory Preconfigured MenuCategory `json:"PreconfiguredProducts"` } `json:"Categorization"` Products map[string]*Product Variants map[string]*Variant Toppings map[string]map[string]Topping Preconfigured map[string]*PreConfiguredProduct `json:"PreconfiguredProducts"` Sides map[string]map[string]struct { ItemCommon Description string } // contains filtered or unexported fields }
Menu represents the dominos menu. It is best if this comes from the Store.Menu() method.
func (*Menu) FindItem ¶
FindItem looks in all the different menu categories for an item code given as an argument.
func (*Menu) GetProduct ¶
GetProduct find the menu item given a product code.
func (*Menu) GetVariant ¶
GetVariant will get a fully initialized variant from the menu.
type MenuCategory ¶
type MenuCategory struct { Categories []MenuCategory Products []string Name string Code string Description string }
MenuCategory is a category on the dominos menu.
func (MenuCategory) HasItems ¶
func (m MenuCategory) HasItems() bool
HasItems will return true if the category has items and false if only has sub-categories.
func (MenuCategory) IsEmpty ¶
func (m MenuCategory) IsEmpty() bool
IsEmpty returns true when the category has nothing in it.
type Order ¶
type Order struct { // CustomerID is a id for a customer (see UserProfile) CustomerID string `json:",omitempty"` // LanguageCode is an ISO international language code. LanguageCode string `json:"LanguageCode"` ServiceMethod string `json:"ServiceMethod"` Products []*OrderProduct `json:"Products"` StoreID string `json:"StoreID"` OrderID string `json:"OrderID"` Address *StreetAddr `json:"Address"` MetaData map[string]interface{} `json:"metaData"` // only for orders sent back FirstName string `json:"FirstName"` LastName string `json:"LastName"` Email string `json:"Email"` Phone string Payments []*orderPayment `json:"Payments"` // OrderName is not a field that is sent to dominos, but is just a way for // users to name a specific order. OrderName string `json:"-"` // contains filtered or unexported fields }
The Order struct is the main work horse of the api wrapper. The Order struct is what will end up being sent to dominos as a json object.
It is suggested that the order object be constructed from the Store.NewOrder method.
func (*Order) AddProduct ¶
AddProduct adds a product to the Order from a Product Object
Example ¶
package main import ( "fmt" "log" "os" "github.com/harrybrwn/apizza/dawg" ) var address = dawg.StreetAddr{ Street: "600 Mountain Ave bldg 5", CityName: "New Providence", State: "NJ", Zipcode: "07974", AddrType: "Business", } func main() { store, err := dawg.NearestStore(&address, "Delivery") if err != nil { log.Fatal(err) } order := store.NewOrder() pizza, err := store.GetVariant("14SCREEN") if err != nil { log.Fatal(err) } pizza.AddTopping("P", dawg.ToppingFull, "1.5") order.AddProduct(pizza) fmt.Println(order.Products[0].Name) }
Output: Large (14") Hand Tossed Pizza
func (*Order) AddProductQty ¶
AddProductQty adds a product to the Order with a quantity of n.
func (*Order) Init ¶
func (o *Order) Init()
Init will make sure that an order is initialized correctly. An order that is not initialized correctly cannot send itself to dominos.
func (*Order) PlaceOrder ¶
PlaceOrder is the method that sends the final order to dominos
func (*Order) RemoveProduct ¶
RemoveProduct will remove the product with a given code from the order.
type OrderProduct ¶
type OrderProduct struct { ItemCommon // Qty is the number of products to be ordered. Qty int `json:"Qty"` // ID is the index of the product within an order. Unless the Product is // being sent back by dominos, then I have no idea what ID means. ID int `json:"ID"` IsNew bool `json:"isNew"` NeedsCustomization bool `json:"NeedsCustomization"` Opts map[string]interface{} `json:"Options"` // contains filtered or unexported fields }
OrderProduct represents an item that will be sent to and from dominos within the Order struct.
func OrderProductFromItem ¶
func OrderProductFromItem(itm Item) *OrderProduct
OrderProductFromItem will construct an order product from an Item.
func (*OrderProduct) AddTopping ¶
func (p *OrderProduct) AddTopping(code, coverage, amount string) error
AddTopping adds a topping to the product. The 'code' parameter is a topping code, a list of which can be found in the menu object. The 'coverage' parameter is for specifying which side of the topping should be on for pizza. The 'amount' parameter is 2.0, 1.5, 1.0, o.5, or 0 and gives the amount of topping should be given.
func (*OrderProduct) Category ¶
func (p *OrderProduct) Category() string
Category returns the product category of the product
func (*OrderProduct) Options ¶
func (p *OrderProduct) Options() map[string]interface{}
Options returns a map of the OrderProdut's options.
func (*OrderProduct) ReadableOptions ¶
func (p *OrderProduct) ReadableOptions() map[string]string
ReadableOptions gives the options that are meant for humans to view.
type Payment ¶
type Payment struct { // Number is the card number. Number string `json:"Number"` // Expiration is the expiration date of the card formatted exactly as // it is on the physical card. Expiration string `json:"Expiration"` CardType string `json:"Type"` CVV string `json:"SecurityCode"` }
Payment just a way to compartmentalize a payment sent to dominos.
type PreConfiguredProduct ¶
type PreConfiguredProduct struct { ItemCommon // Description of the product Description string `json:"Description"` // Opts are a string of options that come with the preconfigured-product. Opts string `json:"Options"` // Size is the size name of the product. It's not a code or anything, its // more for user level stuff. Size string `json:"Size"` }
PreConfiguredProduct is pre-configured product.
func (*PreConfiguredProduct) AddTopping ¶
func (pc *PreConfiguredProduct) AddTopping(code, cover, amnt string) error
AddTopping adds a topping to the product.
func (*PreConfiguredProduct) Category ¶
func (pc *PreConfiguredProduct) Category() string
Category returns the product category. see Item
func (*PreConfiguredProduct) Options ¶
func (pc *PreConfiguredProduct) Options() map[string]interface{}
Options returns a map of the Variant's options.
type Product ¶
type Product struct { ItemCommon // Variants is the list of menu items that are a subset of this product. Variants []string // Short description of the product Description string // The possible toppings that can be added to this product. Formatted as a // a string of comma separated key-value pairs. AvailableToppings string // The possible sides that can be added to this product. Formatted as a // string of comma separated key-value pairs. AvailableSides string // The default toppings that the product has. Formatted as a string of // comma separated key-value pairs. DefaultToppings string // The default sides that the product has. Formatted as a string of // comma separated key-value pairs. DefaultSides string // ProductType is the type of item (ie. 'Bread', 'Pizza'). Used for getting // toppings, sides, sizes, or flavors. ProductType string // contains filtered or unexported fields }
Product is the structure representing a dominos product. The Product struct is meant to instaniated with json data and should be treated as such.
Product is not a the most basic component of the Dominos menu; this is where the Variant structure comes in. The Product structure can be seen as more of a category that houses a list of Variants. Products are still able to be ordered, however.
func (*Product) AddTopping ¶
AddTopping will add a topping to the product, see Item.
Example ¶
package main import ( "fmt" "log" "os" "github.com/harrybrwn/apizza/dawg" ) var address = dawg.StreetAddr{ Street: "600 Mountain Ave bldg 5", CityName: "New Providence", State: "NJ", Zipcode: "07974", AddrType: "Business", } func main() { store, err := dawg.NearestStore(&address, "Delivery") if err != nil { log.Fatal(err) } order := store.NewOrder() pizza, err := store.GetVariant("14SCREEN") if err != nil { log.Fatal(err) } pizza.AddTopping("P", dawg.ToppingLeft, "1.0") // pepperoni on the left pizza.AddTopping("K", dawg.ToppingRight, "2.0") // double bacon on the right order.AddProduct(pizza) fmt.Println(pizza.Options()["P"]) fmt.Println(pizza.Options()["K"]) }
Output: map[1/2:1.0] map[2/2:2.0]
func (*Product) GetVariants ¶
func (p *Product) GetVariants(container ItemContainer) (variants []*Variant)
GetVariants will initialize all the Variants the are a subset of the product.
The function needs a menu to get the data for each variant code.
type Store ¶
type Store struct { ID string `json:"StoreID"` IsOpen bool IsOnlineNow bool IsDeliveryStore bool Phone string PaymentTypes []string `json:"AcceptablePaymentTypes"` CreditCardTypes []string `json:"AcceptableCreditCards"` Address string `json:"AddressDescription"` PostalCode string City string StreetName string StoreCoords map[string]string `json:"StoreCoordinates"` // Min and Max distance MinDistance, MaxDistance float64 ServiceIsOpen map[string]bool ServiceEstimatedWait map[string]struct { Min, Max int } `json:"ServiceMethodEstimatedWaitMinutes"` AllowCarryoutOrders, AllowDeliveryOrders bool // Hours describes when the store will be open Hours StoreHours // ServiceHours describes when the store supports a given service ServiceHours map[string]StoreHours MinDeliveryOrderAmnt float64 `json:"MinimumDeliveryOrderAmount"` Status int // contains filtered or unexported fields }
The Store object represents a physical dominos location.
func GetNearbyStores ¶
GetNearbyStores is a way of getting all the nearby stores except they will by full initialized.
func NearestStore ¶
NearestStore gets the dominos location closest to the given address.
The addr argument should be the address to deliver to not the address of the store itself. The service should be either "Carryout" or "Delivery", this will determine wether the final order will be for pickup or delivery.
Example ¶
package main import ( "fmt" "log" "github.com/harrybrwn/apizza/dawg" ) func main() { var addr = &dawg.StreetAddr{ Street: "1600 Pennsylvania Ave.", CityName: "Washington", State: "DC", Zipcode: "20500", AddrType: "House", } store, err := dawg.NearestStore(addr, "Delivery") if err != nil { log.Fatal(err) } fmt.Println(store.City) }
Output: Washington
func NewStore ¶
NewStore returns the default Store object given a store id.
The service and address arguments are for store functions that require those variables. If the store does not need to use those functions, service can be an empty string, and add can be 'nil'.
The addr argument should be the address to deliver to not the address of the store itself.
func (*Store) GetProduct ¶
GetProduct finds the menu Product that matchs the given product code.
func (*Store) GetVariant ¶
GetVariant will get a fully initialized variant from the menu.
type StoreHours ¶ added in v0.0.3
type StoreHours struct {
Sun, Mon, Tue, Wed, Thu, Fri, Sat []struct {
OpenTime string
CloseTime string
}
}
StoreHours is a struct that holds Dominos store hours.
type StoreLocs ¶ added in v0.0.3
type StoreLocs struct { Granularity string `json:"Granularity"` Address *StreetAddr `json:"Address"` Stores []*Store `json:"Stores"` }
StoreLocs is an internal struct and should not be used. This is only exported because of json Unmarshalling.
type StreetAddr ¶
type StreetAddr struct { // Street should be the street number followed by the street name. Street string `json:"Street"` // StreetNum is just the street number. StreetNum string `json:"StreetNumber"` // StreetName is just the street name. StreetName string `json:"StreetName"` CityName string `json:"City"` State string `json:"Region"` Zipcode string `json:"PostalCode"` // This is a dominos specific field, and should one of the following... // "House", "Apartment", "Business", "Campus/Base", "Hotel", or "Other" AddrType string `json:"Type"` }
StreetAddr represents a street address
func ParseAddress ¶
func ParseAddress(raw string) (*StreetAddr, error)
ParseAddress will parse a raw address and return an address object. This method is prone to all the mishaps that arise when trying to work with addresses, it may not work for all cases.
func StreetAddrFromAddress ¶
func StreetAddrFromAddress(addr Address) *StreetAddr
StreetAddrFromAddress returns a StreetAddr pointer from an Address interface.
func (*StreetAddr) Equal ¶ added in v0.0.3
func (s *StreetAddr) Equal(a Address) bool
Equal will test if an s is the same as the Address given.
func (*StreetAddr) LineOne ¶
func (s *StreetAddr) LineOne() string
LineOne gives the street in the following format
<number> <name> <type> 123 Example St.
func (*StreetAddr) StateCode ¶
func (s *StreetAddr) StateCode() string
StateCode is the code for the state of the address
type Topping ¶
type Topping struct { ItemCommon Description string Availability []interface{} }
Topping is a simple struct that represents a topping on the menu.
Note: this struct does not rempresent a topping that is added to an Item and sent to dominos.
type URLParam ¶
type URLParam interface {
Encode() string
}
URLParam is an interface that represents a url parameter. It was defined so that url.Params from "net/url" can also be used
type UserAddress ¶
type UserAddress struct { // Basic address fields Street string StreetName string StreetNumber string CityName string `json:"City"` Region string PostalCode string AddressType string // Dominos specific meta-data Name string IsDefault bool DeliveryInstructions string UpdateTime string // Other address specific fields AddressLine2 string AddressLine3 string AddressLine4 string StreetField1 string StreetField2 string StreetRange string // Other rarely-used address meta-data fields PropertyType string PropertyNumber string UnitType string UnitNumber string BuildingID string CampusID string Neighborhood string SubNeighborhood string LocationName string Coordinates map[string]float32 }
UserAddress is an address that is saved by dominos and returned when a user signs in.
func UserAddressFromAddress ¶
func UserAddressFromAddress(a Address) *UserAddress
UserAddressFromAddress converts an address to a UserAddress.
func (*UserAddress) City ¶
func (ua *UserAddress) City() string
City returns the city of the address.
func (*UserAddress) LineOne ¶
func (ua *UserAddress) LineOne() string
LineOne returns the first line of the address.
func (*UserAddress) StateCode ¶
func (ua *UserAddress) StateCode() string
StateCode returns the region of the address.
type UserCard ¶ added in v0.0.3
type UserCard struct { // ID is the card id used by dominos internally to reference a user's // card without sending the actual card number over the internet ID string `json:"id"` // NickName is the cards name, given when a user saves a card as a named card NickName string `json:"nickName"` IsDefault bool `json:"isDefault"` TimesCharged int `json:"timesCharged"` TimesChargedIsValid bool `json:"timesChargedIsValid"` // LastFour is a field that gives the last four didgets of the card number LastFour string `json:"lastFour"` // true if the card has expired IsExpired bool `json:"isExpired"` ExpirationMonth int `json:"expirationMonth"` ExpirationYear int `json:"expirationYear"` // LastUpdated shows the date that this card was last updated in // dominos databases LastUpdated string `json:"lastUpdated"` CardType string `json:"cardType"` BillingZip string `json:"billingZip"` }
UserCard holds the card data that Dominos stores and send back to users. For security reasons, Dominos does not send the raw card number or the raw security code. Insted they send a card ID that is used to reference that card. This allows users to reference that card using the card's nickname (see 'NickName' field)
type UserProfile ¶
type UserProfile struct { FirstName string LastName string Phone string // Type of dominos account Type string // Dominos internal user id ID string `json:"CustomerID"` // Identifiers are the pieces of information used to identify the // user (even if they are not signed in) Identifiers []string `json:"CustomerIdentifiers"` // AgreedToTermsOfUse is true if the user has agreed to dominos terms of use. AgreedToTermsOfUse bool `json:"AgreeToTermsOfUse"` // User's gender Gender string // List of all the addresses saved in the dominos account Addresses []*UserAddress // Email is the user's email address Email string // EmailOptIn tells wether the user is opted in for email updates or not EmailOptIn bool // EmailOptInTime shows what time the user last opted in for email updates EmailOptInTime string // SmsPhone is the phone number used for sms updates SmsPhone string // SmsOptIn tells wether the use is opted for sms updates or not SmsOptIn bool // SmsOptInTime shows the last time the user opted in for sms updates SmsOptInTime string // UpdateTime shows the last time the user's profile was updated UpdateTime string // ServiceMethod should be "Delivery" or "Carryout" ServiceMethod string `json:"-"` // this is a package specific field (not from the api) // contains filtered or unexported fields }
UserProfile is a Dominos user profile.
Example ¶
package main import ( "fmt" "log" "os" "github.com/harrybrwn/apizza/dawg" ) var ( username = os.Getenv("DOMINOS_TEST_USER") password = os.Getenv("DOMINOS_TEST_PASS") ) func main() { // Obtain a dawg.UserProfile with the dawg.SignIn function user, err := dawg.SignIn(username, password) if err != nil { log.Fatal(err) } fmt.Println(user.Email == username) fmt.Printf("%T\n", user) }
Output:
func SignIn ¶
func SignIn(username, password string) (*UserProfile, error)
SignIn will create a new UserProfile and sign in the account.
Example ¶
package main import ( "fmt" "log" "os" "github.com/harrybrwn/apizza/dawg" ) var ( username = os.Getenv("DOMINOS_TEST_USER") password = os.Getenv("DOMINOS_TEST_PASS") ) func main() { user, err := dawg.SignIn(username, password) if err != nil { log.Fatal(err) } fmt.Println(user.Email == username) fmt.Printf("%T\n", user) }
Output:
func (*UserProfile) AddAddress ¶
func (u *UserProfile) AddAddress(a Address)
AddAddress will add an address to the dominos account.
Example ¶
package main import ( "fmt" "os" "github.com/harrybrwn/apizza/dawg" ) var user = dawg.UserProfile{} func main() { // The address that is stored in a dawg.UserProfile are the address that dominos // keeps track of and an address may need to be added. fmt.Printf("%+v\n", user.Addresses) user.AddAddress(&dawg.StreetAddr{ Street: "600 Mountain Ave bldg 5", CityName: "New Providence", State: "NJ", Zipcode: "07974", AddrType: "Business", }) fmt.Println(len(user.Addresses) > 0) fmt.Printf("%T\n", user.DefaultAddress()) }
Output: [] true *dawg.UserAddress
func (*UserProfile) Cards ¶ added in v0.0.3
func (u *UserProfile) Cards() ([]*UserCard, error)
Cards will get the cards that Dominos has saved in their database. (see UserCard)
Example ¶
package main import ( "fmt" "log" "os" "github.com/harrybrwn/apizza/dawg" ) var user = dawg.UserProfile{} func main() { cards, err := user.Cards() if err != nil { log.Fatal(err) } fmt.Println("Test Card name:", cards[0].NickName) // This is dependant on the account }
Output:
func (*UserProfile) DefaultAddress ¶
func (u *UserProfile) DefaultAddress() *UserAddress
DefaultAddress will return the address that Dominos has marked as the default. If dominos has not marked any of them as the default, the the first one will be returned and nil if there are no addresses.
func (*UserProfile) GetEasyOrder ¶ added in v0.0.3
func (u *UserProfile) GetEasyOrder() (*EasyOrder, error)
GetEasyOrder will return the user's easy order.
func (*UserProfile) Loyalty ¶ added in v0.0.3
func (u *UserProfile) Loyalty() (*CustomerLoyalty, error)
Loyalty returns the user's loyalty meta-data (see CustomerLoyalty)
func (*UserProfile) NearestStore ¶
func (u *UserProfile) NearestStore(service string) (*Store, error)
NearestStore will find the the store that is closest to the user's default address.
func (*UserProfile) NewOrder ¶ added in v0.0.3
func (u *UserProfile) NewOrder() (*Order, error)
NewOrder will create a new *dawg.Order struct with all of the user's information.
func (*UserProfile) PreviousOrders ¶ added in v0.0.3
func (u *UserProfile) PreviousOrders(n int) ([]*EasyOrder, error)
PreviousOrders will return `n` of the user's previous orders.
func (*UserProfile) SetServiceMethod ¶
func (u *UserProfile) SetServiceMethod(service string) error
SetServiceMethod will set the user's default service method, should be "Delivery" or "Carryout"
func (*UserProfile) SetStore ¶ added in v0.0.3
func (u *UserProfile) SetStore(store *Store) error
SetStore will set the UserProfile struct's internal store variable.
func (*UserProfile) StoresNearMe ¶
func (u *UserProfile) StoresNearMe() ([]*Store, error)
StoresNearMe will find the stores closest to the user's default address.
type Variant ¶
type Variant struct { ItemCommon // the price of the variant. Price string // Product Code is the code for the set of variants that the variant belongs // to. Will coorespond with the code field of one Product. ProductCode string // true if the variant is prepared by dominos Prepared bool // contains filtered or unexported fields }
Variant is a structure that represents a base component of the Dominos menu. It will be a subset of a Product (see Product).
func (*Variant) AddTopping ¶
AddTopping will add a topping to the variant, see Item.
func (*Variant) FindProduct ¶
FindProduct will initialize the Variant with it's parent product and return that products. Returns nil if product is not found.
func (*Variant) GetProduct ¶
GetProduct will return the set of variants (Product) that the variant is a member of.