Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate user agent to new format #143

Merged
merged 1 commit into from
Aug 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/scala/algolia/AlgoliaClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ import scala.concurrent.{ExecutionContext, Future}
class AlgoliaClient(applicationId: String, apiKey: String, customHeader: Map[String, String] = Map.empty) {

if (applicationId == null || applicationId.isEmpty) {
throw new AlgoliaClientException(s"'applicationId' is probably too short: '$applicationId'")
throw AlgoliaClientException(s"'applicationId' is probably too short: '$applicationId'")
}

if (apiKey == null || apiKey.isEmpty) {
throw new AlgoliaClientException(s"'apiKey' is probably too short: '$apiKey'")
throw AlgoliaClientException(s"'apiKey' is probably too short: '$apiKey'")
}

final private val ALGOLIANET_COM_HOST = "algolianet.com"
Expand All @@ -74,7 +74,7 @@ class AlgoliaClient(applicationId: String, apiKey: String, customHeader: Map[Str

val httpClient: AlgoliaHttpClient = AlgoliaHttpClient()
val random: AlgoliaRandom = AlgoliaRandom
val userAgent = s"Algolia for Scala ${BuildInfo.scalaVersion} API ${BuildInfo.version}"
val userAgent = s"Algolia for Scala (${BuildInfo.version}); JVM (${System.getProperty("java.version")}); Scala (${BuildInfo.scalaVersion})"

val headers: Map[String, String] = customHeader ++ Map(
"Accept-Encoding" -> "gzip",
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/algolia/AlgoliaClientTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class AlgoliaClientTest extends AlgoliaTest {
}

it("should set user agent") {
apiClient.userAgent should (startWith("Algolia for Scala 2.11") and include("API 1."))
apiClient.userAgent should (startWith("Algolia for Scala (1.") and include("; JVM (1.8") and include ("; Scala (2.11"))
}

it("should set Content-Type header") {
Expand Down