Skip to content

Commit

Permalink
Add roles to wp_user_info_response
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Sep 3, 2021
1 parent bc31236 commit 06968d1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [3.1.3] - 2021-09-03

* Add roles to wp_user_info_response

## [3.1.2] - 2021-09-02

* Ran flutter format
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ In your flutter project add the dependency:
``` dart
dependencies:
...
wp_json_api: ^3.1.2
wp_json_api: ^3.1.3
```

### Usage example #
Expand Down
9 changes: 9 additions & 0 deletions lib/models/responses/wp_user_info_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Data {
String? email;
String? avatar;
List<MetaData>? metaData;
List<String>? roles;
String? createdAt;

Data(
Expand All @@ -59,6 +60,7 @@ class Data {
this.username,
this.userNicename,
this.displayName,
this.roles,
this.userStatus,
this.email,
this.avatar,
Expand All @@ -74,6 +76,12 @@ class Data {
displayName = json['display_name'];
userStatus = json['user_status'];
email = json['email'];
roles = [];
if (json['roles'] != null) {
(json['roles'] as List).forEach((role) {
roles!.add(role);
});
}
avatar = json['avatar'];
if (json['meta_data'] != null && Map.of(json['meta_data']).isNotEmpty) {
this.metaData = [];
Expand All @@ -94,6 +102,7 @@ class Data {
data['display_name'] = this.displayName;
data['user_status'] = this.userStatus;
data['email'] = this.email;
data['roles'] = (this.roles ?? []).map((e) => e).toList();
data['avatar'] = this.avatar;
if (this.metaData != null) {
data['meta_data'] = this.metaData!.map((e) => e.toJson()).toList();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wp_json_api
description: WordPress and WooCommerce JSON API for Flutter Mobile. API allows you to login, register new users, get users info and more.
version: 3.1.2
version: 3.1.3
homepage: https://woosignal.com
repository: https://github.com/woosignal/wp-json-api-flutter
issue_tracker: https://github.com/woosignal/wp-json-api-flutter/issues
Expand Down

0 comments on commit 06968d1

Please sign in to comment.