Skip to content

Commit 42d3f28

Browse files
authored
[Assets] Restructured / fixed Asset Object
1 parent f988361 commit 42d3f28

File tree

1 file changed

+49
-27
lines changed

1 file changed

+49
-27
lines changed

pyblox3/api/assets.py

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,53 @@
99
from .http import Http
1010
import json
1111

12+
# Asset Object
13+
class Asset:
14+
Name = None
15+
Id = None
16+
ProductId = None
17+
Description = None
18+
AssetTypeId = None
19+
CreatorName = None
20+
CreatorId = None
21+
CreatorTargetId = None
22+
IconImageAssetId = None
23+
Created = None
24+
Updated = None
25+
PriceInRobux = None
26+
Sales = None
27+
IsNew = None
28+
IsForSale = None
29+
IsPublicDomain = None
30+
IsLimited = None
31+
IsLimitedUnique = None
32+
Remaining = None
33+
MinimumMembershipLevel = None
34+
ContentRatingTypeId = None
35+
36+
def __init__(self,data):
37+
self.Name = data["Name"]
38+
self.Id = data["AssetId"]
39+
self.ProductId = data["ProductId"]
40+
self.Description = data["Description"]
41+
self.AssetTypeId = data["AssetTypeId"]
42+
self.CreatorName = data["Creator"]["Name"]
43+
self.CreatorId = data["Creator"]["Id"]
44+
self.CreatorType = data["Creator"]["CreatorType"]
45+
self.CreatorTargetId = data["Creator"]["CreatorTargetId"]
46+
self.IconImageAssetId = data["IconImageAssetId"]
47+
self.Created = data["Created"]
48+
self.Updated = data["Updated"]
49+
self.PriceInRobux = data["PriceInRobux"]
50+
self.Sales = data["Sales"]
51+
self.IsNew = data["IsNew"]
52+
self.IsForSale = data["IsForSale"]
53+
self.IsPublicDomain = data["IsPublicDomain"]
54+
self.IsLimited = data["IsLimited"]
55+
self.IsLimitedUnique = data["IsLimitedUnique"]
56+
self.Remaining = data["Remaining"]
57+
self.MinimumMembershipLevel = data["MinimumMembershipLevel"]
58+
self.ContentRatingTypeId = data["ContentRatingTypeId"]
1259

1360
class Assets:
1461

@@ -25,8 +72,7 @@ def PackageAsset(assetid):
2572
# GET https://api.roblox.com/Ownership/HasAsset?userId={userId}&assetId={assetId}
2673
# Returns Boolean
2774
def hasAsset(userid, assetid):
28-
a = Http.sendRequest(
29-
"https://api.roblox.com/Ownership/HasAsset?userId=" + str(userid) + "&assetId=" + str(assetid))
75+
a = Http.sendRequest("https://api.roblox.com/Ownership/HasAsset?userId=" + str(userid) + "&assetId=" + str(assetid))
3076
if a == "true" or True:
3177
return True
3278
else:
@@ -38,31 +84,7 @@ def Asset(assetid):
3884
c = Http.sendRequest("https://api.roblox.com/Marketplace/ProductInfo?assetId=" + str(assetid))
3985
b = c.decode("utf-8")
4086
a = json.loads(b)
41-
global Asset
42-
Asset = lambda: None
43-
Asset.Name = a["Name"]
44-
Asset.Id = a["AssetId"]
45-
Asset.ProductId = a["ProductId"]
46-
Asset.Description = a["Description"]
47-
Asset.AssetTypeId = a["AssetTypeId"]
48-
Asset.CreatorName = a["Creator"]["Name"]
49-
Asset.CreatorId = a["Creator"]["Id"]
50-
Asset.CreatorType = a["Creator"]["CreatorType"]
51-
Asset.CreatorTargetId = a["Creator"]["CreatorTargetId"]
52-
Asset.IconImageAssetId = a["IconImageAssetId"]
53-
Asset.Created = a["Created"]
54-
Asset.Updated = a["Updated"]
55-
Asset.PriceInRobux = a["PriceInRobux"]
56-
Asset.Sales = a["Sales"]
57-
Asset.IsNew = a["IsNew"]
58-
Asset.IsForSale = a["IsForSale"]
59-
Asset.IsPublicDomain = a["IsPublicDomain"]
60-
Asset.IsLimited = a["IsLimited"]
61-
Asset.IsLimitedUnique = a["IsLimitedUnique"]
62-
Asset.Remaining = a["Remaining"]
63-
Asset.MinimumMembershipLevel = a["MinimumMembershipLevel"]
64-
Asset.ContentRatingTypeId = a["ContentRatingTypeId"]
65-
return Asset
87+
return Asset(a)
6688

6789
# GET https://www.roblox.com/studio/plugins/info?assetId={assetId}
6890
# Returns Table/Array

0 commit comments

Comments
 (0)