-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for pagination and query parameters
- Loading branch information
Showing
5 changed files
with
91 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// By downloading or using this software made available by MagicBell, Inc. | ||
// ("MagicBell") or any documentation that accompanies it (collectively, the | ||
// "Software"), you and the company or entity that you represent (collectively, | ||
// "you" or "your") are consenting to be bound by and are becoming a party to this | ||
// License Agreement (this "Agreement"). You hereby represent and warrant that you | ||
// are authorized and lawfully able to bind such company or entity that you | ||
// represent to this Agreement. If you do not have such authority or do not agree | ||
// to all of the terms of this Agreement, you may not download or use the Software. | ||
// | ||
// For more information, read the LICENSE file. | ||
// | ||
|
||
import Foundation | ||
|
||
extension StorePredicate { | ||
var asQueryItems: [URLQueryItem] { | ||
var queryItems: [URLQueryItem] = [] | ||
|
||
["read": read, | ||
"seen": seen, | ||
"archived": archived].forEach { (key: String, value: Bool?) in | ||
if let value = value { | ||
queryItems.append(URLQueryItem(name: key, value: value.description)) | ||
} | ||
} | ||
|
||
for category in categories { | ||
queryItems.append(URLQueryItem(name: "category", value: category)) | ||
} | ||
for topic in topics { | ||
queryItems.append(URLQueryItem(name: "topic", value: topic)) | ||
} | ||
|
||
return queryItems | ||
} | ||
} | ||
|
||
|
||
extension StorePagePredicate { | ||
var asQueryItems: [URLQueryItem] { | ||
var queryItems: [URLQueryItem] = [] | ||
|
||
["page": page, | ||
"per_page": size].forEach { (key: String, value: Int?) in | ||
if let value = value { | ||
queryItems.append(URLQueryItem(name: key, value: value.description)) | ||
} | ||
} | ||
|
||
return queryItems | ||
} | ||
} | ||
|
||
|
||
extension StoreContext { | ||
var asQueryItems: [URLQueryItem] { | ||
var queryItems: [URLQueryItem] = [] | ||
|
||
queryItems.append(contentsOf: self.store.asQueryItems) | ||
queryItems.append(contentsOf: self.page.asQueryItems) | ||
|
||
return queryItems | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
Source/Features/Store/Data/StoreGraphQLRepresentableExtensions.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters