Skip to content

Commit

Permalink
DirectChannel Model
Browse files Browse the repository at this point in the history
- DirectChannel case class
- unmarshaller
- unmarshaller test
  • Loading branch information
marioosh committed Jun 24, 2015
1 parent 513cf4c commit 2cdac6d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/main/scala/io/scalac/slack/api/ApiActor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import spray.json._

import scala.util.{Failure, Success}

/**
* marioosh
*/
class ApiActor extends Actor with ActorLogging {

import context.dispatcher
Expand Down
3 changes: 1 addition & 2 deletions src/main/scala/io/scalac/slack/api/Message.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package io.scalac.slack.api

/**
* Created on 20.01.15 23:59
* Messages sends between actors
* Messages sended between actors
*/
sealed trait Message

Expand Down
5 changes: 2 additions & 3 deletions src/main/scala/io/scalac/slack/api/Unmarshallers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import io.scalac.slack.models._
import org.joda.time.DateTime
import spray.json._

/**
* Created on 28.01.15 23:06
*/
object Unmarshallers extends DefaultJsonProtocol {

implicit object DateTimeJsonFormat extends JsonFormat[DateTime] {
Expand Down Expand Up @@ -52,4 +49,6 @@ object Unmarshallers extends DefaultJsonProtocol {
implicit val botInfoFormat = jsonFormat(BotInfo, "id", "name")
implicit val rtmStartResponseFormat = jsonFormat(RtmStartResponse, "ok", "url", "users", "channels", "self")
implicit val chatPostMessageResponse = jsonFormat(ChatPostMessageResponse, "ok", "channel", "error")
implicit val imFormat = jsonFormat(DirectChannel, "id", "user")

}
7 changes: 7 additions & 0 deletions src/main/scala/io/scalac/slack/models/DirectChannel.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.scalac.slack.models

/**
* Direct channel object between bot and user
* Object holds user's ID along with channel's ID
*/
case class DirectChannel(id: String, userId: String)
21 changes: 20 additions & 1 deletion src/test/scala/io/scalac/slack/UnmarshallerTest.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.scalac.slack

import io.scalac.slack.api.{ApiTestResponse, AuthTestResponse, RtmStartResponse}
import io.scalac.slack.models.{Away, Channel, ChannelInfo, SlackUser}
import io.scalac.slack.models._
import org.joda.time.DateTime
import org.scalatest.{FunSuite, Matchers}
import spray.json._
Expand Down Expand Up @@ -699,4 +699,23 @@ class UnmarshallerTest extends FunSuite with Matchers {
user.hasFiles should equal(Some(false))
user.presence should equal(Away)
}

test("IM object") {
/*language=JSON*/
val imString = """{
| "last_read": "0000000000.000000",
| "is_open": true,
| "id": "D03DQKG1C",
| "unread_count": 0,
| "is_im": true,
| "latest": null,
| "user": "U03DN1GTQ",
| "created": 1421786647
| }""".stripMargin

val im = imString.parseJson.convertTo[DirectChannel]
im.id should equal("D03DQKG1C")
im.userId should equal("U03DN1GTQ")
}

}

0 comments on commit 2cdac6d

Please sign in to comment.