@@ -163,7 +163,7 @@ import Foundation
163
163
*/
164
164
open func setSubscriptions( interests: Array < String > ) {
165
165
requestQueue. tasks += { _, next in
166
- self . modifySubscription (
166
+ self . replaceSubscriptionSet (
167
167
interests: interests,
168
168
successCallback: next
169
169
)
@@ -192,7 +192,7 @@ import Foundation
192
192
*/
193
193
private func addSubscriptionChangeToTaskQueue( interestName: String , change: SubscriptionChange ) {
194
194
requestQueue. tasks += { _, next in
195
- self . modifySubscription (
195
+ self . subscribeOrUnsubscribeInterest (
196
196
interest: interestName,
197
197
change: change,
198
198
successCallback: next
@@ -208,7 +208,7 @@ import Foundation
208
208
- parameter change: Whether to subscribe or unsubscribe
209
209
- parameter callback: Callback to be called upon success
210
210
*/
211
- private func modifySubscription ( interest: String , change: SubscriptionChange , successCallback: @escaping ( Any ? ) -> Void ) {
211
+ private func subscribeOrUnsubscribeInterest ( interest: String , change: SubscriptionChange , successCallback: @escaping ( Any ? ) -> Void ) {
212
212
guard
213
213
let clientId = clientId,
214
214
let pusherAppKey = pusherAppKey
@@ -221,15 +221,15 @@ import Foundation
221
221
let url = " \( CLIENT_API_V1_ENDPOINT) /clients/ \( clientId) /interests/ \( interest) "
222
222
let params : [ String : Any ] = [ " app_key " : pusherAppKey]
223
223
let request = self . setRequest ( url: url, params: params, change: change)
224
- self . modifySubscription ( interests: [ interest] , request: request, change: change, successCallback: successCallback)
224
+ self . doURLRequest ( interests: [ interest] , request: request, change: change, successCallback: successCallback)
225
225
}
226
226
227
227
/**
228
228
Makes a PUT request for given interests
229
229
- parameter interests: The name of the interests to be subscribed to
230
230
- parameter callback: Callback to be called upon success
231
231
*/
232
- private func modifySubscription ( interests: Array < String > , successCallback: @escaping ( Any ? ) -> Void ) {
232
+ private func replaceSubscriptionSet ( interests: Array < String > , successCallback: @escaping ( Any ? ) -> Void ) {
233
233
guard
234
234
let clientId = clientId,
235
235
let pusherAppKey = pusherAppKey
@@ -242,10 +242,10 @@ import Foundation
242
242
let url = " \( CLIENT_API_V1_ENDPOINT) /clients/ \( clientId) /interests/ "
243
243
let params : [ String : Any ] = [ " app_key " : pusherAppKey, " interests " : interests]
244
244
let request = self . setRequest ( url: url, params: params, change: . setSubscriptions)
245
- self . modifySubscription ( interests: interests, request: request, change: . setSubscriptions, successCallback: successCallback)
245
+ self . doURLRequest ( interests: interests, request: request, change: . setSubscriptions, successCallback: successCallback)
246
246
}
247
247
248
- private func modifySubscription ( interests: Array < String > , request: URLRequest , change: SubscriptionChange , successCallback: @escaping ( Any ? ) -> Void ) {
248
+ private func doURLRequest ( interests: Array < String > , request: URLRequest , change: SubscriptionChange , successCallback: @escaping ( Any ? ) -> Void ) {
249
249
self . delegate? . debugLog ? ( message: " Attempt number: \( self . failedRequestAttempts + 1 ) of \( maxFailedRequestAttempts) " )
250
250
251
251
let task = URLSession . dataTask (
0 commit comments