-
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.
- Loading branch information
Showing
5 changed files
with
117 additions
and
10 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
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,47 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Joao Pedro Monteiro Maia on 22/05/24. | ||
// | ||
|
||
import Foundation | ||
|
||
//TODO: Add docs, this represents a query for a model | ||
public struct ModelQuery{ | ||
var query:String? | ||
var pageNumber:Int = 0 | ||
var pageSize:Int = 40 | ||
var functions:[String] | ||
|
||
public init(query: String? = nil, pageNumber: Int = 0, pageSize: Int = 40, functions: [String]) { | ||
self.query = query | ||
self.pageNumber = pageNumber | ||
self.pageSize = pageSize | ||
self.functions = functions | ||
} | ||
|
||
|
||
|
||
|
||
public func buildQuery() throws ->Data{ | ||
var body:[String:Decodable] = ["pageNumber": pageNumber, "pageSize": pageSize] | ||
|
||
if !functions.isEmpty{ | ||
body["functions"] = functions | ||
} | ||
|
||
if let q = query{ | ||
body["q"] = q | ||
} | ||
|
||
|
||
guard let jsonData = try? JSONSerialization.data(withJSONObject: body, options: []) else { | ||
throw PipelineError.inputEncodingError //TODO: Implement proper error | ||
} | ||
|
||
return jsonData | ||
} | ||
|
||
|
||
} |
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