WPAppNetworkManager class
A networking class to manage all the APIs from "wp_json_api".
Requests are sent to the WP JSON API wpapp/v4 namespace. Authenticated
requests send the user's token in the Authorization: Bearer and
X-WPApp-Token headers, never in the request body.
Every request throws a typed exception when the server returns an error,
e.g. InvalidUserTokenException for wpapp_unauthorized. Errors without
a dedicated exception throw a WPServerException, and requests that fail
without a response (no connection, timeout) throw a WPNetworkException.
Properties
- dio ↔ Dio
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
wcCustomerInfo(
{String? userToken}) → Future< WCCustomerInfoResponse> - Get the user's WooCommerce customer information.
-
wcPointsAndRewardsCalculatePoints(
{required double points, String? userToken}) → Future< WcPointsAndRewardCalculatePoints> -
Calculate the value of
points(0 or more) with WooCommerce Points and Rewards. -
wcPointsAndRewardsUser(
{String? userToken}) → Future< WcPointsAndRewardUser> - Get the user's points from WooCommerce Points and Rewards.
-
wcRegister(
{required String email, required String password, String? username, String? firstName, String? lastName, Map< String, dynamic> ? metaData, int? expiresIn, String? deviceName, bool saveTokenToLocalStorage = true}) → Future<WPUserRegisterResponse> - Sends a request to register a user as a WooCommerce customer. Takes the same parameters as wpRegister.
-
wcUpdateCustomerInfo(
{String? userToken, String? firstName, String? lastName, String? displayName, String? billingFirstName, String? billingLastName, String? billingCompany, String? billingAddress1, String? billingAddress2, String? billingCity, String? billingState, String? billingPostcode, String? billingCountry, String? billingEmail, String? billingPhone, String? shippingFirstName, String? shippingLastName, String? shippingCompany, String? shippingAddress1, String? shippingAddress2, String? shippingCity, String? shippingState, String? shippingPostcode, String? shippingCountry, String? shippingPhone}) → Future< WCCustomerUpdatedResponse> - Sends a request to update the user's WooCommerce customer details. All parameters are optional; only the ones you set are sent.
-
wpGetUserInfo(
{String? userToken}) → Future< WPUserInfoResponse> - Sends a request to get the user's WordPress info.
-
wpLogin(
{String? login, String? email, String? username, required String password, int? expiresIn, String? deviceName, bool saveTokenToLocalStorage = true}) → Future< WPUserLoginResponse> - Sends a request to login a user.
-
wpLogout(
{String? userToken}) → Future< bool> - Logs out the user. Sends a request to revoke the token on the server, then removes the user and token from the device.
-
wpRegister(
{required String email, required String password, String? username, String? firstName, String? lastName, Map< String, dynamic> ? metaData, int? expiresIn, String? deviceName, bool saveTokenToLocalStorage = true}) → Future<WPUserRegisterResponse> -
Sends a request to register a user in WordPress with an
emailandpassword. -
wpResetPassword(
{required String currentPassword, required String password, String? userToken}) → Future< WPUserResetPasswordResponse> -
Changes the user's password.
currentPasswordis the user's current password andpasswordis the new one. -
wpUpdateUserInfo(
{String? userToken, String? firstName, String? lastName, String? displayName, List< WpMetaData> ? metaData}) → Future<WPUserInfoUpdatedResponse> -
Sends a request to update details for a WordPress user. Optional
parameters include a
firstName,lastName,displayNameormetaDatato update. -
wpUserDelete(
{required String password, String? userToken}) → Future< WPUserDeleteResponse> -
Sends a request to delete the user's WordPress account. The user's
current
passwordis required.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → WPAppNetworkManager
-
An instance of WPAppNetworkManager class
final
Constants
- apiNamespace → const String
- The WP JSON API namespace used for all requests.
- tokenHeader → const String
-
The header that carries the token for hosts that strip
Authorization.