Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(code_push_client): remove createPaymentLink #1345

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions packages/shorebird_code_push_client/lib/src/code_push_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -175,21 +175,6 @@ class CodePushClient {
}
}

/// Generates a Stripe payment link for the current user.
Future<Uri> createPaymentLink() async {
final response = await _httpClient.post(
Uri.parse('$_v1/subscriptions/payment_link'),
);

if (response.statusCode != HttpStatus.ok) {
throw _parseErrorResponse(response.statusCode, response.body);
}

return CreatePaymentLinkResponse.fromJson(
json.decode(response.body) as Json,
).paymentLink;
}

/// Create a new artifact for a specific [releaseId].
Future<void> createReleaseArtifact({
required String artifactPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,59 +437,6 @@ void main() {
});
});

group('createPaymentLink', () {
test('makes the correct request', () async {
codePushClient.createPaymentLink().ignore();
final request = verify(() => httpClient.send(captureAny()))
.captured
.single as http.BaseRequest;
expect(request.method, equals('POST'));
expect(request.url, equals(v1('subscriptions/payment_link')));
expect(request.hasStandardHeaders, isTrue);
});

test('throws an exception if the http request fails', () {
when(() => httpClient.send(any())).thenAnswer((_) async {
return http.StreamedResponse(
const Stream.empty(),
HttpStatus.badRequest,
);
});

expect(
codePushClient.createPaymentLink(),
throwsA(
isA<CodePushException>().having(
(e) => e.message,
'message',
CodePushClient.unknownErrorMessage,
),
),
);
});

test('returns a payment link if the http request succeeds', () {
final link = Uri.parse('http://test.com');
when(() => httpClient.send(any())).thenAnswer((_) async {
return http.StreamedResponse(
Stream.value(
utf8.encode(
json.encode(
CreatePaymentLinkResponse(paymentLink: link).toJson(),
),
),
),
HttpStatus.ok,
);
});

expect(
codePushClient.createPaymentLink(),
completion(link),
);
});
});

group('createReleaseArtifact', () {
const appId = 'test-app-id';
const releaseId = 0;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export 'create_channel/create_channel.dart';
export 'create_patch/create_patch.dart';
export 'create_patch_artifact/create_patch_artifact.dart';
export 'create_patch_event/create_patch_event.dart';
export 'create_payment_link/create_payment_link.dart';
export 'create_release/create_release.dart';
export 'create_release_artifact/create_release_artifact.dart';
export 'create_user/create_user.dart';
Expand Down

This file was deleted.