@@ -28,7 +28,7 @@ In your flutter project add the dependency:
2828``` dart
2929dependencies:
3030 ...
31- wp_json_api: ^3.4 .0
31+ wp_json_api: ^3.5 .0
3232```
3333
3434### Usage example #
@@ -45,7 +45,7 @@ import 'package:wp_json_api/wp_json_api.dart';
4545
4646void main() {
4747
48- WPJsonAPI.instance.initWith (baseUrl: "https://mysite.com");
48+ WPJsonAPI.instance.init (baseUrl: "https://mysite.com");
4949
5050...
5151```
@@ -115,29 +115,26 @@ WPUserRegisterResponse wpUserRegisterResponse = await WPJsonAPI.instance
115115 .api((request) => request.wpRegister(
116116 email: email,
117117 password: password,
118- username: username
118+ // username: username // optional - the library will automatically generate a username if not provided
119119 ));
120120```
121121
122122#### WordPress - Get Users Info
123123- 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
125125
126126``` dart
127127WPUserInfoResponse wpUserInfoResponse = await WPJsonAPI.instance
128- .api((request) => request.wpGetUserInfo(
129- userToken
130- ));
128+ .api((request) => request.wpGetUserInfo());
131129```
132130
133131#### WordPress - Update Users Info
134132- 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
136134
137135``` dart
138136WPUserInfoUpdatedResponse wpUserInfoUpdatedResponse = await WPJsonAPI.instance
139137 .api((request) => request.wpUpdateUserInfo(
140- userToken,
141138 firstName: firstName,
142139 lastName: lastName,
143140 displayName: displayName
@@ -146,55 +143,61 @@ WPUserInfoUpdatedResponse wpUserInfoUpdatedResponse = await WPJsonAPI.instance
146143
147144#### WordPress - Update users password
148145- 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
150147
151148``` dart
152149WPUserResetPasswordResponse wpUserResetPasswordResponse = await WPJsonAPI.instance
153150 .api((request) => request.wpResetPassword(
154- userToken,
155151 password: password
156152 ));
157153```
158154
159155#### WordPress - Add a role to a user
160156- 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
162158
163159``` dart
164160WPUserAddRoleResponse wpUserAddRoleResponse = await WPJsonAPI.instance
165161 .api((request) => request.wpUserAddRole(
166- userToken,
167162 role: "customer" // e.g. customer, subscriber
168163 ));
169164```
170165
171166#### WordPress - Remove a role from a user
172167- 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
174169
175170``` dart
176171WPUserRemoveRoleResponse wpUserRemoveRoleResponse = await WPJsonAPI.instance
177172 .api((request) => request.wpUserRemoveRole(
178- userToken,
179173 role: "customer" // e.g. customer, subscriber
180174 ));
181175```
182176
183177#### WordPress - Delete a user
184178- 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
186180- You can pass an optional argument 'reassign' to reassign posts and links to new User ID.
187181
188182``` dart
189183WPUserDeleteResponse 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+ ));
193196```
194197
195198#### WooCommerce - Get users info in WooCommerce
196199- 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
198201
199202``` dart
200203WCCustomerInfoResponse wcCustomerInfoResponse = await WPJsonAPI.instance
@@ -206,12 +209,11 @@ WCCustomerInfoResponse wcCustomerInfoResponse = await WPJsonAPI.instance
206209#### WooCommerce - Update users info in WooCommerce
207210- Used to update a users WooCommerce details
208211- 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
210213
211214``` dart
212215WCCustomerUpdatedResponse wcCustomerUpdatedResponse = await WPJsonAPI.instance
213216 .api((request) => request.wcUpdateCustomerInfo(
214- userToken,
215217 firstName: firstName,
216218 lastName: lastName,
217219 displayName: displayName,
@@ -242,23 +244,20 @@ WCCustomerUpdatedResponse wcCustomerUpdatedResponse = await WPJsonAPI.instance
242244
243245#### WooCommerce Points and Rewards - Get user's points
244246- 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
246248
247249``` dart
248250WcPointsAndRewardUser wcPointsAndRewardUser = await WPJsonAPI.instance
249- .api((request) => request.wcPointsAndRewardsUser(
250- userToken
251- ));
251+ .api((request) => request.wcPointsAndRewardsUser());
252252```
253253
254254#### WooCommerce Points and Rewards - Calculate the value of points
255255- 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
257257
258258``` dart
259259WcPointsAndRewardCalculatePoints wcPointsAndRewardsCalculatePoints = await WPJsonAPI.instance
260260 .api((request) => request.wcPointsAndRewardsCalculatePoints(
261- userToken,
262261 points: 100
263262 ));
264263```
@@ -270,6 +269,6 @@ For help getting started with WooSignal, view our
270269To use this plugin, add ` wp_json_api ` as a [ dependency in your pubspec.yaml file] ( https://flutter.io/platform-plugins/ ) .
271270
272271## 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.
274273
275274Disclaimer: 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