Skip to content

Commit

Permalink
Fix sorting parameters on Conversations display requests for reviews …
Browse files Browse the repository at this point in the history
…(BVReviewsRequest) and Questions (BVQuestionsAndAnswersRequest)
  • Loading branch information
Tim Kelly committed Jan 31, 2017
1 parent 2b51e9b commit 24d14ca
Show file tree
Hide file tree
Showing 25 changed files with 92 additions and 39 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.2.0'
s.version = '6.2.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.2.0</string>
<string>6.2.1</string>
<key>CFBundleVersion</key>
<string>6.2.0</string>
<string>6.2.1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>NSPrincipalClass</key>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ class RatingsAndReviewsViewController: UIViewController, UITableViewDelegate, UI

// Check sorting and filter FilterOptions
if selectedFilterOption == FilterOptions.highestRating.rawValue {
request.addSort(.rating, order: .descending)
request.addReviewSort(.rating, order: .descending)
} else if selectedFilterOption == FilterOptions.lowestRating.rawValue {
request.addSort(.rating, order: .ascending)
request.addReviewSort(.rating, order: .ascending)
} else if selectedFilterOption == FilterOptions.mostHelpful.rawValue {
request.addSort(.helpfulness, order: .descending)
request.addReviewSort(.helpfulness, order: .descending)
} else if selectedFilterOption == FilterOptions.location.rawValue {
if let defaultCachedStore = LocationPreferenceUtils.getDefaultStore(){
request.add(.userLocation, filterOperator: .equalTo, value: (defaultCachedStore.city))
Expand Down
13 changes: 7 additions & 6 deletions Examples/BVSDKDemo/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ PODS:
- Bolts/AppLinks (1.8.4):
- Bolts/Tasks
- Bolts/Tasks (1.8.4)
- BVSDK/BVCurations (6.1.1):
- BVSDK/BVCurations (6.2.1):
- BVSDK/Core
- BVSDK/BVLocation (6.1.1):
- BVSDK/BVLocation (6.2.1):
- BVSDK/Core
- BVSDK/BVNotifications (6.1.1):
- BVSDK/BVNotifications (6.2.1):
- BVSDK/BVLocation
- BVSDK/BVPIN (6.1.1):
- BVSDK/BVPIN
- BVSDK/BVPIN (6.2.1):
- BVSDK/Core
- BVSDK/Core (6.1.1)
- BVSDK/Core (6.2.1)
- Crashlytics (3.8.3):
- Fabric (~> 1.6.3)
- Fabric (1.6.11)
Expand Down Expand Up @@ -87,7 +88,7 @@ CHECKOUT OPTIONS:

SPEC CHECKSUMS:
Bolts: 8a7995239dbe724f9cba2248b766d48b7ebdd322
BVSDK: f7f773700e7a7295b5bc239495feace910d0f19d
BVSDK: ff345cca892ece8de27c60b1f85abc2f1321d596
Crashlytics: 2b6dbe138a42395577cfa73dfa1aa7248cadf39e
Fabric: 5911403591946b8228ab1c51d98f1d7137e863c6
FBSDKCoreKit: 15fef8804a4629f98c6f4e55e81a76c9d725d85e
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ - (void)viewDidLoad {
[self.questionsTableView registerNib:[UINib nibWithNibName:@"MyQuestionTableViewCell" bundle:nil] forCellReuseIdentifier:@"MyQuestionTableViewCell"];

BVQuestionsAndAnswersRequest* request = [[BVQuestionsAndAnswersRequest alloc] initWithProductId:@"test1" limit:20 offset:0];
// optionally add in a sort option
[request addQuestionSort:BVSortOptionQuestionsLastModeratedTime order:BVSortOrderDescending];
// optionally add in a filter
[request addFilter:BVQuestionFilterTypeHasAnswers filterOperator:BVFilterOperatorEqualTo value:@"true"];

[self.questionsTableView load:request success:^(BVQuestionsAndAnswersResponse * _Nonnull response) {
self.questions = response.results;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ - (void)viewDidLoad {
[self.reviewsTableView registerNib:[UINib nibWithNibName:@"MyReviewTableViewCell" bundle:nil] forCellReuseIdentifier:@"MyReviewTableViewCell"];

BVReviewsRequest* request = [[BVReviewsRequest alloc] initWithProductId:@"test1" limit:20 offset:0];
[request addReviewSort:BVSortOptionReviewsSubmissionTime order:BVSortOrderDescending];

[self.reviewsTableView load:request success:^(BVReviewsResponse * _Nonnull response) {
self.reviews = response.results;
[self.reviewsTableView reloadData];
Expand Down
6 changes: 3 additions & 3 deletions Examples/Conversations/Obj-C/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PODS:
- BVSDK/BVConversations (6.1.1):
- BVSDK/BVConversations (6.2.1):
- BVSDK/Core
- BVSDK/Core (6.1.1)
- BVSDK/Core (6.2.1)

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

SPEC CHECKSUMS:
BVSDK: d3469344b264af22303083fccb2d47c92e50b41f
BVSDK: ff345cca892ece8de27c60b1f85abc2f1321d596

PODFILE CHECKSUM: 9e1e2f031337aa6807bc35f4e4832b444a6e4d39

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class QuestionsViewController: UIViewController, UITableViewDataSource, UITableV

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

// optionally add in a sort option
questionsRequest.addQuestionSort(.SubmissionTime, order: .Ascending)
// optionally add in a filter
questionsRequest.addFilter(.HasAnswers, filterOperator: .EqualTo, value: "true")

self.questionsTableView.load(questionsRequest, success: { (response) in

self.questions = response.results
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class ViewController: UIViewController, UITableViewDataSource {
reviewsTableView.registerNib(UINib(nibName: "MyReviewTableViewCell", bundle: nil), forCellReuseIdentifier: "MyReviewTableViewCell")

let reviewsRequest = BVReviewsRequest(productId: "test1", limit: 20, offset: 0)
reviewsRequest.addReviewSort(.SubmissionTime, order: .Descending)

reviewsTableView.load(reviewsRequest, success: { (response) in

self.reviews = response.results
Expand Down Expand Up @@ -54,4 +56,4 @@ class ViewController: UIViewController, UITableViewDataSource {
return tableCell
}

}
}
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.1.1):
- BVSDK/BVConversations (6.2.1):
- BVSDK/Core
- BVSDK/Core (6.1.1)
- BVSDK/Core (6.2.1)

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

SPEC CHECKSUMS:
BVSDK: d3469344b264af22303083fccb2d47c92e50b41f
BVSDK: ff345cca892ece8de27c60b1f85abc2f1321d596

PODFILE CHECKSUM: ff51a28f7873cf9d401e0c25277fa303397c7510

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

/// Provides the master version of the SDK.

#define BV_SDK_VERSION @"6.2.0"
#define BV_SDK_VERSION @"6.2.1"

/// Conversation SDK Version
#define SDK_HEADER_NAME @"X-UA-BV-SDK"
#define SDK_HEADER_VALUE @"IOS_SDK_V620"
#define SDK_HEADER_VALUE @"IOS_SDK_V621"

/// Error domain for NSError results, when present.
#define BVErrDomain @"com.bvsdk.bazaarvoice"
#define SYSTEM_VERSION_IOS_10 ([[[UIDevice currentDevice] systemVersion] compare:@"10.0" options:NSNumericSearch] != NSOrderedAscending)

#define LOG_DEPRECATED_MESSAGE(message) ([[BVLogger sharedLogger] warning:[NSString stringWithFormat:@"%@#%@ is deprecated and will be removed in a future release", NSStringFromClass([self class]), message]]);

#endif /* BVSDKConstants_h */
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ - (nonnull instancetype)includeStatistics:(PDPContentType)contentType {
}

- (nonnull instancetype)sortIncludedReviews:(BVSortOptionReviews)option order:(BVSortOrder)order {
BVSort* sort = [[BVSort alloc] initWithOptionString:[SortOptionReviewUtil toString:option] order:order];
BVSort* sort = [[BVSort alloc] initWithOptionString:[BVSortOptionReviewUtil toString:option] order:order];
[self.reviewSorts addObject:sort];
return self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#import "BVQuestionFilterType.h"
#import "BVFilterOperator.h"
#import "BVSort.h"
#import "BVSortOptionQuestions.h"
#import "BVSortOptionAnswers.h"
#import "BVQuestionsAndAnswersResponse.h"

/*
Expand All @@ -23,7 +25,10 @@
- (nonnull instancetype)initWithProductId:(NSString * _Nonnull)productId limit:(int)limit offset:(int)offset;
- (nonnull instancetype) __unavailable init;

- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order;
- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order; __deprecated_msg("use sortQuestions and sortAnswers instead");

- (nonnull instancetype)addQuestionSort:(BVSortOptionQuestions)option order:(BVSortOrder)order;

- (nonnull instancetype)addFilter:(BVQuestionFilterType)type filterOperator:(BVFilterOperator)filterOperator value:(NSString * _Nonnull)value;
- (nonnull instancetype)addFilter:(BVQuestionFilterType)type filterOperator:(BVFilterOperator)filterOperator values:(NSArray<NSString *> * _Nonnull)values;
- (nonnull instancetype)search:(NSString * _Nonnull)search;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import "BVQuestionsAndAnswersRequest.h"
#import "BVFilter.h"
#import "BVCommaUtil.h"
#import "BVLogger.h"
#import "BVCore.h"

@interface BVQuestionsAndAnswersRequest()

Expand Down Expand Up @@ -40,11 +40,18 @@ - (nonnull instancetype)initWithProductId:(NSString * _Nonnull)productId limit:(
}

- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order {
LOG_DEPRECATED_MESSAGE(@"addSort")
BVSort* sort = [[BVSort alloc] initWithOption:option order:order];
[self.sorts addObject:sort];
return self;
}

- (nonnull instancetype)addQuestionSort:(BVSortOptionQuestions)option order:(BVSortOrder)order{
BVSort* sort = [[BVSort alloc] initWithOptionString:[BVSortOptionQuestionsUtil toString:option] order:order];
[self.sorts addObject:sort];
return self;
}

- (nonnull instancetype)addFilter:(BVQuestionFilterType)type filterOperator:(BVFilterOperator)filterOperator value:(NSString * _Nonnull)value {
[self addFilter:type filterOperator:filterOperator values:@[value]];
return self;
Expand Down
6 changes: 5 additions & 1 deletion Pod/BVConversations/Display/Requests/BVReviewsRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "BVConversationsRequest.h"
#import "BVReviewFilterType.h"
#import "BVFilterOperator.h"
#import "BVSortOptionReviews.h"
#import "BVSort.h"
#import "BVReviewsResponse.h"

Expand All @@ -23,7 +24,10 @@
- (nonnull instancetype)initWithProductId:(NSString * _Nonnull)productId limit:(int)limit offset:(int)offset;
- (nonnull instancetype) __unavailable init;

- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order;
- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order __deprecated_msg("use sortReviews instead");

- (nonnull instancetype)addReviewSort:(BVSortOptionReviews)option order:(BVSortOrder)order;

- (nonnull instancetype)addFilter:(BVReviewFilterType)type filterOperator:(BVFilterOperator)filterOperator value:(NSString * _Nonnull)value;
- (nonnull instancetype)addFilter:(BVReviewFilterType)type filterOperator:(BVFilterOperator)filterOperator values:(NSArray<NSString *> * _Nonnull)values;
- (nonnull instancetype)search:(NSString * _Nonnull)search;
Expand Down
11 changes: 9 additions & 2 deletions Pod/BVConversations/Display/Requests/BVReviewsRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// Copyright © 2016 Bazaarvoice. All rights reserved.
//

#import "BVCore.h"
#import "BVCommaUtil.h"
#import "BVReviewsRequest.h"
#import "BVFilter.h"
#import "BVSort.h"
#import "BVCommaUtil.h"
#import "BVLogger.h"

@interface BVReviewsRequest()

Expand Down Expand Up @@ -41,11 +41,18 @@ - (nonnull instancetype)initWithProductId:(NSString * _Nonnull)productId limit:(
}

- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order {
LOG_DEPRECATED_MESSAGE(@"addSort")
BVSort* sort = [[BVSort alloc] initWithOption:option order:order];
[self.sorts addObject:sort];
return self;
}

- (nonnull instancetype)addReviewSort:(BVSortOptionReviews)option order:(BVSortOrder)order {
BVSort* sort = [[BVSort alloc] initWithOptionString:[BVSortOptionReviewUtil toString:option] order:order];
[self.sorts addObject:sort];
return self;
}

- (nonnull instancetype)addFilter:(BVReviewFilterType)type filterOperator:(BVFilterOperator)filterOperator value:(NSString * _Nonnull)value {
[self addFilter:type filterOperator:filterOperator values:@[value]];
return self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

- (nonnull instancetype)includeStatistics:(BVStoreIncludeContentType)contentType;

- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order;
- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order; __deprecated_msg("use sortReviews instead");

- (nonnull instancetype)addReviewSort:(BVSortOptionReviews)option order:(BVSortOrder)order;

- (nonnull instancetype)addFilter:(BVReviewFilterType)type filterOperator:(BVFilterOperator)filterOperator value:(NSString * _Nonnull)value;
- (nonnull instancetype)addFilter:(BVReviewFilterType)type filterOperator:(BVFilterOperator)filterOperator values:(NSArray<NSString *> * _Nonnull)values;
- (nonnull instancetype)search:(NSString * _Nonnull)search;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,18 @@ - (nonnull instancetype)includeStatistics:(BVStoreIncludeContentType)contentType
}

- (nonnull instancetype)addSort:(BVSortOptionProducts)option order:(BVSortOrder)order {
LOG_DEPRECATED_MESSAGE(@"addSort")
BVSort* sort = [[BVSort alloc] initWithOption:option order:order];
[self.sorts addObject:sort];
return self;
}

- (nonnull instancetype)addReviewSort:(BVSortOptionReviews)option order:(BVSortOrder)order {
BVSort* sort = [[BVSort alloc] initWithOptionString:[BVSortOptionReviewUtil toString:option] order:order];
[self.sorts addObject:sort];
return self;
}

- (nonnull instancetype)addFilter:(BVReviewFilterType)type filterOperator:(BVFilterOperator)filterOperator value:(NSString * _Nonnull)value {
[self addFilter:type filterOperator:filterOperator values:@[value]];
return self;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/*
The allowable sort types for `BVReviewsRequest` and `BVQuestionsAndAnswersRequests` requests.
*/
__deprecated
typedef NS_ENUM(NSInteger, BVSortOptionProducts) {
BVSortOptionProductsId,
BVSortOptionProductsAverageOverallRating,
Expand All @@ -34,4 +35,4 @@ typedef NS_ENUM(NSInteger, BVSortOptionProducts) {

+(NSString* _Nonnull)toString:(BVSortOptionProducts)BVSortOptionProducts;

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ typedef NS_ENUM(NSInteger, BVSortOptionQuestions) {
BVSortOptionQuestionsHasBestAnswer,
BVSortOptionQuestionsHasPhotos,
BVSortOptionQuestionsHasStaffAnswers,
BVSortOptionQuestionsHasVideos,
BVSortOptionQuestionsIsFeatured,
BVSortOptionQuestionsIsSubjectActive,
BVSortOptionQuestionsLastApprovedAnswerSubmissionTime,
BVSortOptionQuestionsLastModeratorCode,
BVSortOptionQuestionsLastModeratedTime,
BVSortOptionQuestionsLastModificationTime,
BVSortOptionQuestionsProductId,
Expand All @@ -33,11 +33,12 @@ typedef NS_ENUM(NSInteger, BVSortOptionQuestions) {
BVSortOptionQuestionsTotalFeedbackCount,
BVSortOptionQuestionsTotalNegativeFeedbackCount,
BVSortOptionQuestionsTotalPositiveFeedbackCount,
BVSortOptionQuestionsUserLocation
BVSortOptionQuestionsUserLocation,
BVSortOptionQuestionsHasVideos, // PRR Only
};

@interface BVSortOptionQuestionsUtil : NSObject

+(NSString* _Nonnull)toString:(BVSortOptionQuestions)BVSortOptionQuestions;

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ +(NSString* _Nonnull)toString:(BVSortOptionQuestions)BVSortOptionQuestions {
case BVSortOptionQuestionsHasBestAnswer: return @"HasBestAnswer";
case BVSortOptionQuestionsHasPhotos: return @"HasPhotos";
case BVSortOptionQuestionsHasStaffAnswers: return @"HasStaffAnswers";
case BVSortOptionQuestionsHasVideos: return @"HasVideos";
case BVSortOptionQuestionsIsFeatured: return @"IsFeatured";
case BVSortOptionQuestionsIsSubjectActive: return @"IsSubjectActive";
case BVSortOptionQuestionsLastApprovedAnswerSubmissionTime: return @"LastApprovedAnswerSubmissionTime";
case BVSortOptionQuestionsLastModeratedTime: return @"LastModeratedTime";
case BVSortOptionQuestionsLastModificationTime: return @"LastModificationTime";
case BVSortOptionQuestionsLastModeratorCode: return @"ModeratorCode";
case BVSortOptionQuestionsProductId: return @"ProductId";
case BVSortOptionQuestionsSubmissionId: return @"SubmissionId";
case BVSortOptionQuestionsSubmissionTime: return @"SubmissionTime";
Expand All @@ -36,6 +36,7 @@ +(NSString* _Nonnull)toString:(BVSortOptionQuestions)BVSortOptionQuestions {
case BVSortOptionQuestionsTotalNegativeFeedbackCount: return @"TotalNegativeFeedbackCount";
case BVSortOptionQuestionsTotalPositiveFeedbackCount: return @"TotalPositiveFeedbackCount";
case BVSortOptionQuestionsUserLocation: return @"UserLocation";
case BVSortOptionQuestionsHasVideos: return @"HasVideos";

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ typedef NS_ENUM(NSInteger, BVSortOptionReviews) {
BVSortOptionReviewsUserLocation
};

@interface SortOptionReviewUtil : NSObject
@interface BVSortOptionReviewUtil : NSObject

+(NSString* _Nonnull)toString:(BVSortOptionReviews)BVSortOptionReviews;

@end
@end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#import "BVSortOptionReviews.h"

@implementation SortOptionReviewUtil
@implementation BVSortOptionReviewUtil

+(NSString* _Nonnull)toString:(BVSortOptionReviews)BVSortOptionReviews {

Expand Down
Loading

0 comments on commit 24d14ca

Please sign in to comment.