Skip to content

Commit

Permalink
Extract direct channels info from server response.
Browse files Browse the repository at this point in the history
  • Loading branch information
marioosh committed Jun 24, 2015
1 parent 2cdac6d commit 128d9c7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/main/scala/io/scalac/slack/api/ResponseObject.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
package io.scalac.slack.api

import io.scalac.slack.models.{Channel, SlackUser}
import io.scalac.slack.models.{Channel, DirectChannel, SlackUser}

/**
* Created on 21.01.15 22:28
*/
sealed trait ResponseObject

case class ApiTestResponse(ok: Boolean, error: Option[String], args: Option[Map[String, String]]) extends ResponseObject

case class AuthTestResponse(ok: Boolean, error: Option[String], url: Option[String], team: Option[String], user: Option[String], team_id: Option[String], user_id: Option[String]) extends ResponseObject

case class RtmStartResponse(ok: Boolean, url: String, users: List[SlackUser], channels: List[Channel], self: BotInfo) extends ResponseObject
case class RtmStartResponse(ok: Boolean, url: String, users: List[SlackUser], channels: List[Channel], self: BotInfo, ims: List[DirectChannel]) extends ResponseObject

object ResponseObject {
implicit def authTestResponseToAuthData(atr: AuthTestResponse): AuthData =
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/io/scalac/slack/api/Unmarshallers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ object Unmarshallers extends DefaultJsonProtocol {
implicit val channelFormat = jsonFormat(Channel, "name", "creator", "is_member", "is_channel", "id", "is_general", "is_archived", "created", "purpose", "topic", "unread_count", "last_read", "members")
implicit val userFormat = jsonFormat(SlackUser, "id", "name", "deleted", "is_admin", "is_owner", "is_primary_owner", "is_restricted", "is_ultra_restricted", "has_files", "is_bot", "presence")
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")
implicit val rtmStartResponseFormat = jsonFormat(RtmStartResponse, "ok", "url", "users", "channels", "self", "ims")
implicit val chatPostMessageResponse = jsonFormat(ChatPostMessageResponse, "ok", "channel", "error")

}
1 change: 1 addition & 0 deletions src/test/scala/io/scalac/slack/UnmarshallerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,7 @@ class UnmarshallerTest extends FunSuite with Matchers {
rtmResponse.channels.size should equal(2)
rtmResponse.self.id should equal("U03DQKG14")
rtmResponse.self.name should equal("secretary")
rtmResponse.ims.size should equal(5)
}

test("long channel unmarshall") {
Expand Down

0 comments on commit 128d9c7

Please sign in to comment.