Skip to content
This repository was archived by the owner on Mar 31, 2023. It is now read-only.

Commit cf62265

Browse files
committed
api renaming
1 parent b50fd4f commit cf62265

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

src/main/scala/akkord/api/ChannelApi.scala

+12-13
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@ package akkord.api
22

33
import akka.actor.Props
44
import akka.http.scaladsl.marshalling.Marshal
5-
import akka.http.scaladsl.model
65
import akka.http.scaladsl.model._
76
import akka.pattern.pipe
87
import akka.stream.ActorMaterializer
9-
import akkord.api.HttpApiActor.ChannelRequest
8+
import akkord.api.DiscordApi.ChannelRequest
109
import de.heikoseeberger.akkahttpcirce.FailFastCirceSupport
1110
import io.circe.Encoder
1211

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 {
1413
import ChannelApi._
1514

1615
override def pipeHttpApiRequest: Receive = {
@@ -19,8 +18,8 @@ class ChannelApi(token: String)(implicit mat: ActorMaterializer) extends HttpApi
1918
}
2019

2120
private def pipeChannelRequest(bundle: ChannelRequestBundle): Unit = {
22-
Marshal(bundle.channelEntity)
23-
.to[model.MessageEntity]
21+
Marshal(bundle.payload)
22+
.to[MessageEntity]
2423
.map { reqEntity =>
2524
val req = HttpRequest(bundle.method, bundle.uri, reqHeaders, reqEntity)
2625
ChannelRequest(bundle.channelId, req)
@@ -30,30 +29,30 @@ class ChannelApi(token: String)(implicit mat: ActorMaterializer) extends HttpApi
3029

3130
private def tellChannelRequestBundle(channelId: String, content: String): Unit = {
3231
val (method, uri) = createMessageEndpoint(channelId)
33-
val channelEntity = MessageEntity(content)
32+
val channelEntity = MessagePayload(content)
3433
self ! ChannelRequestBundle(channelId, method, uri, channelEntity)
3534
}
3635
}
3736

3837
object ChannelApi {
39-
import HttpApiActor._
38+
import DiscordApi._
4039

4140
case class Message(channelId: String, content: String)
4241

43-
sealed trait ChannelEntity
44-
case class MessageEntity(content: String) extends ChannelEntity
42+
sealed trait ChannelPayload
43+
case class MessagePayload(content: String) extends ChannelPayload
4544

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)
4746

4847
def props(token:String)(implicit mat: ActorMaterializer): Props =
4948
Props(classOf[ChannelApi], token, mat)
5049

51-
implicit val encodeChannelEntity: Encoder[ChannelEntity] =
52-
(channelEntity: ChannelEntity) => {
50+
implicit val encodeChannelEntity: Encoder[ChannelPayload] =
51+
(channelEntity: ChannelPayload) => {
5352
import io.circe.generic.auto._
5453
import io.circe.syntax._
5554
channelEntity match {
56-
case entity: ChannelApi.MessageEntity => entity.asJson
55+
case entity: ChannelApi.MessagePayload => entity.asJson
5756
}
5857
}
5958

src/main/scala/akkord/api/HttpApiActor.scala renamed to src/main/scala/akkord/api/DiscordApi.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import akka.stream.ActorMaterializer
99

1010
import scala.collection.{immutable, mutable}
1111

12-
abstract class HttpApiActor(token: String)(implicit mat: ActorMaterializer) extends Actor {
13-
import HttpApiActor._
12+
abstract class DiscordApi(token: String)(implicit mat: ActorMaterializer) extends Actor {
13+
import DiscordApi._
1414

1515
implicit protected val ec = context.system.dispatcher
1616
implicit val system = context.system
@@ -69,7 +69,7 @@ abstract class HttpApiActor(token: String)(implicit mat: ActorMaterializer) exte
6969
def pipeHttpApiRequest: Receive
7070
}
7171

72-
object HttpApiActor {
72+
object DiscordApi {
7373
trait HttpApiRequest { val request: HttpRequest }
7474
case class ChannelRequest(channelId: String, request: HttpRequest) extends HttpApiRequest
7575
case class Response(majorEndpoint: String, response: HttpResponse)

0 commit comments

Comments
 (0)