Skip to content

Commit

Permalink
v4.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
agordn52 committed Nov 27, 2024
1 parent 04cfe01 commit 8265cba
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [4.0.4] - 2024-11-27

* Fix auth issue
* Dependency updates

## [4.0.3] - 2024-11-25

* Dependency updates
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ In your flutter project add the dependency:
``` dart
dependencies:
...
wp_json_api: ^4.0.3
wp_json_api: ^4.0.4
```

### Usage example #
Expand Down
9 changes: 4 additions & 5 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,9 @@ packages:
nylo_support:
dependency: transitive
description:
name: nylo_support
sha256: "7707ecaba8cee2defec4e0609d0e73e6b08a52b3432f6c5a373de6581fe973a9"
url: "https://pub.dev"
source: hosted
path: "/Users/anthony/StudioProjects/support"
relative: false
source: path
version: "6.6.0"
path:
dependency: transitive
Expand Down Expand Up @@ -784,7 +783,7 @@ packages:
path: ".."
relative: true
source: path
version: "4.0.3"
version: "4.0.4"
xdg_directories:
dependency: transitive
description:
Expand Down
25 changes: 13 additions & 12 deletions lib/wp_json_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ library wp_json_api;

import 'package:nylo_support/helpers/auth.dart';
import 'package:nylo_support/local_storage/local_storage.dart';
import 'package:nylo_support/nylo.dart';
import '/helpers/typedefs.dart';
import '/models/wp_user.dart';
import '/networking/network_manager.dart';

/// The version of the wp_json_api
String _wpJsonAPIVersion = "4.0.3";
String _wpJsonAPIVersion = "4.0.4";

/// The base class to initialize and use WPJsonAPI
class WPJsonAPI {
Expand Down Expand Up @@ -51,10 +52,17 @@ class WPJsonAPI {
init(
{required String baseUrl,
String wpJsonPath = '/wp-json',
bool shouldDebug = true}) {
bool shouldDebug = true,
bool nylo = false}) {
_setBaseApi(baseUrl: baseUrl);
_setApiPath(path: wpJsonPath);
_setShouldDebug(value: shouldDebug);

// nylo setup
if (!nylo) {
Nylo.package();
Nylo.instance.addAuthKey(storageKey());
}
}

/// Login a user with the [WpUser]
Expand All @@ -70,21 +78,14 @@ class WPJsonAPI {
/// Authenticate a user if they are logged in
static wpAuth() async {
final data = await storageRead(WPJsonAPI.storageKey());
if (data != null) {
return WpUser.fromJson(data);
}
return null;
if (data != null) return null;
return WpUser.fromJson(data);
}

/// Check if a user is logged in
static Future<bool> wpUserLoggedIn() async {
WpUser? _wpUser = await wpUser();
if (_wpUser == null) {
return false;
}
if (_wpUser.token == null) {
return false;
}
if (_wpUser?.token == null) return false;
return true;
}

Expand Down
7 changes: 3 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,9 @@ packages:
nylo_support:
dependency: "direct main"
description:
name: nylo_support
sha256: "7707ecaba8cee2defec4e0609d0e73e6b08a52b3432f6c5a373de6581fe973a9"
url: "https://pub.dev"
source: hosted
path: "/Users/anthony/StudioProjects/support"
relative: false
source: path
version: "6.6.0"
path:
dependency: transitive
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: wp_json_api
description: WordPress and WooCommerce JSON API for Flutter Mobile. API allows you to login, register new users, get users info and more.
version: 4.0.3
version: 4.0.4
homepage: https://woosignal.com
repository: https://github.com/woosignal/wp-json-api-flutter
issue_tracker: https://github.com/woosignal/wp-json-api-flutter/issues
Expand All @@ -12,7 +12,7 @@ environment:

dependencies:
dio: ^5.7.0
nylo_support: ^6.6.0
nylo_support: ^6.7.0
flutter:
sdk: flutter
collection: ^1.17.0
Expand Down

0 comments on commit 8265cba

Please sign in to comment.