Manos Chorianopoulos

add getCouponSetsAsync, getCampaignsAsync requests

......@@ -7,7 +7,7 @@
<key>Pods-WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>WarplySDKFrameworkIOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -77,6 +77,7 @@
- (NSDictionary*)loginCosmoteWithGuid:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket;
- (void)getCouponsWithSuccessBlock:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getCouponsetsAsync:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1284,4 +1284,17 @@ CMPedometer *pedometer;
}
}];
}
- (void)getInboxAsync:(void (^)(NSArray *list))success failureBlock:(void (^)(NSError *error))failure
{
[[Warply sharedService] getInbox2WithSuccessBlock :^(NSArray *inbox) {
if (success) {
success(inbox);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
......@@ -120,29 +120,50 @@ public class swiftApi {
public class CouponSetsDataModel {
var data: Array<CouponSetItemModel> = []
init() { //initializer method
init() {
}
var getData: Array<CouponSetItemModel> {
get { // getter
return data
}
}
func getCouponSetsData(_ getCouponSetsCallback: @escaping (_ couponSetsData: Array<CouponSetItemModel>?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
let couponSets = instanceOfMyApi.getCouponSets(withActive: true, andVisible: true, andUuids: nil)
var couponSets: [AnyHashable : Any]?
var couponSetsArray:Array<CouponSetItemModel> = []
instanceOfMyApi.getCouponsetsAsync(true, andVisible: true, andUuids: nil, couponSetsCallback, failureBlock: couponSetsFailureCallback)
func couponSetsCallback(_ couponSetsData: [AnyHashable : Any]?) -> Void {
couponSets = couponSetsData ?? ["":""]
if let myCouponsSetsDictionary = couponSets as? [String : AnyObject] {
let couponSetsData = (myCouponsSetsDictionary["MAPP_COUPON"] as! NSArray)
for couponset in couponSetsData {
let tempCouponset = CouponSetItemModel(dictionary: couponset as! [String : Any])
couponSetsArray.append(tempCouponset)
}
}
self.data = couponSetsArray
getCouponSetsCallback(couponSetsArray)
}
func couponSetsFailureCallback(_ error: Error?) -> Void {
print("getCouponSets error: ")
getCouponSetsCallback(nil)
}
var getData: Array<CouponSetItemModel> {
get { // getter
return data
}
}
public func getCouponSetsAsync(_ getCouponSetsCallback: @escaping (_ couponSetsData: Array<CouponSetItemModel>?) -> Void) -> Void {
CouponSetsDataModel().getCouponSetsData(getCouponSetsCallback)
}
public func getCouponSets() -> Array<CouponSetItemModel> {
......@@ -391,27 +412,42 @@ public class swiftApi {
public class CampaignDataModel {
var data: Array<CampaignItemModel> = []
init() { //initializer method
init() {
}
var getData: Array<CampaignItemModel> {
get { // getter
return data
}
}
func getCampaignsData(_ getCampaignsCallback: @escaping (_ campaignsData: Array<CampaignItemModel>?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
let products = instanceOfMyApi.getInbox() as NSMutableArray?
instanceOfMyApi.getInboxAsync(campaignsCallback, failureBlock: campaignsFailureCallback)
var giftsArray:Array<CampaignItemModel> = []
func campaignsCallback(_ campaignsData: [Any]?) -> Void {
var campaignsArray:Array<CampaignItemModel> = []
for gift in products ?? [] {
let tempGift = CampaignItemModel(dictionary: gift as! [String : Any])
giftsArray.append(tempGift)
for item in campaignsData ?? [] {
let tempCampaign = CampaignItemModel(dictionary: item as! [String : Any])
campaignsArray.append(tempCampaign)
}
self.data = giftsArray;
getCampaignsCallback(campaignsArray);
}
func campaignsFailureCallback(_ error: Error?) -> Void {
print("getCampaigns error: ")
getCampaignsCallback(nil)
}
var getData: Array<CampaignItemModel> {
get { // getter
return data
}
}
public func getCampaignsAsync(_ getCampaignsCallback: @escaping (_ campaignsData: Array<CampaignItemModel>?) -> Void) -> Void {
CampaignDataModel().getCampaignsData(getCampaignsCallback)
}
public func getCampaigns() -> Array<CampaignItemModel> {
......