Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
♻️ changing status due to API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
uiboy committed Apr 22, 2019
1 parent 731ee95 commit f6e2907
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 18 deletions.
12 changes: 6 additions & 6 deletions lib/models/user_invite.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ class UserInvite extends UpdatableModel<UserInvite> {
return message;
}

static convertUserInviteStatusToString(UserInviteFilterByStatus value) {
String result;
static convertUserInviteStatusToBool(UserInviteFilterByStatus value) {
bool isPending;
switch (value) {
case UserInviteFilterByStatus.all:
result = 'ALL';
isPending = null;
break;
case UserInviteFilterByStatus.pending:
result = 'PENDING';
isPending = true;
break;
case UserInviteFilterByStatus.accepted:
result = 'ACCEPTED';
isPending = false;
break;
default:
throw 'Unsupported post comment sort type';
}
return result;
return isPending;
}

static void clearCache() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class OBUserInviteTileState extends State<OBUserInviteTile> {
Widget _buildActionableSecondaryText() {
if (widget.userInvite.createdUser != null) {
return OBActionableSmartText(
size: OBTextSize.mediumSecondary,
text: 'Joined with username @${widget.userInvite.createdUser.username}',
);
} else {
Expand Down
16 changes: 8 additions & 8 deletions lib/services/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -726,22 +726,22 @@ class UserService {
}

Future<UserInvitesList> getUserInvites({int offset, int count, UserInviteFilterByStatus status}) async {
String statusValue = status != null ?
UserInvite.convertUserInviteStatusToString(status) :
UserInvite.convertUserInviteStatusToString(UserInviteFilterByStatus.all);
bool isPending = status != null ?
UserInvite.convertUserInviteStatusToBool(status) :
UserInvite.convertUserInviteStatusToBool(UserInviteFilterByStatus.all);

HttpieResponse response = await _userInvitesApiService.getUserInvites(status: statusValue, count: count, offset: offset);
HttpieResponse response = await _userInvitesApiService.getUserInvites(isStatusPending: isPending, count: count, offset: offset);
_checkResponseIsOk(response);
return UserInvitesList.fromJson(json.decode(response.body));
}


Future<UserInvitesList> searchUserInvites({int count, UserInviteFilterByStatus status, String query}) async {
String statusValue = status != null ?
UserInvite.convertUserInviteStatusToString(status) :
UserInvite.convertUserInviteStatusToString(UserInviteFilterByStatus.all);
bool isPending = status != null ?
UserInvite.convertUserInviteStatusToBool(status) :
UserInvite.convertUserInviteStatusToBool(UserInviteFilterByStatus.all);

HttpieResponse response = await _userInvitesApiService.searchUserInvites(status: statusValue, count: count, query: query);
HttpieResponse response = await _userInvitesApiService.searchUserInvites(isStatusPending: isPending, count: count, query: query);
_checkResponseIsOk(response);
return UserInvitesList.fromJson(json.decode(response.body));
}
Expand Down
8 changes: 4 additions & 4 deletions lib/services/user_invites_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class UserInvitesApiService {
Future<HttpieResponse> getUserInvites(
{ int offset,
int count,
String status}) {
bool isStatusPending}) {
Map<String, dynamic> queryParams = {};

if (count != null) queryParams['count'] = count;
if (offset != null) queryParams['offset'] = offset;
if (status != null) queryParams['status'] = status;
if (isStatusPending != null) queryParams['pending'] = isStatusPending;

return _httpService.get(_makeApiUrl(GET_USER_INVITES_PATH),
queryParameters: queryParams,
Expand All @@ -69,13 +69,13 @@ class UserInvitesApiService {

Future<HttpieResponse> searchUserInvites(
{ int count,
String status,
bool isStatusPending,
String query}) {
Map<String, dynamic> queryParams = {};

if (count != null) queryParams['count'] = count;
if (query != null) queryParams['query'] = query;
if (status != null) queryParams['status'] = status;
if (isStatusPending != null) queryParams['pending'] = isStatusPending;

return _httpService.get(_makeApiUrl(SEARCH_USER_INVITES_PATH),
queryParameters: queryParams,
Expand Down

0 comments on commit f6e2907

Please sign in to comment.