-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,346 additions
and
696 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
include: package:lint_hard/all.yaml | ||
# include: package:lints/recommended.yaml | ||
|
||
|
||
analyzer: | ||
# language: | ||
# strict-casts: true | ||
# strict-inference: true | ||
# strict-raw-types: true | ||
|
||
exclude: | ||
- lib/src/pub |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,15 +4,9 @@ | |
* licensed under the GPL v2. | ||
* Written by Brett Sutton <[email protected]>, Jan 2022 | ||
*/ | ||
import 'package:dcli/dcli.dart'; | ||
import 'package:onepub/src/entry_point.dart'; | ||
import 'package:onepub/src/my_runner.dart'; | ||
import 'package:onepub/src/version/version.g.dart'; | ||
|
||
Future<void> main(List<String> arguments) async { | ||
print(orange('OnePub version: $packageVersion ')); | ||
|
||
print(''); | ||
|
||
await entrypoint(arguments, CommandSet.onepub, 'onepub'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import '../util/role_enum.dart'; | ||
|
||
class Member { | ||
Member({ | ||
required this.email, | ||
required this.firstname, | ||
required this.lastname, | ||
required this.roles, | ||
required this.onepubToken, | ||
required this.organisationName, | ||
required this.obfuscatedOrganisationId, | ||
}); | ||
|
||
String email; | ||
String firstname; | ||
String lastname; | ||
Set<RoleEnum> roles; | ||
String organisationName; | ||
String obfuscatedOrganisationId; | ||
String onepubToken; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'dart:io'; | ||
|
||
import '../util/role_enum.dart'; | ||
import '../util/send_command.dart'; | ||
import 'member.dart'; | ||
|
||
class MemberResponse { | ||
MemberResponse(EndpointResponse response, this.onepubToken) { | ||
_success = response.success; | ||
|
||
if (response.status == HttpStatus.notFound) { | ||
notFound = true; | ||
} | ||
|
||
if (!response.success) { | ||
_errorMessage = response.data['message']! as String; | ||
} else { | ||
email = response.data['email'] as String? ?? ''; | ||
firstname = response.data['firstname'] as String? ?? ''; | ||
lastname = response.data['lastname'] as String? ?? ''; | ||
roles = jsonToSet(response.data['roles']); | ||
organisationName = response.data['organisationName'] as String? ?? ''; | ||
obfuscatedOrganisationId = | ||
response.data['obfuscateOrganisationId'] as String? ?? ''; | ||
} | ||
} | ||
|
||
Set<T> jsonToSet<T>(Object? responseData) { | ||
final temp = responseData as List? ?? <dynamic>[]; | ||
final set = <T>{}; | ||
for (final tmp in temp) { | ||
set.add(tmp as T); | ||
} | ||
return set; | ||
} | ||
|
||
List<T> jsonToList<T>(Object? responseData) { | ||
final temp = responseData as List? ?? <dynamic>[]; | ||
final list = <T>[]; | ||
for (final tmp in temp) { | ||
list.add(tmp as T); | ||
} | ||
return list; | ||
} | ||
|
||
late final bool _success; | ||
|
||
final String onepubToken; | ||
late final String email; | ||
late final String firstname; | ||
late final String lastname; | ||
late final Set<String> roles; | ||
late final String organisationName; | ||
late final String obfuscatedOrganisationId; | ||
|
||
bool get success => _success; | ||
|
||
/// If success is false then you can check this field | ||
/// to see if it failed because the organisation wasn't found | ||
/// if this is false then a more serious error occured | ||
bool notFound = false; | ||
|
||
/// if [success] is false this will contain the error message. | ||
late final String? _errorMessage; | ||
|
||
String get errorMessage => _errorMessage ?? ''; | ||
|
||
Member toMember() { | ||
final enumRoles = <RoleEnum>{}; | ||
|
||
for (final role in roles) { | ||
enumRoles.add(RoleEnumHelper.byName(role)); | ||
} | ||
return Member( | ||
onepubToken: onepubToken, | ||
email: email, | ||
firstname: firstname, | ||
lastname: lastname, | ||
roles: enumRoles, | ||
organisationName: organisationName, | ||
obfuscatedOrganisationId: obfuscatedOrganisationId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.