Skip to content

Commit

Permalink
Add support for SyndicationSource for reviews that are flagged with '…
Browse files Browse the repository at this point in the history
…IsSyndicated'
  • Loading branch information
Tim Kelly committed May 5, 2017
1 parent 30ee3c8 commit c4ff907
Show file tree
Hide file tree
Showing 19 changed files with 279 additions and 53 deletions.
2 changes: 1 addition & 1 deletion BVSDK.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

Pod::Spec.new do |s|
s.name = "BVSDK"
s.version = '6.5.1'
s.version = '6.5.2'
s.homepage = 'https://developer.bazaarvoice.com'
s.license = { :type => 'Commercial', :text => 'See https://developer.bazaarvoice.com/API_Terms_of_Use' }
s.author = { 'Bazaarvoice' => '[email protected]' }
Expand Down
18 changes: 15 additions & 3 deletions BVSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@
875411871E1F201E006C5C6E /* BVStoreReviewSimpleNotificationCenter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8754116C1E1F201E006C5C6E /* BVStoreReviewSimpleNotificationCenter.h */; settings = {ATTRIBUTES = (Public, ); }; };
875411881E1F201E006C5C6E /* BVStoreReviewSimpleNotificationCenter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8754116D1E1F201E006C5C6E /* BVStoreReviewSimpleNotificationCenter.m */; };
875411891E1F201E006C5C6E /* mapThumbnail.png in Resources */ = {isa = PBXBuildFile; fileRef = 8754116E1E1F201E006C5C6E /* mapThumbnail.png */; };
8777BB421EBA3823008C4715 /* BVSyndicationSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 8777BB401EBA3823008C4715 /* BVSyndicationSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
8777BB431EBA3823008C4715 /* BVSyndicationSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 8777BB411EBA3823008C4715 /* BVSyndicationSource.m */; };
8777BB451EBA4F26008C4715 /* testSyndicationSource.json in Resources */ = {isa = PBXBuildFile; fileRef = 8777BB441EBA4F26008C4715 /* testSyndicationSource.json */; };
8779DB251DD20D5D00E6CAF5 /* BVStoreReviewsTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8779DB241DD20D5D00E6CAF5 /* BVStoreReviewsTableView.m */; };
8779DB271DD20D8D00E6CAF5 /* BVStoreReviewsTableView.h in Headers */ = {isa = PBXBuildFile; fileRef = 8779DB261DD20D8D00E6CAF5 /* BVStoreReviewsTableView.h */; settings = {ATTRIBUTES = (Public, ); }; };
8779DB6D1DD3AAE800E6CAF5 /* BVInternalAnalyticsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8779DB6C1DD3AAE800E6CAF5 /* BVInternalAnalyticsTest.m */; };
Expand Down Expand Up @@ -579,6 +582,9 @@
8754116C1E1F201E006C5C6E /* BVStoreReviewSimpleNotificationCenter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVStoreReviewSimpleNotificationCenter.h; sourceTree = "<group>"; };
8754116D1E1F201E006C5C6E /* BVStoreReviewSimpleNotificationCenter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVStoreReviewSimpleNotificationCenter.m; sourceTree = "<group>"; };
8754116E1E1F201E006C5C6E /* mapThumbnail.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = mapThumbnail.png; sourceTree = "<group>"; };
8777BB401EBA3823008C4715 /* BVSyndicationSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BVSyndicationSource.h; sourceTree = "<group>"; };
8777BB411EBA3823008C4715 /* BVSyndicationSource.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BVSyndicationSource.m; sourceTree = "<group>"; };
8777BB441EBA4F26008C4715 /* testSyndicationSource.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = testSyndicationSource.json; sourceTree = "<group>"; };
8779DB241DD20D5D00E6CAF5 /* BVStoreReviewsTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = BVStoreReviewsTableView.m; path = Stores/BVStoreReviewsTableView.m; sourceTree = "<group>"; };
8779DB261DD20D8D00E6CAF5 /* BVStoreReviewsTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BVStoreReviewsTableView.h; path = Stores/BVStoreReviewsTableView.h; sourceTree = "<group>"; };
8779DB6C1DD3AAE800E6CAF5 /* BVInternalAnalyticsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BVInternalAnalyticsTest.m; path = Tests/Tests/BVInternalAnalyticsTest.m; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -1372,6 +1378,8 @@
87F2DB421DAD585E00FB43F3 /* BVReviewStatistics.h */,
87F2DB431DAD585E00FB43F3 /* BVReviewStatistics.m */,
87F2DB441DAD585E00FB43F3 /* BVSecondaryRating.h */,
8777BB401EBA3823008C4715 /* BVSyndicationSource.h */,
8777BB411EBA3823008C4715 /* BVSyndicationSource.m */,
87F2DB451DAD585E00FB43F3 /* BVSecondaryRating.m */,
87F2DB461DAD585E00FB43F3 /* BVSecondaryRatingsAverages.h */,
87F2DB471DAD585E00FB43F3 /* BVSecondaryRatingsAverages.m */,
Expand Down Expand Up @@ -1793,6 +1801,7 @@
87F2DD841DAD698400FB43F3 /* testShowStatistics.json */,
87F2DD851DAD698400FB43F3 /* testShowStory.json */,
87F2DD861DAD698500FB43F3 /* testShowStorySparse.json */,
8777BB441EBA4F26008C4715 /* testSyndicationSource.json */,
);
name = conversations;
path = Tests/Tests/resources/conversations;
Expand Down Expand Up @@ -2143,6 +2152,7 @@
87C5FF621E36B416004EE6E8 /* BVAuthor.h in Headers */,
87D424E91E89C32E00147FDB /* BVReviewIncludeType.h in Headers */,
87D425271E8EE39700147FDB /* BVViewedCGCEvent.h in Headers */,
8777BB421EBA3823008C4715 /* BVSyndicationSource.h in Headers */,
879A628B1E80502100F46ECA /* BVBasePIIEvent.h in Headers */,
87F2DC241DAD585E00FB43F3 /* BVContextualInterests.h in Headers */,
87F2DC251DAD585E00FB43F3 /* BVGMBLSighting.h in Headers */,
Expand Down Expand Up @@ -2203,7 +2213,7 @@
87F2DA9E1DAD579D00FB43F3 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = Bazaarvoice;
TargetAttributes = {
87F2DAA61DAD579D00FB43F3 = {
Expand Down Expand Up @@ -2286,6 +2296,7 @@
87F2DDB11DAD698500FB43F3 /* testShowReview.json in Resources */,
87F2DDB91DAD698500FB43F3 /* curationsFeedTest1.json in Resources */,
87F2DDA71DAD698500FB43F3 /* testShowCommentStory.json in Resources */,
8777BB451EBA4F26008C4715 /* testSyndicationSource.json in Resources */,
87F2DD981DAD698500FB43F3 /* conversationsGenericPostResponse.json in Resources */,
87F2DDB71DAD698500FB43F3 /* curations500Error.json in Resources */,
87F2DDA61DAD698500FB43F3 /* testShowCommentsSparse.json in Resources */,
Expand Down Expand Up @@ -2443,6 +2454,7 @@
87F2DCC81DAD585E00FB43F3 /* BVSortOptionQuestions.m in Sources */,
87C5FEBC1E22A05D004EE6E8 /* BVDiagnosticHelpers.m in Sources */,
87F2DD3B1DAD585E00FB43F3 /* BVProductReview.m in Sources */,
8777BB431EBA3823008C4715 /* BVSyndicationSource.m in Sources */,
87C5FF591E368DF2004EE6E8 /* BVAuthorRequest.m in Sources */,
87F2DCF01DAD585E00FB43F3 /* BVReviewSubmissionErrorResponse.m in Sources */,
87F2DCA21DAD585E00FB43F3 /* BVStoreReviewsResponse.m in Sources */,
Expand Down Expand Up @@ -2753,7 +2765,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 3462CE8D50CC0B93A458E62C /* Pods-BVSDKTests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
INFOPLIST_FILE = BVSDKTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.bazaarvoice.bvsdk.BVSDKTests;
Expand All @@ -2767,7 +2779,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 89529D79D81B13BA86882542 /* Pods-BVSDKTests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
INFOPLIST_FILE = BVSDKTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.bazaarvoice.bvsdk.BVSDKTests;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion BVSDK.xcodeproj/xcshareddata/xcschemes/BVSDK.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions BVSDK/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>6.5.1</string>
<string>6.5.2</string>
<key>CFBundleVersion</key>
<string>6.5.1</string>
<string>6.5.2</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class MyReviewTableViewCell: BVReviewTableViewCell {
reviewString?.append("\n")
reviewString?.append("\nIs Recommended? \(review!.isRecommended)")
reviewString?.append("\nIs Syndicated? \(review!.isSyndicated)")

if (review!.isSyndicated && (review!.syndicationSource != nil)){
reviewString?.append("\nSyndication Source: \(review!.syndicationSource!.name!)")
}

reviewString?.append("\nHelpful Count: \(review!.totalPositiveFeedbackCount!)")
reviewString?.append("\nNot Helpful Count: \(review!.totalNegativeFeedbackCount!)")

Expand Down
6 changes: 3 additions & 3 deletions Examples/Conversations/Swift/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- BVSDK/BVConversations (6.5.0):
- BVSDK/BVConversations (6.5.1):
- BVSDK/Core
- BVSDK/Core (6.5.0)
- BVSDK/Core (6.5.1)

DEPENDENCIES:
- BVSDK/BVConversations (from `../../../`)
Expand All @@ -11,7 +11,7 @@ EXTERNAL SOURCES:
:path: "../../../"

SPEC CHECKSUMS:
BVSDK: f71d4466f852ca86901bd703c1cb10b896634dbf
BVSDK: 508f05ebe74170687c9b51cede20d42033e502d8

PODFILE CHECKSUM: ff51a28f7873cf9d401e0c25277fa303397c7510

Expand Down
4 changes: 2 additions & 2 deletions Pod/BVCommon/BVSDKConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@

/// Provides the master version of the SDK.

#define BV_SDK_VERSION @"6.5.1"
#define BV_SDK_VERSION @"6.5.2"

/// Conversation SDK Version
#define SDK_HEADER_NAME @"X-UA-BV-SDK"
#define SDK_HEADER_VALUE @"IOS_SDK_V651"
#define SDK_HEADER_VALUE @"IOS_SDK_V652"

/// Error domain for NSError results, when present.
#define BVErrDomain @"com.bvsdk.bazaarvoice"
Expand Down
22 changes: 22 additions & 0 deletions Pod/BVConversations/Display/Model/BVSyndicationSource.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// BVSyndicationSource.h
// BVSDK
//
// Copyright © 2017 Bazaarvoice. All rights reserved.
//

#import <Foundation/Foundation.h>


/**
If a review is syndicated, a BVSyndicationSource will contain the details of where the syndication is coming from is displayed. NOTE: The API key must be configured to show syndicated content.
*/
@interface BVSyndicationSource : NSObject

@property (readonly) NSString * _Nullable logoImageUrl;
@property (readonly) NSString * _Nullable contentLink;
@property (readonly) NSString * _Nullable name;

-(id _Nullable)initWithApiResponse:(id _Nullable)apiResponse;

@end
32 changes: 32 additions & 0 deletions Pod/BVConversations/Display/Model/BVSyndicationSource.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// BVSyndicationSource.m
// BVSDK
//
// Copyright © 2017 Bazaarvoice. All rights reserved.
//

#import "BVSyndicationSource.h"
#import "BVNullHelper.h"

@implementation BVSyndicationSource

-(id _Nullable)initWithApiResponse:(id _Nullable)apiResponse {
self = [super init];
if(self) {
if (apiResponse == nil || ![apiResponse isKindOfClass:[NSDictionary class]]) {
return nil;
}

NSDictionary* apiObject = [apiResponse objectForKey:@"SyndicationSource"];

if (apiObject){
SET_IF_NOT_NULL(_name, apiObject[@"Name"]);
SET_IF_NOT_NULL(_contentLink, apiObject[@"ContentLink"]);
SET_IF_NOT_NULL(_logoImageUrl, apiObject[@"LogoImageUrl"]);
}

}
return self;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#import "BVContextDataValue.h"
#import "BVBadge.h"
#import "BVSecondaryRating.h"
#import "BVSyndicationSource.h"

@class BVProduct;

/*
Expand Down Expand Up @@ -64,5 +66,6 @@
@property NSDate* _Nullable lastModificationTime;
@property NSDate* _Nullable submissionTime;
@property NSDate* _Nullable lastModeratedTime;
@property BVSyndicationSource* _Nullable syndicationSource;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ -(id)initWithApiResponse:(NSDictionary *)apiResponse includes:(BVConversationsIn
self = [super init];
if(self){


NSString* productId = apiResponse[@"ProductId"];
self.product = [includes getProductById:productId];
self.cons = apiResponse[@"Cons"];
Expand All @@ -35,6 +34,11 @@ -(id)initWithApiResponse:(NSDictionary *)apiResponse includes:(BVConversationsIn
NSNumber* isSyndicated = apiResponse[@"IsSyndicated"];
if(![isSyndicated isKindOfClass:[NSNull class]]) {
self.isSyndicated = [isSyndicated boolValue];

if (self.isSyndicated) {
self.syndicationSource = [[BVSyndicationSource alloc] initWithApiResponse:apiResponse];
}

}

NSNumber* featured = apiResponse[@"IsFeatured"];
Expand Down Expand Up @@ -65,7 +69,6 @@ -(id)initWithApiResponse:(NSDictionary *)apiResponse includes:(BVConversationsIn
self.rating = 0;
}


SET_IF_NOT_NULL(self.contentLocale, apiResponse[@"ContentLocale"])
SET_IF_NOT_NULL(self.ratingRange, apiResponse[@"RatingRange"])
SET_IF_NOT_NULL(self.totalCommentCount, apiResponse[@"TotalCommentCount"])
Expand Down
2 changes: 1 addition & 1 deletion Pod/BVCurations/BVCurationsAddPostRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import "BVCUrationsFeedItem.h"
#import "BVCurationsFeedItem.h"

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

import XCTest
import OHHTTPStubs
@testable import BVSDK

class ReviewDisplayTests: XCTestCase {
Expand Down Expand Up @@ -46,6 +47,7 @@ class ReviewDisplayTests: XCTestCase {
XCTAssertEqual(review.authorId, "endersgame")
XCTAssertEqual(review.userNickname, "endersgame")
XCTAssertEqual(review.userLocation, "San Fransisco, California")
XCTAssertNil(review.syndicationSource)

XCTAssertEqual((review.tagDimensions!["Pro"]! as AnyObject).label, "Pros")
XCTAssertEqual((review.tagDimensions!["Pro"]! as AnyObject).identifier, "Pro")
Expand Down Expand Up @@ -76,7 +78,7 @@ class ReviewDisplayTests: XCTestCase {

}) { (error) in

XCTFail("product display request error: \(error)")
XCTFail("review display request error: \(error)")

}

Expand All @@ -87,10 +89,50 @@ class ReviewDisplayTests: XCTestCase {
}


func testSyndicationSource(){


stub(condition: isHost("stg.api.bazaarvoice.com")) { _ in
// Stub it with our "storeItemWithStatsAndReviews.json" stub file (which is in same bundle as self)
let stubPath = OHPathForFile("testSyndicationSource.json", type(of: self))
return fixture(filePath: stubPath!, headers: ["Content-Type" as NSObject:"application/json" as AnyObject])
}

let expectation = self.expectation(description: "testSyndicationSource")


let request = BVReviewsRequest(productId: "test1", limit: 10, offset: 4)
.addReviewSort(.rating, order: .ascending)
.addInclude(BVReviewIncludeType.products)

request.load({ (response) in

let review = response.results.first

XCTAssertNotNil(review?.syndicationSource)
XCTAssertEqual(review?.syndicationSource?.name, "bazaarvoice")
XCTAssertNil(review?.syndicationSource?.contentLink)
XCTAssertNotNil(review?.syndicationSource?.logoImageUrl)

expectation.fulfill()

}) { (error) in

XCTFail("review display request error: \(error)")

}

self.waitForExpectations(timeout: 10) { (error) in
XCTAssertNil(error, "Something went horribly wrong, request took too long.")
}

}

func testReviewDisplayProductFilteredStats() {

let expectation = self.expectation(description: "testReviewDisplayProductFilteredStats")


let request = BVReviewsRequest(productId: "test1", limit: 10, offset: 4)
.addReviewSort(.rating, order: .ascending)
.addInclude(BVReviewIncludeType.products)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class PhotoUploadTests: XCTestCase {
expectation.fulfill()
}) { (errors) in
XCTAssertEqual(errors.count, 1)
let error = errors.first as! NSError
let error = errors.first! as NSError
XCTAssertEqual(error.userInfo[BVFieldErrorCode] as? String, "ERROR_FORM_IMAGE_PARSE")
XCTAssertEqual(error.userInfo[BVFieldErrorName] as? String, "photo")
XCTAssertEqual(error.userInfo[BVFieldErrorMessage] as? String, "We were unable to parse the image you uploaded. Please ensure that the image is a valid BMP, PNG, GIF or JPEG file.")
Expand Down
Loading

0 comments on commit c4ff907

Please sign in to comment.