From 42727cbe482eb8968a9076eade6d0dfe0f744cf0 Mon Sep 17 00:00:00 2001 From: itzaname Date: Thu, 28 Sep 2017 21:17:47 -0400 Subject: [PATCH] Added hasitem --- item.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/item.go b/item.go index 0c1edef..9b8915d 100644 --- a/item.go +++ b/item.go @@ -23,6 +23,22 @@ type Item struct { Owned bool } +// HasItem will return if you own the item +func (s *Session) HasItem(id int) (bool, error) { + resp, err := s.client.Get(fmt.Sprintf("http://api.roblox.com/Ownership/HasAsset?userId=%d&assetId=%d", s.ID, id)) + if err != nil { + return false, err + } + defer resp.Body.Close() + + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + return false, err + } + + return string(data) == "true", nil +} + // AddItem add item by id to inventory func (s *Session) AddItem(id int, seller int) error { v := url.Values{}