Manos Chorianopoulos

Add getMapDataAsync request

......@@ -116,6 +116,7 @@
- (BOOL)sdkInitialised;
- (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;
- (void)getMapDataAsync:(NSString*)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
- (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token;
- (NSString*)getAccessTokenM;
......
......@@ -1846,6 +1846,18 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getMapDataAsync:(NSString*)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
[[Warply sharedService] getMapDataWithSuccessBlock:language :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
- (void) sendEvent: (NSString *) eventName priority: (BOOL) priority {
NSString *event_Name = eventName;
NSNumber *time_submitted = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]];
......
......@@ -427,6 +427,8 @@ WL_VERSION_INTERFACE()
- (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)getMapDataWithSuccessBlock:(NSString *)language :(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.
......
......@@ -2154,58 +2154,64 @@ public class swiftApi {
public class UnifiedCampaignModel: Codable {
private var couponset_uuid: String?
private var id: String?
private var title: String?
private var position: Int?
private var affiliatedId: String?
private var affiliatedId: Int?
private var shortDescription: String?
private var longDescription: String?
private var isHot: Bool?
private var logoImagePath: String?
private var bigLogoImagePath: String?
private var days: Int?
private var days: Array<String>?
private var dayText: String?
private var imagePath: String?
private var bigImagePath: String?
private var markerImagePath: String?
private var details: String?
private var store_id: String?
private var locations: Array<UnifiedCampaignLocation>?
public init() {
self.couponset_uuid = ""
self.id = ""
self.title = ""
self.position = 0
self.affiliatedId = ""
self.affiliatedId = 0
self.shortDescription = ""
self.longDescription = ""
self.isHot = false
self.logoImagePath = ""
self.bigLogoImagePath = ""
self.days = 0
self.days = []
self.dayText = ""
self.imagePath = ""
self.bigImagePath = ""
self.markerImagePath = ""
self.details = ""
self.store_id = ""
self.locations = []
}
public init(dictionary: [String: Any]) {
self.couponset_uuid = dictionary["COUPONSET_UUID"] as? String? ?? ""
self.id = dictionary["id"] as? String? ?? ""
self.title = dictionary["title"] as? String? ?? ""
self.position = dictionary["position"] as? Int? ?? 0
self.affiliatedId = dictionary["affiliatedId"] as? String? ?? ""
self.affiliatedId = dictionary["affiliatedId"] as? Int? ?? 0
self.shortDescription = dictionary["shortDescription"] as? String? ?? ""
self.longDescription = dictionary["longDescription"] as? String? ?? ""
self.isHot = dictionary["isHot"] as? Bool? ?? false
self.logoImagePath = dictionary["logoImagePath"] as? String? ?? ""
self.bigLogoImagePath = dictionary["bigLogoImagePath"] as? String? ?? ""
self.days = dictionary["days"] as? Int? ?? 0
self.days = dictionary["days"] as? Array<String>? ?? []
self.dayText = dictionary["dayText"] as? String? ?? ""
self.imagePath = dictionary["imagePath"] as? String? ?? ""
self.bigImagePath = dictionary["bigImagePath"] as? String? ?? ""
self.markerImagePath = dictionary["markerImagePath"] as? String? ?? ""
self.details = dictionary["details"] as? String? ?? ""
self.store_id = dictionary["store_id"] as? String? ?? ""
if let locationsData = dictionary["locations"] as? [[String : Any]?] {
var locationsArray:Array<UnifiedCampaignLocation> = []
......@@ -2221,6 +2227,15 @@ public class swiftApi {
}
}
public var _couponset_uuid: String {
get { // getter
return self.couponset_uuid ?? ""
}
set(newValue) { //setter
self.couponset_uuid = newValue
}
}
public var _id: String {
get { // getter
return self.id ?? ""
......@@ -2248,9 +2263,9 @@ public class swiftApi {
}
}
public var _affiliatedId: String {
public var _affiliatedId: Int {
get { // getter
return self.affiliatedId ?? ""
return self.affiliatedId ?? 0
}
set(newValue) { //setter
self.affiliatedId = newValue
......@@ -2302,9 +2317,9 @@ public class swiftApi {
}
}
public var _days: Int {
public var _days: Array<String> {
get { // getter
return self.days ?? 0
return self.days ?? []
}
set(newValue) { //setter
self.days = newValue
......@@ -2356,6 +2371,15 @@ public class swiftApi {
}
}
public var _store_id: String {
get { // getter
return self.store_id ?? ""
}
set(newValue) { //setter
self.store_id = newValue
}
}
public var _locations: Array<UnifiedCampaignLocation> {
get { // getter
return self.locations ?? []
......@@ -2376,7 +2400,7 @@ public class swiftApi {
private var telephone: String?
private var latitude: Double?
private var longitude: Double?
private var afiliateId: String?
private var afiliateId: Int?
private var url: String?
private var logoImage: String?
private var pinLogoImage: String?
......@@ -2390,7 +2414,7 @@ public class swiftApi {
self.telephone = ""
self.latitude = 0.0
self.longitude = 0.0
self.afiliateId = ""
self.afiliateId = 0
self.url = ""
self.logoImage = ""
self.pinLogoImage = ""
......@@ -2405,7 +2429,7 @@ public class swiftApi {
self.telephone = dictionary["telephone"] as? String? ?? ""
self.latitude = dictionary["latitude"] as? Double? ?? 0.0
self.longitude = dictionary["longitude"] as? Double? ?? 0.0
self.afiliateId = dictionary["afiliateId"] as? String? ?? ""
self.afiliateId = dictionary["afiliateId"] as? Int? ?? 0
self.url = dictionary["url"] as? String? ?? ""
self.logoImage = dictionary["logoImage"] as? String? ?? ""
self.pinLogoImage = dictionary["pinLogoImage"] as? String? ?? ""
......@@ -2483,9 +2507,9 @@ public class swiftApi {
}
}
public var _afiliateId: String {
public var _afiliateId: Int {
get { // getter
return self.afiliateId ?? ""
return self.afiliateId ?? 0
}
set(newValue) { //setter
self.afiliateId = newValue
......@@ -8160,7 +8184,83 @@ public class swiftApi {
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
getAvailableCouponsCallback(nil)
// getAvailableCouponsCallback(nil)
if let error = error as? NSError {
// if (error.code == 401) {
// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel()
// sessionEvent._sessionExpired = true
// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent)
// }
failureCallback(error.code)
} else {
failureCallback(-1)
}
}
}
public func getMapDataAsync(language: String, _ successCallback: @escaping (_ mapData: Array<UnifiedCampaignModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.getMapDataAsync(language, getMapDataAsyncCallback, failureBlock: getMapDataFailureCallback)
func getMapDataAsyncCallback(_ responseData: [AnyHashable: Any]?) -> Void {
var campaignsArray:Array<UnifiedCampaignModel> = []
if let responseDataDictionary = responseData as? [String: AnyObject] {
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_success_map_data"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
if let responseDataOffers = responseDataDictionary["offers"] as? [[String : Any]?] {
for item in responseDataOffers {
if let itemDictionary = item {
let tempCampaign = UnifiedCampaignModel(dictionary: itemDictionary)
campaignsArray.append(tempCampaign)
}
}
successCallback(campaignsArray)
} else {
successCallback(nil)
}
} else {
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_error_map_data"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
successCallback(nil)
}
}
func getMapDataFailureCallback(_ error: Error?) -> Void {
print("getMapData error: ")
print(error)
print("====================")
let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
dynatraceEvent._eventName = "custom_error_map_data"
dynatraceEvent._parameters = nil
SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
// successCallback(nil)
if let error = error as? NSError {
// if (error.code == 401) {
// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel()
// sessionEvent._sessionExpired = true
// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent)
// }
failureCallback(error.code)
} else {
failureCallback(-1)
}
}
}
......