friends method

Future<Friends> friends({
  1. int? offset,
  2. int? limit,
  3. FriendOrder? friendOrder,
  4. Order? order,
  5. FriendsContext? context,
})

KO: 카카오톡 친구 목록 가져오기
offset으로 친구 목록 시작 지점 변경
limit로 페이지당 결과 수 변경
friendOrder로 정렬 방식 변경
order로 정렬 방식 변경
context로 친구 목록 조회 설정

EN: Retrieve list of friends
Change the start point of the friend list with offset
Change the number of results in a page with limit
Change the method to sort the friend list with friendOrder
Change the sorting method with order
Set Context for retrieving friend list with context

Implementation

Future<Friends> friends({
  int? offset,
  int? limit,
  FriendOrder? friendOrder,
  Order? order,
  FriendsContext? context,
}) async {
  return ApiFactory.handleApiError(() async {
    final params = {
      Constants.offset: context != null ? context.offset : offset,
      Constants.limit: context != null ? context.limit : limit,
      Constants.friendOrder: context != null && context.friendOrder != null
          ? context.friendOrder!.name
          : (friendOrder?.name),
      Constants.order: context != null && context.order != null
          ? context.order!.name
          : (order?.name),
      Constants.secureResource: true
    };
    params.removeWhere((k, v) => v == null);
    final response =
        await _dio.get(Constants.v1FriendsPath, queryParameters: params);
    return Friends.fromJson(response.data);
  });
}