woocommerce_flutter_api 2.0.0
woocommerce_flutter_api: ^2.0.0 copied to clipboard
A typed, null-safe Flutter/Dart client for the WooCommerce REST API. Manage products, orders, customers, coupons, taxes, shipping and more with pagination, typed exceptions and fake-data mode.
Changelog #
All notable changes to this project are documented in this file.
2.0.0 #
Major release with a redesigned, safer public API. See MIGRATION.md for the v1 → v2 guide.
Fixed #
WooOrder.fromJsonno longer crashes on every real order — it previously assigned raw JSON strings (status,currency, dates, totals) directly into typed fields and threwTypeErrorat runtime. All models now parse through shared null-safe JSON helpers (WooJson).- Enums round-trip against the real WooCommerce wire values —
WooOrderStatus.onHoldserializes ason-hold(wasonHold), categorydisplayasdefault,term_group,date_gmt,menu_order,registered_date, etc..nameserialization is gone. - Unknown values no longer silently coerced — unrecognized/plugin statuses
map to a new
unknownmember instead of silently becomingpending/simple/USD. toJsonnever emits explicitnullvalues (a recurring cause of400 Bad Requeston update requests).- Credentials are never logged — the default-on debug logger (which printed
the
Authorization: Basic ck:csheader) is replaced with a credential-safe logger that is off by default (isDebugnow defaults tofalse). - Web support is real —
dart:ioremoved from the core client. - Bug fixes carried from v1: order refund endpoint path (
/refunds/{id}),db→dpquery parameter, order notetypeparameter,taxeClassestypo, variation date key swap. - Model consistency pass — every model now uses a
factory fromJson(was a mix of factories and generative constructors), ships afake()factory (batch models, category links andWooDeleteResultincluded), fulltoJson/copyWith/==/hashCode(added toWooDeleteResult; fixedWooSettingOption.hashCodeomittingoptions), and oneObject.hashAllhashCode idiom. - Enum consistency pass —
unknownfallback added toWooOrderTaxStatus,WooOrderNoteType,WooReportPeriod,WooContext,WooSort,WooOrderBy,WooFilterStatus,WooApiVersionandWooAuthMethod;WooProductFilterWithTypeis now aWooEnumwith wire values;fake()added toWooApiVersion/WooAuthMethod;WooWebhookTopic.randomTopic()renamedfake(). - Uniform
fake()signatures —fake({int? id})named parameters everywhere (WooCustomer.fake({int? id}), …) instead of a mix of positional and named. - Unified conventions — relative imports within
lib/src,Object.hashAllhashCode style, and uniform==across all models.
Changed (breaking) #
WooCommerce(username:, password:)→WooCommerce(consumerKey:, consumerSecret:).- New optional constructor parameters:
apiVersion(WooApiVersion.v3/v4),authMethod(WooAuthMethod.basic/queryString— query-string credentials are the other officially supported WooCommerce auth scheme),apiPathoverride. - All list methods return
WooPage<T>exposingX-WP-Total/X-WP-TotalPages(items,page,totalItems,totalPages,hasNextPage) instead of a bareList<T>. - All delete methods return
WooDeleteResult(id,deleted) instead of a mix ofbooland models. - All update methods take
(int id, Model model)consistently. - Typed query option classes (
WooProductQuery,WooOrderQuery,WooCustomerQuery, …) replace the per-module 20–30-parameter raw-map builders. - All models: immutable (
finalfields),copyWith, full-field==/hashCode(no more id-only equality). - Consolidated enums: 9 overlapping per-module sort enums → single
WooSortandWooOrderBy; 160-valueWooOrderCurrencyenum →String?plus aWooCurrencyconstants class; the data-module currency model was renamedWooDataCurrency. WooCouponDiscountTypeis now a typed enum; coupon amounts parse todouble?.WooCategoryDisplay.default_renamed tostandard(wire valuedefault).- Fixed typos in the public API:
getProductVaritaions→getProductVariations,WooProductWithChildrens→WooProductWithChildren,WooCustomernApi→WooCustomerApi. - Non-core endpoints (
login/register/forgot-password/change-password, cart, notifications/FCM,sendOrderDetailsToCustomer) are marked@experimentaland documented as requiring a custom WordPress plugin. pretty_dio_loggerkept for debug logging; the default-on v1 logger that printed theAuthorizationheader is replaced by the credential-safeWooLogInterceptor(debug logging is off by default in v2).
Added #
- Typed exception hierarchy mapped from Dio errors:
WooCommerceException,WooCommerceAuthException(401/403),WooCommerceValidationException(400, with field errors),WooCommerceNotFoundException(404),WooCommerceRateLimitException(429, withRetry-After),WooCommerceServerException(5xx),WooCommerceNetworkException,WooCommerceParseException— carryingstatusCode,codeandrequestId. - Global product attributes API (
/products/attributes) with terms: full CRUD + batch operations. - Webhook deliveries (
/webhooks/{id}/deliveries): list and delete. - Reports index (
GET /reports):getReports()returningWooReportItem. ?currency=request override on product list/create/update endpoints.- Query-string authentication (
WooAuthMethod.queryString). - First real test suite: serialization round-trips against real payloads, enum wire values, exception mapping, pagination headers, client construction.
- AI agent skills — the package now ships
skills/with two agent skills installable viadart run skills@ get woocommerce_flutter_api:woocommerce-flutter-api-documentation(full API usage guide with per-module references and links to the WooCommerce REST API docs) andwoocommerce-flutter-api-migration-guide(the v1 → v2 breaking changes). The source code is intentionally comment-free; the skills are the documentation.
1.7.1 #
- Fix
WooProductImagefor product creation: all fourDateTimefields are now nullable and optional.fromJsonkeeps themnullwhen missing andtoJsononly emits them when present. Fixes #31. - Fix
WooProductCategory.displayserialization:fromJsonusesWooCategoryDisplay.fromStringandtoJsonwrites"default". Fixes #30.
1.7.0 #
- Updated
flutter_secure_storageto^11.0.0(WASM-compatible). - Bumped SDK constraint to
>=3.3.0and Flutter constraint to>=3.19.0. - Resolved 18
dangling_library_doc_commentslints. - Fixed 3
comment_referenceslints; cleaned upavoid_printwarnings.
1.6.0 #
- Added batch update APIs for product shipping classes, product reviews, tax rates, webhooks and settings options, with matching batch request/response models.
1.5.0 #
- Enhanced documentation with detailed descriptions, usage examples and JSON serialization for refund, report, tax and variation models.
1.4.0 #
- Updated dependencies to the latest versions.
1.3.0 #
- Fixed
getOrdersorderby query parameter. - Added create/update/delete for product categories.
- Added create/update/delete/duplicate for products.
1.2.2 #
- Fixed issue #23 (category orderby query parameter).
1.2.1 #
- Improved API structure and documentation.
- Added
interceptorsproperty to theWooCommerceclass.
1.2.0 #
- Nearly complete coverage of the official WooCommerce REST API.
1.1.0 #
- Added product reviews, shipping classes, reports, tax rates and tax classes.
1.0.3 #
- Added product tags (
getProductTags()) andWooProductTagSort.
1.0.2 1.0.0 #
- Initial release of the WooCommerce REST API client.