-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #33 from phiHero/feat/presets
Add presets and stopwords endpoints
- Loading branch information
Showing
25 changed files
with
976 additions
and
127 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 |
---|---|---|
@@ -1,38 +1,54 @@ | ||
import Foundation | ||
|
||
public struct Client { | ||
|
||
var configuration: Configuration | ||
var apiCall: ApiCall | ||
public var collections: Collections | ||
|
||
public init(config: Configuration) { | ||
self.configuration = config | ||
self.apiCall = ApiCall(config: config) | ||
self.collections = Collections(config: config) | ||
} | ||
|
||
public func collection(name: String) -> Collection { | ||
return Collection(config: self.configuration, collectionName: name) | ||
} | ||
|
||
public func keys() -> ApiKeys { | ||
return ApiKeys(config: self.configuration) | ||
} | ||
|
||
public func aliases() -> Alias { | ||
return Alias(config: self.configuration) | ||
} | ||
|
||
public func operations() -> Operations { | ||
return Operations(config: self.configuration) | ||
} | ||
|
||
public func multiSearch() -> MultiSearch { | ||
return MultiSearch(config: self.configuration) | ||
} | ||
|
||
public func analytics() -> Analytics { | ||
return Analytics(config: self.configuration) | ||
} | ||
|
||
public func presets() -> Presets { | ||
return Presets(apiCall: apiCall) | ||
} | ||
|
||
public func preset(_ presetName: String) -> Preset { | ||
return Preset(apiCall: apiCall, presetName: presetName) | ||
} | ||
|
||
public func stopwords() -> Stopwords { | ||
return Stopwords(apiCall: apiCall) | ||
} | ||
|
||
public func stopword(_ stopwordsSetId: String) -> Stopword { | ||
return Stopword(apiCall: apiCall, stopwordsSetId: stopwordsSetId) | ||
} | ||
} |
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,21 @@ | ||
// | ||
// PresetDeleteSchema.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
|
||
public struct PresetDeleteSchema: Codable { | ||
|
||
public var name: String | ||
|
||
public init(name: String) { | ||
self.name = name | ||
} | ||
|
||
|
||
} |
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,15 @@ | ||
import Foundation | ||
|
||
|
||
|
||
public struct PresetSchema: Codable { | ||
public var name: String | ||
public var value: PresetValue | ||
|
||
public init(name: String, value: PresetValue) { | ||
self.name = name | ||
self.value = value | ||
} | ||
|
||
|
||
} |
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,14 @@ | ||
import Foundation | ||
|
||
|
||
|
||
public struct PresetUpsertSchema: Codable { | ||
|
||
public var value: PresetValue | ||
|
||
public init(value: PresetValue) { | ||
self.value = value | ||
} | ||
|
||
|
||
} |
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,28 @@ | ||
public enum PresetValue: Codable { | ||
case multiSearch(MultiSearchSearchesParameter) | ||
case singleCollectionSearch(SearchParameters) | ||
|
||
public init (from decoder: Decoder) throws { | ||
if let multiSearch = try? MultiSearchSearchesParameter(from: decoder) { | ||
self = .multiSearch(multiSearch) | ||
} | ||
else if let singleCollectionSearch = try? SearchParameters(from: decoder) { | ||
self = .singleCollectionSearch(singleCollectionSearch) | ||
} else { | ||
throw DecodingError.dataCorrupted(DecodingError.Context( | ||
codingPath: decoder.codingPath, | ||
debugDescription: "Unable to decode value for preset `value`" | ||
) | ||
) | ||
} | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
switch self { | ||
case .multiSearch(let multiSearch): | ||
try multiSearch.encode(to: encoder) | ||
case .singleCollectionSearch(let singleCollectionSearch): | ||
try singleCollectionSearch.encode(to: encoder) | ||
} | ||
} | ||
} |
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,14 @@ | ||
import Foundation | ||
|
||
|
||
|
||
public struct PresetsRetrieveSchema: Codable { | ||
|
||
public var presets: [PresetSchema] | ||
|
||
public init(presets: [PresetSchema]) { | ||
self.presets = presets | ||
} | ||
|
||
|
||
} |
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,16 @@ | ||
import Foundation | ||
|
||
|
||
|
||
public struct StopwordsSetDeleteSchema: Codable { | ||
public var _id: String | ||
|
||
public init(_id: String) { | ||
self._id = _id | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey { | ||
case _id = "id" | ||
} | ||
|
||
} |
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,21 @@ | ||
// | ||
// StopwordsSetRetrieveSchema.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
|
||
public struct StopwordsSetRetrieveSchema: Codable { | ||
|
||
public var stopwords: StopwordsSetSchema | ||
|
||
public init(stopwords: StopwordsSetSchema) { | ||
self.stopwords = stopwords | ||
} | ||
|
||
|
||
} |
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,30 @@ | ||
// | ||
// StopwordsSetSchema.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
|
||
public struct StopwordsSetSchema: Codable { | ||
|
||
public var _id: String | ||
public var stopwords: [String] | ||
public var locale: String? | ||
|
||
public init(_id: String, stopwords: [String], locale: String? = nil) { | ||
self._id = _id | ||
self.stopwords = stopwords | ||
self.locale = locale | ||
} | ||
|
||
public enum CodingKeys: String, CodingKey { | ||
case _id = "id" | ||
case stopwords | ||
case locale | ||
} | ||
|
||
} |
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,23 @@ | ||
// | ||
// StopwordsSetUpsertSchema.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
|
||
public struct StopwordsSetUpsertSchema: Codable { | ||
|
||
public var stopwords: [String] | ||
public var locale: String? | ||
|
||
public init(stopwords: [String], locale: String? = nil) { | ||
self.stopwords = stopwords | ||
self.locale = locale | ||
} | ||
|
||
|
||
} |
21 changes: 21 additions & 0 deletions
21
Sources/Typesense/Models/StopwordsSetsRetrieveAllSchema.swift
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,21 @@ | ||
// | ||
// StopwordsSetsRetrieveAllSchema.swift | ||
// | ||
// Generated by swagger-codegen | ||
// https://github.com/swagger-api/swagger-codegen | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
|
||
public struct StopwordsSetsRetrieveAllSchema: Codable { | ||
|
||
public var stopwords: [StopwordsSetSchema] | ||
|
||
public init(stopwords: [StopwordsSetSchema]) { | ||
self.stopwords = stopwords | ||
} | ||
|
||
|
||
} |
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
Oops, something went wrong.