import { isArrayOf, isObject, isString } from '../../utils/types'

type Trashbox = {
    Name: string,
    Lat: number,
    Lng: number,
    Address: string,
    Categories: string[],
}

const isTrashbox = (obj: unknown): obj is Trashbox => (
    isObject(obj, {
        'Name': 'string',
        'Lat': 'number',
        'Lng': 'number',
        'Address': 'string',
        'Categories': obj => isArrayOf(obj, isString),
    })
)

type TrashboxResponse = Trashbox[]

const isTrashboxResponse = (obj: unknown): obj is Trashbox[] => (
    isArrayOf(obj, isTrashbox)
)

export type { Trashbox, TrashboxResponse }
export { isTrashbox, isTrashboxResponse }
