Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
Fixed #27

commit ee25ba4131493e4f3d4943ac868637a1b2d5cd93
Author: Oliver Brunsmann <oliver@brunsmann.io>
Date:   Thu Aug 11 22:12:05 2022 +0200

    Upgrades packages and rest client

commit dea090e87de72cd33c7868f8111a8af368d4f261
Author: Oliver Brunsmann <oliver@brunsmann.io>
Date:   Thu Aug 11 10:40:18 2022 +0200

    Updates swagger file

commit 0790ed495df2d40737b16f5f61a906f5abd4ff6a
Author: Oliver Brunsmann <oliver@brunsmann.io>
Date:   Thu Aug 11 10:40:03 2022 +0200

    Upgrades packages
  • Loading branch information
obrunsmann committed Aug 11, 2022
1 parent ab8c3d9 commit e3736fc
Show file tree
Hide file tree
Showing 12 changed files with 5,789 additions and 1,439 deletions.
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "flutter",
"command": "flutter",
"args": [
"pub",
"run",
"build_runner",
"build",
"--delete-conflicting-outputs"
],
"problemMatcher": [
"$dart-build_runner"
],
"group": "build",
"label": "flutter: flutter pub run build_runner build",
"detail": ""
}
]
}
10 changes: 4 additions & 6 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ targets:
builders:
chopper_generator:
options:
header: "// Generated code"
header: "// Generated code - do not change"
swagger_dart_code_generator:
options:
include_if_null:
enabled: true
value: true
with_converter: true
input_folder: "lib/src/rest/"
input_folder: "lib/swaggers"
output_folder: "lib/src/rest/"
enums_case_sensitive: true
enums_case_sensitive: true
include_if_null: true
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ packages:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.1"
version: "4.6.0"
jwt_decoder:
dependency: transitive
description:
Expand Down
53 changes: 22 additions & 31 deletions lib/src/nakama_client/nakama_api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import 'dart:convert';
import 'package:chopper/chopper.dart';
import 'package:nakama/api.dart';
import 'package:nakama/nakama.dart';
import 'package:nakama/src/rest/apigrpc.swagger.dart';
import 'package:nakama/src/rest/apigrpc.swagger.dart'
hide $ApiAccountWrappedExtension, $ApiAccountDeviceWrappedExtension;
import 'package:nakama/src/session.dart' as model;

const _kDefaultAppKey = 'default';
Expand All @@ -14,7 +15,7 @@ const _kDefaultAppKey = 'default';
class NakamaRestApiClient extends NakamaBaseClient {
static final Map<String, NakamaRestApiClient> _clients = {};

late final ChopperClient _chopperClient;
late final Apigrpc _api;

/// The key used to authenticate with the server without a session.
/// Defaults to "defaultkey".
Expand Down Expand Up @@ -59,14 +60,9 @@ class NakamaRestApiClient extends NakamaBaseClient {
required int port,
required bool ssl,
}) {
_chopperClient = ChopperClient(
converter: JsonSerializableConverter(),
baseUrl: Uri(
host: host,
scheme: ssl ? 'https' : 'http',
port: port,
).toString(),
services: [Apigrpc.create()],
_api = Apigrpc.create(
baseUrl: Uri(host: host, scheme: ssl ? 'https' : 'http', port: port)
.toString(),
interceptors: [
// Auth Interceptor
(Request request) async {
Expand All @@ -90,8 +86,6 @@ class NakamaRestApiClient extends NakamaBaseClient {
);
}

Apigrpc get _api => _chopperClient.getService<Apigrpc>();

@override
Future<model.Session> authenticateEmail({
required String email,
Expand All @@ -100,7 +94,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.nakamaAuthenticateEmail(
final res = await _api.v2AccountAuthenticateEmailPost(
body: ApiAccountEmail(
email: email,
password: password,
Expand Down Expand Up @@ -130,11 +124,8 @@ class NakamaRestApiClient extends NakamaBaseClient {
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.nakamaAuthenticateDevice(
body: ApiAccountDevice(
id: deviceId,
vars: vars,
),
final res = await _api.v2AccountAuthenticateDevicePost(
body: ApiAccountDevice(id: deviceId, vars: vars),
create: create,
username: username,
);
Expand All @@ -160,7 +151,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
Map<String, String>? vars,
bool import = false,
}) async {
final res = await _api.nakamaAuthenticateFacebook(
final res = await _api.v2AccountAuthenticateFacebookPost(
body: ApiAccountFacebook(
token: token,
vars: vars,
Expand Down Expand Up @@ -190,7 +181,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.nakamaAuthenticateGoogle(
final res = await _api.v2AccountAuthenticateGooglePost(
body: ApiAccountGoogle(
token: token,
vars: vars,
Expand Down Expand Up @@ -224,7 +215,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.nakamaAuthenticateGameCenter(
final res = await _api.v2AccountAuthenticateGamecenterPost(
body: ApiAccountGameCenter(
playerId: playerId,
bundleId: bundleId,
Expand Down Expand Up @@ -258,7 +249,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.nakamaAuthenticateSteam(
final res = await _api.v2AccountAuthenticateSteamPost(
body: ApiAccountSteam(token: token, vars: vars),
create: create,
username: username,
Expand All @@ -284,7 +275,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
String? username,
Map<String, String>? vars,
}) async {
final res = await _api.nakamaAuthenticateCustom(
final res = await _api.v2AccountAuthenticateCustomPost(
body: ApiAccountCustom(id: id, vars: vars),
create: create,
username: username,
Expand All @@ -306,7 +297,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
@override
Future<Account> getAccount(model.Session session) async {
_session = session;
final res = await _api.nakamaGetAccount();
final res = await _api.v2AccountGet();

final acc = Account();
// Some workaround here while protobuf expects the vars map to not be null
Expand All @@ -333,7 +324,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
}) async {
_session = session;

await _api.nakamaUpdateAccount(
await _api.v2AccountPut(
body: ApiUpdateAccountRequest(
username: username,
displayName: displayName,
Expand All @@ -351,7 +342,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
List<String>? usernames,
}) async {
_session = session;
final res = await _api.nakamaGetUsers(
final res = await _api.v2UserGet(
facebookIds: facebookIds,
ids: ids,
usernames: usernames,
Expand All @@ -372,7 +363,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
}) {
_session = session;

return _api.nakamaWriteStorageObjects(
return _api.v2StoragePut(
body: ApiWriteStorageObjectsRequest(
objects: [
ApiWriteStorageObject(
Expand All @@ -397,7 +388,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
}) async {
_session = session;

final res = await _api.nakamaReadStorageObjects(
final res = await _api.v2StoragePost(
body: ApiReadStorageObjectsRequest(
objectIds: [
ApiReadStorageObjectId(
Expand All @@ -424,7 +415,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
assert(limit > 0 && limit <= 100);

_session = session;
final res = await _api.nakamaListChannelMessages(
final res = await _api.v2ChannelChannelIdGet(
channelId: channelId,
limit: limit,
forward: forward,
Expand All @@ -447,7 +438,7 @@ class NakamaRestApiClient extends NakamaBaseClient {

_session = session;

final res = await _api.nakamaListLeaderboardRecords(
final res = await _api.v2LeaderboardLeaderboardIdGet(
leaderboardId: leaderboardName,
ownerIds: ownerIds,
limit: limit,
Expand All @@ -470,7 +461,7 @@ class NakamaRestApiClient extends NakamaBaseClient {
}) async {
_session = session;

final res = await _api.nakamaWriteLeaderboardRecord(
final res = await _api.v2LeaderboardLeaderboardIdPost(
leaderboardId: leaderboardId,
body: WriteLeaderboardRecordRequestLeaderboardRecordWrite(
score: score?.toString(),
Expand Down
70 changes: 28 additions & 42 deletions lib/src/rest/apigrpc.enums.swagger.dart
Original file line number Diff line number Diff line change
@@ -1,61 +1,47 @@
import 'package:json_annotation/json_annotation.dart';

enum ValidatedPurchaseEnvironment {
enum ApiOperator {
@JsonValue('swaggerGeneratedUnknown')
swaggerGeneratedUnknown,
@JsonValue('UNKNOWN')
unknown,
@JsonValue('SANDBOX')
sandbox,
@JsonValue('PRODUCTION')
production
noOverride,
best,
$set,
increment,
decrement
}

const $ValidatedPurchaseEnvironmentMap = {
ValidatedPurchaseEnvironment.unknown: 'UNKNOWN',
ValidatedPurchaseEnvironment.sandbox: 'SANDBOX',
ValidatedPurchaseEnvironment.production: 'PRODUCTION',
ValidatedPurchaseEnvironment.swaggerGeneratedUnknown: ''
const $ApiOperatorMap = {
ApiOperator.noOverride: 'NO_OVERRIDE',
ApiOperator.best: 'BEST',
ApiOperator.$set: 'SET',
ApiOperator.increment: 'INCREMENT',
ApiOperator.decrement: 'DECREMENT'
};

enum ValidatedPurchaseStore {
enum ApiStoreEnvironment {
@JsonValue('swaggerGeneratedUnknown')
swaggerGeneratedUnknown,
@JsonValue('APPLE_APP_STORE')
appleAppStore,
@JsonValue('GOOGLE_PLAY_STORE')
googlePlayStore,
@JsonValue('HUAWEI_APP_GALLERY')
huaweiAppGallery
unknown,
sandbox,
production
}

const $ValidatedPurchaseStoreMap = {
ValidatedPurchaseStore.appleAppStore: 'APPLE_APP_STORE',
ValidatedPurchaseStore.googlePlayStore: 'GOOGLE_PLAY_STORE',
ValidatedPurchaseStore.huaweiAppGallery: 'HUAWEI_APP_GALLERY',
ValidatedPurchaseStore.swaggerGeneratedUnknown: ''
const $ApiStoreEnvironmentMap = {
ApiStoreEnvironment.unknown: 'UNKNOWN',
ApiStoreEnvironment.sandbox: 'SANDBOX',
ApiStoreEnvironment.production: 'PRODUCTION'
};

enum ApiOverrideOperator {
enum ApiStoreProvider {
@JsonValue('swaggerGeneratedUnknown')
swaggerGeneratedUnknown,
@JsonValue('NO_OVERRIDE')
noOverride,
@JsonValue('BEST')
best,
@JsonValue('SET')
$set,
@JsonValue('INCREMENT')
increment,
@JsonValue('DECREMENT')
decrement
appleAppStore,
googlePlayStore,
huaweiAppGallery
}

const $ApiOverrideOperatorMap = {
ApiOverrideOperator.noOverride: 'NO_OVERRIDE',
ApiOverrideOperator.best: 'BEST',
ApiOverrideOperator.$set: 'SET',
ApiOverrideOperator.increment: 'INCREMENT',
ApiOverrideOperator.decrement: 'DECREMENT',
ApiOverrideOperator.swaggerGeneratedUnknown: ''
const $ApiStoreProviderMap = {
ApiStoreProvider.appleAppStore: 'APPLE_APP_STORE',
ApiStoreProvider.googlePlayStore: 'GOOGLE_PLAY_STORE',
ApiStoreProvider.huaweiAppGallery: 'HUAWEI_APP_GALLERY'
};
Loading

0 comments on commit e3736fc

Please sign in to comment.