Skip to content

jjideenschmiede/tillhub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tillhub

With this repository you can access the Tillhub API with the following functions. We will continue to develop these as we go along, so if you want to collaborate, feel free.

If you need help, please feel free to ask us: [email protected].

Install

go get github.com/jjideenschmiede/tillhub

How to use it?

Here you can find an overview of all currently created functions.

Basic authentication

To access the API you need a current Bearer Token. You will receive this token with further information about this function. Here you can see the call in tillhub documentation.

// Get bearer token
data, err := tillhub.AuthBasic("email", "password")
if err != nil {
    fmt.Println(err)
}

// Print token
fmt.Println(data.token)

API key authentication

To access the API you need a current Bearer Token. You will receive this token with further information about this function. Here you can see the call in tillhub documentation.

// Get bearer token
data, err := tillhub.AuthKey("accountId", "apiKey")
if err != nil {
    fmt.Println(err)
}

// Print token
fmt.Println(data.token)

Tax

To find out the tax ids and get more information about the tax you can use the following function. Here you can see the call in tillhub documentation.

// Get tax information
tax, err := Tax("accountId", "token")
if err != nil {
    fmt.Println(err)
}

// Print tax information
fmt.Println(tax)

Read all products

If you want to read out all products, you can do it with this function. Both simple and variable products are returned. Here you can see the call in tillhub documentation.

// Read all products
products, err := tillhub.ReadProducts("userId", "token")
if err != nil {
    fmt.Println(err)
}

// Print products
fmt.Println(products)

Create product

If you want to create a product, you can do this using the following function call. Here you can see the call in tillhub documentation.

// Create product data
body := tillhub.CreateProductBody{
	true,
    "product",
    "parent",
    "J&J Testprodukt",
    "UUIDofTheRevenueAccountObjectInTillhub",
    "UUIDofTheTAXAccountObjectInTillhub",
    "JJTEST2021",
	make(map[string]interface{}),
    []tillhub.CreateProductBodyCodes{},
    nil,
    nil,
    nil,
    tillhub.CreateProductBodyImages{
        "https://jj-ideenschmiede.de/test.png",
		"https://jj-ideenschmiede.de/test.png",
		"https://jj-ideenschmiede.de/test.png",
		"https://jj-ideenschmiede.de/test.png",
		"https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
    },
    nil,
    true,
    nil,
    nil,
    nil,
    tillhub.CreateProductBodyPrices{
        []tillhub.CreateProductBodyPricesDefaultPrices{
            {
			    tillhub.CreateProductBodyPricesDefaultPricesAmount{
                    69,
                    82.11,
                },
                3,
                "EUR",
                20,
                2,
            },
        },
        []tillhub.CreateProductBodyPricesBranchPrices{},
    },
    nil,
    true,
    false,
    nil,
    nil,
    tillhub.CreateProductBodyManufacturer{
        nil,
    },
    tillhub.CreateProductBodySupplier{
        nil,
    },
    nil,
    "simple",
    nil,
    []tillhub.CreateProductBodyTags{},
    false,
    nil,
    tillhub.CreateProductBodyConfiguration{
        true,
		tillhub.CreateProductBodyConfigurationPricing{
            false,
        },
    },
    nil,
    nil}

// Create product function
create, err := tillhub.CreateProduct(body, "userId", "token")
if err != nil {
    fmt.Println(err)
}

// Print product data
fmt.Println(create)

Update product

If you want to update a product, then you can do with the following function. Some data is needed for this. Here you can see the call in tillhub documentation.

// Create product data
body := tillhub.CreateProductBody{
	true,
    "product",  
    "parent",
    "J&J Testprodukt",
    "UUIDofTheRevenueAccountObjectInTillhub",
    "UUIDofTheTAXAccountObjectInTillhub",
    "JJTEST2021",
	make(map[string]interface{}),
    []tillhub.CreateProductBodyCodes{},
    nil,
    nil,
    nil,
    tillhub.CreateProductBodyImages{
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
        "https://jj-ideenschmiede.de/test.png",
    },
    nil,
    true,
    nil,
    nil,
    nil,
    tillhub.CreateProductBodyPrices{
        []tillhub.CreateProductBodyPricesDefaultPrices{
            {
			    tillhub.CreateProductBodyPricesDefaultPricesAmount{
                    69,
                    82.11,
                },
                3,
                "EUR",
                20,
                2,
            },
        },
        []tillhub.CreateProductBodyPricesBranchPrices{},
    },
    nil,
    true,
    false,
    nil,
    nil,
    tillhub.CreateProductBodyManufacturer{
        nil,
    },
    tillhub.CreateProductBodySupplier{
        nil,
    },
    nil,
    "simple",
    nil,
    []tillhub.CreateProductBodyTags{},
    false,
    nil,
    tillhub.CreateProductBodyConfiguration{
        true,
		tillhub.CreateProductBodyConfigurationPricing{
            false,
        },
    },
    nil,
    nil}

// Create product function
create, err := tillhub.UpdateProduct(body, "productId", "userId", "token")
if err != nil {
    fmt.Println(err)
}

// Print product data
fmt.Println(create)

Delete product

To remove a product you need the ID of the product and you can remove it with this function. Here you can see the call in tillhub documentation.

// Delete an product whith his dependencies
delete, err := tillhub.DeleteProduct("productId", "userId", "token")
if err != nil {
    fmt.Println(err)
}

// Print return data
fmt.Println(delete)

Update quantity

If you want to update the quantity, you can do it with this function. Here you can see the call in tillhub documentation.

// Define stock body
body := tillhub.CreateStockBody{220, "locationId"}

// Update stock
stock, err := tillhub.CreateStock(body, "accountId", "productId", "token")
if err != nil {
    fmt.Println(err)
}

// Print stock
fmt.Println(stock.Results[0].Stock.Qty)

Update stock

// Define stock body
body := tillhub.UpdateStockBody{12}

// Update stock
stock, err := tillhub.UpdateStock(body, "stockId", "accountId", "token")
if err != nil {
    fmt.Println(err)
}

// Print stock
fmt.Println(stock.Results[0].Qty)

Delete stock

If you want to delete the stock of a product, you can do it with this function. Here you can see the call in tillhub documentation.

// Delete stock
stock, err := tillhub.DeleteStock("stockId", "accountId", "token")
if err != nil {
    fmt.Println(err)
}

// Print stock
fmt.Println(stock)

Read all product groups

If you want to read out all product groups, you can do it with this function. Both simple and variable products are returned. Here you can see the call in tillhub documentation.

// Get all product groups
groups, err := tillhub.ProductGroups("accountId", "token")
if err != nil {
fmt.Println(err)
}

// Print all product groups
fmt.Println(groups)

Create new product group

To define a new product group the following function can be used. You can find the documentation here.

// Create product body data
body := tillhub.CreateProductGroupBody{
    true,
    "#87cef9",
    "newGroup",
    "00001",
    "f85910a6-94c4-40bd-a0ac-386ef880c857",
    "673ba8d1-f544-48be-b432-122633e92715",
	tillhub.CreateProductGroupBodyImages{
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
    },
}

// Save new product group
group, err := tillhub.CreateProductGroup(body, "accountId", "token")
if err != nil {
    fmt.Println(err)
}

// Print return
fmt.Println(group)

Update a product group

To update a product group the following function can be used. You can find the documentation here.

// Create product body data
body := tillhub.CreateProductGroupBody{
    true,
    "#87cef9",
    "newGroup",
    "00001",
    "f85910a6-94c4-40bd-a0ac-386ef880c857",
    "673ba8d1-f544-48be-b432-122633e92715",
	tillhub.CreateProductGroupBodyImages{
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
        "https://storage.googleapis.com/tillhub-api-images/dd5a5b03-69fd-4747-bd6c-2ecf22ec78c1/productGroups/1a743bf7-10af-4897-891e-13c9924441de_1x.png",
    },
}

// Update product group
group, err := tillhub.UpdateProductGroup(body, "groupId", "accountId", "token")
if err != nil {
    fmt.Println(err)
}

// Print return
fmt.Println(group)

Delete product group

To delete a product group the following function can be used. You can find the documentation here.

// Update product group
delete, err := tillhub.DeleteProductGroup("groupId", "accountId", "token")
if err != nil {
    fmt.Println(err)
}

// Print return
fmt.Println(delete)