Skip to content

Commit c4188f7

Browse files
authored
Merge pull request #77 from PokeAPI/cleanup
Add support for machines and form names
2 parents 19e050f + 3ef3215 commit c4188f7

28 files changed

+515
-310
lines changed

src/main/kotlin/me/sargunvohra/lib/pokekotlin/client/PokeApi.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import me.sargunvohra.lib.pokekotlin.model.Language
2626
import me.sargunvohra.lib.pokekotlin.model.Location
2727
import me.sargunvohra.lib.pokekotlin.model.LocationArea
2828
import me.sargunvohra.lib.pokekotlin.model.LocationAreaEncounter
29+
import me.sargunvohra.lib.pokekotlin.model.Machine
2930
import me.sargunvohra.lib.pokekotlin.model.Move
3031
import me.sargunvohra.lib.pokekotlin.model.MoveAilment
3132
import me.sargunvohra.lib.pokekotlin.model.MoveBattleStyle
@@ -115,6 +116,8 @@ interface PokeApi {
115116

116117
fun getRegionList(offset: Int, limit: Int): NamedApiResourceList
117118

119+
fun getMachineList(offset: Int, limit: Int): ApiResourceList
120+
118121
fun getAbilityList(offset: Int, limit: Int): NamedApiResourceList
119122

120123
fun getCharacteristicList(offset: Int, limit: Int): ApiResourceList
@@ -209,6 +212,8 @@ interface PokeApi {
209212

210213
fun getRegion(id: Int): Region
211214

215+
fun getMachine(id: Int): Machine
216+
212217
fun getAbility(id: Int): Ability
213218

214219
fun getCharacteristic(id: Int): Characteristic

src/main/kotlin/me/sargunvohra/lib/pokekotlin/client/PokeApiClient.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,13 @@ class PokeApiClient(
139139

140140
// endregion
141141

142+
// region Machines
143+
144+
override fun getMachineList(offset: Int, limit: Int) =
145+
service.getMachineList(offset, limit).result()
146+
147+
// endregion Machines
148+
142149
// region Pokemon
143150

144151
override fun getAbilityList(offset: Int, limit: Int) =
@@ -290,6 +297,12 @@ class PokeApiClient(
290297

291298
// endregion Locations
292299

300+
// region Machines
301+
302+
override fun getMachine(id: Int) = service.getMachine(id).result()
303+
304+
// endregion Machines
305+
293306
// region Pokemon
294307

295308
override fun getAbility(id: Int) = service.getAbility(id).result()

src/main/kotlin/me/sargunvohra/lib/pokekotlin/client/PokeApiService.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import me.sargunvohra.lib.pokekotlin.model.Language
2626
import me.sargunvohra.lib.pokekotlin.model.Location
2727
import me.sargunvohra.lib.pokekotlin.model.LocationArea
2828
import me.sargunvohra.lib.pokekotlin.model.LocationAreaEncounter
29+
import me.sargunvohra.lib.pokekotlin.model.Machine
2930
import me.sargunvohra.lib.pokekotlin.model.Move
3031
import me.sargunvohra.lib.pokekotlin.model.MoveAilment
3132
import me.sargunvohra.lib.pokekotlin.model.MoveBattleStyle
@@ -277,6 +278,16 @@ internal interface PokeApiService {
277278

278279
// endregion
279280

281+
// region Machines
282+
283+
@GET("machine/")
284+
fun getMachineList(
285+
@Query("offset") offset: Int,
286+
@Query("limit") limit: Int
287+
): Call<ApiResourceList>
288+
289+
// endregion
290+
280291
// region Pokemon
281292

282293
@GET("ability/")
@@ -508,6 +519,13 @@ internal interface PokeApiService {
508519

509520
// endregion Locations
510521

522+
// region Machines
523+
524+
@GET("machine/{id}/")
525+
fun getMachine(@Path("id") id: Int): Call<Machine>
526+
527+
// endregion
528+
511529
// region Pokemon
512530

513531
@GET("ability/{id}/")

src/main/kotlin/me/sargunvohra/lib/pokekotlin/client/RxPokeApi.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import me.sargunvohra.lib.pokekotlin.model.Language
2626
import me.sargunvohra.lib.pokekotlin.model.Location
2727
import me.sargunvohra.lib.pokekotlin.model.LocationArea
2828
import me.sargunvohra.lib.pokekotlin.model.LocationAreaEncounter
29+
import me.sargunvohra.lib.pokekotlin.model.Machine
2930
import me.sargunvohra.lib.pokekotlin.model.Move
3031
import me.sargunvohra.lib.pokekotlin.model.MoveAilment
3132
import me.sargunvohra.lib.pokekotlin.model.MoveBattleStyle
@@ -116,6 +117,8 @@ interface RxPokeApi {
116117

117118
fun getRegionList(offset: Int, limit: Int): Observable<NamedApiResourceList>
118119

120+
fun getMachineList(offset: Int, limit: Int): Observable<ApiResourceList>
121+
119122
fun getAbilityList(offset: Int, limit: Int): Observable<NamedApiResourceList>
120123

121124
fun getCharacteristicList(offset: Int, limit: Int): Observable<ApiResourceList>
@@ -210,6 +213,8 @@ interface RxPokeApi {
210213

211214
fun getRegion(id: Int): Observable<Region>
212215

216+
fun getMachine(id: Int): Observable<Machine>
217+
213218
fun getAbility(id: Int): Observable<Ability>
214219

215220
fun getCharacteristic(id: Int): Observable<Characteristic>

src/main/kotlin/me/sargunvohra/lib/pokekotlin/client/RxPokeApiClient.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package me.sargunvohra.lib.pokekotlin.client
22

33
class RxPokeApiClient(
4-
private val clientConfig: ClientConfig = ClientConfig()
4+
clientConfig: ClientConfig = ClientConfig()
55
) : RxPokeApi {
66

77
private val service = RxPokeApiServiceImpl(clientConfig)
@@ -126,6 +126,12 @@ class RxPokeApiClient(
126126

127127
// endregion
128128

129+
// region Machines
130+
131+
override fun getMachineList(offset: Int, limit: Int) = service.getMachineList(offset, limit)
132+
133+
// endregion
134+
129135
// region Pokemon
130136

131137
override fun getAbilityList(offset: Int, limit: Int) = service.getAbilityList(offset, limit)
@@ -270,6 +276,12 @@ class RxPokeApiClient(
270276

271277
// endregion Locations
272278

279+
// region Machines
280+
281+
override fun getMachine(id: Int) = service.getMachine(id)
282+
283+
// endregion Machines
284+
273285
// region Pokemon
274286

275287
override fun getAbility(id: Int) = service.getAbility(id)

src/main/kotlin/me/sargunvohra/lib/pokekotlin/client/RxPokeApiService.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import me.sargunvohra.lib.pokekotlin.model.Language
2626
import me.sargunvohra.lib.pokekotlin.model.Location
2727
import me.sargunvohra.lib.pokekotlin.model.LocationArea
2828
import me.sargunvohra.lib.pokekotlin.model.LocationAreaEncounter
29+
import me.sargunvohra.lib.pokekotlin.model.Machine
2930
import me.sargunvohra.lib.pokekotlin.model.Move
3031
import me.sargunvohra.lib.pokekotlin.model.MoveAilment
3132
import me.sargunvohra.lib.pokekotlin.model.MoveBattleStyle
@@ -277,6 +278,16 @@ internal interface RxPokeApiService {
277278

278279
// endregion
279280

281+
// region Machines
282+
283+
@GET("machine/")
284+
fun getMachineList(
285+
@Query("offset") offset: Int,
286+
@Query("limit") limit: Int
287+
): Observable<ApiResourceList>
288+
289+
// endregion
290+
280291
// region Pokemon
281292

282293
@GET("ability/")
@@ -508,6 +519,13 @@ internal interface RxPokeApiService {
508519

509520
// endregion Locations
510521

522+
// region Machines
523+
524+
@GET("machine/{id}/")
525+
fun getMachine(@Path("id") id: Int): Observable<Machine>
526+
527+
// endregion
528+
511529
// region Pokemon
512530

513531
@GET("ability/{id}/")

src/main/kotlin/me/sargunvohra/lib/pokekotlin/model/Language.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package me.sargunvohra.lib.pokekotlin.model
2+
3+
data class Machine(
4+
val id: Int,
5+
val item: NamedApiResource,
6+
val move: NamedApiResource,
7+
val versionGroup: NamedApiResource
8+
)

src/main/kotlin/me/sargunvohra/lib/pokekotlin/model/items.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ data class Item(
1414
val names: List<Name>,
1515
val heldByPokemon: List<ItemHolderPokemon>,
1616
val babyTriggerFor: ApiResource?,
17-
val sprites: ItemSprites
17+
val sprites: ItemSprites,
18+
val machines: List<MachineVersionDetail>
1819
)
1920

2021
data class ItemSprites(

src/main/kotlin/me/sargunvohra/lib/pokekotlin/model/moves.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ data class Move(
2323
val pastValues: List<PastMoveStatValues>,
2424
val statChanges: List<MoveStatChange>,
2525
val target: NamedApiResource,
26-
val type: NamedApiResource
26+
val type: NamedApiResource,
27+
val machines: List<MachineVersionDetail>
2728
)
2829

2930
data class ContestComboSets(

0 commit comments

Comments
 (0)