@@ -19,6 +19,37 @@ let baseURL: String = "http://pokeapi.co/api/v2"
1919
2020// MARK: Classes
2121
22+ /*
23+ id The identifier for this language resource integer
24+ name The name for this language resource string
25+ official Whether or not the games are published in this language boolean
26+ iso639 The two-letter code of the country where this language is spoken. Note that it is not unique. string
27+ iso3166 The two-letter code of the language. Note that it is not unique. string
28+ names The name of this language listed in different languages list Name
29+ */
30+ public class PKMLanguage : Mappable {
31+ public var id : Int ?
32+ public var name : String ?
33+ public var official : Bool ?
34+ public var iso639 : String ?
35+ public var iso3166 : String ?
36+ public var names : [ PKMName ] ?
37+
38+ required public init ? ( _ map: Map ) {
39+
40+ }
41+
42+ public func mapping( map: Map ) {
43+ id <- map [ " id " ]
44+ name <- map [ " name " ]
45+ official <- map [ " official " ]
46+ iso639 <- map [ " iso639 " ]
47+ iso3166 <- map [ " iso3166 " ]
48+ names <- map [ " names " ]
49+ }
50+ }
51+
52+
2253/*
2354slot The order the Pokémon's types are listed in integer
2455pokemon The Pokémon that has the referenced type NamedAPIResource (Pokemon)
@@ -4007,6 +4038,38 @@ public func fetchType(typeId: String) -> Promise<PKMType>{
40074038 reject ( response. result. error!)
40084039 }
40094040
4041+ }
4042+ }
4043+ }
4044+
4045+ //Language
4046+
4047+ public func fetchLanguages( ) -> Promise < PKMPagedObject > {
4048+ return Promise { fulfill, reject in
4049+ let URL = baseURL + " /language "
4050+
4051+ Alamofire . request ( . GET, URL) . responseObject ( ) { ( response: Response < PKMPagedObject , NSError > ) in
4052+ if ( response. result. isSuccess) {
4053+ fulfill ( response. result. value!)
4054+ } else {
4055+ reject ( response. result. error!)
4056+ }
4057+ }
4058+ }
4059+ }
4060+
4061+ public func fetchLanguage( languageId: String ) -> Promise < PKMLanguage > {
4062+ return Promise { fulfill, reject in
4063+ let URL = baseURL + " /language/ " + languageId
4064+
4065+ Alamofire . request ( . GET, URL) . responseObject ( ) { ( response: Response < PKMLanguage , NSError > ) in
4066+
4067+ if ( response. result. isSuccess) {
4068+ fulfill ( response. result. value!)
4069+ } else {
4070+ reject ( response. result. error!)
4071+ }
4072+
40104073 }
40114074 }
40124075}
0 commit comments