class RestImpl {

    void getRoomFiles(String roomId,
                      BaseRoom.RoomType roomType,
                      int offset,
                      Attachment.SortBy sortBy,
                      Sort sort,
                      final PaginatedCallback<Attachment> callback) {
        checkNotNull(roomId, "roomId == null");
        checkNotNull(roomType, "roomType == null");
        checkNotNull(sortBy, "sortBy == null");
        checkNotNull(sort, "sort == null");
        checkNotNull(callback, "callback == null");

        HttpUrl httpUrl = requestUrl(baseUrl, getRestApiMethodNameByRoomType(roomType, "files"))
                .addQueryParameter("roomId", roomId)
                .addQueryParameter("offset", String.valueOf(offset))
                .addQueryParameter("sort", "{\"" + sortBy.getPropertyName() + "\":" + sort.getDirection() + "}")
                .build();

        Request request = requestBuilder(httpUrl)
                .get()
                .build();

        client.newCall(request).enqueue(new okhttp3.Callback() {
            @Override
            public void onFailure(Call call, IOException e) {
                callback.onError(new RocketChatNetworkErrorException("network error", e));
            }

            @Override
            public void onResponse(Call call, Response response) throws IOException {
                if (!response.isSuccessful()) {
                    processCallbackError(response, ERROR_HANDLER(callback));
                    return;
                }

                try {
                    JSONObject json = new JSONObject(response.body().string());
                    logger.info("Response = " + json.toString());

                    JSONArray filesJSONArray = json.getJSONArray("files");
                    int length = filesJSONArray.length();
                    List<Attachment> attachments = new ArrayList<>(length);
                    for (int i = 0; i < length; ++i) {
                        attachments.add(new Attachment(filesJSONArray.getJSONObject(i), baseUrl.url().toString()));
                    }

                    callback.onSuccess(attachments, json.optInt("total"));
                } catch (JSONException e) {
                    callback.onError(new RocketChatInvalidResponseException(e.getMessage(), e));
                }
            }
        });

    }

      RestImpl(OkHttpClient client, Moshi moshi, HttpUrl baseUrl, TokenProvider tokenProvider, Logger logger);

}