solvingmaze

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

README

go-solvingmaze

SolvingMaze API Library for Go

GoDoc

Import

import github.com/jeffdoubleyou/go-solvingmaze

Usage

package main

import (
	"fmt"
	"go-solvingmaze"
)

func main() {
	sm := solvingmaze.New("ABCDEFGHIJKLMNOP", "Los Angeles", 5, true)
	// Create a new quote
	quote := sm.NewPackAndQuote()

	// Define an item to add to the quote
	itemProps := make(map[string]interface{})
	itemProps["Name"] = "Widget"
	itemProps["Sku"] = "W11122"

	// Add the item to the quote
	item, err := quote.AddItem(itemProps)
	if err != nil {
		fmt.Printf("Error: %v", err)
	}

	// Add dimensions for the item
	dimension := item.AddDimensions(map[string]interface{}{"Length": 12, "Width": 8, "Height": 5})

	// Change the dimension height
	dimension.Height(10)

	// Add a second, empty dimension for the item
	dimension2 := item.AddDimensions()

	// Set dimensions individually
	dimension2.Length(24)
	dimension2.Width(12)
	dimension2.Height(8)

	// Define the destination address
	address := make(map[string]interface{})
	address["post"] = "48072"
	address["region"] = "MI"
	address["city"] = "Berkley"
	address["country"] = "US"
	address["residential"] = true

	// Add the destination to the quote
	_, err = quote.Destination(address)
	if err != nil {
		fmt.Printf("Error adding destination: %s", err)
	}

	// Add a void dimension
	void := item.AddVoidDimensions(map[string]interface{}{"Length": 12, "Width": 8, "Height": 2})

	// Change void height
	void.Height(4)

	// Send calculation request
	calc, err := quote.Calculate()

	if err != nil {
		fmt.Printf("Failed to calculate shipping: %s", err)
	} else {
		fmt.Printf("\nRate: $%v\n", calc.Services[0].Rate)
	}
}

Documentation

Index

Constants

View Source
const (
	API_BASE = "https://api.solvingmaze.com/"
)

Variables

This section is empty.

Functions

func NewClient

func NewClient(apiKey string, warehouseId string, timeout int, debug bool) (c *client)

Types

type Destination

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

type Dimension

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

func (*Dimension) Height

func (dim *Dimension) Height(h float64)

func (*Dimension) Length

func (dim *Dimension) Length(l float64)

func (*Dimension) Width

func (dim *Dimension) Width(w float64)

type Item

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

func (*Item) AddDimensions

func (item *Item) AddDimensions(props ...map[string]interface{}) *Dimension

func (*Item) AddPackaging

func (item *Item) AddPackaging(props ...map[string]interface{}) *Packaging

func (*Item) AddPrepackage

func (item *Item) AddPrepackage(props ...map[string]interface{}) *Prepackage

func (*Item) AddStack

func (item *Item) AddStack(props ...map[string]interface{}) *Stack

func (*Item) AddVoidDimensions

func (item *Item) AddVoidDimensions(props ...map[string]interface{}) *Dimension

type PackAndQuote

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

func (*PackAndQuote) AddItem

func (pq *PackAndQuote) AddItem(props map[string]interface{}) (*Item, error)

func (*PackAndQuote) Calculate

func (pq *PackAndQuote) Calculate() (*models.PackResponse, error)

func (*PackAndQuote) Destination

func (pq *PackAndQuote) Destination(props map[string]interface{}) (*Destination, error)

type Packaging

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

func (*Packaging) Height

func (p *Packaging) Height(h float64)

func (*Packaging) Irregular

func (p *Packaging) Irregular(i bool)

func (*Packaging) Length

func (p *Packaging) Length(l float64)

func (*Packaging) Weight

func (p *Packaging) Weight(w float64)

func (*Packaging) Width

func (p *Packaging) Width(w float64)

type Prepackage

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

func (*Prepackage) Capacity

func (p *Prepackage) Capacity(c int)

func (*Prepackage) DimensionUnit

func (p *Prepackage) DimensionUnit(u string)

func (*Prepackage) Height

func (p *Prepackage) Height(h float64)

func (*Prepackage) Length

func (p *Prepackage) Length(l float64)

func (*Prepackage) Weight

func (p *Prepackage) Weight(w float64)

func (*Prepackage) Width

func (p *Prepackage) Width(w float64)

type SolvingMaze

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

func New

func New(ApiKey string, WarehouseId string, timeout int, debug bool) *SolvingMaze

func (*SolvingMaze) NewPackAndQuote

func (sm *SolvingMaze) NewPackAndQuote() *PackAndQuote

type Stack

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

func (*Stack) HeightIncrement

func (s *Stack) HeightIncrement(h float64)

func (*Stack) LengthIncrement

func (s *Stack) LengthIncrement(l float64)

func (*Stack) MaxQty

func (s *Stack) MaxQty(q int)

func (*Stack) WidthIncrement

func (s *Stack) WidthIncrement(w float64)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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