diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 927ad3c..bc3aded 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -416,7 +416,7 @@ TargetAttributes = { BDCA2E0E1DA38B7B004C2EF7 = { CreatedOnToolsVersion = 8.0; - DevelopmentTeam = NKN6QECX9M; + DevelopmentTeam = 345PN8HV64; LastSwiftMigration = 1030; ProvisioningStyle = Automatic; }; @@ -706,11 +706,11 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = 18; - DEVELOPMENT_TEAM = NKN6QECX9M; + CURRENT_PROJECT_VERSION = 19; + DEVELOPMENT_TEAM = 345PN8HV64; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.8.7; + MARKETING_VERSION = 1.9.0; PRODUCT_BUNDLE_IDENTIFIER = com.visenze.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -722,11 +722,11 @@ buildSettings = { ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CURRENT_PROJECT_VERSION = 18; - DEVELOPMENT_TEAM = NKN6QECX9M; + CURRENT_PROJECT_VERSION = 19; + DEVELOPMENT_TEAM = 345PN8HV64; INFOPLIST_FILE = Example/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = 1.8.7; + MARKETING_VERSION = 1.9.0; PRODUCT_BUNDLE_IDENTIFIER = com.visenze.Example; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/ViSearchSDK/ViSearchSDK.xcodeproj/project.pbxproj b/ViSearchSDK/ViSearchSDK.xcodeproj/project.pbxproj index 5dfb738..75bf52e 100644 --- a/ViSearchSDK/ViSearchSDK.xcodeproj/project.pbxproj +++ b/ViSearchSDK/ViSearchSDK.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ BD06D1361DA3BDE600EC9B38 /* ViResponseData.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD06D1351DA3BDE600EC9B38 /* ViResponseData.swift */; }; BD06D1381DA3F59A00EC9B38 /* ViRequestSerialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD06D1371DA3F59A00EC9B38 /* ViRequestSerialization.swift */; }; + BD283ABB29B7101600912D82 /* ViBestImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD283ABA29B7101600912D82 /* ViBestImage.swift */; }; BD3A860125F22B6400BB71CF /* ViProductSearch.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3A860025F22B6400BB71CF /* ViProductSearch.swift */; }; BD50FD621DA8B4220035FD78 /* UIColorExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD50FD611DA8B4220035FD78 /* UIColorExtension.swift */; }; BD5BE9E625F5F778004995D0 /* ViProductSearchResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD5BE9E525F5F778004995D0 /* ViProductSearchResponse.swift */; }; @@ -83,6 +84,7 @@ /* Begin PBXFileReference section */ BD06D1351DA3BDE600EC9B38 /* ViResponseData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViResponseData.swift; sourceTree = ""; }; BD06D1371DA3F59A00EC9B38 /* ViRequestSerialization.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViRequestSerialization.swift; sourceTree = ""; }; + BD283ABA29B7101600912D82 /* ViBestImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViBestImage.swift; sourceTree = ""; }; BD3A860025F22B6400BB71CF /* ViProductSearch.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViProductSearch.swift; sourceTree = ""; }; BD50FD611DA8B4220035FD78 /* UIColorExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIColorExtension.swift; path = Helper/UIColorExtension.swift; sourceTree = ""; }; BD5BE9E525F5F778004995D0 /* ViProductSearchResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViProductSearchResponse.swift; sourceTree = ""; }; @@ -267,6 +269,7 @@ BD7020EE1E49BB99006BAE40 /* ViFacetItem.swift */, BD815AA71FC8003800E8DA76 /* ViObjectResult.swift */, BDD3C4D128C7A56400C0C1A4 /* ViSetInfo.swift */, + BD283ABA29B7101600912D82 /* ViBestImage.swift */, ); path = Response; sourceTree = ""; @@ -442,6 +445,7 @@ BD5F70582601F1B100132A1F /* ViProductObjectResult.swift in Sources */, BDB76A2626983C6C000C750A /* ViStrategy.swift in Sources */, BD72A3A025FF0FA1005C8BC0 /* ViGroupResult.swift in Sources */, + BD283ABB29B7101600912D82 /* ViBestImage.swift in Sources */, BD65405A1DA63F5200E10162 /* ViSearch.swift in Sources */, BD7DEDAB1DA2B6C400CDF6DE /* ViColorSearchParams.swift in Sources */, BD5BE9F225F61FE0004995D0 /* ViProduct.swift in Sources */, diff --git a/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProduct.swift b/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProduct.swift index f3f1a60..12e2fb6 100644 --- a/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProduct.swift +++ b/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProduct.swift @@ -34,4 +34,6 @@ open class ViProduct { public var alternatives: [ViProduct] = [] public var pinned: Bool? = nil + + public var bestImages: [ViBestImage] = [] } diff --git a/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProductSearchResponse.swift b/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProductSearchResponse.swift index 9e13dca..c5eb81c 100644 --- a/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProductSearchResponse.swift +++ b/ViSearchSDK/ViSearchSDK/Classes/Response/ProductSearch/ViProductSearchResponse.swift @@ -241,6 +241,10 @@ open class ViProductSearchResponse : NSObject { item.alternatives = ViProductSearchResponse.parseProductResults(alt) } + if let bestImages = dict["best_images"] as? [Any] { + item.bestImages = ViResponseData.parseBestImages(bestImages) + } + if let score = dict["score"] as? Double { item.score = score } diff --git a/ViSearchSDK/ViSearchSDK/Classes/Response/ViBestImage.swift b/ViSearchSDK/ViSearchSDK/Classes/Response/ViBestImage.swift new file mode 100644 index 0000000..39ed98c --- /dev/null +++ b/ViSearchSDK/ViSearchSDK/Classes/Response/ViBestImage.swift @@ -0,0 +1,15 @@ +// +// ViBestImage.swift +// ViSearchSDK +// +// Created by Hung on 7/3/23. +// Copyright © 2023 Hung. All rights reserved. +// + +import Foundation + +open class ViBestImage: NSObject { + public var type : String? = nil + public var url : String? = nil + public var index : String? = nil +} diff --git a/ViSearchSDK/ViSearchSDK/Classes/Response/ViImageResult.swift b/ViSearchSDK/ViSearchSDK/Classes/Response/ViImageResult.swift index 1bf6bb0..84d3baa 100644 --- a/ViSearchSDK/ViSearchSDK/Classes/Response/ViImageResult.swift +++ b/ViSearchSDK/ViSearchSDK/Classes/Response/ViImageResult.swift @@ -26,6 +26,8 @@ open class ViImageResult: NSObject { public var pinned: Bool? = nil + public var bestImages: [ViBestImage] = [] + public init?(_ im_name: String) { if im_name.isEmpty{ print("\(type(of: self)).\(#function)[line:\(#line)] - error: im_name is missing") diff --git a/ViSearchSDK/ViSearchSDK/Classes/Response/ViResponseData.swift b/ViSearchSDK/ViSearchSDK/Classes/Response/ViResponseData.swift index 9b75cd1..530d555 100644 --- a/ViSearchSDK/ViSearchSDK/Classes/Response/ViResponseData.swift +++ b/ViSearchSDK/ViSearchSDK/Classes/Response/ViResponseData.swift @@ -174,6 +174,25 @@ open class ViResponseData: NSObject { return results } + public static func parseBestImages(_ arr: [Any]) -> [ViBestImage]{ + var results = [ViBestImage]() + for jsonItem in arr { + if let dict = jsonItem as? [String:Any] { + let type = dict["type"] as? String + let url = dict["url"] as? String + let index = dict["index"] as? String + + let item = ViBestImage() + item.type = type + item.url = url + item.index = index + + results.append(item) + } + } + + return results + } public static func parseProductTypes(_ arr: [Any]) -> [ViProductType]{ var results = [ViProductType]() @@ -269,6 +288,10 @@ open class ViResponseData: NSObject { item.alternatives = ViResponseData.parseResults(alternatives) } + if let bestImages = dict["best_images"] as? [Any] { + item.bestImages = ViResponseData.parseBestImages(bestImages) + } + results.append(item) } else{