@@ -28,7 +28,7 @@ In your flutter project add the dependency:
28
28
``` dart
29
29
dependencies:
30
30
...
31
- wp_json_api: ^3.4 .0
31
+ wp_json_api: ^3.5 .0
32
32
```
33
33
34
34
### Usage example #
@@ -45,7 +45,7 @@ import 'package:wp_json_api/wp_json_api.dart';
45
45
46
46
void main() {
47
47
48
- WPJsonAPI.instance.initWith (baseUrl: "https://mysite.com");
48
+ WPJsonAPI.instance.init (baseUrl: "https://mysite.com");
49
49
50
50
...
51
51
```
@@ -115,29 +115,26 @@ WPUserRegisterResponse wpUserRegisterResponse = await WPJsonAPI.instance
115
115
.api((request) => request.wpRegister(
116
116
email: email,
117
117
password: password,
118
- username: username
118
+ // username: username // optional - the library will automatically generate a username if not provided
119
119
));
120
120
```
121
121
122
122
#### WordPress - Get Users Info
123
123
- Used to get a WordPress users info
124
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
124
+ - After you login/register, you can all this method to get the users info
125
125
126
126
``` dart
127
127
WPUserInfoResponse wpUserInfoResponse = await WPJsonAPI.instance
128
- .api((request) => request.wpGetUserInfo(
129
- userToken
130
- ));
128
+ .api((request) => request.wpGetUserInfo());
131
129
```
132
130
133
131
#### WordPress - Update Users Info
134
132
- Used to update a WordPress users info
135
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
133
+ - After you login/register, you can all this method to update the users info
136
134
137
135
``` dart
138
136
WPUserInfoUpdatedResponse wpUserInfoUpdatedResponse = await WPJsonAPI.instance
139
137
.api((request) => request.wpUpdateUserInfo(
140
- userToken,
141
138
firstName: firstName,
142
139
lastName: lastName,
143
140
displayName: displayName
@@ -146,55 +143,61 @@ WPUserInfoUpdatedResponse wpUserInfoUpdatedResponse = await WPJsonAPI.instance
146
143
147
144
#### WordPress - Update users password
148
145
- Used to update a users password
149
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
146
+ - After you login/register, you can all this method to update the users password
150
147
151
148
``` dart
152
149
WPUserResetPasswordResponse wpUserResetPasswordResponse = await WPJsonAPI.instance
153
150
.api((request) => request.wpResetPassword(
154
- userToken,
155
151
password: password
156
152
));
157
153
```
158
154
159
155
#### WordPress - Add a role to a user
160
156
- Used to add a role to a user in WordPress
161
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
157
+ - After you login/register, you can all this method to add a role to the user
162
158
163
159
``` dart
164
160
WPUserAddRoleResponse wpUserAddRoleResponse = await WPJsonAPI.instance
165
161
.api((request) => request.wpUserAddRole(
166
- userToken,
167
162
role: "customer" // e.g. customer, subscriber
168
163
));
169
164
```
170
165
171
166
#### WordPress - Remove a role from a user
172
167
- Used to remove a role from a user in WordPress
173
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
168
+ - After you login/register, you can all this method to remove a role from the user
174
169
175
170
``` dart
176
171
WPUserRemoveRoleResponse wpUserRemoveRoleResponse = await WPJsonAPI.instance
177
172
.api((request) => request.wpUserRemoveRole(
178
- userToken,
179
173
role: "customer" // e.g. customer, subscriber
180
174
));
181
175
```
182
176
183
177
#### WordPress - Delete a user
184
178
- Used to delete a user in WordPress
185
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
179
+ - After you login/register, you can all this method to delete the user
186
180
- You can pass an optional argument 'reassign' to reassign posts and links to new User ID.
187
181
188
182
``` dart
189
183
WPUserDeleteResponse wpUserDeleteResponse = await WPJsonAPI.instance
190
- .api((request) => request.wpUserDelete(
191
- userToken
192
- ));
184
+ .api((request) => request.wpUserDelete());
185
+ ```
186
+
187
+ #### WooCommerce - Register
188
+ - Used to register a user
189
+
190
+ ``` dart
191
+ WPUserRegisterResponse wpUserRegisterResponse = await WPJsonAPI.instance
192
+ .api((request) => request.wpRegister(
193
+ email: email,
194
+ password: password
195
+ ));
193
196
```
194
197
195
198
#### WooCommerce - Get users info in WooCommerce
196
199
- Used to get WooCommerce info for a given user
197
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
200
+ - After you login/register, you can all this method to get the users WooCommerce info
198
201
199
202
``` dart
200
203
WCCustomerInfoResponse wcCustomerInfoResponse = await WPJsonAPI.instance
@@ -206,12 +209,11 @@ WCCustomerInfoResponse wcCustomerInfoResponse = await WPJsonAPI.instance
206
209
#### WooCommerce - Update users info in WooCommerce
207
210
- Used to update a users WooCommerce details
208
211
- All the parameter are optional so if you wanted to just update the name, you could just add first_name and last_name
209
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
212
+ - After you login/register, you can all this method to update the users WooCommerce info
210
213
211
214
``` dart
212
215
WCCustomerUpdatedResponse wcCustomerUpdatedResponse = await WPJsonAPI.instance
213
216
.api((request) => request.wcUpdateCustomerInfo(
214
- userToken,
215
217
firstName: firstName,
216
218
lastName: lastName,
217
219
displayName: displayName,
@@ -242,23 +244,20 @@ WCCustomerUpdatedResponse wcCustomerUpdatedResponse = await WPJsonAPI.instance
242
244
243
245
#### WooCommerce Points and Rewards - Get user's points
244
246
- This is used to get the user's current points in the [ WooCommerce Points and Rewards] ( https://woo.com/products/woocommerce-points-and-rewards/ ) plugin
245
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
247
+ - After you login/register, you can all this method to get the users points
246
248
247
249
``` dart
248
250
WcPointsAndRewardUser wcPointsAndRewardUser = await WPJsonAPI.instance
249
- .api((request) => request.wcPointsAndRewardsUser(
250
- userToken
251
- ));
251
+ .api((request) => request.wcPointsAndRewardsUser());
252
252
```
253
253
254
254
#### WooCommerce Points and Rewards - Calculate the value of points
255
255
- This is used to calculate the value of points in the [ WooCommerce Points and Rewards] ( https://woo.com/products/woocommerce-points-and-rewards/ ) plugin
256
- - The first parameter is the ** userToken ** which is returned from the login/register response. You should have this saved somewhere e.g. shared_pref
256
+ - After you login/register, you can all this method to calculate the value of points
257
257
258
258
``` dart
259
259
WcPointsAndRewardCalculatePoints wcPointsAndRewardsCalculatePoints = await WPJsonAPI.instance
260
260
.api((request) => request.wcPointsAndRewardsCalculatePoints(
261
- userToken,
262
261
points: 100
263
262
));
264
263
```
@@ -270,6 +269,6 @@ For help getting started with WooSignal, view our
270
269
To use this plugin, add ` wp_json_api ` as a [ dependency in your pubspec.yaml file] ( https://flutter.io/platform-plugins/ ) .
271
270
272
271
## Note
273
- Install our WordPress plugin "[ WP JSON API] ( https://woosignal.com/plugins/wordpress/wp-json-api ) " v3.3.2 to use this flutter plugin.
272
+ Install our WordPress plugin "[ WP JSON API] ( https://woosignal.com/plugins/wordpress/wp-json-api ) " v3.4.0 to use this flutter plugin.
274
273
275
274
Disclaimer: This plugin is not affiliated with or supported by Automattic, Inc. All logos and trademarks are the property of their respective owners.
0 commit comments