paylike_dart_request 1.0.10 paylike_dart_request: ^1.0.10 copied to clipboard
Low level API client for Paylike which helps executing requests in a similiar way as in the JS version
example/paylike_dart_request_example.dart
import 'package:paylike_dart_request/paylike_dart_request.dart';
Future<void> fetchBodyAsStream(
PaylikeRequester requester, RequestOptions opts) async {
var response = await requester.request('http://foo', opts);
var reader = await response.getBodyReader();
await reader.forEach((element) {
print(element);
});
}
void main() {
var requester = PaylikeRequester().setLog((dynamic o) => print(o));
var opts = RequestOptions.fromClientId('dart-1')
.setQuery({
'foo': 'bar',
})
.setVersion(1)
.setData({
'foo': 'bar',
});
requester.request('http://foo', opts).then((response) {
return response.getBody();
}).then((body) {
print(body);
}).catchError((error) {
print(error);
});
fetchBodyAsStream(requester, opts).catchError((error) {
print(error);
});
}