Merge branch 'master' of https://git.warp.ly/open-source/warply_sdk_framework
Showing
6 changed files
with
79 additions
and
29 deletions
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>0</integer> | 10 | + <integer>1</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> | 7 | <key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key> |
8 | <dict> | 8 | <dict> |
9 | <key>orderHint</key> | 9 | <key>orderHint</key> |
10 | - <integer>1</integer> | 10 | + <integer>0</integer> |
11 | </dict> | 11 | </dict> |
12 | </dict> | 12 | </dict> |
13 | </dict> | 13 | </dict> | ... | ... |
No preview for this file type
... | @@ -77,6 +77,7 @@ | ... | @@ -77,6 +77,7 @@ |
77 | - (NSDictionary*)loginCosmoteWithGuid:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket; | 77 | - (NSDictionary*)loginCosmoteWithGuid:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket; |
78 | - (void)getCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 78 | - (void)getCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
79 | - (void)getCouponsetsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 79 | - (void)getCouponsetsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
80 | +- (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure; | ||
80 | 81 | ||
81 | @end | 82 | @end |
82 | #endif /* MyApi_h */ | 83 | #endif /* MyApi_h */ | ... | ... |
... | @@ -1284,4 +1284,17 @@ CMPedometer *pedometer; | ... | @@ -1284,4 +1284,17 @@ CMPedometer *pedometer; |
1284 | } | 1284 | } |
1285 | }]; | 1285 | }]; |
1286 | } | 1286 | } |
1287 | + | ||
1288 | +- (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure | ||
1289 | +{ | ||
1290 | + [[Warply sharedService] getInbox2WithSuccessBlock :^(NSArray *inbox) { | ||
1291 | + if (success) { | ||
1292 | + success(inbox); | ||
1293 | + } | ||
1294 | + } failureBlock:^(NSError *error) { | ||
1295 | + if (failure) { | ||
1296 | + failure(error); | ||
1297 | + } | ||
1298 | + }]; | ||
1299 | +} | ||
1287 | @end | 1300 | @end | ... | ... |
... | @@ -120,30 +120,51 @@ public class swiftApi { | ... | @@ -120,30 +120,51 @@ public class swiftApi { |
120 | public class CouponSetsDataModel { | 120 | public class CouponSetsDataModel { |
121 | var data: Array<CouponSetItemModel> = [] | 121 | var data: Array<CouponSetItemModel> = [] |
122 | 122 | ||
123 | - init() { //initializer method | 123 | + init() { |
124 | + } | ||
125 | + | ||
126 | + var getData: Array<CouponSetItemModel> { | ||
127 | + get { // getter | ||
128 | + return data | ||
129 | + } | ||
130 | + } | ||
131 | + | ||
132 | + func getCouponSetsData(_ getCouponSetsCallback: @escaping (_ couponSetsData: Array<CouponSetItemModel>?) -> Void) -> Void { | ||
133 | + | ||
124 | let instanceOfMyApi = MyApi() | 134 | let instanceOfMyApi = MyApi() |
125 | - let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil) | 135 | + var couponSets: [AnyHashable : Any]? |
126 | var couponSetsArray:Array<CouponSetItemModel> = [] | 136 | var couponSetsArray:Array<CouponSetItemModel> = [] |
127 | 137 | ||
128 | - if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { | 138 | + |
129 | - let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! NSArray) | 139 | + instanceOfMyApi.getCouponsetsAsync(true, andVisible: true, andUuids: nil, couponSetsCallback, failureBlock: couponSetsFailureCallback) |
130 | - | 140 | + |
141 | + func couponSetsCallback(_ couponSetsData: [AnyHashable : Any]?) -> Void { | ||
142 | + couponSets = couponSetsData ?? ["":""] | ||
131 | 143 | ||
132 | - for couponset in couponSetsData { | 144 | + if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { |
133 | - let tempCouponset = CouponSetItemModel(dictionary: couponset as! [String : Any]) | 145 | + let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! NSArray) |
134 | - couponSetsArray.append(tempCouponset) | 146 | + |
147 | + for couponset in couponSetsData { | ||
148 | + let tempCouponset = CouponSetItemModel(dictionary: couponset as! [String : Any]) | ||
149 | + couponSetsArray.append(tempCouponset) | ||
150 | + } | ||
151 | + | ||
135 | } | 152 | } |
136 | 153 | ||
154 | + getCouponSetsCallback(couponSetsArray) | ||
137 | } | 155 | } |
138 | - self.data = couponSetsArray | 156 | + |
139 | - } | 157 | + func couponSetsFailureCallback(_ error: Error?) -> Void { |
140 | - | 158 | + print("getCouponSets error: ") |
141 | - var getData: Array<CouponSetItemModel> { | 159 | + getCouponSetsCallback(nil) |
142 | - get { // getter | ||
143 | - return data | ||
144 | } | 160 | } |
161 | + | ||
145 | } | 162 | } |
146 | } | 163 | } |
164 | + | ||
165 | + public func getCouponSetsAsync(_ getCouponSetsCallback: @escaping (_ couponSetsData: Array<CouponSetItemModel>?) -> Void) -> Void { | ||
166 | + CouponSetsDataModel().getCouponSetsData(getCouponSetsCallback) | ||
167 | + } | ||
147 | 168 | ||
148 | public func getCouponSets() -> Array<CouponSetItemModel> { | 169 | public func getCouponSets() -> Array<CouponSetItemModel> { |
149 | return CouponSetsDataModel().getData | 170 | return CouponSetsDataModel().getData |
... | @@ -391,27 +412,42 @@ public class swiftApi { | ... | @@ -391,27 +412,42 @@ public class swiftApi { |
391 | public class CampaignDataModel { | 412 | public class CampaignDataModel { |
392 | var data: Array<CampaignItemModel> = [] | 413 | var data: Array<CampaignItemModel> = [] |
393 | 414 | ||
394 | - init() { //initializer method | 415 | + init() { |
416 | + } | ||
417 | + | ||
418 | + var getData: Array<CampaignItemModel> { | ||
419 | + get { // getter | ||
420 | + return data | ||
421 | + } | ||
422 | + } | ||
423 | + | ||
424 | + func getCampaignsData(_ getCampaignsCallback: @escaping (_ campaignsData: Array<CampaignItemModel>?) -> Void) -> Void { | ||
425 | + | ||
395 | let instanceOfMyApi = MyApi() | 426 | let instanceOfMyApi = MyApi() |
396 | - let products = instanceOfMyApi.getInbox() as NSMutableArray? | 427 | + instanceOfMyApi.getInboxAsync(campaignsCallback, failureBlock: campaignsFailureCallback) |
397 | 428 | ||
398 | - var giftsArray:Array<CampaignItemModel> = [] | ||
399 | - | ||
400 | 429 | ||
401 | - for gift in products ?? [] { | 430 | + func campaignsCallback(_ campaignsData: [Any]?) -> Void { |
402 | - let tempGift = CampaignItemModel(dictionary: gift as! [String : Any]) | 431 | + var campaignsArray:Array<CampaignItemModel> = [] |
403 | - giftsArray.append(tempGift) | 432 | + |
433 | + for item in campaignsData ?? [] { | ||
434 | + let tempCampaign = CampaignItemModel(dictionary: item as! [String : Any]) | ||
435 | + campaignsArray.append(tempCampaign) | ||
436 | + } | ||
437 | + | ||
438 | + getCampaignsCallback(campaignsArray); | ||
404 | } | 439 | } |
405 | 440 | ||
406 | - self.data = giftsArray; | 441 | + func campaignsFailureCallback(_ error: Error?) -> Void { |
442 | + print("getCampaigns error: ") | ||
443 | + getCampaignsCallback(nil) | ||
444 | + } | ||
407 | 445 | ||
408 | } | 446 | } |
447 | + } | ||
409 | 448 | ||
410 | - var getData: Array<CampaignItemModel> { | 449 | + public func getCampaignsAsync(_ getCampaignsCallback: @escaping (_ campaignsData: Array<CampaignItemModel>?) -> Void) -> Void { |
411 | - get { // getter | 450 | + CampaignDataModel().getCampaignsData(getCampaignsCallback) |
412 | - return data | ||
413 | - } | ||
414 | - } | ||
415 | } | 451 | } |
416 | 452 | ||
417 | public func getCampaigns() -> Array<CampaignItemModel> { | 453 | public func getCampaigns() -> Array<CampaignItemModel> { | ... | ... |
-
Please register or login to post a comment