pantry

package module
v0.0.0-...-001aa03 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MIT Imports: 10 Imported by: 0

README

pantry-go


Helper library to interface with the Pantry API in Go.

Installation

You can download this repo with go get.

go get github.com/Terminator15474/pantry-go/

Usage

package main

import (
	"fmt"

	"github.com/Terminator15474/pantry-go"
)

type Test struct {
	Name string
}

func main() {
	// your API key
	apiKey := "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
	pantry_api := pantry.CreatePantry(apiKey)

	fmt.Println(pantry_api.CreateOrReplaceBasket("name", Test{Name: "test"}))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasketInfo

type BasketInfo struct {
	Name string `json:"name"`
	Ttl  string `json:"ttl"`
}

type Pantry

type Pantry struct {
	// GetDetails returns the details of the pantry
	GetDetails func() (PantryInfo, error)

	// UpdateDetails updates the details of the pantry
	UpdateDetails func(info UpdatedInfo) (PantryInfo, error)

	// CreateOrReplaceBasket creates or replaces a basket in the pantry
	// with the given name and data and returns true if successful
	CreateOrReplaceBasket func(name string, data any) (bool, error)

	// UpdateBasketContent updates the content of the basket
	// with the given name and returns the updated data
	UpdateBasketContent func(name string, data any) (any, error)

	// GetBasketContent returns the content of the basket
	// with the given name in the given format
	GetBasketContent func(name string, format any) (any, error)

	// DeleteBasket deletes the basket with the given name
	// and returns true if successful
	// THIS WILL DELETE ALL THE DATA IN THE BASKET
	DeleteBasket func(name string) (bool, error)

	// HasBasket checks if the pantry has a basket with the given name
	HasBasket func(name string) (bool, error)
}

func CreatePantry

func CreatePantry(apiKey string) Pantry

func CreateRateLimitedPantry

func CreateRateLimitedPantry(apiKey string) Pantry

CreatePantry creates a new rateLimited Pantry API Wrapper with the given API key

type PantryInfo

type PantryInfo struct {
	Name          string       `json:"name"`
	Description   string       `json:"description"`
	Errors        []string     `json:"errors"`
	Notifications bool         `json:"notifications"`
	PercentFull   int8         `json:"percentFull"`
	Baskets       []BasketInfo `json:"baskets"`
}

type UpdatedInfo

type UpdatedInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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