Skip to content

Commit

Permalink
reverse client member name
Browse files Browse the repository at this point in the history
  • Loading branch information
hayribakici committed Jul 6, 2024
1 parent 7d6a272 commit d4c85a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
26 changes: 13 additions & 13 deletions lib/src/spotify_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ abstract class SpotifyApiBase {

bool _shouldWait = false;

late SpotifyClient _client;
SpotifyClient get client => _client;

late SpotifyClient _spotifyClient;
SpotifyClient get spotifyClient => _spotifyClient;
@visibleForTesting
FutureOr<oauth2.Client> get oauthClient => _client._inner;
FutureOr<oauth2.Client> get client async => _spotifyClient._inner;

late Artists _artists;
Artists get artists => _artists;
Expand Down Expand Up @@ -66,7 +66,7 @@ abstract class SpotifyApiBase {
Shows get shows => _shows;

SpotifyApiBase.fromClient(FutureOr<oauth2.Client> client) {
_client = SpotifyClient(client);
_spotifyClient = SpotifyClient(client);

_artists = Artists(this);
_albums = Albums(this);
Expand Down Expand Up @@ -185,8 +185,8 @@ abstract class SpotifyApiBase {
/// to [LoggingDetail.simple].
void enableDebugMode(bool enable,
[LoggingDetail loggingDetail = LoggingDetail.simple]) {
_client.enableLogging = enable;
_client.logginDetail = loggingDetail;
_spotifyClient.enableLogging = enable;
_spotifyClient.logginDetail = loggingDetail;
}

/// Expands shortened spotify [url]
Expand Down Expand Up @@ -214,19 +214,19 @@ abstract class SpotifyApiBase {
return await _requestWrapper(() async {
final request = http.Request('HEAD', Uri.parse(url));
request.headers.addAll(headers);
return _client.send(request);
return _spotifyClient.send(request);
});
}

Future<String> _getImpl(String url, Map<String, String> headers) async {
return await _requestWrapper(
() async => await _client.get(Uri.parse(url), headers: headers));
() async => await _spotifyClient.get(Uri.parse(url), headers: headers));
}

Future<String> _postImpl(
String url, Map<String, String> headers, dynamic body) async {
return await _requestWrapper(() async =>
await _client.post(Uri.parse(url), headers: headers, body: body));
await _spotifyClient.post(Uri.parse(url), headers: headers, body: body));
}

Future<String> _deleteImpl(
Expand All @@ -235,14 +235,14 @@ abstract class SpotifyApiBase {
final request = http.Request('DELETE', Uri.parse(url));
request.headers.addAll(headers);
request.body = body;
return await http.Response.fromStream(await _client.send(request));
return await http.Response.fromStream(await _spotifyClient.send(request));
});
}

Future<String> _putImpl(
String url, Map<String, String> headers, dynamic body) async {
return await _requestWrapper(() async =>
await _client.put(Uri.parse(url), headers: headers, body: body));
await _spotifyClient.put(Uri.parse(url), headers: headers, body: body));
}

// the reason we are using [http.BaseResponse] is because
Expand Down Expand Up @@ -278,7 +278,7 @@ abstract class SpotifyApiBase {
}

Future<SpotifyApiCredentials> getCredentials() async {
return SpotifyApiCredentials._fromClient(await _client._inner);
return SpotifyApiCredentials._fromClient(await client);
}

String handleResponseWithBody(http.Response response) {
Expand Down
4 changes: 2 additions & 2 deletions test/spotify_mock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class SpotifyApiMock extends SpotifyApiBase {
: super.fromClient(MockClient(credentials));

set mockHttpErrors(Iterator<MockHttpError> errors) =>
(oauthClient as MockClient)._mockHttpErrors = errors;
(client as MockClient)._mockHttpErrors = errors;

set interceptor(
Function(String method, String url, Map<String, String>? headers,
[String? body])?
interceptor) =>
(oauthClient as MockClient).interceptFunction = interceptor;
(client as MockClient).interceptFunction = interceptor;
}

class MockClient implements oauth2.Client {
Expand Down

0 comments on commit d4c85a2

Please sign in to comment.