Skip to content

Commit

Permalink
Merge pull request #215 from Kinvey/feature/MLIBZ-1908-custom-request…
Browse files Browse the repository at this point in the history
…-properties

MLIBZ-1908: x-kinvey-custom-request-properties header
  • Loading branch information
heyzooi authored Jul 17, 2017
2 parents bb5fbc2 + ba3a80d commit d994f97
Show file tree
Hide file tree
Showing 32 changed files with 3,228 additions and 560 deletions.
23 changes: 20 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
11 changes: 5 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 @@ -356,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 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 d994f97

Please sign in to comment.