Skip to content

Commit

Permalink
paginated: Open up the position, data, info and paginated structs
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonycastelli committed Jun 19, 2018
1 parent 753c15e commit be3a121
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Sources/Pagination/Paginated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,43 @@ public struct Position: Content {
public var next: Int?
public var previous: Int?
public var max: Int

public init(current: Int, next: Int? = nil, previous: Int? = nil, max: Int) {
self.current = current
self.next = next
self.previous = previous
self.max = max
}
}

public struct PageData: Content {
public var per: Int
public var total: Int

public init(per: Int, total: Int) {
self.per = per
self.total = total
}
}

public struct PageInfo: Content {
public var position: Position
public var data: PageData

public init(position: Position, data: PageData) {
self.position = position
self.data = data
}
}

public struct Paginated<M: Content>: Content {
public var page: PageInfo
public var data: [M]

public init(page: PageInfo, data: [M]) {
self.page = page
self.data = data
}
}

extension Page where M: Content {
Expand Down

0 comments on commit be3a121

Please sign in to comment.