From ec8ddfae830103af1b14d31c494868dce6afa347 Mon Sep 17 00:00:00 2001 From: Rahul Bawane Date: Thu, 30 Jan 2025 11:41:52 +0530 Subject: [PATCH] Develop (#68) --- BVSwift.podspec | 2 +- BVSwift.xcodeproj/project.pbxproj | 8 +- .../BVCommon/Configuration/BVConstants.swift | 2 +- BVSwift/BVCommon/Query/BVQueryable.swift | 10 --- .../Display/Fields/Types/BVFormatStats.swift | 45 +++++++++++ .../Types/BVReviewSummaryFormatFilter.swift | 78 ------------------- .../Types/BVReviewSummaryFormatStats.swift | 30 ------- .../Display/BVReviewSummaryQuery.swift | 8 +- .../BVProductSentimentsConstants.swift | 2 + .../Sentiments/Stats/BVEmbedStats.swift | 17 +++- .../Sentiments/Stats/BVLanguageStats.swift | 2 +- .../Types/BVSummarisedFeaturesQuery.swift | 6 +- BVSwift/Support/Info.plist | 2 +- .../Display/BVReviewSummaryQueryTest.swift | 3 +- .../BVSummarisedFeaturesQueryTest.swift | 2 +- 15 files changed, 77 insertions(+), 140 deletions(-) create mode 100644 BVSwift/BVConversations/Display/Fields/Types/BVFormatStats.swift delete mode 100644 BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatFilter.swift delete mode 100644 BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatStats.swift diff --git a/BVSwift.podspec b/BVSwift.podspec index e723feb6..4b98ea77 100644 --- a/BVSwift.podspec +++ b/BVSwift.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'BVSwift' - s.version = '1.15.2' + s.version = '1.15.3' s.summary = 'Simple Swift based iOS SDK to interact with the Bazaarvoice platform API.' s.description = 'The Bazaarvoice Software Development Kit (SDK) is a Swift iOS library that provides an easy way to generate REST calls to the Bazaarvoice Developer API. Using this SDK, mobile developers can quickly integrate Bazaarvoice content into their native iOS apps for iPhone and iPad on iOS 8.0 or newer.' diff --git a/BVSwift.xcodeproj/project.pbxproj b/BVSwift.xcodeproj/project.pbxproj index 94959a0a..b80cbd5f 100644 --- a/BVSwift.xcodeproj/project.pbxproj +++ b/BVSwift.xcodeproj/project.pbxproj @@ -299,7 +299,7 @@ B74C3F562CC9332C00D3EA13 /* BVProductExpressionsQueryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B74C3F552CC9332C00D3EA13 /* BVProductExpressionsQueryTest.swift */; }; B7C8336F2D365DBF0088B7C0 /* BVReviewSummary.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C8336E2D365DBF0088B7C0 /* BVReviewSummary.swift */; }; B7C833712D365F790088B7C0 /* BVReviewSummaryQuery.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C833702D365F790088B7C0 /* BVReviewSummaryQuery.swift */; }; - B7C833732D3661870088B7C0 /* BVReviewSummaryFormatStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C833722D3661870088B7C0 /* BVReviewSummaryFormatStats.swift */; }; + B7C833732D3661870088B7C0 /* BVFormatStats.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C833722D3661870088B7C0 /* BVFormatStats.swift */; }; B7C833752D366A680088B7C0 /* BVReviewSummaryQueryTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C833742D366A680088B7C0 /* BVReviewSummaryQueryTest.swift */; }; B7C833772D3793290088B7C0 /* BVReviewSummaryQueryResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C833762D3793290088B7C0 /* BVReviewSummaryQueryResponse.swift */; }; B7C8337D2D390E1C0088B7C0 /* BVReviewSummaryQueryable.swift in Sources */ = {isa = PBXBuildFile; fileRef = B7C8337C2D390E1C0088B7C0 /* BVReviewSummaryQueryable.swift */; }; @@ -611,7 +611,7 @@ B74C3F552CC9332C00D3EA13 /* BVProductExpressionsQueryTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVProductExpressionsQueryTest.swift; sourceTree = ""; }; B7C8336E2D365DBF0088B7C0 /* BVReviewSummary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVReviewSummary.swift; sourceTree = ""; }; B7C833702D365F790088B7C0 /* BVReviewSummaryQuery.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVReviewSummaryQuery.swift; sourceTree = ""; }; - B7C833722D3661870088B7C0 /* BVReviewSummaryFormatStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVReviewSummaryFormatStats.swift; sourceTree = ""; }; + B7C833722D3661870088B7C0 /* BVFormatStats.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVFormatStats.swift; sourceTree = ""; }; B7C833742D366A680088B7C0 /* BVReviewSummaryQueryTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVReviewSummaryQueryTest.swift; sourceTree = ""; }; B7C833762D3793290088B7C0 /* BVReviewSummaryQueryResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVReviewSummaryQueryResponse.swift; sourceTree = ""; }; B7C8337C2D390E1C0088B7C0 /* BVReviewSummaryQueryable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BVReviewSummaryQueryable.swift; sourceTree = ""; }; @@ -1092,7 +1092,7 @@ 89E3106E27F4C9F700D42042 /* BVTagStats.swift */, 894615B128913424007B2138 /* BVCostomSort.swift */, 894615AD288FE812007B2138 /* BVRelevancySort.swift */, - B7C833722D3661870088B7C0 /* BVReviewSummaryFormatStats.swift */, + B7C833722D3661870088B7C0 /* BVFormatStats.swift */, ); path = Types; sourceTree = ""; @@ -1623,7 +1623,7 @@ 9F51CA50240CD1150043AED5 /* BVReviewHighlightsConfiguration.swift in Sources */, 98686CB22407115900D67889 /* BVConversationsSubmissionable.swift in Sources */, 98686C64240710AE00D67889 /* BVAnswerFilter.swift in Sources */, - B7C833732D3661870088B7C0 /* BVReviewSummaryFormatStats.swift in Sources */, + B7C833732D3661870088B7C0 /* BVFormatStats.swift in Sources */, 98686D422407136400D67889 /* BVRecommendationsCategory.swift in Sources */, 98686C9B2407113100D67889 /* BVAnswer.swift in Sources */, 98686CA32407113100D67889 /* BVComment.swift in Sources */, diff --git a/BVSwift/BVCommon/Configuration/BVConstants.swift b/BVSwift/BVCommon/Configuration/BVConstants.swift index 5997dea0..19e5abdd 100644 --- a/BVSwift/BVCommon/Configuration/BVConstants.swift +++ b/BVSwift/BVCommon/Configuration/BVConstants.swift @@ -18,7 +18,7 @@ internal struct BVConstants { static let appVersionField: String = "_appVersion" static let buildNumberField: String = "_buildNumber" static let sdkVersionField: String = "_bvIosSwiftSdkVersion" - static let bvSwiftSDKVersion: String = "1.15.2" + static let bvSwiftSDKVersion: String = "1.15.3" } internal extension Bundle { diff --git a/BVSwift/BVCommon/Query/BVQueryable.swift b/BVSwift/BVCommon/Query/BVQueryable.swift index dcab5fe1..f7330f95 100644 --- a/BVSwift/BVCommon/Query/BVQueryable.swift +++ b/BVSwift/BVCommon/Query/BVQueryable.swift @@ -131,16 +131,6 @@ public protocol BVQueryLanguageStatable { func language(_ value: String) -> Self } -/// Protocol definition for the behavior of adding embedded values -public protocol BVQueryEmbedStatable { - func embed(_ value: String) -> Self -} - -/// Protocol definition for the behavior of adding summary format values -public protocol BVQueryFormatStatable { - func formatType(_ value: String) -> Self -} - /// Protocol definition for the behavior of adding custom query fields /// - Note: /// \ diff --git a/BVSwift/BVConversations/Display/Fields/Types/BVFormatStats.swift b/BVSwift/BVConversations/Display/Fields/Types/BVFormatStats.swift new file mode 100644 index 00000000..2284f3d7 --- /dev/null +++ b/BVSwift/BVConversations/Display/Fields/Types/BVFormatStats.swift @@ -0,0 +1,45 @@ +// +// +// BVFormatStats.swift +// BVSwift +// +// Copyright © 2025 Bazaarvoice. All rights reserved. +// + +import Foundation + +internal struct BVFormatStats: BVQueryField { + + private let value: CustomStringConvertible + + var internalDescription: String { + return BVConversationsConstants.BVReviewSummary.Keys.formatType + } + + var representedValue: CustomStringConvertible { + return value + } + + var description: String { + return internalDescription + } + + init(_ _value: BVFormatStatsType) { + value = _value.representedValue + } +} + +public enum BVFormatStatsType: Int { + + case bullet + case paragraph + + public var representedValue: CustomStringConvertible { + switch self { + case .bullet: + return BVConversationsConstants.BVReviewSummary.Keys.bullet + case .paragraph: + return BVConversationsConstants.BVReviewSummary.Keys.paragraph + } + } +} diff --git a/BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatFilter.swift b/BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatFilter.swift deleted file mode 100644 index 45f7a4bd..00000000 --- a/BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatFilter.swift +++ /dev/null @@ -1,78 +0,0 @@ -// -// -// BVReviewSummaryFormatFilter.swift -// BVSwift -// -// Copyright © 2025 Bazaarvoice. All rights reserved. -// - -import Foundation - -/// An enum that represents the possible filtering comparators to filter on for -/// the BVComment[s]Query. -/// - Note: -/// \ -/// Used for conformance with the BVQueryFilterable protocol. -/// -internal struct BVReviewSummaryFormatStats: BVQueryField { - - private let value: CustomStringConvertible - - var internalDescription: String { - return BVConversationsConstants.BVReviewSummary.Keys.formatType - } - - var representedValue: CustomStringConvertible { - return value - } - - var description: String { - return internalDescription - } - - init(_ _value: BVReviewSummaryFormatFilter) { - value = "\(_value.internalDescription)" - } -} - -public enum BVReviewSummaryFormatFilter: BVQueryFilter { - - case bullet - case paragraph - - public static var filterPrefix: String { - return BVConversationsConstants.BVQueryFilter.defaultField - } - - public static var filterTypeSeparator: String { - return BVConversationsConstants.BVQueryFilter.typeSeparatorField - } - - public static var filterValueSeparator: String { - return BVConversationsConstants.BVQueryFilter.valueSeparatorField - } - - public var description: String { - return internalDescription - } - - public var representedValue: CustomStringConvertible { - switch self { - case .bullet: - return BVConversationsConstants.BVReviewSummary.Keys.bullet - case .paragraph: - return BVConversationsConstants.BVReviewSummary.Keys.paragraph - } - } -} - -extension BVReviewSummaryFormatFilter: BVConversationsQueryValue { - internal var internalDescription: String { - switch self { - case .bullet: - return BVConversationsConstants.BVReviewSummary.Keys.bullet - case .paragraph: - return BVConversationsConstants.BVReviewSummary.Keys.paragraph - } - } -} diff --git a/BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatStats.swift b/BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatStats.swift deleted file mode 100644 index 763bc3a2..00000000 --- a/BVSwift/BVConversations/Display/Fields/Types/BVReviewSummaryFormatStats.swift +++ /dev/null @@ -1,30 +0,0 @@ -// -// -// BVReviewSummaryFormatStats.swift -// BVSwift -// -// Copyright © 2025 Bazaarvoice. All rights reserved. -// - -import Foundation - -internal struct BVReviewSummaryFormatStats: BVQueryField { - - private let value: CustomStringConvertible - - var internalDescription: String { - return BVConversationsConstants.BVReviewSummary.Keys.formatType - } - - var representedValue: CustomStringConvertible { - return value - } - - var description: String { - return internalDescription - } - - init(_ _value: String) { - value = "\(_value)" - } -} diff --git a/BVSwift/BVConversations/Display/Types/ReviewSummary/Display/BVReviewSummaryQuery.swift b/BVSwift/BVConversations/Display/Types/ReviewSummary/Display/BVReviewSummaryQuery.swift index 874ffa94..d46df90e 100644 --- a/BVSwift/BVConversations/Display/Types/ReviewSummary/Display/BVReviewSummaryQuery.swift +++ b/BVSwift/BVConversations/Display/Types/ReviewSummary/Display/BVReviewSummaryQuery.swift @@ -212,11 +212,9 @@ extension BVReviewSummaryQuery: BVQueryUnsafeField { } } -// MARK: - BVReviewSummaryQuery: BVQueryEmbedStatable -extension BVReviewSummaryQuery: BVQueryFormatStatable { - @discardableResult - public func formatType(_ value: String) -> Self { - let formatType: BVURLParameter = .field(BVReviewSummaryFormatStats(value), nil) +extension BVReviewSummaryQuery { + public func formatType(_ value: BVFormatStatsType) -> Self { + let formatType: BVURLParameter = .field(BVFormatStats(value), nil) add(formatType) return self } diff --git a/BVSwift/BVProductSentiments/BVProductSentimentsConstants.swift b/BVSwift/BVProductSentiments/BVProductSentimentsConstants.swift index 78987540..2b4cca86 100644 --- a/BVSwift/BVProductSentiments/BVProductSentimentsConstants.swift +++ b/BVSwift/BVProductSentiments/BVProductSentimentsConstants.swift @@ -28,7 +28,9 @@ internal struct BVProductSentimentsConstants { static let productId: String = "productId" static let limit: String = "limit" static let embed: String = "embed" + static let quotes: String = "quotes" static let feature: String = "feature" + static let language: String = "language" } } diff --git a/BVSwift/BVProductSentiments/Sentiments/Stats/BVEmbedStats.swift b/BVSwift/BVProductSentiments/Sentiments/Stats/BVEmbedStats.swift index dc4cb80b..72475b75 100644 --- a/BVSwift/BVProductSentiments/Sentiments/Stats/BVEmbedStats.swift +++ b/BVSwift/BVProductSentiments/Sentiments/Stats/BVEmbedStats.swift @@ -25,7 +25,20 @@ internal struct BVEmbedStats: BVQueryField { return internalDescription } - init(_ _value: String) { - value = "\(_value)" + init(_ _value: BVEmbedStatsType) { + value = _value.representedValue } } + + +public enum BVEmbedStatsType: Int { + + case quotes + + public var representedValue: CustomStringConvertible { + switch self { + case .quotes: + return BVProductSentimentsConstants.BVQueryType.Keys.quotes + } + } +} diff --git a/BVSwift/BVProductSentiments/Sentiments/Stats/BVLanguageStats.swift b/BVSwift/BVProductSentiments/Sentiments/Stats/BVLanguageStats.swift index 8d1f82a1..098136ae 100644 --- a/BVSwift/BVProductSentiments/Sentiments/Stats/BVLanguageStats.swift +++ b/BVSwift/BVProductSentiments/Sentiments/Stats/BVLanguageStats.swift @@ -13,7 +13,7 @@ internal struct BVLanguageStats: BVQueryField { private let value: CustomStringConvertible var internalDescription: String { - return BVConversationsConstants.BVQueryType.Keys.language + return BVProductSentimentsConstants.BVQueryType.Keys.language } var representedValue: CustomStringConvertible { diff --git a/BVSwift/BVProductSentiments/Sentiments/Types/BVSummarisedFeaturesQuery.swift b/BVSwift/BVProductSentiments/Sentiments/Types/BVSummarisedFeaturesQuery.swift index 4551331d..644b4da5 100644 --- a/BVSwift/BVProductSentiments/Sentiments/Types/BVSummarisedFeaturesQuery.swift +++ b/BVSwift/BVProductSentiments/Sentiments/Types/BVSummarisedFeaturesQuery.swift @@ -58,10 +58,8 @@ extension BVSummarisedFeaturesQuery: BVQueryLanguageStatable { } } -// MARK: - BVSummarisedFeaturesQuery: BVQueryEmbedStatable -extension BVSummarisedFeaturesQuery: BVQueryEmbedStatable { - @discardableResult - public func embed(_ value: String) -> Self { +extension BVSummarisedFeaturesQuery { + public func embed(_ value: BVEmbedStatsType) -> Self { let embed: BVURLParameter = .field(BVEmbedStats(value), nil) add(embed) return self diff --git a/BVSwift/Support/Info.plist b/BVSwift/Support/Info.plist index e88c1895..d45698e4 100644 --- a/BVSwift/Support/Info.plist +++ b/BVSwift/Support/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.15.2 + 1.15.3 CFBundleVersion 1 NSPrincipalClass diff --git a/BVSwiftTests/BVConversations/Display/BVReviewSummaryQueryTest.swift b/BVSwiftTests/BVConversations/Display/BVReviewSummaryQueryTest.swift index b08ea15a..04b0fc80 100644 --- a/BVSwiftTests/BVConversations/Display/BVReviewSummaryQueryTest.swift +++ b/BVSwiftTests/BVConversations/Display/BVReviewSummaryQueryTest.swift @@ -47,7 +47,7 @@ class BVReviewSummaryQueryTest: XCTestCase { description: "testProductReviewSummaryQuery") let reviewSummaryQueryRequest = BVProductReviewSummaryQuery(productId: "P000036") - .formatType("bullet") //paragraph + .formatType(.paragraph) //.bullet .configure(BVReviewSummaryQueryTest.config) .handler { (response: BVReviewSummaryQueryResponse) in // success @@ -68,7 +68,6 @@ class BVReviewSummaryQueryTest: XCTestCase { XCTAssertNotNil(reviewSummary.summary) expectation.fulfill() } - reviewSummaryQueryRequest.async() self.waitForExpectations(timeout: 20) { (error) in XCTAssertNil( diff --git a/BVSwiftTests/BVProductSentiments/BVSummarisedFeaturesQueryTest.swift b/BVSwiftTests/BVProductSentiments/BVSummarisedFeaturesQueryTest.swift index 98b3836d..f0ce1945 100644 --- a/BVSwiftTests/BVProductSentiments/BVSummarisedFeaturesQueryTest.swift +++ b/BVSwiftTests/BVProductSentiments/BVSummarisedFeaturesQueryTest.swift @@ -43,7 +43,7 @@ class BVSummarisedFeaturesQueryTest: XCTestCase { self.expectation(description: "testProductSummarisedFeatures") let query = BVSummarisedFeaturesQuery(productId: "P000010") - .embed("quotes") + .embed(.quotes) .language("en") .configure(BVSummarisedFeaturesQueryTest.config) .handler { (response: BVProductSentimentsQueryResponse) in