Manos Chorianopoulos

Added editProfileAsync, setTrackersEnabled

...@@ -102,6 +102,7 @@ ...@@ -102,6 +102,7 @@
102 // - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state; 102 // - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
103 - (void)didReceiveNotification:(NSDictionary *)payload; 103 - (void)didReceiveNotification:(NSDictionary *)payload;
104 - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken; 104 - (void)sendDeviceInfoIfNecessary:(NSString *)newDeviceToken;
105 +- (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;
105 106
106 @end 107 @end
107 #endif /* MyApi_h */ 108 #endif /* MyApi_h */
......
...@@ -1615,4 +1615,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify"; ...@@ -1615,4 +1615,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
1615 [[Warply sharedService].pushManager sendDeviceInfoIfNecessary:newDeviceToken]; 1615 [[Warply sharedService].pushManager sendDeviceInfoIfNecessary:newDeviceToken];
1616 } 1616 }
1617 1617
1618 +- (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 {
1619 + [[Warply sharedService] editProfileWithSuccessBlock:firstname andLastName:lastname andEmail:email andSalutation:salutation andMsisdn:msisdn andNickname:nickname andGender:gender andBirthday:birthday andNameDay:nameday andTaxID:taxid andProfileMetadata:profileMetadata optin:optin newsLetter:newsletter andSMS:sms andSegmentation:segmentation andSMSSegmentation:smsSegmentation :^(NSDictionary *response) {
1620 + if (success) {
1621 + success(response);
1622 + }
1623 + } failureBlock:^(NSError *error) {
1624 + if (failure) {
1625 + failure(error);
1626 + }
1627 + }];
1628 +}
1629 +
1618 @end 1630 @end
......
...@@ -1130,7 +1130,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1130,7 +1130,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1130 if (taxID && ![taxID isEqual:@""]) { 1130 if (taxID && ![taxID isEqual:@""]) {
1131 [data setValue:taxID forKey:@"tax_id"]; 1131 [data setValue:taxID forKey:@"tax_id"];
1132 } 1132 }
1133 - if (profileMetadata && ![profileMetadata isEqual:@{}]) { 1133 + if (profileMetadata && ![profileMetadata isEqual:@{}]) {
1134 +// if (profileMetadata && !([profileMetadata count] == 0)) {
1134 [data setValue:profileMetadata forKey:@"profile_metadata"]; 1135 [data setValue:profileMetadata forKey:@"profile_metadata"];
1135 } 1136 }
1136 if (optin && ![optin isEqual:@NO]) { 1137 if (optin && ![optin isEqual:@NO]) {
...@@ -1153,9 +1154,9 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1153,9 +1154,9 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1153 [consumerData setValue:@"handle_user_details" forKey:@"action"]; 1154 [consumerData setValue:@"handle_user_details" forKey:@"action"];
1154 [consumerData setValue:@"edit" forKey:@"process"]; 1155 [consumerData setValue:@"edit" forKey:@"process"];
1155 [consumerData setValue:@NO forKey:@"del_empty"]; 1156 [consumerData setValue:@NO forKey:@"del_empty"];
1156 - if(data && ![data isEqual:@{}]) { 1157 +// if(data && ![data isEqual:@{}]) {
1157 [consumerData setValue:data forKey:@"data"]; 1158 [consumerData setValue:data forKey:@"data"];
1158 - } 1159 +// }
1159 1160
1160 NSMutableDictionary *postDictionary = [[NSMutableDictionary alloc] init]; 1161 NSMutableDictionary *postDictionary = [[NSMutableDictionary alloc] init];
1161 [postDictionary setValue:consumerData forKey:@"consumer_data"]; 1162 [postDictionary setValue:consumerData forKey:@"consumer_data"];
...@@ -1165,6 +1166,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1165,6 +1166,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1165 if (success) { 1166 if (success) {
1166 success(contextResponse); 1167 success(contextResponse);
1167 } 1168 }
1169 + NSLog(@"**************** WARPLY Response *****************" );
1170 + NSLog(@"%@", contextResponse );
1168 } failureBlock:^(NSError *error) { 1171 } failureBlock:^(NSError *error) {
1169 if (failure) { 1172 if (failure) {
1170 NSDictionary* dict = [NSDictionary alloc]; 1173 NSDictionary* dict = [NSDictionary alloc];
...@@ -1176,6 +1179,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) ...@@ -1176,6 +1179,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
1176 if (success) { 1179 if (success) {
1177 success(contextResponse); 1180 success(contextResponse);
1178 } 1181 }
1182 + NSLog(@"**************** WARPLY Response *****************" );
1183 + NSLog(@"%@", contextResponse );
1179 } failureBlock:^(NSError *error) { 1184 } failureBlock:^(NSError *error) {
1180 if (failure) { 1185 if (failure) {
1181 failure(error); 1186 failure(error);
......
...@@ -5586,4 +5586,65 @@ public class swiftApi { ...@@ -5586,4 +5586,65 @@ public class swiftApi {
5586 } 5586 }
5587 5587
5588 5588
5589 + public func editProfileAsync(firstname: String? = "", lastname: String? = "", email: String? = "", salutation: String? = "", msisdn: String? = "", nickname: String? = "", gender: String? = "", birthday: String? = "", nameday: String? = "", taxid: String? = "", profileMetadata: [String: Any]? = [String: Any](), optin: Bool? = false, newsletter: Bool? = false, sms: Bool? = false, segmentation: Bool? = false, smsSegmentation: Bool? = false, _ editProfileCallback: @escaping (_ editProfileData: VerifyTicketResponseModel?) -> Void) -> Void {
5590 +
5591 + let instanceOfMyApi = MyApi()
5592 + instanceOfMyApi.editProfileAsync(firstname, andLastname: lastname, andEmail: email, andSalutation: salutation, andMsisdn: msisdn, andNickname: nickname, andGender: gender, andBirthday: birthday, andNameDay: nameday, andTaxID: taxid, andProfileMetadata: profileMetadata, optin: optin as? NSNumber, newsLetter: newsletter as? NSNumber, andSMS: sms as? NSNumber, andSegmentation: segmentation as? NSNumber, andSMSSegmentation: smsSegmentation as? NSNumber, editProfileAsyncCallback, failureBlock: editProfileAsyncFailureCallback)
5593 +
5594 + func editProfileAsyncCallback(_ editProfileData: [AnyHashable: Any]?) -> Void {
5595 +
5596 + if let editProfileDataDictionary = editProfileData as? [String: Any] {
5597 +
5598 + let tempResponse = VerifyTicketResponseModel(dictionary: editProfileDataDictionary)
5599 +
5600 + editProfileCallback(tempResponse);
5601 +
5602 + if (tempResponse.getStatus == 1) {
5603 + swiftApi().getProfileAsync(getProfileCallback)
5604 + }
5605 +
5606 + } else {
5607 + editProfileCallback(nil)
5608 + }
5609 +
5610 + }
5611 +
5612 + func editProfileAsyncFailureCallback(_ error: Error?) -> Void {
5613 + print("editProfile error: ")
5614 + print(error)
5615 + print("====================")
5616 + editProfileCallback(nil)
5617 + }
5618 +
5619 + func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
5620 + if (profileData != nil) {
5621 + DispatchQueue.main.async {
5622 + swiftApi().setConsumer(profileData ?? swiftApi.ProfileModel())
5623 + swiftApi().setConsumerInternal(profileData ?? swiftApi.ProfileModel())
5624 + swiftApi().setUserTag(profileData?._badge ?? "")
5625 + }
5626 + } else {
5627 +
5628 + }
5629 + }
5630 + }
5631 +
5632 +
5633 + public func setTrackersEnabled(_ isEnabled: Bool) -> Void {
5634 +
5635 + var newProfileMetadata: [String: Any] = ["trackers_enabled": isEnabled]
5636 +
5637 + swiftApi().editProfileAsync(firstname: "", lastname: "", email: "", salutation: "", msisdn: "", nickname: "", gender: "", birthday: "", nameday: "", taxid: "", profileMetadata: newProfileMetadata, optin: false, newsletter: false, sms: false, segmentation: false, smsSegmentation: false, editProfileCallback)
5638 +
5639 + func editProfileCallback (_ editProfileData: swiftApi.VerifyTicketResponseModel?) -> Void {
5640 + if (editProfileData != nil) {
5641 +
5642 + DispatchQueue.main.async {
5643 + }
5644 + } else {
5645 + }
5646 + }
5647 + }
5648 +
5649 +
5589 } 5650 }
......