Skip to content

Commit 06968d1

Browse files
committed
Add roles to wp_user_info_response
1 parent bc31236 commit 06968d1

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [3.1.3] - 2021-09-03
2+
3+
* Add roles to wp_user_info_response
4+
15
## [3.1.2] - 2021-09-02
26

37
* Ran flutter format

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ In your flutter project add the dependency:
2727
``` dart
2828
dependencies:
2929
...
30-
wp_json_api: ^3.1.2
30+
wp_json_api: ^3.1.3
3131
```
3232

3333
### Usage example #

lib/models/responses/wp_user_info_response.dart

+9
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Data {
5050
String? email;
5151
String? avatar;
5252
List<MetaData>? metaData;
53+
List<String>? roles;
5354
String? createdAt;
5455

5556
Data(
@@ -59,6 +60,7 @@ class Data {
5960
this.username,
6061
this.userNicename,
6162
this.displayName,
63+
this.roles,
6264
this.userStatus,
6365
this.email,
6466
this.avatar,
@@ -74,6 +76,12 @@ class Data {
7476
displayName = json['display_name'];
7577
userStatus = json['user_status'];
7678
email = json['email'];
79+
roles = [];
80+
if (json['roles'] != null) {
81+
(json['roles'] as List).forEach((role) {
82+
roles!.add(role);
83+
});
84+
}
7785
avatar = json['avatar'];
7886
if (json['meta_data'] != null && Map.of(json['meta_data']).isNotEmpty) {
7987
this.metaData = [];
@@ -94,6 +102,7 @@ class Data {
94102
data['display_name'] = this.displayName;
95103
data['user_status'] = this.userStatus;
96104
data['email'] = this.email;
105+
data['roles'] = (this.roles ?? []).map((e) => e).toList();
97106
data['avatar'] = this.avatar;
98107
if (this.metaData != null) {
99108
data['meta_data'] = this.metaData!.map((e) => e.toJson()).toList();

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wp_json_api
22
description: WordPress and WooCommerce JSON API for Flutter Mobile. API allows you to login, register new users, get users info and more.
3-
version: 3.1.2
3+
version: 3.1.3
44
homepage: https://woosignal.com
55
repository: https://github.com/woosignal/wp-json-api-flutter
66
issue_tracker: https://github.com/woosignal/wp-json-api-flutter/issues

0 commit comments

Comments
 (0)