tallgrass/berry
Types
pub type Berry {
Berry(
id: Int,
name: String,
growth_time: Int,
max_harvest: Int,
natural_gift_power: Int,
size: Int,
smoothness: Int,
soil_dryness: Int,
firmness: Resource,
flavors: List(BerryFlavorMap),
item: Resource,
natural_gift_type: Resource,
)
}
Constructors
-
Berry( id: Int, name: String, growth_time: Int, max_harvest: Int, natural_gift_power: Int, size: Int, smoothness: Int, soil_dryness: Int, firmness: Resource, flavors: List(BerryFlavorMap), item: Resource, natural_gift_type: Resource, )
pub type BerryFlavorMap {
BerryFlavorMap(potency: Int, flavor: Resource)
}
Constructors
-
BerryFlavorMap(potency: Int, flavor: Resource)
Functions
pub fn fetch(client: Client) -> Result(PaginatedResource, Error)
Fetches a paginated list of berry resources.
Example
let result = berry.new() |> berry.fetch()
pub fn fetch_by_id(
client: Client,
id: Int,
) -> Result(Berry, Error)
Fetches a berry given the berry ID.
Example
let result = berry.new() |> berry.fetch_by_id(1)
pub fn fetch_by_name(
client: Client,
name: String,
) -> Result(Berry, Error)
Fetches a berry given the berry name.
Example
let result = berry.new() |> berry.fetch_by_name("cheri")
pub fn fetch_resource(
client: Client,
resource: Resource,
) -> Result(Berry, Error)
Fetches a berry given a berry resource.
Example
let client = berry.new()
use res <- result.try(client |> berry.fetch())
let assert Ok(first) = res.results |> list.first
client |> berry.fetch_resource(first)