Showing
5 changed files
with
354 additions
and
17 deletions
... | @@ -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. | ... | ... |
... | @@ -4084,6 +4084,29 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -4084,6 +4084,29 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
4084 | } | 4084 | } |
4085 | 4085 | ||
4086 | /////////////////////////////////////////////////////////////////////////////// | 4086 | /////////////////////////////////////////////////////////////////////////////// |
4087 | +- (BOOL)getContextWithPathMap:(NSString *)path | ||
4088 | + language:(NSString *)language | ||
4089 | + successBlock:(void (^)(id contextResponse))successBlock | ||
4090 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
4091 | +{ | ||
4092 | + | ||
4093 | + if ([self isRegistrationValid] == NO) { | ||
4094 | + [_pendingOperationsQueue setSuspended:YES]; | ||
4095 | + [self registration]; | ||
4096 | + } | ||
4097 | + | ||
4098 | + NSInvocation *invocation = [self contextRequestInvocationWithTypeMap:WLContextRequestTypeGet | ||
4099 | + data:nil path:path language:language | ||
4100 | + successBlock:[successBlock copy] | ||
4101 | + failureBlock:[failureBlock copy]]; | ||
4102 | + | ||
4103 | + NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithInvocation:invocation]; | ||
4104 | + [_pendingOperationsQueue addOperation:operation]; | ||
4105 | + | ||
4106 | + return [self isRegistrationValid]; | ||
4107 | +} | ||
4108 | + | ||
4109 | +/////////////////////////////////////////////////////////////////////////////// | ||
4087 | - (BOOL)sendContext:(NSData*)context | 4110 | - (BOOL)sendContext:(NSData*)context |
4088 | successBlock:(void (^)(NSDictionary *contextResponse))successBlock | 4111 | successBlock:(void (^)(NSDictionary *contextResponse))successBlock |
4089 | failureBlock:(void (^)(NSError *error))failureBlock | 4112 | failureBlock:(void (^)(NSError *error))failureBlock |
... | @@ -6212,6 +6235,30 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6212,6 +6235,30 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
6212 | return invocation; | 6235 | return invocation; |
6213 | } | 6236 | } |
6214 | 6237 | ||
6238 | +- (NSInvocation *)contextRequestInvocationWithTypeMap:(WLContextRequestType)type | ||
6239 | + data:(NSData *)context | ||
6240 | + path:(NSString *)path | ||
6241 | + language:(NSString *)language | ||
6242 | + successBlock:(void (^)(NSDictionary *contextResponse))successBlock | ||
6243 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
6244 | +{ | ||
6245 | + void (^ successBlockCopy)(void) = [successBlock copy]; | ||
6246 | + void (^ failureBlockCopy)(void) = [failureBlock copy]; | ||
6247 | + | ||
6248 | + NSMethodSignature *sgn = [self methodSignatureForSelector:@selector(runContextRequestWithTypeMap:data:path:language:successBlock:failureBlock:)]; | ||
6249 | + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:sgn]; | ||
6250 | + [invocation setTarget:self]; | ||
6251 | + [invocation setSelector:@selector(runContextRequestWithTypeMap:data:path:language:successBlock:failureBlock:)]; | ||
6252 | + [invocation setArgument:&type atIndex:2]; | ||
6253 | + [invocation setArgument:&context atIndex:3]; | ||
6254 | + [invocation setArgument:&path atIndex:4]; | ||
6255 | + [invocation setArgument:&language atIndex:5]; | ||
6256 | + [invocation setArgument:&successBlockCopy atIndex:6]; | ||
6257 | + [invocation setArgument:&failureBlockCopy atIndex:7]; | ||
6258 | + [invocation retainArguments]; | ||
6259 | + return invocation; | ||
6260 | +} | ||
6261 | + | ||
6215 | - (NSInvocation *)contextRequestInvocationWithType2:(WLContextRequestType)type | 6262 | - (NSInvocation *)contextRequestInvocationWithType2:(WLContextRequestType)type |
6216 | data:(NSData *)context | 6263 | data:(NSData *)context |
6217 | path:(NSString *)path | 6264 | path:(NSString *)path |
... | @@ -6724,6 +6771,164 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -6724,6 +6771,164 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
6724 | } | 6771 | } |
6725 | } | 6772 | } |
6726 | 6773 | ||
6774 | +- (void)runContextRequestWithTypeMap:(WLContextRequestType)requestType | ||
6775 | + data:(NSData*)context | ||
6776 | + path:(NSString *)path | ||
6777 | + language:(NSString *)language | ||
6778 | + successBlock:(void (^)(id contextResponse))successBlock | ||
6779 | + failureBlock:(void (^)(NSError *error))failureBlock | ||
6780 | +{ | ||
6781 | + NSString *environment = @""; | ||
6782 | + if ([_appUUID isEqualToString:@"0086a2088301440792091b9f814c2267"]) { | ||
6783 | + environment = @"prod"; | ||
6784 | + } else { | ||
6785 | + environment = @"dev"; | ||
6786 | + } | ||
6787 | + | ||
6788 | + //Create REQUEST | ||
6789 | + NSMutableString *urlString = [NSMutableString stringWithFormat:@"%@/partners/cosmote/%@/map_data?language=%@", _baseURL, environment, language]; // 'https://engage-stage.warp.ly/partners/cosmote/prod/map_data?language=el' | ||
6790 | + | ||
6791 | + WLLOG(@"[WARP Trace] HTTP URL: %@", urlString); | ||
6792 | + | ||
6793 | + NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:30.0]; | ||
6794 | + [request setTimeoutInterval:30.0]; | ||
6795 | + | ||
6796 | + NSDictionary *parameters; | ||
6797 | + | ||
6798 | + if (context != nil) { | ||
6799 | + parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL]; | ||
6800 | + } | ||
6801 | + | ||
6802 | + SuccessResponse successResponse = ^(NSURLSessionDataTask * _Nonnull task, id _Nullable JSON) { | ||
6803 | + if (JSON == nil) { | ||
6804 | + successBlock(@{@"status": @"0"}); | ||
6805 | + } | ||
6806 | + else { | ||
6807 | + | ||
6808 | +// NSData *responseData = [NSJSONSerialization dataWithJSONObject:JSON options:NSJSONWritingPrettyPrinted error:NULL]; | ||
6809 | +// NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; | ||
6810 | + // WLLOG(@"[WARP Trace] HTTP %@ Response:%@", request.HTTPMethod, responseString); | ||
6811 | + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod); | ||
6812 | + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId); | ||
6813 | + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey); | ||
6814 | + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString); | ||
6815 | + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding]; | ||
6816 | + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString); | ||
6817 | + WLLOG(@"*************************************************"); | ||
6818 | + NSDictionary *contextResponse=[JSON valueForKey:@"result"]; | ||
6819 | + | ||
6820 | + if ([JSON objectForKey:@"status"]) { | ||
6821 | + | ||
6822 | + int status = [[JSON valueForKey:@"status"] intValue]; | ||
6823 | + | ||
6824 | + // if (status != WLResultCodesSuccess) | ||
6825 | + // { | ||
6826 | + // if ((status == WLResultCodesInvalidWebID) || (status == WLResultCodesDeviceRegistrationFailed)) | ||
6827 | + // { | ||
6828 | + // self.webId = nil; | ||
6829 | + // self.apiKey = nil; | ||
6830 | + | ||
6831 | + // [_pendingOperationsQueue setSuspended:YES]; | ||
6832 | + // } | ||
6833 | + | ||
6834 | + // NSString *errorDescrition = (status <= [WLResultCodesDescriptions count]) && status > 0 ? (WLResultCodesDescriptions[(status-1)]) : ([NSString stringWithFormat:@"Internal WARP Server error %d", status]); | ||
6835 | + | ||
6836 | + // NSDictionary *eDict = @{NSLocalizedDescriptionKey: errorDescrition}; | ||
6837 | + // NSError *error = [NSError errorWithDomain:WARP_ERROR_DOMAIN code:status userInfo:eDict]; | ||
6838 | + | ||
6839 | + // if (failureBlock) | ||
6840 | + // failureBlock(error); | ||
6841 | + | ||
6842 | + // return; | ||
6843 | + // } | ||
6844 | + | ||
6845 | + if (successBlock) | ||
6846 | + { | ||
6847 | + if ([path length]!=0) | ||
6848 | + { | ||
6849 | + successBlock([contextResponse valueForKey:path]); | ||
6850 | + return; | ||
6851 | + } | ||
6852 | + successBlock(contextResponse); | ||
6853 | + } | ||
6854 | + | ||
6855 | + | ||
6856 | + }else{ | ||
6857 | + NSError *error = [NSError errorWithDomain:WARP_ERROR_DOMAIN code:1026 userInfo:@{NSLocalizedDescriptionKey: NSLocalizedString(@"Empty response", @"Warply")}]; | ||
6858 | + if (failureBlock) | ||
6859 | + failureBlock(error); | ||
6860 | + | ||
6861 | + } | ||
6862 | + | ||
6863 | + } | ||
6864 | + }; | ||
6865 | + | ||
6866 | + FailureResponse faliureResponse = ^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { | ||
6867 | + WLLOG(@"************ WARP %@ CONTEXT ******************", request.HTTPMethod); | ||
6868 | + WLLOG(@"[WARP Trace] HTTP Web Id: %@", _webId); | ||
6869 | + WLLOG(@"[WARP Trace] HTTP API Key: %@", _apiKey); | ||
6870 | + WLLOG(@"[WARP Trace] HTTP %@ Request URL: %@", request.HTTPMethod, request.URL.absoluteString); | ||
6871 | + NSString *contextString = [[NSString alloc] initWithData:context encoding:NSUTF8StringEncoding]; | ||
6872 | + | ||
6873 | + | ||
6874 | + WLLOG(@"[WARP Trace] HTTP %@ Request Body: %@", request.HTTPMethod, contextString); | ||
6875 | + WLLOG(@"[WARP Trace] Error: %@", [error description]); | ||
6876 | + WLLOG(@"*************************************************"); | ||
6877 | + if (failureBlock) | ||
6878 | + failureBlock(error); | ||
6879 | + }; | ||
6880 | + | ||
6881 | + _httpClient.responseSerializer = [AFJSONResponseSerializer serializer]; | ||
6882 | + _httpClient.requestSerializer = [AFJSONRequestSerializer serializer]; | ||
6883 | + [_httpClient.requestSerializer setTimeoutInterval:30]; | ||
6884 | + | ||
6885 | + //Set HTTP Headers | ||
6886 | + time_t timestamp = (time_t) [[NSDate date] timeIntervalSince1970]; | ||
6887 | + | ||
6888 | + NSString *loyaltyDate = @""; | ||
6889 | + NSString *loyaltySignature = @""; | ||
6890 | + NSString *bundleId = @""; | ||
6891 | + @try { | ||
6892 | + loyaltyDate = [NSString stringWithFormat:@"%lu", timestamp]; | ||
6893 | + loyaltySignature = [[NSString stringWithFormat:@"%@%lu", _apiKey, timestamp] SHA256Sum]; | ||
6894 | + bundleId = [NSString stringWithFormat:@"ios:%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]]; | ||
6895 | + } | ||
6896 | + @catch (NSException *exception) { | ||
6897 | + NSLog(@"HTTPHeaders error: %@", exception.reason); | ||
6898 | + if (failureBlock) { | ||
6899 | + NSError *error = nil; | ||
6900 | + failureBlock(error); | ||
6901 | + } | ||
6902 | + } | ||
6903 | + @finally { | ||
6904 | +// NSLog(@"Finally condition"); | ||
6905 | + } | ||
6906 | + | ||
6907 | + [_httpClient.requestSerializer setValue:_webId forHTTPHeaderField:@"loyalty-web-id"]; | ||
6908 | + // [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"%lu", timestamp] forHTTPHeaderField:@"loyalty-date"]; | ||
6909 | + // [_httpClient.requestSerializer setValue:[[NSString stringWithFormat:@"%@%lu", _apiKey, timestamp] SHA256Sum] forHTTPHeaderField:@"loyalty-signature"]; | ||
6910 | + [_httpClient.requestSerializer setValue:loyaltyDate forHTTPHeaderField:@"loyalty-date"]; | ||
6911 | + [_httpClient.requestSerializer setValue:loyaltySignature forHTTPHeaderField:@"loyalty-signature"]; | ||
6912 | + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"Accept-Encoding"]; | ||
6913 | + [_httpClient.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"Accept"]; | ||
6914 | + [_httpClient.requestSerializer setValue:@"gzip" forHTTPHeaderField:@"User-Agent"]; | ||
6915 | + // [_httpClient.requestSerializer setValue:[NSString stringWithFormat:@"ios:%@", [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]] forHTTPHeaderField:@"loyalty-bundle-id"]; | ||
6916 | + [_httpClient.requestSerializer setValue:bundleId forHTTPHeaderField:@"loyalty-bundle-id"]; | ||
6917 | + [_httpClient.requestSerializer setValue:[[[UIDevice currentDevice] identifierForVendor] UUIDString] forHTTPHeaderField:@"unique-device-id"]; | ||
6918 | + [_httpClient.requestSerializer setValue:@"apple" forHTTPHeaderField:@"vendor"]; | ||
6919 | + [_httpClient.requestSerializer setValue:@"platform" forHTTPHeaderField:@"ios"]; | ||
6920 | + [_httpClient.requestSerializer setValue:@"os_version" forHTTPHeaderField:[[UIDevice currentDevice] systemVersion]]; | ||
6921 | + [_httpClient.requestSerializer setValue:@"mobile" forHTTPHeaderField:@"channel"]; | ||
6922 | + if (requestType == WLContextRequestTypePost) { | ||
6923 | +// NSDictionary *parameters = [NSJSONSerialization JSONObjectWithData:context options:NSJSONReadingAllowFragments error:NULL]; | ||
6924 | + | ||
6925 | + [_httpClient POST:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse]; | ||
6926 | + } | ||
6927 | + else { | ||
6928 | + [_httpClient GET:urlString parameters:parameters progress:nil success:successResponse failure:faliureResponse]; | ||
6929 | + } | ||
6930 | +} | ||
6931 | + | ||
6727 | - (void)runContextRequestWithTypeCosmote:(WLContextRequestType)requestType | 6932 | - (void)runContextRequestWithTypeCosmote:(WLContextRequestType)requestType |
6728 | data:(NSData*)context | 6933 | data:(NSData*)context |
6729 | path:(NSString *)path | 6934 | path:(NSString *)path |
... | @@ -7670,6 +7875,23 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg | ... | @@ -7670,6 +7875,23 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg |
7670 | } | 7875 | } |
7671 | 7876 | ||
7672 | /////////////////////////////////////////////////////////////////////////////// | 7877 | /////////////////////////////////////////////////////////////////////////////// |
7878 | +- (void)getMapDataWithSuccessBlock:(NSString *)language :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
7879 | +{ | ||
7880 | + [self getContextWithPathMap:nil language:language successBlock:^(NSDictionary *contextResponse) { | ||
7881 | + if (success){ | ||
7882 | + success(contextResponse); | ||
7883 | + } | ||
7884 | + NSLog(@"**************** WARPLY Response *****************" ); | ||
7885 | + NSLog(@"%@", contextResponse ); | ||
7886 | + } failureBlock:^(NSError *error) { | ||
7887 | + if (failure) { | ||
7888 | + failure(error); | ||
7889 | + } | ||
7890 | + NSLog(@"Error at get Map Data %@", error ); | ||
7891 | + }]; | ||
7892 | +} | ||
7893 | + | ||
7894 | +/////////////////////////////////////////////////////////////////////////////// | ||
7673 | - (void)networkReachabilityReporting | 7895 | - (void)networkReachabilityReporting |
7674 | { | 7896 | { |
7675 | __weak Warply *myself = self; | 7897 | __weak Warply *myself = self; | ... | ... |
... | @@ -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 | ... | ... |
-
Please register or login to post a comment