Manos Chorianopoulos

getSingleCampaignAsync and new badge functionality

......@@ -173,6 +173,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
vc.ccms = campaigns[indexPath.row]._ccms
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
......@@ -185,6 +189,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
vc.ccms = item
vc.campaign = campaigns[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
......@@ -217,6 +225,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
......@@ -272,6 +284,10 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else {
let seasonalEvent = swiftApi.LoyaltyGiftsForYouOfferClickEvent()
seasonalEvent._title = campaigns[indexPath.row]._title ?? ""
......@@ -282,4 +298,17 @@ extension GiftsViewController: UITableViewDelegate, UITableViewDataSource{
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
}
func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (getSingleCampaignData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
}
......
......@@ -115,6 +115,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
vc.ccms = campaigns[indexPath.row]._ccms
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
} else if (campaigns[indexPath.row]._type != nil && campaigns[indexPath.row]._type == "telco") {
let ccmsCampaigns = swiftApi().getCCMSLoyaltyCampaigns()
let loyaltyCampaignIdExists = ccmsCampaigns.contains { $0._loyaltyCampaignId == campaigns[indexPath.row].session_uuid }
......@@ -127,6 +131,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
vc.ccms = item
vc.campaign = campaigns[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
}
......@@ -158,6 +166,10 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
......@@ -218,6 +230,23 @@ extension MFYViewController: UITableViewDelegate, UITableViewDataSource{
vc.campaignUrl = url
vc.params = params
self.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaigns[indexPath.row].session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
}
func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (getSingleCampaignData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
......
......@@ -103,6 +103,7 @@
- (void)didReceiveNotification:(NSDictionary *)payload;
- (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
- (void)editProfileAsync:(NSString*)firstname andLastname:(NSString*)lastname andEmail:(NSString *)email andSalutation:(NSString *)salutation andMsisdn:(NSString *)msisdn andNickname:(NSString *)nickname andGender:(NSString *)gender andBirthday:(NSString *)birthday andNameDay:(NSString *)nameday andTaxID:(NSString *)taxid andProfileMetadata:(NSDictionary *)profileMetadata optin:(NSNumber *)optin newsLetter:(NSNumber *)newsletter andSMS:(NSNumber *)sms andSegmentation:(NSNumber *)segmentation andSMSSegmentation:(NSNumber *)smsSegmentation :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1627,4 +1627,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
[[Warply sharedService] getSingleCampaignWithSuccessBlock:sessionUuid :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
......@@ -402,6 +402,9 @@ WL_VERSION_INTERFACE()
- (void) validateCouponWithSuccessBlock:(NSString*) coupon :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)loginCosmoteWithSuccessBlock:(NSString*)guid andAppUuid:(NSString*)appUuid andTicket:(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
/*!
@abstract Get the full page add accordint to the display_type of a campaign.
@attributeblock successBlock This block is called when getInbox is sucessful and allOffers is empty or nil and returns an array with the available WLInboxItem items. Otherwise, the allOffers array is filtered.
......
......@@ -4921,6 +4921,10 @@ public class swiftApi {
vc.campaign = campaign
controller.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
......@@ -4933,6 +4937,22 @@ public class swiftApi {
vc.campaignUrl = swiftApi().constructCampaignUrl(campaign)
vc.params = swiftApi().constructCampaignParams(campaign)
controller.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = campaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
}
func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (getSingleCampaignData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
}
......@@ -4962,6 +4982,10 @@ public class swiftApi {
vc.campaignUrl = swiftApi().constructCcmsUrl(loyaltyCampaign, ccms)
vc.params = swiftApi().constructCcmsParams(loyaltyCampaign, ccms)
controller.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = loyaltyCampaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
} else if (isTelco && (loyaltyCampaign.session_uuid == ccms._loyaltyCampaignId)) {
......@@ -4971,11 +4995,27 @@ public class swiftApi {
vc.ccms = ccms
vc.campaign = loyaltyCampaign
controller.navigationController?.pushViewController(vc, animated: true)
if let sessionUuid = loyaltyCampaign.session_uuid {
getSingleCampaignAsyncRequest(sessionUuid: sessionUuid)
}
break;
}
}
}
func getSingleCampaignAsyncRequest(sessionUuid: String) {
swiftApi().getSingleCampaignAsync(sessionUuid: sessionUuid, getSingleCampaignCallback)
}
func getSingleCampaignCallback (_ getSingleCampaignData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (getSingleCampaignData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
}
......@@ -5647,4 +5687,56 @@ public class swiftApi {
}
public func getSingleCampaignAsync(sessionUuid: String, _ getSingleCampaignCallback: @escaping (_ getSingleCampaignData: VerifyTicketResponseModel?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.getSingleCampaignAsync(sessionUuid, getSingleCampaignAsyncCallback, failureBlock: getSingleCampaignFailureCallback)
func getSingleCampaignAsyncCallback(_ getSingleCampaignData: [AnyHashable: Any]?) -> Void {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback)
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
if let getSingleCampaignDataDictionary = getSingleCampaignData as? [String: Any] {
let tempResponse = VerifyTicketResponseModel(dictionary: getSingleCampaignDataDictionary)
getSingleCampaignCallback(tempResponse);
if (tempResponse.getStatus == 1) {
}
} else {
getSingleCampaignCallback(nil)
}
}
func getSingleCampaignFailureCallback(_ error: Error?) -> Void {
swiftApi().getCampaignsAsyncNew(language: "en", filters: [String : Any](), getCampaignsCallback)
func getCampaignsCallback (_ campaignsData: Array<swiftApi.CampaignItemModel>?) -> Void {
if (campaignsData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
print("getSingleCampaign error: ")
print(error)
print("====================")
getSingleCampaignCallback(nil)
}
}
}
......