photos method

Request<List<Photo>> photos(
  1. String username, {
  2. int? page,
  3. int? perPage,
  4. PhotoOrder? orderBy,
  5. bool? stats,
  6. StatisticsResolution? resolution,
  7. PhotoOrientation? orientation,
  8. int? quantity,
})

List a user’s photos

Get a list of photos uploaded by a user.

See: Unsplash docs

Implementation

Request<List<Photo>> photos(
  String username, {
  int? page,
  int? perPage,
  PhotoOrder? orderBy,
  bool? stats,
  StatisticsResolution? resolution,
  PhotoOrientation? orientation,
  int? quantity,
}) {
  assert(page == null || page >= 0);
  assert(perPage == null ||
      perPage >= 0 && perPage <= client.settings.maxPageSize);
  assert(quantity == null || quantity >= 0);

  final params = queryParams({
    'page': page,
    'per_page': perPage,
    'order_by': orderBy?.let(enumName),
    'stats': stats,
    'resolution': resolution?.let(enumName),
    'orientation': orientation?.let(enumName),
    'quantity': quantity,
  });

  final url =
      baseUrl.resolve('$username/photos').replace(queryParameters: params);

  return Request(
    client: client,
    httpRequest: http.Request('GET', url),
    isPublicAction: true,
    bodyDeserializer: (dynamic json) =>
        deserializeObjectList(json, (json) => Photo.fromJson(json)),
  );
}