-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import LeagueSuperclass from './LeagueSuperclass' | ||
import Request from 'RequestClient/Request' | ||
import METHOD_NAMES from 'Enums/method-names' | ||
|
||
class LeagueEntriesEndpointV4 extends LeagueSuperclass { | ||
constructor(config, limiter) { | ||
super() | ||
|
||
this.config = config | ||
|
||
this.by = { | ||
summonerID: this.summonerID.bind(this), | ||
} | ||
|
||
this.list = this.list.bind(this) | ||
|
||
this.limiter = limiter | ||
} | ||
|
||
/** | ||
* Get league entries in all queues for a given summoner ID. | ||
* | ||
* Implements GET `/lol/league/v4/entries/by-summoner/{encryptedSummonerId}`. | ||
* | ||
* @param {string} encryptedSummonerId - The encrypted id of the summoner. | ||
*/ | ||
summonerID(summonerID) { | ||
return new Request( | ||
this.config, | ||
this.serviceName, | ||
`entries/by-summoner/${summonerID}`, | ||
METHOD_NAMES.LEAGUE.GET_LEAGUE_ENTRIES_BY_SUMMONER_ID_V4, | ||
'GET', | ||
this.limiter, | ||
null, | ||
false, | ||
4, | ||
) | ||
} | ||
|
||
/** | ||
* Get all the league entries. | ||
* | ||
* Implements GET `/lol/league/v4/entries/{queue}/{tier}/{division}`. | ||
* | ||
* @param {string} queue - The queue to search for. e.g. RANKED_SOLO_5x5 | ||
* @param {string} tier - The tier to search for. e.g. DIAMOND | ||
* @param {string} division - The division to search for. e.g. I | ||
*/ | ||
list(queue, tier, division) { | ||
return new Request( | ||
this.config, | ||
this.serviceName, | ||
`entries/${queue}/${tier}/${division}`, | ||
METHOD_NAMES.LEAGUE.GET_LEAGUE_ENTRIES_BY_QUEUE_TIER_DIVISION_V4, | ||
'GET', | ||
this.limiter, | ||
null, | ||
false, | ||
4, | ||
) | ||
} | ||
} | ||
|
||
export default LeagueEntriesEndpointV4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
test/unit/endpoints/LeagueEndpoint/LeagueEntriesEndpointV4.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { expect, should, assert } from 'chai' | ||
|
||
import TestUtils from '../../../TestUtils' | ||
const { kaynInstance, defaultConfig } = TestUtils | ||
|
||
const { kayn, REGIONS, METHOD_TYPES } = kaynInstance | ||
import LeagueEntriesEndpointV4 from '../../../../lib/Endpoints/LeagueEndpoint/LeagueEntriesEndpointV4' | ||
import mocks from '../../../mocks' | ||
|
||
describe('LeagueEntriesEndpointV4', function() { | ||
this.timeout(0) | ||
|
||
beforeEach(function() { | ||
this.LeagueEntries = new LeagueEntriesEndpointV4(defaultConfig) | ||
}) | ||
|
||
describe('.by.summonerID', function() { | ||
it('should have the correct payload #1', function() { | ||
const { payload } = this.LeagueEntries.by.summonerID('abcdefgh') | ||
expect(payload).to.deep.equal({ | ||
method: 'GET', | ||
serviceName: 'league', | ||
endpoint: 'entries/by-summoner/abcdefgh', | ||
query: [], | ||
region: '', | ||
isTournament: false, | ||
version: 4, | ||
}) | ||
}) | ||
|
||
it('should have the correct method name', function() { | ||
const { methodName } = this.LeagueEntries.by | ||
.summonerID('abcdefgh') | ||
.region('na') | ||
expect(methodName).to.equal( | ||
'LEAGUE.GET_LEAGUE_ENTRIES_BY_SUMMONER_ID_V4', | ||
) | ||
}) | ||
}) | ||
|
||
describe('.list', function() { | ||
it('should have the correct payload #1', function() { | ||
const { payload } = this.LeagueEntries.list( | ||
'RANKED_SOLO_5x5', | ||
'DIAMOND', | ||
'I', | ||
).region('kr') | ||
expect(payload).to.deep.equal({ | ||
method: 'GET', | ||
serviceName: 'league', | ||
endpoint: 'entries/RANKED_SOLO_5x5/DIAMOND/I', | ||
query: [], | ||
region: 'kr', | ||
isTournament: false, | ||
version: 4, | ||
}) | ||
}) | ||
|
||
it('should have the correct method name', function() { | ||
const { methodName } = this.LeagueEntries.list( | ||
'RANKED_SOLO_5x5', | ||
'DIAMOND', | ||
'I', | ||
).region('na') | ||
expect(methodName).to.equal( | ||
'LEAGUE.GET_LEAGUE_ENTRIES_BY_QUEUE_TIER_DIVISION_V4', | ||
) | ||
}) | ||
}) | ||
}) |