listReferralTransactions method

Future<Response<BuiltList<ReferralTransaction>>> listReferralTransactions({
  1. BuiltList<String>? sort,
  2. BuiltList<String>? currency,
  3. BuiltList<ReferralTransactionType>? type,
  4. DateTime? createdAtAfter,
  5. DateTime? createdAtBefore,
  6. int? perPage,
  7. int? page,
  8. CancelToken? cancelToken,
  9. Map<String, dynamic>? headers,
  10. Map<String, dynamic>? extra,
  11. ValidateStatus? validateStatus,
  12. ProgressCallback? onSendProgress,
  13. ProgressCallback? onReceiveProgress,
})

Get referral transactions

Parameters:

  • sort - Sort by provided field
  • currency - Filter by currency
  • type - Transaction type
  • createdAtAfter
  • createdAtBefore
  • perPage
  • page
  • cancelToken - A CancelToken that can be used to cancel the operation
  • headers - Can be used to add additional headers to the request
  • extras - Can be used to add flags to the request
  • validateStatus - A ValidateStatus callback that can be used to determine request success based on the HTTP status of the response
  • onSendProgress - A ProgressCallback that can be used to get the send progress
  • onReceiveProgress - A ProgressCallback that can be used to get the receive progress

Returns a Future containing a Response with a BuiltList<ReferralTransaction> as data Throws DioError if API call or serialization fails

Implementation

Future<Response<BuiltList<ReferralTransaction>>> listReferralTransactions({
  BuiltList<String>? sort,
  BuiltList<String>? currency,
  BuiltList<ReferralTransactionType>? type,
  DateTime? createdAtAfter,
  DateTime? createdAtBefore,
  int? perPage,
  int? page,
  CancelToken? cancelToken,
  Map<String, dynamic>? headers,
  Map<String, dynamic>? extra,
  ValidateStatus? validateStatus,
  ProgressCallback? onSendProgress,
  ProgressCallback? onReceiveProgress,
}) async {
  final _path = r'/referral/transactions/';
  final _options = Options(
    method: r'GET',
    headers: <String, dynamic>{
      ...?headers,
    },
    extra: <String, dynamic>{
      'secure': <Map<String, String>>[
        {
          'type': 'http',
          'scheme': 'bearer',
          'name': 'bearerAuth',
        },
      ],
      ...?extra,
    },
    validateStatus: validateStatus,
  );

  final _queryParameters = <String, dynamic>{
    if (sort != null) r'sort': encodeCollectionQueryParameter<String>(_serializers, sort, const FullType(BuiltList, [FullType(String)]), format: ListFormat.csv,),
    if (currency != null) r'currency': encodeCollectionQueryParameter<String>(_serializers, currency, const FullType(BuiltList, [FullType(String)]), format: ListFormat.csv,),
    if (type != null) r'type': encodeCollectionQueryParameter<ReferralTransactionType>(_serializers, type, const FullType(BuiltList, [FullType(ReferralTransactionType)]), format: ListFormat.multi,),
    if (createdAtAfter != null) r'created_at_after': encodeQueryParameter(_serializers, createdAtAfter, const FullType(DateTime)),
    if (createdAtBefore != null) r'created_at_before': encodeQueryParameter(_serializers, createdAtBefore, const FullType(DateTime)),
    if (perPage != null) r'per_page': encodeQueryParameter(_serializers, perPage, const FullType(int)),
    if (page != null) r'page': encodeQueryParameter(_serializers, page, const FullType(int)),
  };

  final _response = await _dio.request<Object>(
    _path,
    options: _options,
    queryParameters: _queryParameters,
    cancelToken: cancelToken,
    onSendProgress: onSendProgress,
    onReceiveProgress: onReceiveProgress,
  );

  BuiltList<ReferralTransaction>? _responseData;

  try {
    final rawResponse = _response.data;
    _responseData = rawResponse == null ? null : _serializers.deserialize(
      rawResponse,
      specifiedType: const FullType(BuiltList, [FullType(ReferralTransaction)]),
    ) as BuiltList<ReferralTransaction>;

  } catch (error, stackTrace) {
    throw DioError(
      requestOptions: _response.requestOptions,
      response: _response,
      type: DioErrorType.unknown,
      error: error,
      stackTrace: stackTrace,
    );
  }

  return Response<BuiltList<ReferralTransaction>>(
    data: _responseData,
    headers: _response.headers,
    isRedirect: _response.isRedirect,
    requestOptions: _response.requestOptions,
    redirects: _response.redirects,
    statusCode: _response.statusCode,
    statusMessage: _response.statusMessage,
    extra: _response.extra,
  );
}