Skip to content

Commit

Permalink
- Parse the 'IsSyndicated' flag in the BVReview object
Browse files Browse the repository at this point in the history
- Update the /Examples/Conversations/Swift example to show for advanced data for reviews.
- Bump SDK to 6.5.1
  • Loading branch information
Tim Kelly committed May 2, 2017
1 parent 86ac1c9 commit 30ee3c8
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 38 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.0'
s.version = '6.5.1'
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
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.0</string>
<string>6.5.1</string>
<key>CFBundleVersion</key>
<string>6.5.0</string>
<string>6.5.1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
874863A01D4BE64A00B43F00 /* MyQuestionTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8748639C1D4BE64A00B43F00 /* MyQuestionTableViewCell.xib */; };
874863A11D4BE64A00B43F00 /* MyReviewTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8748639D1D4BE64A00B43F00 /* MyReviewTableViewCell.xib */; };
874863A21D4BE64A00B43F00 /* StatisticTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8748639E1D4BE64A00B43F00 /* StatisticTableViewCell.xib */; };
8777BB3F1EB7BE18008C4715 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8777BB3E1EB7BE18008C4715 /* Constants.swift */; };
879143F21CF4F05C00976220 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 879143F11CF4F05C00976220 /* AppDelegate.swift */; };
879143F41CF4F05C00976220 /* ReviewsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 879143F31CF4F05C00976220 /* ReviewsViewController.swift */; };
87A36D231D4A911D00C3B41F /* AnswersViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 87A36D161D4A911D00C3B41F /* AnswersViewController.swift */; };
Expand All @@ -40,6 +41,7 @@
8748639C1D4BE64A00B43F00 /* MyQuestionTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyQuestionTableViewCell.xib; sourceTree = "<group>"; };
8748639D1D4BE64A00B43F00 /* MyReviewTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MyReviewTableViewCell.xib; sourceTree = "<group>"; };
8748639E1D4BE64A00B43F00 /* StatisticTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = StatisticTableViewCell.xib; sourceTree = "<group>"; };
8777BB3E1EB7BE18008C4715 /* Constants.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
879143EE1CF4F05C00976220 /* ConversationsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ConversationsExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
879143F11CF4F05C00976220 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
879143F31CF4F05C00976220 /* ReviewsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewsViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -122,6 +124,7 @@
15E077DB1E5769CA001C89D0 /* bvsdk_config_prod.json */,
15E077DC1E5769CA001C89D0 /* bvsdk_config_staging.json */,
879143F11CF4F05C00976220 /* AppDelegate.swift */,
8777BB3E1EB7BE18008C4715 /* Constants.swift */,
87FF7F341D4FA90700019D54 /* View Controllers */,
87FF7F351D4FA91600019D54 /* Table View Cells */,
874863751D4BD8E000B43F00 /* Base.lproj */,
Expand Down Expand Up @@ -295,6 +298,7 @@
87A36D2E1D4A911D00C3B41F /* StatisticTableViewCell.swift in Sources */,
879143F41CF4F05C00976220 /* ReviewsViewController.swift in Sources */,
87A36D241D4A911D00C3B41F /* InlineRatingsViewController.swift in Sources */,
8777BB3F1EB7BE18008C4715 /* Constants.swift in Sources */,
879143F21CF4F05C00976220 /* AppDelegate.swift in Sources */,
87A36D2C1D4A911D00C3B41F /* QuestionsViewController.swift in Sources */,
87A36D2B1D4A911D00C3B41F /* PDPViewController.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ class AuthorViewController: UIViewController, UITableViewDataSource {
authorProfileTableView.register(UINib(nibName: "MyQuestionTableViewCell", bundle: nil), forCellReuseIdentifier: "MyQuestionTableViewCell")
authorProfileTableView.register(UINib(nibName: "MyAnswerTableViewCell", bundle: nil), forCellReuseIdentifier: "MyAnswerTableViewCell")

let authorId = "data-gen-user-c3k8hjvtpn03dupvxcui1rj3"

let request = BVAuthorRequest(authorId: authorId)

let request = BVAuthorRequest(authorId: Constants.TEST_AUTHOR_ID)
// stats includes
request.includeStatistics(.answers)
request.includeStatistics(.questions)
Expand Down Expand Up @@ -90,24 +89,28 @@ class AuthorViewController: UIViewController, UITableViewDataSource {

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

if self.authorResponse == nil {
if let author = self.authorResponse?.results.first {

switch section {
case AuthorSections.ProfileStats.rawValue:
return 1;
case AuthorSections.IncludedReviews.rawValue:
return (author.includedReviews.count);
case AuthorSections.IncludedQuestions.rawValue:
return (author.includedQuestions.count);
case AuthorSections.IncludedAnswers.rawValue:
return (author.includedAnswers.count);
default:
return 0;
}
}
else {
print("Error: No results to display")
return 0;
}

let author = self.authorResponse?.results.first!

switch section {
case AuthorSections.ProfileStats.rawValue:
return 1;
case AuthorSections.IncludedReviews.rawValue:
return (author?.includedReviews.count)!;
case AuthorSections.IncludedQuestions.rawValue:
return (author?.includedQuestions.count)!;
case AuthorSections.IncludedAnswers.rawValue:
return (author?.includedAnswers.count)!;
default:
return 0;
}


}

Expand Down
21 changes: 21 additions & 0 deletions Examples/Conversations/Swift/ConversationsExample/Constants.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Constants.swift
// ConversationsExample
//
// Copyright © 2017 Bazaarvoice. All rights reserved.
//

import UIKit

struct Constants {

// Used for Reviews & Questions (Submission & Display) and PDP Stats Request (Display)
static let TEST_PRODUCT_ID = "test1"

// Used for a BVBulkRatingsRequest
static let TEST_PRODUCT_IDS_ARRAY = ["test1", "test2","test3", "test4", "test5", "test6"]

// Used for a BVAuthorRequest
static let TEST_AUTHOR_ID = "data-gen-user-c3k8hjvtpn03dupvxcui1rj3"

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ class InlineRatingsViewController: UIViewController, UITableViewDataSource {
inlineReviewsTableView.rowHeight = UITableViewAutomaticDimension
inlineReviewsTableView.register(UINib(nibName: "StatisticTableViewCell", bundle: nil), forCellReuseIdentifier: "StatisticTableViewCell")

let productIds = ["test1", "test2","test3", "test4", "test5", "test6"]

let reviews = BVBulkRatingsRequest(productIds: productIds, statistics: BulkRatingsStatsType.all)
let reviews = BVBulkRatingsRequest(productIds: Constants.TEST_PRODUCT_IDS_ARRAY, statistics: BulkRatingsStatsType.all)

reviews.load({ (response) in
self.productStatistics = response.results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,52 @@ class MyReviewTableViewCell: BVReviewTableViewCell {

override var review: BVReview? {
didSet {
reviewTitle.text = review?.title
reviewText.text = review?.reviewText

var titleString = review?.title

// Get the author and date
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
let dateString = dateFormatter.string(from: (review?.submissionTime)!)

var badgesString = "\nBadges: ["

// let's see if this author has any badges
for badge : BVBadge in (review?.badges)! {

badgesString += " \(badge.identifier!)) "

}

badgesString += "]"

titleString = titleString?.appending("\nBy \(review!.authorId ?? "no author") on \(dateString)\(badgesString)")

reviewTitle.text = titleString

// Create a review body some example of data we can pull in.
var reviewString = review?.reviewText

reviewString?.append("\n")
reviewString?.append("\nIs Recommended? \(review!.isRecommended)")
reviewString?.append("\nIs Syndicated? \(review!.isSyndicated)")
reviewString?.append("\nHelpful Count: \(review!.totalPositiveFeedbackCount!)")
reviewString?.append("\nNot Helpful Count: \(review!.totalNegativeFeedbackCount!)")

// See if there are context data values
var secondaryRatingsText = "\nSecondary Ratings: ["

// Check and see if this reviewer supplied any of the secondary ratings
for rating : BVSecondaryRating in (review?.secondaryRatings)! {
secondaryRatingsText += " \(rating.label!)(\(rating.value!)) "
}

secondaryRatingsText += "]"

reviewString?.append(secondaryRatingsText)

reviewText.text = reviewString

}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12118" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12086"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -15,16 +19,16 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="165.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Review Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GEY-BS-M4Z">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="252" text="Review Title" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="GEY-BS-M4Z">
<rect key="frame" x="8" y="8" width="304" height="19.5"/>
<fontDescription key="fontDescription" type="system" pointSize="16"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="wordWrap" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Yim-Om-s0V">
<rect key="frame" x="8" y="35.5" width="304" height="122"/>
<fontDescription key="fontDescription" type="system" pointSize="13"/>
<color key="textColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
<color key="textColor" red="0.33333333333333331" green="0.33333333333333331" blue="0.33333333333333331" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PDPViewController: BVProductDisplayPageViewController, UITableViewDataSour
demoStatsTableView.rowHeight = UITableViewAutomaticDimension
demoStatsTableView.register(UINib(nibName: "StatisticTableViewCell", bundle: nil), forCellReuseIdentifier: "StatisticTableViewCell")

let productPage = BVProductDisplayPageRequest(productId: "test1")
let productPage = BVProductDisplayPageRequest(productId: Constants.TEST_PRODUCT_ID)
.includeStatistics(.reviews)
.includeStatistics(.questions)
.includeStatistics(.answers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class QuestionsViewController: UIViewController, UITableViewDataSource, UITableV
questionsTableView.rowHeight = UITableViewAutomaticDimension
questionsTableView.register(UINib(nibName: "MyQuestionTableViewCell", bundle: nil), forCellReuseIdentifier: "MyQuestionTableViewCell")

let questionsRequest = BVQuestionsAndAnswersRequest(productId: "test1", limit: 20, offset: 0)
let questionsRequest = BVQuestionsAndAnswersRequest(productId: Constants.TEST_PRODUCT_ID, limit: 20, offset: 0)

// optionally add in a sort option
questionsRequest.addQuestionSort(.submissionTime, order: .ascending)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ReviewsViewController: UIViewController, UITableViewDataSource {
reviewsTableView.rowHeight = UITableViewAutomaticDimension
reviewsTableView.register(UINib(nibName: "MyReviewTableViewCell", bundle: nil), forCellReuseIdentifier: "MyReviewTableViewCell")

let reviewsRequest = BVReviewsRequest(productId: "test1", limit: 20, offset: 0)
let reviewsRequest = BVReviewsRequest(productId: Constants.TEST_PRODUCT_ID, limit: 20, offset: 0)
reviewsRequest.addReviewSort(.submissionTime, order: .descending)

reviewsTableView.load(reviewsRequest, success: { (response) in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RootViewController: UIViewController {
let reviewSubmission = BVReviewSubmission(reviewTitle: "Review Title",
reviewText: "Review text...This needs to be long enough to be accepted.",
rating: 5,
productId: "test1")
productId: Constants.TEST_PRODUCT_ID)

// a working example of posting a review.
reviewSubmission.action = BVSubmissionAction.submit // Don't actually post, just run in preview mode!
Expand Down Expand Up @@ -55,7 +55,7 @@ class RootViewController: UIViewController {

@IBAction func submitQuestionTapped(sender: AnyObject) {

let submission = BVQuestionSubmission(productId: "test1")
let submission = BVQuestionSubmission(productId: Constants.TEST_PRODUCT_ID)
submission.action = .preview // don't actually just submit for real, this is just for demo
submission.questionSummary = "Question Summary"
submission.questionDetails = "Question details..."
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.0"
#define BV_SDK_VERSION @"6.5.1"

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

/// Error domain for NSError results, when present.
#define BVErrDomain @"com.bvsdk.bazaarvoice"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
@property NSString* _Nullable cons;
@property bool isRecommended;
@property bool isRatingsOnly;
@property bool isSyndicated;
@property NSString* _Nullable pros;
@property NSArray<BVPhoto*>* _Nonnull photos;
@property NSArray<BVContextDataValue*>* _Nonnull contextDataValues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ -(id)initWithApiResponse:(NSDictionary *)apiResponse includes:(BVConversationsIn
self.isRatingsOnly = [ratingsOnly boolValue];
}

NSNumber* isSyndicated = apiResponse[@"IsSyndicated"];
if(![isSyndicated isKindOfClass:[NSNull class]]) {
self.isSyndicated = [isSyndicated boolValue];
}

NSNumber* featured = apiResponse[@"IsFeatured"];
if(![featured isKindOfClass:[NSNull class]]) {
self.isFeatured = [featured boolValue];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ReviewDisplayTests: XCTestCase {
XCTAssertEqual(review.identifier, "191975")
XCTAssertNil(review.product)
XCTAssertEqual(review.isRatingsOnly, false)
XCTAssertEqual(review.isSyndicated, false)
XCTAssertEqual(review.isFeatured, false)
XCTAssertEqual(review.productId, "test1")
XCTAssertEqual(review.authorId, "endersgame")
Expand Down

0 comments on commit 30ee3c8

Please sign in to comment.