Skip to content

Commit 8265cba

Browse files
committed
v4.0.4
1 parent 04cfe01 commit 8265cba

File tree

6 files changed

+28
-24
lines changed

6 files changed

+28
-24
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## [4.0.4] - 2024-11-27
2+
3+
* Fix auth issue
4+
* Dependency updates
5+
16
## [4.0.3] - 2024-11-25
27

38
* Dependency updates

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ In your flutter project add the dependency:
3030
``` dart
3131
dependencies:
3232
...
33-
wp_json_api: ^4.0.3
33+
wp_json_api: ^4.0.4
3434
```
3535

3636
### Usage example #

example/pubspec.lock

+4-5
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,9 @@ packages:
400400
nylo_support:
401401
dependency: transitive
402402
description:
403-
name: nylo_support
404-
sha256: "7707ecaba8cee2defec4e0609d0e73e6b08a52b3432f6c5a373de6581fe973a9"
405-
url: "https://pub.dev"
406-
source: hosted
403+
path: "/Users/anthony/StudioProjects/support"
404+
relative: false
405+
source: path
407406
version: "6.6.0"
408407
path:
409408
dependency: transitive
@@ -784,7 +783,7 @@ packages:
784783
path: ".."
785784
relative: true
786785
source: path
787-
version: "4.0.3"
786+
version: "4.0.4"
788787
xdg_directories:
789788
dependency: transitive
790789
description:

lib/wp_json_api.dart

+13-12
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@ library wp_json_api;
1717

1818
import 'package:nylo_support/helpers/auth.dart';
1919
import 'package:nylo_support/local_storage/local_storage.dart';
20+
import 'package:nylo_support/nylo.dart';
2021
import '/helpers/typedefs.dart';
2122
import '/models/wp_user.dart';
2223
import '/networking/network_manager.dart';
2324

2425
/// The version of the wp_json_api
25-
String _wpJsonAPIVersion = "4.0.3";
26+
String _wpJsonAPIVersion = "4.0.4";
2627

2728
/// The base class to initialize and use WPJsonAPI
2829
class WPJsonAPI {
@@ -51,10 +52,17 @@ class WPJsonAPI {
5152
init(
5253
{required String baseUrl,
5354
String wpJsonPath = '/wp-json',
54-
bool shouldDebug = true}) {
55+
bool shouldDebug = true,
56+
bool nylo = false}) {
5557
_setBaseApi(baseUrl: baseUrl);
5658
_setApiPath(path: wpJsonPath);
5759
_setShouldDebug(value: shouldDebug);
60+
61+
// nylo setup
62+
if (!nylo) {
63+
Nylo.package();
64+
Nylo.instance.addAuthKey(storageKey());
65+
}
5866
}
5967

6068
/// Login a user with the [WpUser]
@@ -70,21 +78,14 @@ class WPJsonAPI {
7078
/// Authenticate a user if they are logged in
7179
static wpAuth() async {
7280
final data = await storageRead(WPJsonAPI.storageKey());
73-
if (data != null) {
74-
return WpUser.fromJson(data);
75-
}
76-
return null;
81+
if (data != null) return null;
82+
return WpUser.fromJson(data);
7783
}
7884

7985
/// Check if a user is logged in
8086
static Future<bool> wpUserLoggedIn() async {
8187
WpUser? _wpUser = await wpUser();
82-
if (_wpUser == null) {
83-
return false;
84-
}
85-
if (_wpUser.token == null) {
86-
return false;
87-
}
88+
if (_wpUser?.token == null) return false;
8889
return true;
8990
}
9091

pubspec.lock

+3-4
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,9 @@ packages:
400400
nylo_support:
401401
dependency: "direct main"
402402
description:
403-
name: nylo_support
404-
sha256: "7707ecaba8cee2defec4e0609d0e73e6b08a52b3432f6c5a373de6581fe973a9"
405-
url: "https://pub.dev"
406-
source: hosted
403+
path: "/Users/anthony/StudioProjects/support"
404+
relative: false
405+
source: path
407406
version: "6.6.0"
408407
path:
409408
dependency: transitive

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: wp_json_api
22
description: WordPress and WooCommerce JSON API for Flutter Mobile. API allows you to login, register new users, get users info and more.
3-
version: 4.0.3
3+
version: 4.0.4
44
homepage: https://woosignal.com
55
repository: https://github.com/woosignal/wp-json-api-flutter
66
issue_tracker: https://github.com/woosignal/wp-json-api-flutter/issues
@@ -12,7 +12,7 @@ environment:
1212

1313
dependencies:
1414
dio: ^5.7.0
15-
nylo_support: ^6.6.0
15+
nylo_support: ^6.7.0
1616
flutter:
1717
sdk: flutter
1818
collection: ^1.17.0

0 commit comments

Comments
 (0)