Skip to content
HAT client library for Scala with Play framework
Scala
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
project
src
.gitignore
.travis.yml
CONTRIBUTING.md
DCO
LICENSE.md
README.md
build.sbt

README.md

Scala API wrappers for the HAT

Current Version: 2.6.6-SNAPSHOT

This repository provides convenience wrappers around HAT HTTP APIs and contains the most up-to-date set of typesafe HAT Data Models and Play-JSON based serializers and deserializers for them.

It relies on Play-WS for an asynchronous HTTP client.

Usage

The library artifacts are hosted on AWS S3:

resolvers += "HAT Library Artifacts Releases" at "https://s3-eu-west-1.amazonaws.com/library-artifacts-releases.hubofallthings.com"
// Or for SNAPSHOTS:
// "HAT Library Artifacts Snapshots" at "https://s3-eu-west-1.amazonaws.com/library-artifacts-snapshots.hubofallthings.com"
libraryDependencies ++= "org.hatdex" %% "hat-client-scala-play" % 2.6.5

To use the client, it is sufficient to create a new one with minimal configuration:

new HatClient(wsClient, hatAddress, schema)

Where:

  • wsClient is an instance of the WS Client, ideally dependency-injected in most cases - check Play documentation for details
  • hatAddress is the fully-qualified domain name of the HAT (e.g. example.hubofallthings.net)
  • schema is the schema of the address, can either be "http://" (only for development environments) or "https://" (the default if you omit the parameter)

The client is non-blocking and is built around standard Scala Futures. For example, to authenticate with a HAT and request data from it you would then run:

val hat = new HatClient(wsClient, hatAddress, schema)
for {
  accessToken <- hat.authenticateForToken(dataShopperUsername, dataShopperPassword)
  values <- hat.dataDebitValues(dataDebitId)
} yield values
You can’t perform that action at this time.