Manos Chorianopoulos

add getMultilingualMerchantsAsync, MerchantModel

......@@ -97,6 +97,7 @@
- (void)getCampaignsAsyncNew:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getCampaignsPersonalizedAsync:(NSString*)language :(NSDictionary*)filters :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getSharingHistoryAsync:(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure;
@end
#endif /* MyApi_h */
......
......@@ -1216,32 +1216,32 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
return resp;
}
- (NSDictionary*)retrieveMultilingualMerchantsWithCategories:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance {
__block NSDictionary *resp = [NSDictionary alloc];
__block BOOL isRunLoopNested = NO;
__block BOOL isOperationCompleted = NO;
[[Warply sharedService] retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:categories andDefaultShown:defaultShown andCenter:center andTags:tags andUuid:uuid andDistance:distance :^(NSDictionary *response) {
resp = response;
isOperationCompleted = YES;
if (isRunLoopNested) {
CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns
}
} failureBlock:^(NSError *error) {
NSLog(@"%@", error);
resp = nil;
isOperationCompleted = YES;
if (isRunLoopNested) {
CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns
}
}];
if ( ! isOperationCompleted) {
isRunLoopNested = YES;
NSLog(@"Waiting...");
CFRunLoopRun(); // Magic!
isRunLoopNested = NO;
}
return resp;
}
// - (NSDictionary*)retrieveMultilingualMerchantsWithCategories:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance {
// __block NSDictionary *resp = [NSDictionary alloc];
// __block BOOL isRunLoopNested = NO;
// __block BOOL isOperationCompleted = NO;
// [[Warply sharedService] retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:categories andDefaultShown:defaultShown andCenter:center andTags:tags andUuid:uuid andDistance:distance :^(NSDictionary *response) {
// resp = response;
// isOperationCompleted = YES;
// if (isRunLoopNested) {
// CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns
// }
// } failureBlock:^(NSError *error) {
// NSLog(@"%@", error);
// resp = nil;
// isOperationCompleted = YES;
// if (isRunLoopNested) {
// CFRunLoopStop(CFRunLoopGetCurrent()); // CFRunLoopRun() returns
// }
// }];
// if ( ! isOperationCompleted) {
// isRunLoopNested = YES;
// NSLog(@"Waiting...");
// CFRunLoopRun(); // Magic!
// isRunLoopNested = NO;
// }
// return resp;
// }
- (NSDictionary*)getCouponSetsWithActive:(NSNumber*)active andVisible:(NSNumber*)visible andUuids:(NSArray*)uuids {
__block NSDictionary *resp = [NSDictionary alloc];
......@@ -1578,4 +1578,17 @@ NSString *VERIFY_URL = @"/partners/cosmote/verify";
}];
}
- (void)getMultilingualMerchantsAsync:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void (^)(NSDictionary *response))success failureBlock:(void (^)(NSError *error))failure {
[[Warply sharedService] retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:categories andDefaultShown:defaultShown andCenter:center andTags:tags andUuid:uuid andDistance:distance parent_uuids:parent_uuids :^(NSDictionary *response) {
if (success) {
success(response);
}
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
}
}];
}
@end
......
......@@ -383,7 +383,7 @@ WL_VERSION_INTERFACE()
- (void)resetPasswordWithPasswordWithSuccessBlock:(NSString*)password andConfCode:(NSString*)confCode andOtpUuid:(NSString*)otpUuid andConfToken:(NSString*)confToken :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void)retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
- (void) getCouponSetsWithSuccessBlock:(NSNumber*) active andVisible:(NSNumber*) visible andUuids:(NSArray*) uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure;
......
......@@ -2045,7 +2045,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}];
}
- (void)retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
- (void)retrieveMultilingualMerchantsWithCategoriesWithSuccessBlock:(NSArray*)categories andDefaultShown:(NSNumber*)defaultShown andCenter:(NSNumber*)center andTags:(NSArray*)tags andUuid:(NSString*)uuid andDistance:(NSNumber*)distance parent_uuids:(NSArray*)parent_uuids :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure
{
NSString* appUuid = [NSString alloc];
appUuid = [WLKeychain getStringForKey:@"NBAPPUuid"];
......@@ -2060,7 +2060,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
} else {
[data setValue:[NSNull null] forKey:@"default_shown"];
}
if (tags) {
if (tags && ![tags isEqual:@[]]) {
[data setValue:tags forKey:@"tags"];
} else {
[data setValue:[NSNull null] forKey:@"tags"];
......@@ -2068,7 +2068,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (uuid && ![uuid isEqual:@""]) {
[data setValue:uuid forKey:@"uuid"];
}
if (distance != 0 && center) {
if (distance && ![distance isEqual:@0] && center) {
NSMutableDictionary* dataLocation = [[NSMutableDictionary alloc] init];
[dataLocation setValue:distance forKey:@"distance"];
[dataLocation setValue:center forKey:@"center"];
......@@ -2078,7 +2078,11 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
} else {
[data setValue:[NSNull null] forKey:@"location"];
}
if (parent_uuids && ![parent_uuids isEqual:@[]]) {
[data setValue:parent_uuids forKey:@"parent_uuids"];
} else {
[data setValue:[NSNull null] forKey:@"parent_uuids"];
}
NSMutableDictionary* dataShops = [[NSMutableDictionary alloc] init];
[dataShops setValue:data forKey:@"shops"];
......@@ -2087,6 +2091,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (success) {
success(contextResponse);
}
NSLog(@"**************** WARPLY Response *****************" );
NSLog(@"%@", contextResponse );
} failureBlock:^(NSError *error) {
if (failure) {
failure(error);
......
......@@ -302,6 +302,7 @@ public class swiftApi {
public let buyable: Bool?
public let visible: Bool?
public let terms: String?
public let merchant_uuid: String?
public init(dictionary: [String: Any]) {
self.uuid = dictionary["uuid"] as? String? ?? ""
......@@ -316,6 +317,7 @@ public class swiftApi {
self.buyable = dictionary["buyable"] as? Bool? ?? false
self.visible = dictionary["visible"] as? Bool? ?? false
self.terms = dictionary["terms"] as? String? ?? ""
self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? ""
let expirationObject = dictionary["expiration"] as? [String: Any]? ?? ["":""]
let expirationString = expirationObject?["value"] as? String? ?? ""
......@@ -4087,4 +4089,548 @@ public class swiftApi {
}
}
// _ center: Array<Double>
public func getMultilingualMerchantsAsync(_ categories: Array<String>, _ defaultShown: Bool, _ center: Double, _ tags: Array<String>, _ uuid: String, _ distance: Int, _ parent_uuids: Array<String>, _ getMerchantsCallback: @escaping (_ getMerchantsData: Array<MerchantModel>?) -> Void) -> Void {
let instanceOfMyApi = MyApi()
instanceOfMyApi.getMultilingualMerchantsAsync(categories, andDefaultShown:defaultShown as NSNumber, andCenter:center as NSNumber, andTags:tags, andUuid:uuid, andDistance:distance as NSNumber, parent_uuids:parent_uuids, requestCallback, failureBlock: requestFailureCallback)
func requestCallback(_ getMerchantsData: [AnyHashable: Any]?) -> Void { // [Any]? - [AnyHashable: Any]?
var merchantsArray:Array<MerchantModel> = []
if let responseDataDictionary = getMerchantsData as? [String: AnyObject] {
if (responseDataDictionary["MAPP_SHOPS-status"] as? Int == 1) {
if let responseDataMappShops = responseDataDictionary["MAPP_SHOPS"] as? [String: Any] {
if let responseDataResult = responseDataMappShops["result"] as? [[String: Any]?] {
for item in responseDataResult {
if let itemDictionary = item {
let tempMerchItem = MerchantModel(dictionary: itemDictionary)
merchantsArray.append(tempMerchItem)
}
}
getMerchantsCallback(merchantsArray);
} else {
getMerchantsCallback(nil)
}
} else {
getMerchantsCallback(nil)
}
} else {
getMerchantsCallback(nil)
}
} else {
getMerchantsCallback(nil)
}
}
func requestFailureCallback(_ error: Error?) -> Void {
print("getMultilingualMerchants error: ")
print(error)
print("====================")
getMerchantsCallback(nil)
}
}
public class MerchantModel: Codable {
private var address: String?
private var id: String?
private var store_id: String?
private var name: String?
private var logo: String?
private var website: String?
private var email: String?
private var telephone: String?
private var category: String?
private var description: String?
private var short_description: String?
private var region: String?
private var latitude: Double?
private var longitude: Double?
private var image: String?
// private var extra_fields: [String: Any]?
private var active: Bool?
private var city: String?
private var country: String?
private var postal_code: String?
private var vat: String?
private var uuid: String?
private var category_uuid: String?
private var created: String?
private var parent: String?
// private var img: [[String: Any]]?
private var img_preview: String?
private var admin_name: String?
private var sorting: Int?
private var body: String?
private var owner_name: String?
private var preview: String?
// private var merchant_metadata: [String: Any]?
private var promoted: Bool?
private var distance: Int?
private var default_shown: Bool?
private var hidden: Bool?
// private var working_hours: [String: Any]?
// private var tags: [[String: Any]]?
// private var product: [String: Any]?
public init() {
self.address = ""
self.id = ""
self.store_id = ""
self.name = ""
self.logo = ""
self.website = ""
self.email = ""
self.telephone = ""
self.category = ""
self.description = ""
self.short_description = ""
self.region = ""
self.latitude = 0.0
self.longitude = 0.0
self.image = ""
// self.extra_fields = [String: Any]()
self.active = false
self.city = ""
self.country = ""
self.postal_code = ""
self.vat = ""
self.uuid = ""
self.category_uuid = ""
self.created = ""
self.parent = ""
// self.img = [[String: Any]]()
self.img_preview = ""
self.admin_name = ""
self.sorting = 0
self.body = ""
self.owner_name = ""
self.preview = ""
// self.merchant_metadata = [String: Any]()
self.promoted = false
self.distance = 0
self.default_shown = false
self.hidden = false
// self.working_hours = [String: Any]()
// self.tags = [[String: Any]]()
// self.product = [String: Any]()
}
public init(dictionary: [String: Any]) {
self.address = dictionary["address"] as? String? ?? ""
self.id = dictionary["id"] as? String? ?? ""
self.store_id = dictionary["store_id"] as? String? ?? ""
self.name = dictionary["name"] as? String? ?? ""
self.logo = dictionary["logo"] as? String? ?? ""
self.website = dictionary["website"] as? String? ?? ""
self.email = dictionary["email"] as? String? ?? ""
self.telephone = dictionary["telephone"] as? String? ?? ""
self.category = dictionary["category"] as? String? ?? ""
self.description = dictionary["description"] as? String? ?? ""
self.short_description = dictionary["short_description"] as? String? ?? ""
self.region = dictionary["region"] as? String? ?? ""
self.latitude = dictionary["latitude"] as? Double? ?? 0.0
self.longitude = dictionary["longitude"] as? Double? ?? 0.0
self.image = dictionary["image"] as? String? ?? ""
// self.extra_fields = dictionary["extra_fields"] as? [String: Any]? ?? [String: Any]()
self.active = dictionary["active"] as? Bool? ?? false
self.city = dictionary["city"] as? String? ?? ""
self.country = dictionary["country"] as? String? ?? ""
self.postal_code = dictionary["postal_code"] as? String? ?? ""
self.vat = dictionary["vat"] as? String? ?? ""
self.uuid = dictionary["uuid"] as? String? ?? ""
self.category_uuid = dictionary["category_uuid"] as? String? ?? ""
self.created = dictionary["created"] as? String? ?? ""
self.parent = dictionary["parent"] as? String? ?? ""
// self.img = dictionary["img"] as? [[String: Any]]? ?? [[String: Any]]()
self.img_preview = dictionary["img_preview"] as? String? ?? ""
self.admin_name = dictionary["admin_name"] as? String? ?? ""
self.sorting = dictionary["sorting"] as? Int? ?? 0
self.body = dictionary["body"] as? String? ?? ""
self.owner_name = dictionary["owner_name"] as? String? ?? ""
self.preview = dictionary["preview"] as? String? ?? ""
// self.merchant_metadata = dictionary["merchant_metadata"] as? [String: Any]? ?? [String: Any]()
self.promoted = dictionary["promoted"] as? Bool? ?? false
self.distance = dictionary["distance"] as? Int? ?? 0
self.default_shown = dictionary["default_shown"] as? Bool? ?? false
self.hidden = dictionary["hidden"] as? Bool? ?? false
// self.working_hours = dictionary["working_hours"] as? [String: Any]? ?? [String: Any]()
// self.tags = dictionary["tags"] as? [[String: Any]]? ?? [[String: Any]]()
// self.product = dictionary["product"] as? [String: Any]? ?? [String: Any]()
}
public var _address: String {
get { // getter
return self.address ?? ""
}
set(newValue) { //setter
self.address = newValue
}
}
public var _id: String {
get { // getter
return self.id ?? ""
}
set(newValue) { //setter
self.id = newValue
}
}
public var _store_id: String {
get { // getter
return self.store_id ?? ""
}
set(newValue) { //setter
self.store_id = newValue
}
}
public var _name: String {
get { // getter
return self.name ?? ""
}
set(newValue) { //setter
self.name = newValue
}
}
public var _logo: String {
get { // getter
return self.logo ?? ""
}
set(newValue) { //setter
self.logo = newValue
}
}
public var _website: String {
get { // getter
return self.website ?? ""
}
set(newValue) { //setter
self.website = newValue
}
}
public var _email: String {
get { // getter
return self.email ?? ""
}
set(newValue) { //setter
self.email = newValue
}
}
public var _telephone: String {
get { // getter
return self.telephone ?? ""
}
set(newValue) { //setter
self.telephone = newValue
}
}
public var _category: String {
get { // getter
return self.category ?? ""
}
set(newValue) { //setter
self.category = newValue
}
}
public var _description: String {
get { // getter
return self.description ?? ""
}
set(newValue) { //setter
self.description = newValue
}
}
public var _short_description: String {
get { // getter
return self.short_description ?? ""
}
set(newValue) { //setter
self.short_description = newValue
}
}
public var _region: String {
get { // getter
return self.region ?? ""
}
set(newValue) { //setter
self.region = newValue
}
}
public var _latitude: Double {
get { // getter
return self.latitude ?? 0.0
}
set(newValue) { //setter
self.latitude = newValue
}
}
public var _longitude: Double {
get { // getter
return self.longitude ?? 0.0
}
set(newValue) { //setter
self.longitude = newValue
}
}
public var _image: String {
get { // getter
return self.image ?? ""
}
set(newValue) { //setter
self.image = newValue
}
}
// public var _extra_fields: [String: Any] {
// get { // getter
// return self.extra_fields ?? [String: Any]()
// }
// set(newValue) { //setter
// self.extra_fields = newValue
// }
// }
public var _active: Bool {
get { // getter
return self.active ?? false
}
set(newValue) { //setter
self.active = newValue
}
}
public var _city: String {
get { // getter
return self.city ?? ""
}
set(newValue) { //setter
self.city = newValue
}
}
public var _country: String {
get { // getter
return self.country ?? ""
}
set(newValue) { //setter
self.country = newValue
}
}
public var _postal_code: String {
get { // getter
return self.postal_code ?? ""
}
set(newValue) { //setter
self.postal_code = newValue
}
}
public var _vat: String {
get { // getter
return self.vat ?? ""
}
set(newValue) { //setter
self.vat = newValue
}
}
public var _uuid: String {
get { // getter
return self.uuid ?? ""
}
set(newValue) { //setter
self.uuid = newValue
}
}
public var _category_uuid: String {
get { // getter
return self.category_uuid ?? ""
}
set(newValue) { //setter
self.category_uuid = newValue
}
}
public var _created: String {
get { // getter
return self.created ?? ""
}
set(newValue) { //setter
self.created = newValue
}
}
public var _parent: String {
get { // getter
return self.parent ?? ""
}
set(newValue) { //setter
self.parent = newValue
}
}
// public var _img: [[String: Any]] {
// get { // getter
// return self.img ?? [[String: Any]]()
// }
// set(newValue) { //setter
// self.img = newValue
// }
// }
public var _img_preview: String {
get { // getter
return self.img_preview ?? ""
}
set(newValue) { //setter
self.img_preview = newValue
}
}
public var _admin_name: String {
get { // getter
return self.admin_name ?? ""
}
set(newValue) { //setter
self.admin_name = newValue
}
}
public var _sorting: Int {
get { // getter
return self.sorting ?? 0
}
set(newValue) { //setter
self.sorting = newValue
}
}
public var _body: String {
get { // getter
return self.body ?? ""
}
set(newValue) { //setter
self.body = newValue
}
}
public var _owner_name: String {
get { // getter
return self.owner_name ?? ""
}
set(newValue) { //setter
self.owner_name = newValue
}
}
public var _preview: String {
get { // getter
return self.preview ?? ""
}
set(newValue) { //setter
self.preview = newValue
}
}
// public var _merchant_metadata: [String: Any] {
// get { // getter
// return self.merchant_metadata ?? [String: Any]()
// }
// set(newValue) { //setter
// self.merchant_metadata = newValue
// }
// }
public var _promoted: Bool {
get { // getter
return self.promoted ?? false
}
set(newValue) { //setter
self.promoted = newValue
}
}
public var _distance: Int {
get { // getter
return self.distance ?? 0
}
set(newValue) { //setter
self.distance = newValue
}
}
public var _default_shown: Bool {
get { // getter
return self.default_shown ?? false
}
set(newValue) { //setter
self.default_shown = newValue
}
}
public var _hidden: Bool {
get { // getter
return self.hidden ?? false
}
set(newValue) { //setter
self.hidden = newValue
}
}
// public var _working_hours: [String: Any] {
// get { // getter
// return self.working_hours ?? [String: Any]()
// }
// set(newValue) { //setter
// self.working_hours = newValue
// }
// }
// public var _tags: [[String: Any]] {
// get { // getter
// return self.tags ?? [[String: Any]]()
// }
// set(newValue) { //setter
// self.tags = newValue
// }
// }
// public var _product: [String: Any] {
// get { // getter
// return self.product ?? [String: Any]()
// }
// set(newValue) { //setter
// self.product = newValue
// }
// }
}
}
......