From 1c54dc7a35b3193ee8aa56904f5be0717e2c0155 Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 18:00:57 +0100 Subject: [PATCH 01/12] Created getClubCampaignById --- src/lib/api/live-services.ts | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index c80d4b5..0dbd587 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -102,6 +102,36 @@ export const getClubCampaigns = async ( return response['data'] } +/** + * Find a campaign by passing its club ID and its own ID + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} clubId - Club ID + * @param {number} campaignId - Campaign ID + * + */ + export const getClubCampaignById = async ( + accessToken: string, + clubId: number, + campaignId: number, +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/' + + clubId + + '/campaign/' + + campaignId, + method: 'GET', + headers, + }) + + return response['data'] +} /** * Returns your record in everymap of that group, and your position in each zone @@ -540,6 +570,21 @@ export interface IclubCampaigns { itemCount: number } +export interface IclubCampaign { + clubId: number + clubIconUrl: string + clubDecalUrl: string + campaignId: number + publicationTimestamp: number + publishedOn: number + creationTimestamp: number + activityId: number + mediaUrl: string + name: string + campaign: campaign + popularityLevel: number +} + type clubCampaign = { clubId: number clubIconUrl: string From 9838d28678443abd577c271fdecb2cb945631139 Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 18:02:24 +0100 Subject: [PATCH 02/12] Updated getClubCampaignById desc --- src/lib/api/live-services.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 0dbd587..9d5fd7a 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -103,7 +103,7 @@ export const getClubCampaigns = async ( return response['data'] } /** - * Find a campaign by passing its club ID and its own ID + * Returns info about the campaign based on both the campaignId and the clubId (used in Clubs) * * ## **Requires level 2 authentication** * From e5508d4efe0b16c519bb4437498cef70390dc0bd Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 18:10:26 +0100 Subject: [PATCH 03/12] Added getClubRoomById --- src/lib/api/live-services.ts | 46 ++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 9d5fd7a..3a1149d 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -133,6 +133,37 @@ export const getClubCampaigns = async ( return response['data'] } +/** + * Returns info about the room based on both the roomId and the clubId (used in Clubs) + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} clubId - Club ID + * @param {number} roomId - Room ID + * + */ + export const getClubRoomById = async ( + accessToken: string, + clubId: number, + roomId: number, +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/' + + clubId + + '/room/' + + roomId, + method: 'GET', + headers, + }) + + return response['data'] +} + /** * Returns your record in everymap of that group, and your position in each zone * @@ -660,6 +691,21 @@ export interface IclubRooms { itemCount: number } +export interface IclubRoom { + id: number + clubId: number + nadeo: boolean + roomId: number + campaignId: unknown + playerServerLogin: unknown + activityId: number + mediaUrl: string + name: string + room: room + popularityLevel: number + creationTimestamp: number +} + type clubRoom = { id: number clubId: number From b9822f35bbc4788312bfa408007f75eb32374add Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 18:47:22 +0100 Subject: [PATCH 04/12] Moved getClubRoomById to make more sense --- src/lib/api/live-services.ts | 62 ++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 3a1149d..d65c1c3 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -133,37 +133,6 @@ export const getClubCampaigns = async ( return response['data'] } -/** - * Returns info about the room based on both the roomId and the clubId (used in Clubs) - * - * ## **Requires level 2 authentication** - * - * @category level 2 - * @param {string} accessToken - Access token - * @param {number} clubId - Club ID - * @param {number} roomId - Room ID - * - */ - export const getClubRoomById = async ( - accessToken: string, - clubId: number, - roomId: number, -): Promise => { - const headers = setHeaders(accessToken, 'nadeo') - const response = await axios({ - url: - urls.liveServices + - '/api/token/club/' + - clubId + - '/room/' + - roomId, - method: 'GET', - headers, - }) - - return response['data'] -} - /** * Returns your record in everymap of that group, and your position in each zone * @@ -398,6 +367,37 @@ export const getClubRooms = async ( return response['data'] } +/** + * Returns info about the room based on both the roomId and the clubId (used in Clubs) + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} clubId - Club ID + * @param {number} roomId - Room ID + * + */ + export const getClubRoomById = async ( + accessToken: string, + clubId: number, + roomId: number, +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/' + + clubId + + '/room/' + + roomId, + method: 'GET', + headers, + }) + + return response['data'] +} + /** * Obtain the information about the current arcade room and the next room * From 9e5804acf0ceaf2d2acdf23ea8877bce65156e10 Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 19:01:53 +0100 Subject: [PATCH 05/12] Added getClubSkins --- src/lib/api/live-services.ts | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index d65c1c3..6f2b816 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -418,6 +418,46 @@ export const getArcadeRooms = async (accessToken: string): Promise return response['data'] } +/** + * This is used to obtain the skins in the Create section of the game + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} offset - Offset (default = 0) + * @param {number} length - Length (default = 75) + * @param {string} sort - Sort (default = 'popularity') + * @param {string} order - Order (default = 'DESC') + * + */ +export const getClubSkins = async ( + accessToken: string, + offset: number = 0, + length: number = 75, + sort: string = 'popularity', + order: string = 'DESC', +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/room?offset=' + + offset + + '&length=' + + length + + '&sort=' + + sort + + '&order=' + + order, + method: 'GET', + headers, + }) + + return response['data'] +} + + /** * List all the clubs in the club section * @@ -761,6 +801,25 @@ type timeSlot = { mediaUrl: string } +export interface IclubSkins { + clubBucketList: clubSkin[] + maxPage: number + itemCount: number +} + +type clubSkin = { + type: string + bucketItemCount: number + popularityLevel: number + popularityValue: number + medialUrl: string + id: number + clubId: number + clubName: string + name: string + creationTimestamp: number +} + export interface Iclubs { clubList: unknown[] maxPage: number From f782a9d318927885c639a66145c206cc7c8fdb0d Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 19:06:41 +0100 Subject: [PATCH 06/12] Updated small descs --- src/lib/api/live-services.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 6f2b816..201e0cc 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -103,7 +103,7 @@ export const getClubCampaigns = async ( return response['data'] } /** - * Returns info about the campaign based on both the campaignId and the clubId (used in Clubs) + * Obtain all the information about the campaigns of a club * * ## **Requires level 2 authentication** * @@ -368,7 +368,7 @@ export const getClubRooms = async ( } /** - * Returns info about the room based on both the roomId and the clubId (used in Clubs) + * Obtain all the information about the rooms of a club * * ## **Requires level 2 authentication** * From 72a6055dcea1b4134eddb2859cedf6fec30bdf8c Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 19:13:28 +0100 Subject: [PATCH 07/12] Added getClubSkinById --- src/lib/api/live-services.ts | 63 ++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 201e0cc..7e91726 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -457,6 +457,44 @@ export const getClubSkins = async ( return response['data'] } +/** + * Obtain all the information about the skins of a club + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} clubId - Club ID + * @param {number} roomId - Room ID + * @param {number} offset - Offset (default = 0) + * @param {number} length - Length (default = 24) + * + */ + export const getClubSkinById = async ( + accessToken: string, + clubId: number, + skinId: number, + offset: number = 0, + length: number = 24, +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/' + + clubId + + '/bucket/' + + skinId + + '?offset=' + + offset + + '&length=' + + length, + method: 'GET', + headers, + }) + + return response['data'] +} /** * List all the clubs in the club section @@ -802,12 +840,12 @@ type timeSlot = { } export interface IclubSkins { - clubBucketList: clubSkin[] + clubBucketList: clubSkins[] maxPage: number itemCount: number } -type clubSkin = { +type clubSkins = { type: string bucketItemCount: number popularityLevel: number @@ -820,6 +858,27 @@ type clubSkin = { creationTimestamp: number } +export interface IclubSkin { + type: string + bucketItemList: clubSkin[] + bucketItemCount: number + popularityLevel: number + popularityValue: number + medialUrl: string + id: number + clubId: number + clubName: string + name: string + creationTimestamp: number +} + +type clubSkin = { + itemId: string + position: number + description: string + mediaUrls: unknown[] +} + export interface Iclubs { clubList: unknown[] maxPage: number From 538f4886f49a4bde5821ecb768e6111659758569 Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 19:24:47 +0100 Subject: [PATCH 08/12] Added getClubCompetitions --- src/lib/api/live-services.ts | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 7e91726..2894053 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -527,6 +527,45 @@ export const getClubs = async ( return response['data'] } +/** + * This is used to obtain the competitions in the Events section of the game + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} offset - Offset (default = 0) + * @param {number} length - Length (default = 75) + * @param {string} sort - Sort (default = 'popularity') + * @param {string} order - Order (default = 'DESC') + * + */ + export const getClubCompetitions = async ( + accessToken: string, + offset: number = 0, + length: number = 75, + sort: string = 'popularity', + order: string = 'DESC', +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/competition?offset=' + + offset + + '&length=' + + length + + '&sort=' + + sort + + '&order=' + + order, + method: 'GET', + headers, + }) + + return response['data'] +} + /** * Obtain all the information about the members of a club * @@ -879,6 +918,24 @@ type clubSkin = { mediaUrls: unknown[] } +export interface IclubCompetitions { + clubCompetitionList: competition[] + maxPage: number + itemCount: number +} + +type competition = { + competitionId: number + mediaUrl: string + popularityLevel: number + popularityValue: number + id: number + clubId: number + clubName: string + name: string + creationTimestamp: number +} + export interface Iclubs { clubList: unknown[] maxPage: number From 3cd741944b33a10d1febd6ec593ab0efd0d5de1a Mon Sep 17 00:00:00 2001 From: Sigeth Date: Sun, 14 Mar 2021 19:33:33 +0100 Subject: [PATCH 09/12] Added getClubById --- src/lib/api/live-services.ts | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 2894053..8b437f5 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -527,6 +527,33 @@ export const getClubs = async ( return response['data'] } +/** + * Obtain all the information about a club + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} clubId - Club ID + * + */ + export const getClubById = async ( + accessToken: string, + clubId: number, +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/' + + clubId, + method: 'GET', + headers, + }) + + return response['data'] +} + /** * This is used to obtain the competitions in the Events section of the game * @@ -942,6 +969,26 @@ export interface Iclubs { clubCount: number } +export interface Iclub { + id: number + name: string + tag: string + description: string + iconUrl: string + logoUrl: string + decalUrl: string + screen16x9Url: string + decalSponsor4x1Url: string + screen8x1Url: string + screen16x1Url: string + verticalUrl: string + backgroundUrl: string + creationTimestamp: number + popularityLevel: number + state: string + featured: boolean +} + export interface IclubMembers { clubMemberList: clubMember[] maxPage: number From 22c73c5b895c9e3b4649b543953aaf36a2704ee6 Mon Sep 17 00:00:00 2001 From: Sigeth Date: Mon, 15 Mar 2021 12:21:07 +0100 Subject: [PATCH 10/12] Added getClubActivitiesById --- src/lib/api/live-services.ts | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index 8b437f5..a433c7c 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -593,6 +593,45 @@ export const getClubs = async ( return response['data'] } +/** + * This is used to obtain the competitions in the Events section of the game + * + * ## **Requires level 2 authentication** + * + * @category level 2 + * @param {string} accessToken - Access token + * @param {number} clubId - Club ID + * @param {number} offset - Offset (default = 0) + * @param {number} length - Length (default = 75) + * @param {number} active - Active (default = 1) + * + */ + export const getClubActivitiesById = async ( + accessToken: string, + clubId: number, + offset: number = 0, + length: number = 75, + active: number = 1, +): Promise => { + const headers = setHeaders(accessToken, 'nadeo') + const response = await axios({ + url: + urls.liveServices + + '/api/token/club/' + + clubId + + 'activity?offset=' + + offset + + '&length=' + + length + + '&active=' + + active, + method: 'GET', + headers, + }) + + return response['data'] +} + /** * Obtain all the information about the members of a club * @@ -963,6 +1002,27 @@ type competition = { creationTimestamp: number } +export interface IclubActivities { + activityList: activity[] + maxPage: number + itemCount: number +} + +type activity = { + id: number + name: string + activityType: string + activityId: number + targetActivityId: number + campaignId: number + position: number + public: boolean + active: boolean + mediaUrl: string + externalId: number + password: boolean +} + export interface Iclubs { clubList: unknown[] maxPage: number From 8171036ce8cfcafc11099f159018ad2b475838aa Mon Sep 17 00:00:00 2001 From: Sigeth Date: Mon, 22 Mar 2021 19:56:45 +0100 Subject: [PATCH 11/12] Changed getClubSkinById to getClubBucketById I realised that "buckets" are used to store items, so it can leads to a skin-upload, but also a map-upload or an item-upload --- src/lib/api/live-services.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/api/live-services.ts b/src/lib/api/live-services.ts index a433c7c..8c74574 100644 --- a/src/lib/api/live-services.ts +++ b/src/lib/api/live-services.ts @@ -470,13 +470,13 @@ export const getClubSkins = async ( * @param {number} length - Length (default = 24) * */ - export const getClubSkinById = async ( + export const getClubBucketById = async ( accessToken: string, clubId: number, - skinId: number, + bucketId: number, offset: number = 0, length: number = 24, -): Promise => { +): Promise => { const headers = setHeaders(accessToken, 'nadeo') const response = await axios({ url: @@ -484,7 +484,7 @@ export const getClubSkins = async ( '/api/token/club/' + clubId + '/bucket/' + - skinId + + bucketId + '?offset=' + offset + '&length=' + @@ -963,9 +963,9 @@ type clubSkins = { creationTimestamp: number } -export interface IclubSkin { +export interface IclubBucket { type: string - bucketItemList: clubSkin[] + bucketItemList: bucketItem[] bucketItemCount: number popularityLevel: number popularityValue: number @@ -977,7 +977,7 @@ export interface IclubSkin { creationTimestamp: number } -type clubSkin = { +type bucketItem = { itemId: string position: number description: string From 523e16f8baa5f0140a561984cc19c0bc8eddd52a Mon Sep 17 00:00:00 2001 From: Sigeth Date: Mon, 22 Mar 2021 20:47:33 +0100 Subject: [PATCH 12/12] Added some tests --- src/lib/api/live-services.spec.ts | 88 +++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/lib/api/live-services.spec.ts b/src/lib/api/live-services.spec.ts index ea49c49..937bd29 100644 --- a/src/lib/api/live-services.spec.ts +++ b/src/lib/api/live-services.spec.ts @@ -7,6 +7,7 @@ import { getSeasons, getTOTDs, getClubCampaigns, + getClubCampaignById, getMyGroupRecords, getMyPositionGroup, getTopPlayersGroup, @@ -14,8 +15,14 @@ import { getTopGroupPlayersMap, getSurroundingPlayersMap, getClubRooms, + getClubRoomById, getArcadeRooms, + getClubSkins, + getClubBucketById, getClubs, + getClubById, + getClubCompetitions, + getClubActivitiesById, getClubMembers, getPlayerRankings, getLeaderboardsAroundScore, @@ -63,6 +70,19 @@ test('List club campaigns', async t => { } }) +test('Get a specific club campaign', async t => { + try { + const response = await getClubCampaignById( + t.context.account.lv2liveAccessToken, + 0, + 6151 + ) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + test('Get my group records', async t => { try { const response = await getMyGroupRecords( @@ -160,6 +180,19 @@ test('Get club rooms', async t => { } }) +test('Get a specific club room', async t => { + try { + const response = await getClubRoomById( + t.context.account.lv2liveAccessToken, + 41, + 766 + ) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + test('Get arcade rooms', async t => { try { const response = await getArcadeRooms(t.context.account.lv2liveAccessToken) @@ -169,6 +202,28 @@ test('Get arcade rooms', async t => { } }) +test('List club skins', async t => { + try { + const response = await getClubSkins(t.context.account.lv2liveAccessToken) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + +test('Get a specific club bucket', async t => { + try { + const response = await getClubBucketById( + t.context.account.lv2liveAccessToken, + 383, + 100982 + ) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + test('Get clubs', async t => { try { const response = await getClubs(t.context.account.lv2liveAccessToken) @@ -178,6 +233,39 @@ test('Get clubs', async t => { } }) +test('Get a specific club', async t => { + try { + const response = await getClubById( + t.context.account.lv2liveAccessToken, + 383 + ) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + +test('List club competitions', async t => { + try { + const response = await getClubCompetitions(t.context.account.lv2liveAccessToken) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + +test('Get activities from a specific club', async t => { + try { + const response = await getClubActivitiesById( + t.context.account.lv2liveAccessToken, + 383 + ) + t.assert(response) + } catch (err) { + t.fail(JSON.stringify(err.response.data)) + } +}) + test('Get club members', async t => { try { const response = await getClubMembers(t.context.account.lv2liveAccessToken, 1)