get method

Future<ApiResponseModel<ChallengeModel?>> get({
  1. required String id,
  2. required String companyId,
})

Gets details of a specific challenge.

id is the ID of the challenge. companyId is the company ID. Returns the ChallengeModel instance with full details.

Implementation

Future<ApiResponseModel<ChallengeModel?>> get({
  required String id,
  required String companyId,
}) async {
  final url = "$_baseUrl/challenges/$id";

  final payload = {
    'apiKey': _apiKey,
    'companyId': companyId,
  };

  debugPrint("flutter_mon_sms_pro/challenges/get/payload: $payload");

  final r = await _dio.post(url, data: payload);

  debugPrint("flutter_mon_sms_pro/challenges/get/data: ${r.data}");

  final response = ApiResponseModel.fromJson(
    r.data,
    (data) => ChallengeModel.fromJson(data as Map<String, dynamic>),
  );

  return response;
}