Simple 3D bin packaging API


import requests

data = {
    "containers": [
        {"width": 50, "height": 15, "depth": 15, "max_weight": 100, "tag": "Truck A"},
        {"width": 13, "height": 8, "depth": 6, "max_weight": 200, "tag": "Truck B"},
    ],
    "items": [
        {"width": 5, "height": 3, "depth": 2, "qt": 20, "weight": 10, "tag": "Goods"},
        {"width": 3, "height": 3, "depth": 3, "qt": 30, "weight": 12.5, "tag": "TV"},
    ],
    "options": {"blueprint": True, "beta": True},
}
requests.post("https://api.robo-packing.ml/containers/gen-A1?api_key=ak_45111910264f4e68a08b18434ab4e4f", json=data)


from dataclasses import dataclass
from typing import List


@dataclass
class Container:
    width: int
    height: int
    depth: int
    max_weight: int
    tag: str


@dataclass
class Item:
    width: int
    height: int
    depth: int
    qt: int
    weight: float
    tag: str


@dataclass
class Options:
    blueprint: bool
    beta: bool


@dataclass
class Request:
    containers: List[Container]
    items: List[Item]
    options: Options



//    payload, err := UnmarshalPayload(bytes)
//    bytes, err = Payload.Marshal()

package main

import "encoding/json"

func UnmarshalPayload(data []byte) (Payload, error) {
	var r Payload
	err := json.Unmarshal(data, &r)
	return r, err
}

func (r *Payload) Marshal() ([]byte, error) {
	return json.Marshal(r)
}

type Payload struct {
	Containers []Container `json:"containers"`
	Items      []Item      `json:"items"`
	Options    Options     `json:"options"`
}

type Container struct {
	Width     int64  `json:"width"`
	Height    int64  `json:"height"`
	Depth     int64  `json:"depth"`
	MaxWeight int64  `json:"max_weight"`
	Tag       string `json:"tag"`
}

type Item struct {
	Width  int64   `json:"width"`
	Height int64   `json:"height"`
	Depth  int64   `json:"depth"`
	Qt     int64   `json:"qt"`
	Weight float64 `json:"weight"`
	Tag    string  `json:"tag"`
}

type Options struct {
	Blueprint bool `json:"blueprint"`
	Beta      bool `json:"beta"`
}
        

eliza@robo-packing.ml

Questions? Please reach out and I'll be happy to assist you.