Manos Chorianopoulos

Added editProfileAsync, setTrackersEnabled

......@@ -102,6 +102,7 @@
// - (void)didReceiveNotification:(NSDictionary *)userInfo whileAppWasInState:(WLApplicationState)state;
- (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;
@end
#endif /* MyApi_h */
......
......@@ -1615,4 +1615,16 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
[[Warply sharedService].pushManager sendDeviceInfoIfNecessary: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 {
[[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) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
......@@ -1131,6 +1131,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
[data setValue:taxID forKey:@"tax_id"];
}
if (profileMetadata && ![profileMetadata isEqual:@{}]) {
// if (profileMetadata && !([profileMetadata count] == 0)) {
[data setValue:profileMetadata forKey:@"profile_metadata"];
}
if (optin && ![optin isEqual:@NO]) {
......@@ -1153,9 +1154,9 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
[consumerData setValue:@"handle_user_details" forKey:@"action"];
[consumerData setValue:@"edit" forKey:@"process"];
[consumerData setValue:@NO forKey:@"del_empty"];
if(data && ![data isEqual:@{}]) {
// if(data && ![data isEqual:@{}]) {
[consumerData setValue:data forKey:@"data"];
}
// }
NSMutableDictionary *postDictionary = [[NSMutableDictionary alloc] init];
[postDictionary setValue:consumerData forKey:@"consumer_data"];
......@@ -1165,6 +1166,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (success) {
success(contextResponse);
}
NSLog(@"**************** WARPLY Response *****************" );
NSLog(@"%@", contextResponse );
} failureBlock:^(NSError *error) {
if (failure) {
NSDictionary* dict = [NSDictionary alloc];
......@@ -1176,6 +1179,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (success) {
success(contextResponse);
}
NSLog(@"**************** WARPLY Response *****************" );
NSLog(@"%@", contextResponse );
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
......
......@@ -5586,4 +5586,65 @@ public class swiftApi {
}
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 {
let instanceOfMyApi = MyApi()
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)
func editProfileAsyncCallback(_ editProfileData: [AnyHashable: Any]?) -> Void {
if let editProfileDataDictionary = editProfileData as? [String: Any] {
let tempResponse = VerifyTicketResponseModel(dictionary: editProfileDataDictionary)
editProfileCallback(tempResponse);
if (tempResponse.getStatus == 1) {
swiftApi().getProfileAsync(getProfileCallback)
}
} else {
editProfileCallback(nil)
}
}
func editProfileAsyncFailureCallback(_ error: Error?) -> Void {
print("editProfile error: ")
print(error)
print("====================")
editProfileCallback(nil)
}
func getProfileCallback (_ profileData: swiftApi.ProfileModel?) -> Void {
if (profileData != nil) {
DispatchQueue.main.async {
swiftApi().setConsumer(profileData ?? swiftApi.ProfileModel())
swiftApi().setConsumerInternal(profileData ?? swiftApi.ProfileModel())
swiftApi().setUserTag(profileData?._badge ?? "")
}
} else {
}
}
}
public func setTrackersEnabled(_ isEnabled: Bool) -> Void {
var newProfileMetadata: [String: Any] = ["trackers_enabled": isEnabled]
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)
func editProfileCallback (_ editProfileData: swiftApi.VerifyTicketResponseModel?) -> Void {
if (editProfileData != nil) {
DispatchQueue.main.async {
}
} else {
}
}
}
}
......