artificer/api/schemas/single_item.zig

23 lines
655 B
Zig

const std = @import("std");
const Server = @import("../server.zig");
const json_utils = @import("../json_utils.zig");
const json = std.json;
const Allocator = std.mem.Allocator;
const Item = @import("./item.zig");
const SingleItem = @This();
item: Item,
// TODO: Grand exchange
pub fn parse(api: *Server, obj: json.ObjectMap, allocator: Allocator) !SingleItem {
const item_obj = json_utils.getObject(obj, "item") orelse return error.MissingProperty;
const ge_obj = json_utils.getObject(obj, "ge") orelse return error.MissingProperty;
_ = ge_obj;
return SingleItem{
.item = try Item.parse(api, item_obj, allocator),
};
}