aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/spraytest/ClientTest.scala
blob: 07532d0af830e31cc265947f0f18f30db706e750 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package spraytest

import akka.actor.ActorSystem
import spray.client.pipelining._
import spray.httpx.SprayJsonSupport
import spray.json._
import scala.concurrent.Future
import spray.can.Http
import akka.io.IO

/**
 *    BEGIN JSON Infrastructure
 */
case class Container(data: List[PointOfInterest])
case class Geolocation(latitude: Float, longitude: Float)
case class PointOfInterest(ma: Option[String], a: Option[String], c: String, s: Option[String], geolocation: Geolocation)

object GeoJsonProtocol extends DefaultJsonProtocol {
  implicit val geolocationFormat = jsonFormat2(Geolocation)
  implicit val pointOfInterestFormat = jsonFormat5(PointOfInterest)
  implicit val containerFormat = jsonFormat1(Container)
}
/**   END-OF JSON Infrastructure */






class ClientTest extends App {
  implicit val actorSystem = ActorSystem("spray-client-test")
  import actorSystem.dispatcher


  import GeoJsonProtocol._
  import SprayJsonSupport._


  val actor = IO(Http)

  val pipeline =  sendReceive ~> unmarshal[Container]

  val response = pipeline {
    Get("http://geo.despegar.com/geo-services-web/service/Autocomplete/DESAR/1/0/0/10/0/0/Obelisco")
  } onSuccess {
    case a => {
      println(a)
    }
  }
}