Showing
6 changed files
with
69 additions
and
19 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,29 +120,50 @@ public class swiftApi { | ... | @@ -120,29 +120,50 @@ 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 | ||
138 | + | ||
139 | + instanceOfMyApi.getCouponsetsAsync(true, andVisible: true, andUuids: nil, couponSetsCallback, failureBlock: couponSetsFailureCallback) | ||
140 | + | ||
141 | + func couponSetsCallback(_ couponSetsData: [AnyHashable : Any]?) -> Void { | ||
142 | + couponSets = couponSetsData ?? ["":""] | ||
143 | + | ||
128 | if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { | 144 | if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] { |
129 | let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! NSArray) | 145 | let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! NSArray) |
130 | 146 | ||
131 | - | ||
132 | for couponset in couponSetsData { | 147 | for couponset in couponSetsData { |
133 | let tempCouponset = CouponSetItemModel(dictionary: couponset as! [String : Any]) | 148 | let tempCouponset = CouponSetItemModel(dictionary: couponset as! [String : Any]) |
134 | couponSetsArray.append(tempCouponset) | 149 | couponSetsArray.append(tempCouponset) |
135 | } | 150 | } |
136 | 151 | ||
137 | } | 152 | } |
138 | - self.data = couponSetsArray | 153 | + |
154 | + getCouponSetsCallback(couponSetsArray) | ||
155 | + } | ||
156 | + | ||
157 | + func couponSetsFailureCallback(_ error: Error?) -> Void { | ||
158 | + print("getCouponSets error: ") | ||
159 | + getCouponSetsCallback(nil) | ||
139 | } | 160 | } |
140 | 161 | ||
141 | - var getData: Array<CouponSetItemModel> { | ||
142 | - get { // getter | ||
143 | - return data | ||
144 | } | 162 | } |
145 | } | 163 | } |
164 | + | ||
165 | + public func getCouponSetsAsync(_ getCouponSetsCallback: @escaping (_ couponSetsData: Array<CouponSetItemModel>?) -> Void) -> Void { | ||
166 | + CouponSetsDataModel().getCouponSetsData(getCouponSetsCallback) | ||
146 | } | 167 | } |
147 | 168 | ||
148 | public func getCouponSets() -> Array<CouponSetItemModel> { | 169 | public func getCouponSets() -> Array<CouponSetItemModel> { |
... | @@ -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 | 429 | ||
430 | + func campaignsCallback(_ campaignsData: [Any]?) -> Void { | ||
431 | + var campaignsArray:Array<CampaignItemModel> = [] | ||
400 | 432 | ||
401 | - for gift in products ?? [] { | 433 | + for item in campaignsData ?? [] { |
402 | - let tempGift = CampaignItemModel(dictionary: gift as! [String : Any]) | 434 | + let tempCampaign = CampaignItemModel(dictionary: item as! [String : Any]) |
403 | - giftsArray.append(tempGift) | 435 | + campaignsArray.append(tempCampaign) |
404 | } | 436 | } |
405 | 437 | ||
406 | - self.data = giftsArray; | 438 | + getCampaignsCallback(campaignsArray); |
439 | + } | ||
407 | 440 | ||
441 | + func campaignsFailureCallback(_ error: Error?) -> Void { | ||
442 | + print("getCampaigns error: ") | ||
443 | + getCampaignsCallback(nil) | ||
408 | } | 444 | } |
409 | 445 | ||
410 | - var getData: Array<CampaignItemModel> { | ||
411 | - get { // getter | ||
412 | - return data | ||
413 | } | 446 | } |
414 | } | 447 | } |
448 | + | ||
449 | + public func getCampaignsAsync(_ getCampaignsCallback: @escaping (_ campaignsData: Array<CampaignItemModel>?) -> Void) -> Void { | ||
450 | + CampaignDataModel().getCampaignsData(getCampaignsCallback) | ||
415 | } | 451 | } |
416 | 452 | ||
417 | public func getCampaigns() -> Array<CampaignItemModel> { | 453 | public func getCampaigns() -> Array<CampaignItemModel> { | ... | ... |
-
Please register or login to post a comment