Update petstore swift client

This commit is contained in:
Thomas Gilbert 2016-03-02 08:14:37 +01:00
parent 785136e991
commit dea699f1ef
12 changed files with 312 additions and 189 deletions

View File

@ -129,7 +129,7 @@ public class PetAPI: APIBase {
Finds Pets by status
- parameter status: (query) Status values that need to be considered for filter
- parameter status: (query) Status values that need to be considered for query
- parameter completion: completion handler to receive the data and the error objects
*/
public class func findPetsByStatus(status status: [String]?, completion: ((data: [Pet]?, error: ErrorType?) -> Void)) {
@ -142,7 +142,7 @@ public class PetAPI: APIBase {
Finds Pets by status
- parameter status: (query) Status values that need to be considered for filter
- parameter status: (query) Status values that need to be considered for query
- returns: Promise<[Pet]>
*/
public class func findPetsByStatus(status status: [String]?) -> Promise<[Pet]> {
@ -162,24 +162,24 @@ public class PetAPI: APIBase {
Finds Pets by status
- GET /pet/findByStatus
- Multiple status values can be provided with comma seperated strings
- Multiple status values can be provided with comma separated strings
- OAuth:
- type: oauth2
- name: petstore_auth
- examples: [{example=[ {
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
- examples: [{contentType=application/json, example=[ {
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"id" : 123456789,
"category" : {
"id" : 123456789,
"name" : "aeiou"
"name" : "aeiou",
"id" : 123456789
},
"status" : "aeiou",
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
} ], contentType=application/json}, {example=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -188,21 +188,21 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
- examples: [{example=[ {
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
</Pet>}]
- examples: [{contentType=application/json, example=[ {
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"id" : 123456789,
"category" : {
"id" : 123456789,
"name" : "aeiou"
"name" : "aeiou",
"id" : 123456789
},
"status" : "aeiou",
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
} ], contentType=application/json}, {example=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -211,9 +211,9 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
</Pet>}]
- parameter status: (query) Status values that need to be considered for filter
- parameter status: (query) Status values that need to be considered for query
- returns: RequestBuilder<[Pet]>
*/
@ -272,20 +272,20 @@ public class PetAPI: APIBase {
- OAuth:
- type: oauth2
- name: petstore_auth
- examples: [{example=[ {
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
- examples: [{contentType=application/json, example=[ {
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"id" : 123456789,
"category" : {
"id" : 123456789,
"name" : "aeiou"
"name" : "aeiou",
"id" : 123456789
},
"status" : "aeiou",
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
} ], contentType=application/json}, {example=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -294,21 +294,21 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
- examples: [{example=[ {
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
</Pet>}]
- examples: [{contentType=application/json, example=[ {
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"id" : 123456789,
"category" : {
"id" : 123456789,
"name" : "aeiou"
"name" : "aeiou",
"id" : 123456789
},
"status" : "aeiou",
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
} ], contentType=application/json}, {example=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -317,7 +317,7 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
</Pet>}]
- parameter tags: (query) Tags to filter by
@ -375,26 +375,26 @@ public class PetAPI: APIBase {
- GET /pet/{petId}
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- API Key:
- type: apiKey api_key
- name: api_key
- OAuth:
- type: oauth2
- name: petstore_auth
- examples: [{example={
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
- API Key:
- type: apiKey api_key
- name: api_key
- examples: [{contentType=application/json, example={
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"id" : 123456789,
"category" : {
"id" : 123456789,
"name" : "aeiou"
"name" : "aeiou",
"id" : 123456789
},
"status" : "aeiou",
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
}, contentType=application/json}, {example=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -403,21 +403,21 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
- examples: [{example={
"tags" : [ {
"id" : 123456789,
"name" : "aeiou"
} ],
</Pet>}]
- examples: [{contentType=application/json, example={
"photoUrls" : [ "aeiou" ],
"name" : "doggie",
"id" : 123456789,
"category" : {
"id" : 123456789,
"name" : "aeiou"
"name" : "aeiou",
"id" : 123456789
},
"status" : "aeiou",
"name" : "doggie",
"photoUrls" : [ "aeiou" ]
}, contentType=application/json}, {example=<Pet>
"tags" : [ {
"name" : "aeiou",
"id" : 123456789
} ],
"status" : "aeiou"
}}, {contentType=application/xml, example=<Pet>
<id>123456</id>
<name>doggie</name>
<photoUrls>
@ -426,7 +426,7 @@ public class PetAPI: APIBase {
<tags>
</tags>
<status>string</status>
</Pet>, contentType=application/xml}]
</Pet>}]
- parameter petId: (path) ID of pet that needs to be fetched
@ -578,11 +578,11 @@ public class PetAPI: APIBase {
- parameter petId: (path) ID of pet to update
- parameter additionalMetadata: (form) Additional data to pass to server
- parameter file: (form) file to upload
- parameter _file: (form) file to upload
- parameter completion: completion handler to receive the data and the error objects
*/
public class func uploadFile(petId petId: Int, additionalMetadata: String?, file: NSURL?, completion: ((error: ErrorType?) -> Void)) {
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?, completion: ((error: ErrorType?) -> Void)) {
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, _file: _file).execute { (response, error) -> Void in
completion(error: error);
}
}
@ -593,12 +593,12 @@ public class PetAPI: APIBase {
- parameter petId: (path) ID of pet to update
- parameter additionalMetadata: (form) Additional data to pass to server
- parameter file: (form) file to upload
- parameter _file: (form) file to upload
- returns: Promise<Void>
*/
public class func uploadFile(petId petId: Int, additionalMetadata: String?, file: NSURL?) -> Promise<Void> {
public class func uploadFile(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> Promise<Void> {
let deferred = Promise<Void>.pendingPromise()
uploadFile(petId: petId, additionalMetadata: additionalMetadata, file: file) { error in
uploadFile(petId: petId, additionalMetadata: additionalMetadata, _file: _file) { error in
if let error = error {
deferred.reject(error)
} else {
@ -620,18 +620,18 @@ public class PetAPI: APIBase {
- parameter petId: (path) ID of pet to update
- parameter additionalMetadata: (form) Additional data to pass to server
- parameter file: (form) file to upload
- parameter _file: (form) file to upload
- returns: RequestBuilder<Void>
*/
public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, file: NSURL?) -> RequestBuilder<Void> {
public class func uploadFileWithRequestBuilder(petId petId: Int, additionalMetadata: String?, _file: NSURL?) -> RequestBuilder<Void> {
var path = "/pet/{petId}/uploadImage"
path = path.stringByReplacingOccurrencesOfString("{petId}", withString: "\(petId)", options: .LiteralSearch, range: nil)
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [
"additionalMetadata": additionalMetadata,
"file": file
"file": _file
]
let parameters = APIHelper.rejectNil(nillableParameters)
@ -678,14 +678,14 @@ public class PetAPI: APIBase {
- GET /pet/{petId}?testing_byte_array=true
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
- API Key:
- type: apiKey api_key
- name: api_key
- OAuth:
- type: oauth2
- name: petstore_auth
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
- examples: [{example="", contentType=application/json}, {example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e, contentType=application/xml}]
- API Key:
- type: apiKey api_key
- name: api_key
- examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}]
- examples: [{contentType=application/json, example=""}, {contentType=application/xml, example=not implemented io.swagger.models.properties.BinaryProperty@55e6ae9e}]
- parameter petId: (path) ID of pet that needs to be fetched

View File

@ -11,6 +11,99 @@ import PromiseKit
public class StoreAPI: APIBase {
/**
Finds orders by status
- parameter status: (query) Status value that needs to be considered for query
- parameter completion: completion handler to receive the data and the error objects
*/
public class func findOrdersByStatus(status status: String?, completion: ((data: [Order]?, error: ErrorType?) -> Void)) {
findOrdersByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
completion(data: response?.body, error: error);
}
}
/**
Finds orders by status
- parameter status: (query) Status value that needs to be considered for query
- returns: Promise<[Order]>
*/
public class func findOrdersByStatus(status status: String?) -> Promise<[Order]> {
let deferred = Promise<[Order]>.pendingPromise()
findOrdersByStatus(status: status) { data, error in
if let error = error {
deferred.reject(error)
} else {
deferred.fulfill(data!)
}
}
return deferred.promise
}
/**
Finds orders by status
- GET /store/findByStatus
- A single status value can be provided as a string
- API Key:
- type: apiKey x-test_api_client_id
- name: test_api_client_id
- API Key:
- type: apiKey x-test_api_client_secret
- name: test_api_client_secret
- examples: [{contentType=application/json, example=[ {
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>}]
- examples: [{contentType=application/json, example=[ {
"petId" : 123456789,
"quantity" : 123,
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
} ]}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>}]
- parameter status: (query) Status value that needs to be considered for query
- returns: RequestBuilder<[Order]>
*/
public class func findOrdersByStatusWithRequestBuilder(status status: String?) -> RequestBuilder<[Order]> {
let path = "/store/findByStatus"
let URLString = PetstoreClientAPI.basePath + path
let nillableParameters: [String:AnyObject?] = [
"status": status
]
let parameters = APIHelper.rejectNil(nillableParameters)
let requestBuilder: RequestBuilder<[Order]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
return requestBuilder.init(method: "GET", URLString: URLString, parameters: parameters, isBody: false)
}
/**
Returns pet inventories by status
@ -50,12 +143,12 @@ public class StoreAPI: APIBase {
- API Key:
- type: apiKey api_key
- name: api_key
- examples: [{example={
- examples: [{contentType=application/json, example={
"key" : 123
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
- examples: [{example={
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
- examples: [{contentType=application/json, example={
"key" : 123
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
- returns: RequestBuilder<[String:Int]>
*/
@ -115,36 +208,36 @@ public class StoreAPI: APIBase {
- API Key:
- type: apiKey x-test_api_client_secret
- name: test_api_client_secret
- examples: [{example={
"id" : 123456789,
- examples: [{contentType=application/json, example={
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
</Order>}]
- examples: [{contentType=application/json, example={
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
</Order>}]
- parameter body: (body) order placed for purchasing the pet
@ -199,42 +292,42 @@ public class StoreAPI: APIBase {
- GET /store/order/{orderId}
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
- API Key:
- type: apiKey test_api_key_header
- name: test_api_key_header
- API Key:
- type: apiKey test_api_key_query (QUERY)
- name: test_api_key_query
- examples: [{example={
"id" : 123456789,
- API Key:
- type: apiKey test_api_key_header
- name: test_api_key_header
- examples: [{contentType=application/json, example={
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
- examples: [{example={
"id" : 123456789,
</Order>}]
- examples: [{contentType=application/json, example={
"petId" : 123456789,
"complete" : true,
"status" : "aeiou",
"quantity" : 123,
"shipDate" : "2000-01-23T04:56:07.000+0000"
}, contentType=application/json}, {example=<Order>
"id" : 123456789,
"shipDate" : "2000-01-23T04:56:07.000+0000",
"complete" : true,
"status" : "aeiou"
}}, {contentType=application/xml, example=<Order>
<id>123456</id>
<petId>123456</petId>
<quantity>0</quantity>
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
<status>string</status>
<complete>true</complete>
</Order>, contentType=application/xml}]
</Order>}]
- parameter orderId: (path) ID of pet that needs to be fetched

View File

@ -213,8 +213,8 @@ public class UserAPI: APIBase {
- GET /user/login
-
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
- parameter username: (query) The user name for login
- parameter password: (query) The password for login in clear text
@ -325,7 +325,7 @@ public class UserAPI: APIBase {
- GET /user/{username}
-
- examples: [{example={
- examples: [{contentType=application/json, example={
"id" : 1,
"username" : "johnp",
"firstName" : "John",
@ -334,7 +334,7 @@ public class UserAPI: APIBase {
"password" : "-secret-",
"phone" : "0123456789",
"userStatus" : 0
}, contentType=application/json}]
}}]
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.

View File

@ -124,6 +124,24 @@ class Decoders {
fatalError("formatter failed to parse \(source)")
}
// Decoder for [Order]
Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in
return Decoders.decode(clazz: [Order].self, source: source)
}
// Decoder for Order
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Order()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"])
instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"])
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
return instance
}
// Decoder for [User]
Decoders.addDecoder(clazz: [User].self) { (source: AnyObject) -> [User] in
return Decoders.decode(clazz: [User].self, source: source)
@ -158,6 +176,20 @@ class Decoders {
}
// Decoder for [Tag]
Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in
return Decoders.decode(clazz: [Tag].self, source: source)
}
// Decoder for Tag
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Tag()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
return instance
}
// Decoder for [Pet]
Decoders.addDecoder(clazz: [Pet].self) { (source: AnyObject) -> [Pet] in
return Decoders.decode(clazz: [Pet].self, source: source)
@ -175,38 +207,6 @@ class Decoders {
return instance
}
// Decoder for [Tag]
Decoders.addDecoder(clazz: [Tag].self) { (source: AnyObject) -> [Tag] in
return Decoders.decode(clazz: [Tag].self, source: source)
}
// Decoder for Tag
Decoders.addDecoder(clazz: Tag.self) { (source: AnyObject) -> Tag in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Tag()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.name = Decoders.decodeOptional(clazz: String.self, source: sourceDictionary["name"])
return instance
}
// Decoder for [Order]
Decoders.addDecoder(clazz: [Order].self) { (source: AnyObject) -> [Order] in
return Decoders.decode(clazz: [Order].self, source: source)
}
// Decoder for Order
Decoders.addDecoder(clazz: Order.self) { (source: AnyObject) -> Order in
let sourceDictionary = source as! [NSObject:AnyObject]
let instance = Order()
instance.id = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["id"])
instance.petId = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["petId"])
instance.quantity = Decoders.decodeOptional(clazz: Int.self, source: sourceDictionary["quantity"])
instance.shipDate = Decoders.decodeOptional(clazz: NSDate.self, source: sourceDictionary["shipDate"])
instance.status = Order.Status(rawValue: (sourceDictionary["status"] as? String) ?? "")
instance.complete = Decoders.decodeOptional(clazz: Bool.self, source: sourceDictionary["complete"])
return instance
}
}
}
}

View File

@ -10,17 +10,17 @@ PODS:
- PetstoreClient (0.0.1):
- Alamofire (~> 3.1.4)
- PromiseKit (~> 3.0.0)
- PromiseKit (3.0.2):
- PromiseKit/Foundation (= 3.0.2)
- PromiseKit/QuartzCore (= 3.0.2)
- PromiseKit/UIKit (= 3.0.2)
- PromiseKit/CorePromise (3.0.2)
- PromiseKit/Foundation (3.0.2):
- PromiseKit (3.0.3):
- PromiseKit/Foundation (= 3.0.3)
- PromiseKit/QuartzCore (= 3.0.3)
- PromiseKit/UIKit (= 3.0.3)
- PromiseKit/CorePromise (3.0.3)
- PromiseKit/Foundation (3.0.3):
- OMGHTTPURLRQ (~> 3.1.0)
- PromiseKit/CorePromise
- PromiseKit/QuartzCore (3.0.2):
- PromiseKit/QuartzCore (3.0.3):
- PromiseKit/CorePromise
- PromiseKit/UIKit (3.0.2):
- PromiseKit/UIKit (3.0.3):
- PromiseKit/CorePromise
DEPENDENCIES:
@ -34,6 +34,6 @@ SPEC CHECKSUMS:
Alamofire: 5f730ba29fd113b7ddd71c1e65d0c630acf5d7b0
OMGHTTPURLRQ: 633f98ee745aeda02345935a52eec1784cddb589
PetstoreClient: c9a3d06cf7954479a767135676406c4922cd3c4a
PromiseKit: ab1a380f7a30cf8cce663a2411e8b3580b10313d
PromiseKit: 00ec2a219bf5ad2833f95977698e921932b8dfd3
COCOAPODS: 0.39.0

View File

@ -10,17 +10,17 @@ PODS:
- PetstoreClient (0.0.1):
- Alamofire (~> 3.1.4)
- PromiseKit (~> 3.0.0)
- PromiseKit (3.0.2):
- PromiseKit/Foundation (= 3.0.2)
- PromiseKit/QuartzCore (= 3.0.2)
- PromiseKit/UIKit (= 3.0.2)
- PromiseKit/CorePromise (3.0.2)
- PromiseKit/Foundation (3.0.2):
- PromiseKit (3.0.3):
- PromiseKit/Foundation (= 3.0.3)
- PromiseKit/QuartzCore (= 3.0.3)
- PromiseKit/UIKit (= 3.0.3)
- PromiseKit/CorePromise (3.0.3)
- PromiseKit/Foundation (3.0.3):
- OMGHTTPURLRQ (~> 3.1.0)
- PromiseKit/CorePromise
- PromiseKit/QuartzCore (3.0.2):
- PromiseKit/QuartzCore (3.0.3):
- PromiseKit/CorePromise
- PromiseKit/UIKit (3.0.2):
- PromiseKit/UIKit (3.0.3):
- PromiseKit/CorePromise
DEPENDENCIES:
@ -34,6 +34,6 @@ SPEC CHECKSUMS:
Alamofire: 5f730ba29fd113b7ddd71c1e65d0c630acf5d7b0
OMGHTTPURLRQ: 633f98ee745aeda02345935a52eec1784cddb589
PetstoreClient: c9a3d06cf7954479a767135676406c4922cd3c4a
PromiseKit: ab1a380f7a30cf8cce663a2411e8b3580b10313d
PromiseKit: 00ec2a219bf5ad2833f95977698e921932b8dfd3
COCOAPODS: 0.39.0

View File

@ -51,7 +51,7 @@
}
- (void)viewDidLoad {
_promise = [AnyPromise promiseWithResolver:&resolve];
_promise = [[AnyPromise alloc] initWithResolver:&resolve];
}
- (void)later {

View File

@ -45,7 +45,7 @@ If you still are using Xcode 6 and Swift 1.2 then use PromiseKit 2.
# PromiseKit 2
PromiseKit 2 contains many interesting and important additions. Check out our our [release announcement](http://promisekit.org/PromiseKit-2.0-Released/) for full details.
PromiseKit 2 contains many interesting and important additions. Check out our our [release announcement](http://promisekit.org/PromiseKit-2.0-Released) for full details.
# PromiseKit 1

View File

@ -154,7 +154,7 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
@param block The provided block is immediately executed, inside the block
call `resolve` to resolve this promise and cause any attached handlers to
execute. If you are wrapping a delegate-based system, we recommend
instead to use: promiseWithResolver:
instead to use: initWithResolver:
@return A new promise.
@ -173,7 +173,7 @@ typedef NS_ENUM(NSInteger, PMKCatchPolicy) {
prefer resolverWithBlock: as the resulting code is more elegant.
PMKResolver resolve;
AnyPromise *promise = [AnyPromise promiseWithResolver:&resolve];
AnyPromise *promise = [[AnyPromise alloc] initWithResolver:&resolve];
// later
resolve(@"foo");
@ -216,7 +216,7 @@ typedef void (^PMKBooleanAdapter)(BOOL, NSError * __nullable);
provide this convenience adapter to make wrapping such systems more
elegant.
return [PMKPromise promiseWithAdapter:^(PMKAdapter adapter){
return [PMKPromise promiseWithAdapterBlock:^(PMKAdapter adapter){
PFQuery *query = [PFQuery ];
[query findObjectsInBackgroundWithBlock:adapter];
}];

View File

@ -50,6 +50,15 @@ import Foundation.NSError
self.init(bound: bound.then(on: zalgo) { NSDictionary(dictionary: $0) })
}
/**
- Returns: A new AnyPromise bound to a `Promise<String>`.
The two promises represent the same task, any changes to either will instantly reflect on both.
The value is converted to an NSString so Objective-C can use it.
*/
convenience public init(bound: Promise<String>) {
self.init(bound: bound.then(on: zalgo) { NSString(string: $0) })
}
/**
- Returns: A new AnyPromise bound to a `Promise<Int>`.
The two promises represent the same task, any changes to either will instantly reflect on both.
@ -59,6 +68,15 @@ import Foundation.NSError
self.init(bound: bound.then(on: zalgo) { NSNumber(integer: $0) })
}
/**
- Returns: A new AnyPromise bound to a `Promise<Bool>`.
The two promises represent the same task, any changes to either will instantly reflect on both.
The value is converted to an NSNumber so Objective-C can use it.
*/
convenience public init(bound: Promise<Bool>) {
self.init(bound: bound.then(on: zalgo) { NSNumber(bool: $0) })
}
/**
- Returns: A new AnyPromise bound to a `Promise<Void>`.
The two promises represent the same task, any changes to either will instantly reflect on both.

View File

@ -173,6 +173,18 @@ public class Promise<T> {
}
}
/**
A `typealias` for the return values of `pendingPromise()`. Simplifies declaration of properties that reference the values' containing tuple when this is necessary. For example, when working with multiple `pendingPromise()`s within the same scope, or when the promise initialization must occur outside of the caller's initialization.
```
class Foo: BarDelegate {
var pendingPromise: Promise<Int>.PendingPromise?
}
```
- SeeAlso: pendingPromise()
*/
public typealias PendingPromise = (promise: Promise, fulfill: (T) -> Void, reject: (ErrorType) -> Void)
/**
Making promises that wrap asynchronous delegation systems or other larger asynchronous systems without a simple completion handler is easier with pendingPromise.
@ -193,7 +205,7 @@ public class Promise<T> {
2) A function that fulfills that promise
3) A function that rejects that promise
*/
public class func pendingPromise() -> (promise: Promise, fulfill: (T) -> Void, reject: (ErrorType) -> Void) {
public class func pendingPromise() -> PendingPromise {
var fulfill: ((T) -> Void)!
var reject: ((ErrorType) -> Void)!
let promise = Promise { fulfill = $0; reject = $1 }

View File

@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.0.2</string>
<string>3.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>