-
Notifications
You must be signed in to change notification settings - Fork 14
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
24 changed files
with
164 additions
and
162 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.../algolia/search/configuration/CallType.kt → ....algolia.client/configuration/CallType.kt
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
7 changes: 3 additions & 4 deletions
7
...lia/search/configuration/Configuration.kt → ...lia.client/configuration/Configuration.kt
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
6 changes: 3 additions & 3 deletions
6
...golia/search/configuration/Credentials.kt → ...golia.client/configuration/Credentials.kt
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
2 changes: 1 addition & 1 deletion
2
.../com/algolia/search/configuration/Host.kt → .../com.algolia.client/configuration/Host.kt
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
2 changes: 1 addition & 1 deletion
2
...algolia/search/configuration/UserAgent.kt → ...algolia.client/configuration/UserAgent.kt
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
2 changes: 1 addition & 1 deletion
2
...ia/search/exception/EmptyListException.kt → ...ia.client/exception/EmptyListException.kt
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
2 changes: 1 addition & 1 deletion
2
.../search/exception/EmptyStringException.kt → ....client/exception/EmptyStringException.kt
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
24 changes: 24 additions & 0 deletions
24
...nt-kotlin/client/src/commonMain/kotlin/com.algolia.client/exception/internal/Throwable.kt
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,24 @@ | ||
package com.algolia.client.exception.internal | ||
|
||
import com.algolia.client.exception.AlgoliaApiException | ||
import com.algolia.client.exception.AlgoliaClientException | ||
import com.algolia.client.exception.AlgoliaRuntimeException | ||
import io.ktor.client.plugins.ResponseException | ||
|
||
/** | ||
* Coerce a Throwable to a [AlgoliaClientException]. | ||
*/ | ||
internal fun Throwable.asClientException(): com.algolia.client.exception.AlgoliaClientException { | ||
return com.algolia.client.exception.AlgoliaClientException(message = message, cause = this) | ||
} | ||
|
||
/** | ||
* Coerce a [ResponseException] to a [AlgoliaRuntimeException]. | ||
*/ | ||
internal fun ResponseException.asApiException(): com.algolia.client.exception.AlgoliaApiException { | ||
return com.algolia.client.exception.AlgoliaApiException( | ||
message = message, | ||
cause = this, | ||
httpErrorCode = response.status.value | ||
) | ||
} |
2 changes: 1 addition & 1 deletion
2
...in/com/algolia/search/logging/LogLevel.kt → ...in/com.algolia.client/logging/LogLevel.kt
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,4 +1,4 @@ | ||
package com.algolia.search.logging | ||
package com.algolia.client.logging | ||
|
||
/** | ||
* Http client logging log level. | ||
|
4 changes: 2 additions & 2 deletions
4
...tlin/com/algolia/search/logging/Logger.kt → ...tlin/com.algolia.client/logging/Logger.kt
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
4 changes: 2 additions & 2 deletions
4
...g/internal/MessageLengthLimitingLogger.kt → ...g/internal/MessageLengthLimitingLogger.kt
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
4 changes: 2 additions & 2 deletions
4
...kotlin/com/algolia/search/model/APIKey.kt → ...kotlin/com.algolia.client/model/APIKey.kt
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
4 changes: 2 additions & 2 deletions
4
...com/algolia/search/model/ApplicationID.kt → ...com.algolia.client/model/ApplicationID.kt
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
55 changes: 55 additions & 0 deletions
55
...lient-kotlin/client/src/commonMain/kotlin/com.algolia.client/transport/CustomRequester.kt
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,55 @@ | ||
package com.algolia.client.transport | ||
|
||
import com.algolia.client.configuration.CallType | ||
import io.ktor.http.* | ||
import io.ktor.util.reflect.* | ||
|
||
public interface CustomRequester { | ||
|
||
/** | ||
* Perform a custom request. | ||
* | ||
* @param method represents an HTTP method | ||
* @param callType indicate whether the HTTP call performed is of type Read (GET) or Write (POST, PUT..) | ||
* @param path request path | ||
* @param requestOptions configure request locally | ||
* @param body request body | ||
* @param responseType return value type | ||
* | ||
* @return request's response; type [T] must be serializable | ||
*/ | ||
public suspend fun <T> customRequest( | ||
method: HttpMethod, | ||
callType: CallType, | ||
path: String, | ||
responseType: TypeInfo, | ||
body: String? = null, | ||
requestOptions: RequestOptions? = null, | ||
): T | ||
} | ||
|
||
/** | ||
* Perform a custom request. | ||
* | ||
* @param method represents an HTTP method | ||
* @param callType indicate whether the HTTP call performed is of type Read (GET) or Write (POST, PUT..) | ||
* @param path request path | ||
* @param requestOptions configure request locally | ||
* @param body request body | ||
* | ||
* @return request's response; type [T] must be serializable | ||
*/ | ||
public suspend inline fun <reified T> CustomRequester.customRequest( | ||
method: HttpMethod, | ||
callType: CallType, | ||
path: String, | ||
body: String? = null, | ||
requestOptions: RequestOptions? = null, | ||
): T = customRequest( | ||
method = method, | ||
callType = callType, | ||
path = path, | ||
requestOptions = requestOptions, | ||
body = body, | ||
responseType = typeInfo<T>() | ||
) |
2 changes: 1 addition & 1 deletion
2
...lgolia/search/transport/RequestOptions.kt → ...lgolia.client/transport/RequestOptions.kt
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
15 changes: 15 additions & 0 deletions
15
...-client-kotlin/client/src/commonMain/kotlin/com.algolia.client/transport/internal/Host.kt
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 @@ | ||
package com.algolia.client.transport.internal | ||
|
||
import com.algolia.client.configuration.CallType | ||
import com.algolia.client.configuration.Host | ||
import com.algolia.client.model.ApplicationID | ||
|
||
internal val ApplicationID.searchHosts | ||
get() = listOf( | ||
Host("$this-dsn.algolia.net", CallType.Read), | ||
Host("$this.algolia.net", CallType.Write), | ||
) + mutableListOf( | ||
Host("$this-1.algolianet.com"), | ||
Host("$this-2.algolianet.com"), | ||
Host("$this-3.algolianet.com") | ||
).apply { shuffle() } |
8 changes: 4 additions & 4 deletions
8
.../transport/internal/HttpRequestBuilder.kt → .../transport/internal/HttpRequestBuilder.kt
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
6 changes: 3 additions & 3 deletions
6
...earch/transport/internal/RetryableHost.kt → ...lient/transport/internal/RetryableHost.kt
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
2 changes: 1 addition & 1 deletion
2
...algolia/search/transport/internal/Time.kt → ...algolia.client/transport/internal/Time.kt
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
Oops, something went wrong.