Skip to content

Commit

Permalink
Migrate user agent to new format (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElPicador committed Aug 3, 2016
1 parent 619767e commit 063302f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 063302f

Please sign in to comment.