Merge pull request #2 from itzaname/v2

Added hasitem
This commit is contained in:
itzaname 2017-09-28 21:22:09 -04:00 committed by GitHub
commit 26038aec3a

16
item.go
View File

@ -23,6 +23,22 @@ type Item struct {
Owned bool 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 // AddItem add item by id to inventory
func (s *Session) AddItem(id int, seller int) error { func (s *Session) AddItem(id int, seller int) error {
v := url.Values{} v := url.Values{}