@@ -2,15 +2,14 @@ package akkord.api
2
2
3
3
import akka .actor .Props
4
4
import akka .http .scaladsl .marshalling .Marshal
5
- import akka .http .scaladsl .model
6
5
import akka .http .scaladsl .model ._
7
6
import akka .pattern .pipe
8
7
import akka .stream .ActorMaterializer
9
- import akkord .api .HttpApiActor .ChannelRequest
8
+ import akkord .api .DiscordApi .ChannelRequest
10
9
import de .heikoseeberger .akkahttpcirce .FailFastCirceSupport
11
10
import io .circe .Encoder
12
11
13
- class ChannelApi (token : String )(implicit mat : ActorMaterializer ) extends HttpApiActor (token) with FailFastCirceSupport {
12
+ class ChannelApi (token : String )(implicit mat : ActorMaterializer ) extends DiscordApi (token) with FailFastCirceSupport {
14
13
import ChannelApi ._
15
14
16
15
override def pipeHttpApiRequest : Receive = {
@@ -19,8 +18,8 @@ class ChannelApi(token: String)(implicit mat: ActorMaterializer) extends HttpApi
19
18
}
20
19
21
20
private def pipeChannelRequest (bundle : ChannelRequestBundle ): Unit = {
22
- Marshal (bundle.channelEntity )
23
- .to[model. MessageEntity ]
21
+ Marshal (bundle.payload )
22
+ .to[MessageEntity ]
24
23
.map { reqEntity =>
25
24
val req = HttpRequest (bundle.method, bundle.uri, reqHeaders, reqEntity)
26
25
ChannelRequest (bundle.channelId, req)
@@ -30,30 +29,30 @@ class ChannelApi(token: String)(implicit mat: ActorMaterializer) extends HttpApi
30
29
31
30
private def tellChannelRequestBundle (channelId : String , content : String ): Unit = {
32
31
val (method, uri) = createMessageEndpoint(channelId)
33
- val channelEntity = MessageEntity (content)
32
+ val channelEntity = MessagePayload (content)
34
33
self ! ChannelRequestBundle (channelId, method, uri, channelEntity)
35
34
}
36
35
}
37
36
38
37
object ChannelApi {
39
- import HttpApiActor ._
38
+ import DiscordApi ._
40
39
41
40
case class Message (channelId : String , content : String )
42
41
43
- sealed trait ChannelEntity
44
- case class MessageEntity (content : String ) extends ChannelEntity
42
+ sealed trait ChannelPayload
43
+ case class MessagePayload (content : String ) extends ChannelPayload
45
44
46
- private case class ChannelRequestBundle (channelId : String , method : HttpMethod , uri : String , channelEntity : ChannelEntity )
45
+ private case class ChannelRequestBundle (channelId : String , method : HttpMethod , uri : String , payload : ChannelPayload )
47
46
48
47
def props (token: String )(implicit mat : ActorMaterializer ): Props =
49
48
Props (classOf [ChannelApi ], token, mat)
50
49
51
- implicit val encodeChannelEntity : Encoder [ChannelEntity ] =
52
- (channelEntity : ChannelEntity ) => {
50
+ implicit val encodeChannelEntity : Encoder [ChannelPayload ] =
51
+ (channelEntity : ChannelPayload ) => {
53
52
import io .circe .generic .auto ._
54
53
import io .circe .syntax ._
55
54
channelEntity match {
56
- case entity : ChannelApi .MessageEntity => entity.asJson
55
+ case entity : ChannelApi .MessagePayload => entity.asJson
57
56
}
58
57
}
59
58
0 commit comments