Manos Chorianopoulos

Add getMapDataAsync request

...@@ -116,6 +116,7 @@ ...@@ -116,6 +116,7 @@
116 - (BOOL)sdkInitialised; 116 - (BOOL)sdkInitialised;
117 - (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; 117 - (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;
118 - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 118 - (void)getSingleCampaignAsync:(NSString*)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
119 +- (void)getMapDataAsync:(NSString*)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
119 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority; 120 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority;
120 - (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token; 121 - (void)updateRefreshTokenMA:(NSString*)access_token :(NSString*)refresh_token;
121 - (NSString*)getAccessTokenM; 122 - (NSString*)getAccessTokenM;
......
...@@ -1846,6 +1846,18 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1846,6 +1846,18 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1846 }]; 1846 }];
1847 } 1847 }
1848 1848
1849 +- (void)getMapDataAsync:(NSString*)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure {
1850 + [[Warply sharedService] getMapDataWithSuccessBlock:language :^(NSDictionary *response) {
1851 + if (success) {
1852 + success(response);
1853 + }
1854 + } failureBlock:^(NSError *error) {
1855 + if (failure) {
1856 + failure(error);
1857 + }
1858 + }];
1859 +}
1860 +
1849 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority { 1861 - (void) sendEvent: (NSString *) eventName priority: (BOOL) priority {
1850 NSString *event_Name = eventName; 1862 NSString *event_Name = eventName;
1851 NSNumber *time_submitted = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]]; 1863 NSNumber *time_submitted = [NSNumber numberWithDouble:[[NSDate date] timeIntervalSince1970]];
......
...@@ -427,6 +427,8 @@ WL_VERSION_INTERFACE() ...@@ -427,6 +427,8 @@ WL_VERSION_INTERFACE()
427 427
428 - (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; 428 - (void)getSingleCampaignWithSuccessBlock:(NSString *)sessionUuid :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
429 429
430 +- (void)getMapDataWithSuccessBlock:(NSString *)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
431 +
430 /*! 432 /*!
431 @abstract Get the full page add accordint to the display_type of a campaign. 433 @abstract Get the full page add accordint to the display_type of a campaign.
432 @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. 434 @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 { ...@@ -2154,58 +2154,64 @@ public class swiftApi {
2154 2154
2155 2155
2156 public class UnifiedCampaignModel: Codable { 2156 public class UnifiedCampaignModel: Codable {
2157 + private var couponset_uuid: String?
2157 private var id: String? 2158 private var id: String?
2158 private var title: String? 2159 private var title: String?
2159 private var position: Int? 2160 private var position: Int?
2160 - private var affiliatedId: String? 2161 + private var affiliatedId: Int?
2161 private var shortDescription: String? 2162 private var shortDescription: String?
2162 private var longDescription: String? 2163 private var longDescription: String?
2163 private var isHot: Bool? 2164 private var isHot: Bool?
2164 private var logoImagePath: String? 2165 private var logoImagePath: String?
2165 private var bigLogoImagePath: String? 2166 private var bigLogoImagePath: String?
2166 - private var days: Int? 2167 + private var days: Array<String>?
2167 private var dayText: String? 2168 private var dayText: String?
2168 private var imagePath: String? 2169 private var imagePath: String?
2169 private var bigImagePath: String? 2170 private var bigImagePath: String?
2170 private var markerImagePath: String? 2171 private var markerImagePath: String?
2171 private var details: String? 2172 private var details: String?
2173 + private var store_id: String?
2172 private var locations: Array<UnifiedCampaignLocation>? 2174 private var locations: Array<UnifiedCampaignLocation>?
2173 2175
2174 public init() { 2176 public init() {
2177 + self.couponset_uuid = ""
2175 self.id = "" 2178 self.id = ""
2176 self.title = "" 2179 self.title = ""
2177 self.position = 0 2180 self.position = 0
2178 - self.affiliatedId = "" 2181 + self.affiliatedId = 0
2179 self.shortDescription = "" 2182 self.shortDescription = ""
2180 self.longDescription = "" 2183 self.longDescription = ""
2181 self.isHot = false 2184 self.isHot = false
2182 self.logoImagePath = "" 2185 self.logoImagePath = ""
2183 self.bigLogoImagePath = "" 2186 self.bigLogoImagePath = ""
2184 - self.days = 0 2187 + self.days = []
2185 self.dayText = "" 2188 self.dayText = ""
2186 self.imagePath = "" 2189 self.imagePath = ""
2187 self.bigImagePath = "" 2190 self.bigImagePath = ""
2188 self.markerImagePath = "" 2191 self.markerImagePath = ""
2189 self.details = "" 2192 self.details = ""
2193 + self.store_id = ""
2190 self.locations = [] 2194 self.locations = []
2191 } 2195 }
2192 2196
2193 public init(dictionary: [String: Any]) { 2197 public init(dictionary: [String: Any]) {
2198 + self.couponset_uuid = dictionary["COUPONSET_UUID"] as? String? ?? ""
2194 self.id = dictionary["id"] as? String? ?? "" 2199 self.id = dictionary["id"] as? String? ?? ""
2195 self.title = dictionary["title"] as? String? ?? "" 2200 self.title = dictionary["title"] as? String? ?? ""
2196 self.position = dictionary["position"] as? Int? ?? 0 2201 self.position = dictionary["position"] as? Int? ?? 0
2197 - self.affiliatedId = dictionary["affiliatedId"] as? String? ?? "" 2202 + self.affiliatedId = dictionary["affiliatedId"] as? Int? ?? 0
2198 self.shortDescription = dictionary["shortDescription"] as? String? ?? "" 2203 self.shortDescription = dictionary["shortDescription"] as? String? ?? ""
2199 self.longDescription = dictionary["longDescription"] as? String? ?? "" 2204 self.longDescription = dictionary["longDescription"] as? String? ?? ""
2200 self.isHot = dictionary["isHot"] as? Bool? ?? false 2205 self.isHot = dictionary["isHot"] as? Bool? ?? false
2201 self.logoImagePath = dictionary["logoImagePath"] as? String? ?? "" 2206 self.logoImagePath = dictionary["logoImagePath"] as? String? ?? ""
2202 self.bigLogoImagePath = dictionary["bigLogoImagePath"] as? String? ?? "" 2207 self.bigLogoImagePath = dictionary["bigLogoImagePath"] as? String? ?? ""
2203 - self.days = dictionary["days"] as? Int? ?? 0 2208 + self.days = dictionary["days"] as? Array<String>? ?? []
2204 self.dayText = dictionary["dayText"] as? String? ?? "" 2209 self.dayText = dictionary["dayText"] as? String? ?? ""
2205 self.imagePath = dictionary["imagePath"] as? String? ?? "" 2210 self.imagePath = dictionary["imagePath"] as? String? ?? ""
2206 self.bigImagePath = dictionary["bigImagePath"] as? String? ?? "" 2211 self.bigImagePath = dictionary["bigImagePath"] as? String? ?? ""
2207 self.markerImagePath = dictionary["markerImagePath"] as? String? ?? "" 2212 self.markerImagePath = dictionary["markerImagePath"] as? String? ?? ""
2208 self.details = dictionary["details"] as? String? ?? "" 2213 self.details = dictionary["details"] as? String? ?? ""
2214 + self.store_id = dictionary["store_id"] as? String? ?? ""
2209 2215
2210 if let locationsData = dictionary["locations"] as? [[String : Any]?] { 2216 if let locationsData = dictionary["locations"] as? [[String : Any]?] {
2211 var locationsArray:Array<UnifiedCampaignLocation> = [] 2217 var locationsArray:Array<UnifiedCampaignLocation> = []
...@@ -2221,6 +2227,15 @@ public class swiftApi { ...@@ -2221,6 +2227,15 @@ public class swiftApi {
2221 } 2227 }
2222 } 2228 }
2223 2229
2230 + public var _couponset_uuid: String {
2231 + get { // getter
2232 + return self.couponset_uuid ?? ""
2233 + }
2234 + set(newValue) { //setter
2235 + self.couponset_uuid = newValue
2236 + }
2237 + }
2238 +
2224 public var _id: String { 2239 public var _id: String {
2225 get { // getter 2240 get { // getter
2226 return self.id ?? "" 2241 return self.id ?? ""
...@@ -2248,9 +2263,9 @@ public class swiftApi { ...@@ -2248,9 +2263,9 @@ public class swiftApi {
2248 } 2263 }
2249 } 2264 }
2250 2265
2251 - public var _affiliatedId: String { 2266 + public var _affiliatedId: Int {
2252 get { // getter 2267 get { // getter
2253 - return self.affiliatedId ?? "" 2268 + return self.affiliatedId ?? 0
2254 } 2269 }
2255 set(newValue) { //setter 2270 set(newValue) { //setter
2256 self.affiliatedId = newValue 2271 self.affiliatedId = newValue
...@@ -2302,9 +2317,9 @@ public class swiftApi { ...@@ -2302,9 +2317,9 @@ public class swiftApi {
2302 } 2317 }
2303 } 2318 }
2304 2319
2305 - public var _days: Int { 2320 + public var _days: Array<String> {
2306 get { // getter 2321 get { // getter
2307 - return self.days ?? 0 2322 + return self.days ?? []
2308 } 2323 }
2309 set(newValue) { //setter 2324 set(newValue) { //setter
2310 self.days = newValue 2325 self.days = newValue
...@@ -2356,6 +2371,15 @@ public class swiftApi { ...@@ -2356,6 +2371,15 @@ public class swiftApi {
2356 } 2371 }
2357 } 2372 }
2358 2373
2374 + public var _store_id: String {
2375 + get { // getter
2376 + return self.store_id ?? ""
2377 + }
2378 + set(newValue) { //setter
2379 + self.store_id = newValue
2380 + }
2381 + }
2382 +
2359 public var _locations: Array<UnifiedCampaignLocation> { 2383 public var _locations: Array<UnifiedCampaignLocation> {
2360 get { // getter 2384 get { // getter
2361 return self.locations ?? [] 2385 return self.locations ?? []
...@@ -2376,7 +2400,7 @@ public class swiftApi { ...@@ -2376,7 +2400,7 @@ public class swiftApi {
2376 private var telephone: String? 2400 private var telephone: String?
2377 private var latitude: Double? 2401 private var latitude: Double?
2378 private var longitude: Double? 2402 private var longitude: Double?
2379 - private var afiliateId: String? 2403 + private var afiliateId: Int?
2380 private var url: String? 2404 private var url: String?
2381 private var logoImage: String? 2405 private var logoImage: String?
2382 private var pinLogoImage: String? 2406 private var pinLogoImage: String?
...@@ -2390,7 +2414,7 @@ public class swiftApi { ...@@ -2390,7 +2414,7 @@ public class swiftApi {
2390 self.telephone = "" 2414 self.telephone = ""
2391 self.latitude = 0.0 2415 self.latitude = 0.0
2392 self.longitude = 0.0 2416 self.longitude = 0.0
2393 - self.afiliateId = "" 2417 + self.afiliateId = 0
2394 self.url = "" 2418 self.url = ""
2395 self.logoImage = "" 2419 self.logoImage = ""
2396 self.pinLogoImage = "" 2420 self.pinLogoImage = ""
...@@ -2405,7 +2429,7 @@ public class swiftApi { ...@@ -2405,7 +2429,7 @@ public class swiftApi {
2405 self.telephone = dictionary["telephone"] as? String? ?? "" 2429 self.telephone = dictionary["telephone"] as? String? ?? ""
2406 self.latitude = dictionary["latitude"] as? Double? ?? 0.0 2430 self.latitude = dictionary["latitude"] as? Double? ?? 0.0
2407 self.longitude = dictionary["longitude"] as? Double? ?? 0.0 2431 self.longitude = dictionary["longitude"] as? Double? ?? 0.0
2408 - self.afiliateId = dictionary["afiliateId"] as? String? ?? "" 2432 + self.afiliateId = dictionary["afiliateId"] as? Int? ?? 0
2409 self.url = dictionary["url"] as? String? ?? "" 2433 self.url = dictionary["url"] as? String? ?? ""
2410 self.logoImage = dictionary["logoImage"] as? String? ?? "" 2434 self.logoImage = dictionary["logoImage"] as? String? ?? ""
2411 self.pinLogoImage = dictionary["pinLogoImage"] as? String? ?? "" 2435 self.pinLogoImage = dictionary["pinLogoImage"] as? String? ?? ""
...@@ -2483,9 +2507,9 @@ public class swiftApi { ...@@ -2483,9 +2507,9 @@ public class swiftApi {
2483 } 2507 }
2484 } 2508 }
2485 2509
2486 - public var _afiliateId: String { 2510 + public var _afiliateId: Int {
2487 get { // getter 2511 get { // getter
2488 - return self.afiliateId ?? "" 2512 + return self.afiliateId ?? 0
2489 } 2513 }
2490 set(newValue) { //setter 2514 set(newValue) { //setter
2491 self.afiliateId = newValue 2515 self.afiliateId = newValue
...@@ -8160,7 +8184,83 @@ public class swiftApi { ...@@ -8160,7 +8184,83 @@ public class swiftApi {
8160 dynatraceEvent._parameters = nil 8184 dynatraceEvent._parameters = nil
8161 SwiftEventBus.post("dynatrace", sender: dynatraceEvent) 8185 SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
8162 8186
8163 - getAvailableCouponsCallback(nil) 8187 + // getAvailableCouponsCallback(nil)
8188 + if let error = error as? NSError {
8189 +// if (error.code == 401) {
8190 +// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel()
8191 +// sessionEvent._sessionExpired = true
8192 +// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent)
8193 +// }
8194 +
8195 + failureCallback(error.code)
8196 + } else {
8197 + failureCallback(-1)
8198 + }
8199 + }
8200 + }
8201 +
8202 +
8203 + public func getMapDataAsync(language: String, _ successCallback: @escaping (_ mapData: Array<UnifiedCampaignModel>?) -> Void, failureCallback: @escaping (_ errorCode: Int) -> Void) -> Void {
8204 +
8205 + let instanceOfMyApi = MyApi()
8206 + instanceOfMyApi.getMapDataAsync(language, getMapDataAsyncCallback, failureBlock: getMapDataFailureCallback)
8207 +
8208 + func getMapDataAsyncCallback(_ responseData: [AnyHashable: Any]?) -> Void {
8209 + var campaignsArray:Array<UnifiedCampaignModel> = []
8210 +
8211 + if let responseDataDictionary = responseData as? [String: AnyObject] {
8212 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
8213 + dynatraceEvent._eventName = "custom_success_map_data"
8214 + dynatraceEvent._parameters = nil
8215 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
8216 +
8217 + if let responseDataOffers = responseDataDictionary["offers"] as? [[String : Any]?] {
8218 + for item in responseDataOffers {
8219 + if let itemDictionary = item {
8220 + let tempCampaign = UnifiedCampaignModel(dictionary: itemDictionary)
8221 + campaignsArray.append(tempCampaign)
8222 + }
8223 + }
8224 +
8225 + successCallback(campaignsArray)
8226 +
8227 + } else {
8228 + successCallback(nil)
8229 + }
8230 +
8231 + } else {
8232 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
8233 + dynatraceEvent._eventName = "custom_error_map_data"
8234 + dynatraceEvent._parameters = nil
8235 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
8236 +
8237 + successCallback(nil)
8238 + }
8239 +
8240 + }
8241 +
8242 + func getMapDataFailureCallback(_ error: Error?) -> Void {
8243 + print("getMapData error: ")
8244 + print(error)
8245 + print("====================")
8246 +
8247 + let dynatraceEvent = swiftApi.LoyaltySDKDynatraceEventModel()
8248 + dynatraceEvent._eventName = "custom_error_map_data"
8249 + dynatraceEvent._parameters = nil
8250 + SwiftEventBus.post("dynatrace", sender: dynatraceEvent)
8251 +
8252 + // successCallback(nil)
8253 + if let error = error as? NSError {
8254 +// if (error.code == 401) {
8255 +// let sessionEvent = swiftApi.LoyaltySDKSessionExpiredEventModel()
8256 +// sessionEvent._sessionExpired = true
8257 +// SwiftEventBus.post("sdk_session_expired", sender: sessionEvent)
8258 +// }
8259 +
8260 + failureCallback(error.code)
8261 + } else {
8262 + failureCallback(-1)
8263 + }
8164 } 8264 }
8165 } 8265 }
8166 8266
......