Represents a Guild Wars 2 item chat code.
Item chat codes are used by the game to link items in chat. An item link always contains an item id and quantity, and may also include a skin id and up to two upgrade ids.
Use this struct with GW2.ChatCode.encode/1 and GW2.ChatCode.decode/1.
Examples
iex> GW2.ChatCode.decode("[&AgH2twBA8F8AAA==]")
{:ok, %GW2.ChatCode.Item{id: 47094, quantity: 1, skin_id: nil, upgrade_ids: [24560]}}
iex> GW2.ChatCode.encode(%GW2.ChatCode.Item{id: 30691, skin_id: 13826, upgrade_ids: [91439, 91607]})
{:ok, "[&AgHjdwDgAjYAAC9lAQDXZQEA]"}Fields
:id- the Guild Wars 2 item id.:quantity- the linked item quantity. It must fit in one byte.:skin_id- an optional skin id applied to the item.:upgrade_ids- optional upgrade component ids. Only the first two upgrade ids are encoded, matching the chat code format.
Summary
Functions
Decodes an item chat code payload into an item struct.
Encodes an item struct into the binary payload used inside a chat code.
Types
@type t() :: %GW2.ChatCode.Item{ id: non_neg_integer(), quantity: non_neg_integer(), skin_id: non_neg_integer() | nil, upgrade_ids: [non_neg_integer()] }
An item link decoded from, or ready to encode as, a chat code.
Functions
Decodes an item chat code payload into an item struct.
Most applications should call GW2.ChatCode.decode/1 instead, which accepts
the full chat code string.
Encodes an item struct into the binary payload used inside a chat code.
Most applications should call GW2.ChatCode.encode/1 instead, which also
adds the chat code wrapper and Base64-encodes the payload.