Types
AnimalApi = object of RootObj url*: string token*: Option[string]
AnimalUrls = enum TheCatApiUrl = "https://api.thecatapi.com/v1", TheDogApiUrl = "https://api.thedogapi.com/v1"
ApiBreed = object of RootObj name*, life_span*: string description*: Option[string] weight*: Option[ImperialMetricValues] ## General Information origin*: Option[string] country_code*: Option[string] ## Origin country (countries for thedogapi)
ApiBreedCat = object of ApiBreed id*, temperament*: string cfa_url*, vetstreet_url*, vcahospitals_url*, wikipedia_url*: Option[string] country_codes: string ## Only for parsing, not meant to be accessable. affection_level*, adaptability*, cat_friendly*, child_friendly*, dog_friendly*, energy_level*, grooming*, health_issues*, intelligence*, shedding_level*, social_needs*, stranger_friendly*, vocalisation*: Option[ range[0 .. 5]] ## 5-star ratings natural*, hypoallergenic*, suppressed_tail*, experimental*, hairless*, short_legs*, rex*, rare*: Option[range[0 .. 1]] ## Booleans as numbers, because that makes sense indoor*, lap*, bidability*: Option[int] ## My best guess is, these are also booleans (they are never used by the api)
ApiBreedDog = object of ApiBreed id: int temperament: Option[string] height*: Option[ImperialMetricValues] bred_for*, breed_group*: Option[string] reference_image_id*: Option[string] image*: Option[ReferenceImage] ## Reference Image
Breed = object of RootObj name*, lifeSpan*: string temperament*: seq[string] weight*: Option[ImperialMetricValues]
CatBreed = object of Breed id*, description*: string informationUrls*: Option[seq[string]] ## Links to websites with information about breed originCountry*: tuple[name, code: string] rating*: tuple[affectionLevel, adaptability, catFriendly, childFriendly, dogFriendly, energyLevel, grooming, healthIssues, intelligence, sheddingLevel, socialNeeds, strangerFriendly, vocalisation: Option[ float]] ## Percentage ratings attributes*: tuple[natural, hypoallergenic, suppressedTail, experimental, hairless, shortLegs, rex, rare, indoor, lap, bidability: Option[ bool]] ## Breed attributes
Category = tuple[id: int, name: string]
DogBreed = object of Breed id*: int description*: Option[string] height*: Option[ImperialMetricValues] referenceImage*: Option[ReferenceImage] group*, purpose*: Option[string] originCountries*: seq[string]
ImageFormat = enum formatGif = "gif", formatPng = "png", formatJpg = "jpg"
ImageSize = enum sizeNone = "", ## sizeNone is an internal value for signaling no specific selection, do not use manually sizeFull = "full", sizeMed = "med", sizeSmall = "small"
ImperialMetricValues = tuple[imperial, metric: string]
ReferenceImage = tuple[id, url: string, width, height: Option[int]]
Request = object limit*: Option[int] size*: Option[ImageSize] mime_types*: Option[seq[ImageFormat]] has_breeds*: Option[bool]
Procs
proc convert(apiBreed: ApiBreedCat): CatBreed {....raises: [], tags: [].}
- Converts breed information from the api into easy to use object with some QoL conversions like for example range[0..1] converted to bool!
proc convert(apiBreed: ApiBreedDog): DogBreed {....raises: [], tags: [].}
proc convert(apiBreeds: seq[ApiBreedCat]): seq[CatBreed] {....raises: [], tags: [].}
- Converts breed information from the api into easy-to-use object with some QoL conversions like for example range[0..1] converted to bool!
proc convert(apiBreeds: seq[ApiBreedDog]): seq[DogBreed] {....raises: [], tags: [].}
- Converts breed information from the api into easy-to-use object.