Skip to content

Commit

Permalink
Merge branch 'release/3.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Barros committed Jul 17, 2017
2 parents bece599 + 2e69266 commit cf5154c
Show file tree
Hide file tree
Showing 46 changed files with 4,127 additions and 631 deletions.
4 changes: 2 additions & 2 deletions Kinvey.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "Kinvey"
s.version = "3.5.4"
s.version = "3.6.0"
s.summary = "Kinvey iOS SDK"

# This description is used to generate tags and improve search results.
Expand Down Expand Up @@ -70,7 +70,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = "9.0"
s.osx.deployment_target = "10.12"
s.watchos.deployment_target = "2.2"
s.tvos.deployment_target = "9.2"
# s.tvos.deployment_target = "9.2"


# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
Expand Down
1 change: 1 addition & 0 deletions Kinvey/Kinvey/Acl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ extension Acl: Mappable {

extension Acl {

/// Property names for Acl
public struct Key {

static let creator = "creator"
Expand Down
35 changes: 32 additions & 3 deletions Kinvey/Kinvey/AggregateOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ class AggregateOperation<T: Persistable>: ReadOperation<T, [JsonDictionary], Swi
let aggregation: Aggregation
let predicate: NSPredicate?

init(aggregation: Aggregation, condition predicate: NSPredicate? = nil, readPolicy: ReadPolicy, cache: AnyCache<T>?, client: Client) {
init(
aggregation: Aggregation,
condition predicate: NSPredicate? = nil,
readPolicy: ReadPolicy,
cache: AnyCache<T>?,
options: Options?
) {
self.aggregation = aggregation
self.predicate = predicate
super.init(readPolicy: readPolicy, cache: cache, client: client)
super.init(
readPolicy: readPolicy,
cache: cache,
options: options
)
}

func executeLocal(_ completionHandler: CompletionHandler? = nil) -> Request {
Expand All @@ -32,7 +42,14 @@ class AggregateOperation<T: Persistable>: ReadOperation<T, [JsonDictionary], Swi
}

func executeNetwork(_ completionHandler: CompletionHandler? = nil) -> Request {
let request = client.networkRequestFactory.buildAppDataGroup(collectionName: T.collectionName(), keys: aggregation.keys, initialObject: aggregation.initialObject, reduceJSFunction: aggregation.reduceJSFunction, condition: predicate)
let request = client.networkRequestFactory.buildAppDataGroup(
collectionName: T.collectionName(),
keys: aggregation.keys,
initialObject: aggregation.initialObject,
reduceJSFunction: aggregation.reduceJSFunction,
condition: predicate,
options: options
)
request.execute() { data, response, error in
if let response = response, response.isOK,
let data = data,
Expand Down Expand Up @@ -125,6 +142,10 @@ enum Aggregation {

public typealias AggregationCustomResult<T: Persistable> = (value: T, custom: JsonDictionary)

/**
Protocol that marks all types that are compatible as a Count type such as Int,
Int8, Int16, Int32 and Int64
*/
public protocol CountType {}
extension Int: CountType {}
extension Int8: CountType {}
Expand All @@ -134,6 +155,10 @@ extension Int64: CountType {}

public typealias AggregationCountResult<T: Persistable, Count: CountType> = (value: T, count: Count)

/**
Protocol that marks all types that are compatible as a Add type such as
NSNumber, Double, Float, Int, Int8, Int16, Int32 and Int64
*/
public protocol AddableType {}
extension NSNumber: AddableType {}
extension Double: AddableType {}
Expand All @@ -147,6 +172,10 @@ extension Int64: AddableType {}
public typealias AggregationSumResult<T: Persistable, Sum: AddableType> = (value: T, sum: Sum)
public typealias AggregationAvgResult<T: Persistable, Avg: AddableType> = (value: T, avg: Avg)

/**
Protocol that marks all types that are compatible as a Min type such as
NSNumber, Double, Float, Int, Int8, Int16, Int32, Int64, Date and NSDate
*/
public protocol MinMaxType {}
extension NSNumber: MinMaxType {}
extension Double: MinMaxType {}
Expand Down
28 changes: 22 additions & 6 deletions Kinvey/Kinvey/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,10 @@ open class Client: Credential {
/// Timeout interval for this client instance.
open var timeoutInterval: TimeInterval = 60

/// App version for this client instance.
open var clientAppVersion: String?

/// Custom request properties for this client instance.
open var customRequestProperties: [String : String] = [:]
/**
Hold default optional values for all calls made by this `Client` instance
*/
open var options: Options?

/// The default value for `apiHostName` variable.
open static let defaultApiHostName = URL(string: "https://baas.kinvey.com/")!
Expand Down Expand Up @@ -327,6 +326,10 @@ open class Client: Credential {
return Client.fileURL(appKey: self.appKey!, tag: tag)
}

/**
Check if the `appKey` and `appSecret` properties are correct doing a ping
call to the server.
*/
@discardableResult
public func ping(completionHandler: @escaping (EnvironmentInfo?, Swift.Error?) -> Void) -> Request {
return ping() { (result: Result<EnvironmentInfo, Swift.Error>) in
Expand All @@ -339,6 +342,11 @@ open class Client: Credential {
}
}

/**
Checks connectivity to your backend. A successful response returns a
summary of your backend environment and confirms that the app can talk to
the backend.
*/
@discardableResult
public func ping(completionHandler: @escaping (Result<EnvironmentInfo, Swift.Error>) -> Void) -> Request {
guard let _ = appKey, let _ = appSecret else {
Expand All @@ -347,7 +355,7 @@ open class Client: Credential {
}
return LocalRequest()
}
let request = networkRequestFactory.buildAppDataPing()
let request = networkRequestFactory.buildAppDataPing(options: options)
Promise<EnvironmentInfo> { fulfill, reject in
request.execute() { data, response, error in
if let response = response,
Expand All @@ -371,11 +379,19 @@ open class Client: Credential {
}
}

/// Environment Information for a specific `appKey` and `appSecret`
public struct EnvironmentInfo: StaticMappable {

/// Version of the backend
public let version: String

/// Hello message from Kinvey
public let kinvey: String

/// Application Name
public let appName: String

/// Environment Name
public let environmentName: String

public static func objectForMapping(map: Map) -> BaseMappable? {
Expand Down
19 changes: 16 additions & 3 deletions Kinvey/Kinvey/CountOperation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ class CountOperation<T: Persistable>: ReadOperation<T, Int, Swift.Error>, ReadOp

let query: Query?

init(query: Query? = nil, readPolicy: ReadPolicy, cache: AnyCache<T>?, client: Client) {
init(
query: Query? = nil,
readPolicy: ReadPolicy,
cache: AnyCache<T>?,
options: Options?
) {
self.query = query
super.init(readPolicy: readPolicy, cache: cache, client: client)
super.init(
readPolicy: readPolicy,
cache: cache,
options: options
)
}

func executeLocal(_ completionHandler: CompletionHandler? = nil) -> Request {
Expand All @@ -31,7 +40,11 @@ class CountOperation<T: Persistable>: ReadOperation<T, Int, Swift.Error>, ReadOp
}

func executeNetwork(_ completionHandler: CompletionHandler? = nil) -> Request {
let request = client.networkRequestFactory.buildAppDataCountByQuery(collectionName: T.collectionName(), query: query)
let request = client.networkRequestFactory.buildAppDataCountByQuery(
collectionName: T.collectionName(),
query: query,
options: options
)
request.execute() { data, response, error in
if let response = response, response.isOK,
let data = data,
Expand Down
Loading

0 comments on commit cf5154c

Please sign in to comment.