GifListPagination.swift 690 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // GifListPagination.swift
  3. // LiveLikeGiphyChallenge
  4. //
  5. // Created by Ljupco Nastevski on 30.1.22.
  6. //
  7. import Foundation
  8. struct GifListPagination: Codable {
  9. let offset: Int
  10. let totalCount: Int
  11. let count: Int
  12. var nextOffset: Int {
  13. return offset + count
  14. }
  15. var canLoadMore: Bool {
  16. return offset == 0 || self.count == Constants.GiphyPaginationLimit
  17. }
  18. init() {
  19. offset = 0
  20. totalCount = 0
  21. count = 0
  22. }
  23. }
  24. extension GifListPagination {
  25. enum CodingKeys: String, CodingKey {
  26. case offset = "offset"
  27. case totalCount = "total_count"
  28. case count = "count"
  29. }
  30. }