Guest User

GroupsAPI v1-v2

a guest
Mar 19th, 2025
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.97 KB | None | 0 0
  1. -- dogo8me2
  2. local HttpClient = require(script.HttpClient)
  3. local HttpService = game:GetService("HttpService")
  4. local GroupsAPI = {}
  5.  
  6. -- https://groups.roblox.com/docs/index.html?urls.primaryName=Groups%20Api%20v1
  7.  
  8. local API_URL = "https://groups.roproxy.com"
  9. --local API_KEY = "G1B00Od+3kmFne25y22x6tTTuxeNjpCrG7KjUyV8UJrZaOVr" -- dogo8me api key
  10. local API_KEY = "5gFT8kV2qE6gzw1RWnVwknU7Xu3j85R/rzYBFb94kOyRoI2g" -- group API key
  11.  
  12. function GroupsAPI.GetGroupInformationByIds(groupIds: {number}): any
  13.     local newUrl = API_URL .. "/v2/groups"
  14.     return HttpClient.getRequest(newUrl, API_KEY, {["groupIds"] = groupIds})
  15. end
  16.  
  17. function GroupsAPI.GetGroupInformationById(groupId: number): any -- GET
  18.     local newUrl = API_URL .. "/v1/groups/" .. groupId
  19.     return HttpClient.getRequest(newUrl, API_KEY)
  20. end
  21. --Gets the Group's audit log.
  22. function GroupsAPI.GetGroupAuditLog(groupId: number): any -- GET
  23.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/audit-log"
  24.     return HttpClient.getRequest(newUrl, API_KEY)
  25. end
  26. --Gets the Group's name change history.
  27. function GroupsAPI.GetGroupNameChangeHistory(groupId: number, limit: string, cursor: string, sortOrder: string) -- GET
  28.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/name-history"
  29.     local dataBody = {
  30.         ["limit"] = limit,
  31.         ["cursor"] = cursor,
  32.         ["sortOrder"] = sortOrder
  33.     }
  34.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  35. end
  36. --Gets the Group's settings.
  37. function GroupsAPI.GetGroupSettings(groupId: number): any -- GET
  38.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/settings"
  39.     return HttpClient.getRequest(newUrl, API_KEY)
  40. end
  41. --Updates the group's settings.
  42. function GroupsAPI.UpdateGroupSettings(groupId: number, isApprovalRequired: boolean, areEnemiesAllowed: boolean, areGroupFundsVisible: boolean, areGroupGamesVisible: boolean): any -- PATCH
  43.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/settings"
  44.     local dataBody = {
  45.         ["isApprovalRequired"] = isApprovalRequired,
  46.         ["areEnemiesAllowed"] = areEnemiesAllowed,
  47.         ["areGroupFundsVisible"] = areGroupFundsVisible,
  48.         ["areGroupGamesVisible"] = areGroupGamesVisible
  49.     }
  50.     return HttpClient.patchRequest(newUrl, API_KEY, dataBody)
  51. end
  52. --Gets Group configuration contextual information.
  53. function GroupsAPI.GetGroupConfigurationMetadata(groupId: number): any -- GET
  54.     local newUrl = API_URL .. "/v1/groups/configuration/metadata"
  55.     return HttpClient.getRequest(newUrl, API_KEY)
  56. end
  57. --Gets Groups contextual information: Max number of groups a user can be part of. Current number of groups a user is a member of. Whether to show/hide certain features based on device type.
  58. function GroupsAPI.GetGroupMetadata(groupId: number): any -- GET
  59.     local newUrl = API_URL .. "/v1/groups/metadata"
  60.     return HttpClient.getRequest(newUrl, API_KEY)
  61. end
  62. --Creates a new group.
  63. function GroupsAPI.CreateNewGroup(name: string, description: string, publicGroup: boolean, buildersClubMembersOnly: boolean): any -- POST
  64.     local newUrl = API_URL .. "/v1/groups/create"
  65.     local dataBody = {
  66.         ["name"] = name,
  67.         ["description"] = description,
  68.         ["publicGroup"] = publicGroup,
  69.         ["buildersClubMembersOnly"] = buildersClubMembersOnly
  70.     }
  71.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  72. end
  73. --Gets group policy info used for compliance.
  74. function GroupsAPI.GetGroupPolicies(groupId: number): any -- POST
  75.     local newUrl = API_URL .. "/v1/groups/policies"
  76.     return HttpClient.getRequest(newUrl, API_KEY, {["groupId"] = groupId})
  77. end
  78. --Updates the groups description.
  79. function GroupsAPI.UpdateGroupDescription(groupId: number, description: string): any -- PATCH
  80.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/description"
  81.     return HttpClient.patchRequest(newUrl, API_KEY, {["description"] = description})
  82. end
  83. --Updates the group's name.
  84. function GroupsAPI.UpdateGroupName(groupId: number, name: string): any -- PATCH
  85.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/name"
  86.     return HttpClient.patchRequest(newUrl, API_KEY, {["name"] = name})
  87. end
  88. --Updates the Notification Preference.
  89. function GroupsAPI.UpdateGroupNotificationPreference(groupId: number, notificationsEnabled: boolean): any -- PATCH
  90.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/notification-preference"
  91.     return HttpClient.patchRequest(newUrl, API_KEY, {["notificationsEnabled"] = notificationsEnabled})
  92. end
  93. --Sets group status
  94. function GroupsAPI.UpdateGroupStatus(groupId: number, message: string): any -- PATCH
  95.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/status"
  96.     return HttpClient.patchRequest(newUrl, API_KEY, {["message"] = message})
  97. end
  98. --Batch declines group join requests
  99. function GroupsAPI.BatchDeclineGroupJoinRequests(groupId: number, UserIds: {number}): any -- DELETE
  100.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/join-requests"
  101.     return HttpClient.deleteRequest(newUrl, API_KEY, {["UserIds"] = UserIds})
  102. end
  103. --Gets a page of Group Join Requests for a group.
  104. function GroupsAPI.GetGroupJoinRequests(groupId: number, limit: string, cursor: string, sortOrder: string): any -- GET
  105.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/join-requests"
  106.     local dataBody = {
  107.         ["limit"] = limit,
  108.         ["cursor"] = cursor,
  109.         ["sortOrder"] = sortOrder
  110.     }
  111.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  112. end
  113. --Batch accepts group join requests
  114. function GroupsAPI.BatchAcceptGroupJoinRequests(groupId: number, UserIds: {number}): any -- POST
  115.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/join-requests"
  116.     return HttpClient.postRequest(newUrl, API_KEY, {["UserIds"] = UserIds})
  117. end
  118. --Declines/cancels a group join request.
  119. function GroupsAPI.DeclineGroupJoinRequest(groupId: number, userId: number): any -- DELETE
  120.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/join-requests/users/" .. userId
  121.     return HttpClient.deleteRequest(newUrl, API_KEY)
  122. end
  123. --Gets a group join request by userId.
  124. function GroupsAPI.GetGroupJoinRequestByUserId(groupId: number, userId: number): any -- GET
  125.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/join-requests/users/" .. userId
  126.     return HttpClient.getRequest(newUrl, API_KEY)
  127. end
  128. --Accepts a group join request.
  129. function GroupsAPI.AcceptGroupJoinRequest(groupId: number, userId: number): any -- POST
  130.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/join-requests/users/" .. userId
  131.     return HttpClient.postRequest(newUrl, API_KEY)
  132. end
  133. --Gets group membership information in the context of the authenticated user
  134. function GroupsAPI.GetGroupMembership(groupId: number, includeNotificationPreferences): any -- GET
  135.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/membership"
  136.     return HttpClient.getRequest(newUrl, API_KEY, {["includeNotificationPreferences"] = includeNotificationPreferences})
  137. end
  138. --Gets a list of the rolesets in a group.
  139. function GroupsAPI.GetGroupRoles(groupId: number): any -- GET
  140.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/roles"
  141.     return HttpClient.getRequest(newUrl, API_KEY)
  142. end
  143. --Gets a list of users in a group for a specific roleset.
  144. function GroupsAPI.GetPlayersInGroupRoles(groupId: number, roleSetId: number, limit: string, cursor: string, sortOrder: string): any -- GET
  145.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/roles/" .. roleSetId .. "/users"
  146.     local dataBody = {
  147.         ["limit"] = limit,
  148.         ["cursor"] = cursor,
  149.         ["sortOrder"] = sortOrder
  150.     }
  151.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  152. end
  153. --Gets a list of users in a group.
  154. function GroupsAPI.GetPlayersInGroup(groupId: number, limit: string, cursor: string, sortOrder: string): any -- GET
  155.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/users"
  156.     local dataBody = {
  157.         ["limit"] = limit,
  158.         ["cursor"] = cursor,
  159.         ["sortOrder"] = sortOrder
  160.     }
  161.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  162. end
  163. --Joins a group
  164. function GroupsAPI.JoinGroup(groupId: number, sessionId: string, redemptionToken: string, captchaId: string, captchaToken: string, captchaProvider: string, challengeId: string): any -- POST
  165.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/users"
  166.     local dataBody = {
  167.         ["sessionId"] = sessionId,
  168.         ["redemptionToken"] = redemptionToken,
  169.         ["captchaId"] = captchaId,
  170.         ["captchaToken"] = captchaToken,
  171.         ["captchaProvider"] = captchaProvider,
  172.         ["challengeId"] = challengeId,
  173.     }
  174.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  175. end
  176. --Gets groups that the authenticated user has requested to join
  177. function GroupsAPI.GetPending(): any -- GET
  178.     local newUrl = API_URL .. "/v1/user/groups/pending"
  179.     return HttpClient.getRequest(newUrl, API_KEY)
  180. end
  181. --Gets a list of all groups the specified users' friends are in.
  182. function GroupsAPI.GetFriendsGroups(userId: number): any -- GET
  183.     local newUrl = API_URL .. "/v1/users/" .. userId .. "/friends/groups/roles"
  184.     return HttpClient.getRequest(newUrl, API_KEY)
  185. end
  186. --Gets a list of all group roles for groups the specified user is in.
  187. function GroupsAPI.GetAllRolesForUserId(userId: number): any -- GET
  188.     local newUrl = API_URL .. "/v1/users/" .. userId .. "/groups/roles"
  189.     return HttpClient.getRequest(newUrl, API_KEY)
  190. end
  191. --Changes the group owner to another user.
  192. function GroupsAPI.ChangeGroupOwner(groupId: number, userId: number): any -- POST
  193.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/change-owner"
  194.     return HttpClient.postRequest(newUrl, API_KEY, {["userId"] = userId})
  195. end
  196. --Claims ownership of the group as the authenticated user
  197. function GroupsAPI.ClaimGroupOwnership(groupId: number): any -- POST
  198.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/claim-ownership"
  199.     return HttpClient.postRequest(newUrl, API_KEY)
  200. end
  201. --Removes a user from a group
  202. function GroupsAPI.RemoveGroupPlayer(groupId: number, userId: number, roleId: number): any -- DELETE
  203.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/users/" .. userId
  204.     return HttpClient.deleteRequest(newUrl, API_KEY, {["roleId"] = roleId})
  205. end
  206. --Updates a users role in a group.
  207. function GroupsAPI.UpdateGroupPlayerRoles(groupId: number, userId: number, roleId: number): any -- PATCH
  208.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/users/" .. userId
  209.     return HttpClient.patchRequest(newUrl, API_KEY, {["roleId"] = roleId})
  210. end
  211. --Gets a value indicating whether the group can use payout feature
  212. function GroupsAPI.GroupCanUsePayout(groupId: number): any -- GET
  213.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/payout-restriction"
  214.     return HttpClient.getRequest(newUrl, API_KEY)
  215. end
  216. --Gets a list of the group payout percentages
  217. function GroupsAPI.GetCurrentRecurringPayouts(groupId: number): any -- GET
  218.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/payouts"
  219.     return HttpClient.getRequest(newUrl, API_KEY)
  220. end
  221. --Pays out a user in Robux.
  222. function GroupsAPI.PayoutGroupFundsToUser(groupId: number, PayoutType: number, Recipients: {["recipientId"]: number, ["recipientType"]: number, ["amount"]: number}): any -- POST
  223.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/payouts"
  224.     local dataBody = {
  225.         ["PayoutType"] = PayoutType,
  226.         ["Recipients"] = Recipients
  227.     }
  228.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  229. end
  230. --Updates recurring payouts.
  231. function GroupsAPI.UpdateRecurringPayouts(groupId: number, PayoutType: number, Recipients: {["recipientId"]: number, ["recipientType"]: number, ["amount"]: number}): any -- POST
  232.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/payouts/recurring"
  233.     local dataBody = {
  234.         ["PayoutType"] = PayoutType,
  235.         ["Recipients"] = Recipients
  236.     }
  237.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  238. end
  239. --Gets a group's relationships
  240. function GroupsAPI.GetGroupRelationships(groupId: number, groupRelationshipType: number, StartRowIndex: number, MaxRows: number): any -- GET
  241.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType
  242.     local dataBody = {
  243.         ["StartRowIndex"] = StartRowIndex,
  244.         ["MaxRows"] = MaxRows
  245.     }
  246.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  247. end
  248. --Batch declines group affiliate requests
  249. function GroupsAPI.DeclineGroupAffiliateRequests(groupId: number, groupRelationshipType: number, GroupIds: number): any -- DELETE
  250.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/requests"
  251.     local dataBody = {
  252.         ["GroupIds"] = GroupIds
  253.     }
  254.     return HttpClient.deleteRequest(newUrl, API_KEY, dataBody)
  255. end
  256. --Gets a group's relationship requests
  257. function GroupsAPI.GetGroupRelationshipRequests(groupId: number, groupRelationshipType: number, StartRowIndex: number, MaxRows: number): any -- GET
  258.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/requests"
  259.     local dataBody = {
  260.         ["StartRowIndex"] = StartRowIndex,
  261.         ["MaxRows"] = MaxRows
  262.     }
  263.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  264. end
  265. --Batch accepts group affiliate requests
  266. function GroupsAPI.AcceptGroupAffiliateRequests(groupId: number, groupRelationshipType: number, GroupIds: number): any -- POST
  267.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/requests"
  268.     local dataBody = {
  269.         ["GroupIds"] = GroupIds
  270.     }
  271.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  272. end
  273. --Deletes a group relationship.
  274. function GroupsAPI.DeleteGroupRelationship(groupId: number, relatedGroupId: number, groupRelationshipType: number): any -- DELETE
  275.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/" .. relatedGroupId
  276.     return HttpClient.deleteRequest(newUrl, API_KEY)
  277. end
  278. --Create a group relationship.
  279. function GroupsAPI.CreateGroupRelationship(groupId: number, relatedGroupId: number, groupRelationshipType: number): any -- POST
  280.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/" .. relatedGroupId
  281.     return HttpClient.postRequest(newUrl, API_KEY)
  282. end
  283. --Declines a group relationship request.
  284. function GroupsAPI.DeclineGroupRelationshipRequest(groupId: number, relatedGroupId: number, groupRelationshipType: number): any -- DELETE
  285.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/requests/" .. relatedGroupId
  286.     return HttpClient.deleteRequest(newUrl, API_KEY)
  287. end
  288. --Accepts a group relationship request.
  289. function GroupsAPI.AcceptGroupRelationshipRequest(groupId: number, relatedGroupId: number, groupRelationshipType: number): any -- POST
  290.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/relationships/" .. groupRelationshipType .. "/requests/" .. relatedGroupId
  291.     return HttpClient.postRequest(newUrl, API_KEY)
  292. end
  293. --Gets the permissions for a group's roleset. The authorized user must either be the group owner or the roleset being requested, except for guest roles, which can be viewed by all (members and guests).
  294. function GroupsAPI.GetGroupRolePermissions(groupId: number, roleSetId: number): any -- GET
  295.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/roles/" .. roleSetId .. "/permissions"
  296.     return HttpClient.getRequest(newUrl, API_KEY)
  297. end
  298. --Updates the permissions for a group's roleset. The authorized user must be the group owner.
  299. function GroupsAPI.UpdateRolePermissions(groupId: number, roleSetId: number, DeleteFromWall: boolean, PostToWall: boolean, InviteMembers: boolean, PostToStatus: boolean, RemoveMembers: boolean, BanMembers: boolean, ViewStatus: boolean, ViewWall: boolean, ChangeRank: boolean, AdvertiseGroup: boolean, ManageRelationships: boolean, AddGroupPlaces: boolean, ViewAuditLogs: boolean, CreateItems: boolean, ManageItems: boolean, SpendGroupFunds: boolean, ManageClan: boolean, ManageGroupGames: boolean, UseCloudAuthentication: boolean, AdministerCloudAuthentication: boolean, ViewAnalytics: boolean): any
  300.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/roles/" .. roleSetId .. "/permissions"
  301.  
  302.     local dataBody = {
  303.         permissions = {
  304.             DeleteFromWall = DeleteFromWall,
  305.             PostToWall = PostToWall,
  306.             InviteMembers = InviteMembers,
  307.             PostToStatus = PostToStatus,
  308.             RemoveMembers = RemoveMembers,
  309.             BanMembers = BanMembers,
  310.             ViewStatus = ViewStatus,
  311.             ViewWall = ViewWall,
  312.             ChangeRank = ChangeRank,
  313.             AdvertiseGroup = AdvertiseGroup,
  314.             ManageRelationships = ManageRelationships,
  315.             AddGroupPlaces = AddGroupPlaces,
  316.             ViewAuditLogs = ViewAuditLogs,
  317.             CreateItems = CreateItems,
  318.             ManageItems = ManageItems,
  319.             SpendGroupFunds = SpendGroupFunds,
  320.             ManageClan = ManageClan,
  321.             ManageGroupGames = ManageGroupGames,
  322.             UseCloudAuthentication = UseCloudAuthentication,
  323.             AdministerCloudAuthentication = AdministerCloudAuthentication,
  324.             ViewAnalytics = ViewAnalytics
  325.         }
  326.     }
  327.  
  328.     return HttpClient.patchRequest(newUrl, API_KEY, dataBody)
  329. end
  330. --Gets the permissions for a group's guest roleset. These can be viewed by all (members and guests) users.
  331. function GroupsAPI.GetGuestPermissions(groupId: number): any -- GET
  332.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/roles/guest/permissions"
  333.     return HttpClient.getRequest(newUrl, API_KEY)
  334. end
  335. --Gets all permissions for each role
  336. function GroupsAPI.GetEveryRolesPermissions(groupId: number): any -- GET
  337.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/roles/permissions"
  338.     return HttpClient.getRequest(newUrl, API_KEY)
  339. end
  340. --Get social link data associated with a group
  341. function GroupsAPI.GetGroupSocialLinkData(groupId: number): any -- GET
  342.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/social-links"
  343.     return HttpClient.getRequest(newUrl, API_KEY)
  344. end
  345. --Posts a social links
  346. function GroupsAPI.AddGroupSocialLink(groupId: number, type: number, url: string, title: string): any -- POST
  347.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/social-links"
  348.     local dataBody = {
  349.         ["type"] = type,
  350.         ["url"] = url,
  351.         ["title"] = title
  352.     }
  353.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  354. end
  355. --Deletes a social link
  356. function GroupsAPI.DeleteGroupSocialLink(groupId: number, socialLinkId: number): any -- DELETE
  357.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/social-links/" .. socialLinkId
  358.     return HttpClient.deleteRequest(newUrl, API_KEY)
  359. end
  360. --Updates a social link
  361. function GroupsAPI.UpdateGroupSocialLink(groupId: number, socialLinkId: number, type: number, url: string, title: string): any -- PATCH
  362.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/social-links/" .. socialLinkId
  363.     local dataBody = {
  364.         ["type"] = type,
  365.         ["url"] = url,
  366.         ["title"] = title
  367.     }
  368.     return HttpClient.patchRequest(newUrl, API_KEY, dataBody)
  369. end
  370. --Gets a list of group wall posts.
  371. function GroupsAPI.GetGroupWallPosts(groupId: number, limit: string, cursor: string, sortOrder: string): any -- GET
  372.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/wall/posts"
  373.     local dataBody = {
  374.         ["limit"] = limit,
  375.         ["cursor"] = cursor,
  376.         ["sortOrder"] = sortOrder
  377.     }
  378.     return HttpClient.getRequest(newUrl, API_KEY, dataBody)
  379. end
  380. --Creates a post on a group wall
  381. function GroupsAPI.GroupWallPostRequest(groupId: number, body: string, captchaId: string, captchaToken: string, captchaProvider: string, challengeId: string): any -- POST
  382.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/wall/posts"
  383.     local dataBody = {
  384.         ["body"] = body,
  385.         ["captchaId"] = captchaId,
  386.         ["captchaToken"] = captchaToken,
  387.         ["captchaProvider"] = captchaProvider,
  388.         ["challengeId"] = challengeId,
  389.     }
  390.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  391. end
  392. --Subscribes the authenticated user to notifications of group wall events.
  393. function GroupsAPI.SubscribeToGroupWall(groupId: number): any -- POST
  394.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/wall/subscribe"
  395.     return HttpClient.postRequest(newUrl, API_KEY)
  396. end
  397. --Deletes a group wall post.
  398. function GroupsAPI.DeleteGroupWallPost(groupId: number, postId: number): any -- DELETE
  399.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/wall/posts/" .. postId
  400.     return HttpClient.deleteRequest(newUrl, API_KEY)
  401. end
  402. --Deletes all group wall posts made by a specific user.
  403. function GroupsAPI.DeleteUsersGroupWallPosts(groupId: number, userId: number): any -- DELETE
  404.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/wall/users/" .. userId .. "/posts"
  405.     return HttpClient.deleteRequest(newUrl, API_KEY)
  406. end
  407. --Search for groups by keyword.
  408. function GroupsAPI.SearchForGroupsByKeyword(keyword: string, prioritizeExactMatch: boolean, limit: string, cursor: string): any -- GET
  409.     local newUrl = API_URL .. "/v1/groups/search"
  410.     local dataBody = {
  411.         ["keyword"] = keyword,
  412.         ["prioritizeExactMatch"] = prioritizeExactMatch,
  413.         ["limit"] = limit,
  414.         ["cursor"] = cursor,
  415.     }
  416.     return HttpClient.getRequest(newUrl, API_KEY, BrickColor)
  417. end
  418. --Looks up groups by a name. Prioritizes an exact match as the first result.
  419. function GroupsAPI.LookUpGroupByName(groupName: string): any -- GET
  420.     local newUrl = API_URL .. "/v1/groups/search/lookup"
  421.     return HttpClient.getRequest(newUrl, API_KEY, {["groupName"] = groupName})
  422. end
  423. --Get suggested groups and other miscellaneous information needed for the group/join page like flags
  424. function GroupsAPI.GetGroupSearchMetadata(): any -- GET
  425.     local newUrl = API_URL .. "/v1/groups/search/metadata"
  426.     return HttpClient.getRequest(newUrl, API_KEY)
  427. end
  428. --Gets the Roles by their ids.
  429. function GroupsAPI.GetGroupRoleById(ids: {number}): any -- GET
  430.     local newUrl = API_URL .. "/v1/roles"
  431.     return HttpClient.getRequest(newUrl, API_KEY, {["ids"] = ids})
  432. end
  433. --Gets a user's primary group.
  434. function GroupsAPI.GetPrimaryGroupByUserId(userId: number): any -- GET
  435.     local newUrl = API_URL .. "/v1/users/" .. userId .. "/groups/primary/role"
  436.     return HttpClient.getRequest(newUrl, API_KEY)
  437. end
  438. --Removes the authenticated user's primary group
  439. function GroupsAPI.RemovePrimaryGroup(): any -- DELETE
  440.     local newUrl = API_URL .. "/v1/user/groups/primary"
  441.     return HttpClient.deleteRequest(newUrl, API_KEY)
  442. end
  443. --Sets the authenticated user's primary group
  444. function GroupsAPI.SetPrimaryGroup(groupId: number): any -- POST
  445.     local newUrl = API_URL .. "/v1/user/groups/primary"
  446.     return HttpClient.postRequest(newUrl, API_KEY, {["groupId"] = groupId})
  447. end
  448. --Creates new group roleset.
  449. function GroupsAPI.CreateNewGroupRoleset(groupId: number, name: string, description: string, rank: number, usingGroupFunds: boolean): any -- POST
  450.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/rolesets/create"
  451.     local dataBody = {
  452.         ["name"] = name,
  453.         ["description"] = description,
  454.         ["rank"] = rank,
  455.         ["usingGroupFunds"] = usingGroupFunds
  456.     }
  457.     return HttpClient.postRequest(newUrl, API_KEY, dataBody)
  458. end
  459. --Deletes existing group roleset.
  460. function GroupsAPI.DeleteGroupRoleset(groupId: number, roleSetId: number): any -- DELETE
  461.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/rolesets/" .. roleSetId
  462.     return HttpClient.deleteRequest(newUrl, API_KEY)
  463. end
  464. --Updates existing group roleset.
  465. function GroupsAPI.UpdateGroupRoleset(groupId: number, roleSetId: number, name: string, description: string, rank: number): any -- PATCH
  466.     local newUrl = API_URL .. "/v1/groups/" .. groupId .. "/rolesets/" .. roleSetId
  467.     local dataBody = {
  468.         ["name"] = name,
  469.         ["description"] = description,
  470.         ["rank"] = rank
  471.     }
  472.     return HttpClient.patchRequest(newUrl, API_KEY, dataBody)
  473. end
  474. return GroupsAPI
Advertisement
Add Comment
Please, Sign In to add comment