authorize method

Future<PayUAuthResponse> authorize(
  1. int? clientId,
  2. String? clientSecret
)

Implementation

Future<PayUAuthResponse> authorize(
    int? clientId, String? clientSecret) async {
  String data =
      'grant_type=client_credentials&client_id=$clientId&client_secret=$clientSecret';
  http.Response res = await http
      .post(Uri.parse('$baseUrl/pl/standard/user/oauth/authorize?$data'));
  if (res.statusCode != 200)
    throw Exception('http.post error: statusCode= ${res.statusCode}');
  Map<String, dynamic> json = jsonDecode(res.body);
  return PayUAuthResponse.fromJson(json);
}