GifListPagination.swift 613 B

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