-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from mmvpm/connect_telegram_bot_with_backend
Connect telegram bot with backend (#12)
- Loading branch information
Showing
24 changed files
with
467 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
ofs { | ||
base-url = "http://localhost:8080" | ||
request-timeout = 20s | ||
request-timeout = 5s | ||
} |
10 changes: 8 additions & 2 deletions
10
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/OfsClient.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
package com.github.mmvpm.bot.client.ofs | ||
|
||
import cats.data.EitherT | ||
import com.github.mmvpm.model.{OfferDescription, Session} | ||
import com.github.mmvpm.bot.client.ofs.error.OfsClientError | ||
import com.github.mmvpm.bot.client.ofs.response.{CreateOfferResponse, SignInResponse, SignUpResponse, UserIdResponse} | ||
import com.github.mmvpm.bot.client.ofs.response._ | ||
import com.github.mmvpm.bot.model.{Draft, OfferPatch} | ||
import com.github.mmvpm.model.{OfferDescription, OfferID, Session} | ||
|
||
trait OfsClient[F[_]] { | ||
|
||
def signUp(name: String, login: String, password: String): EitherT[F, OfsClientError, SignUpResponse] | ||
def signIn(login: String, password: String): EitherT[F, OfsClientError, SignInResponse] | ||
def whoami(session: Session): EitherT[F, OfsClientError, UserIdResponse] | ||
|
||
def getOffer(offerId: OfferID): EitherT[F, OfsClientError, OfferResponse] | ||
def getOffers(offerIds: Seq[OfferID]): EitherT[F, OfsClientError, OffersResponse] | ||
def getMyOffers(session: Session): EitherT[F, OfsClientError, OffersResponse] | ||
def createOffer(session: Session, description: OfferDescription): EitherT[F, OfsClientError, CreateOfferResponse] | ||
def updateOffer(session: Session, offerId: OfferID, patch: OfferPatch): EitherT[F, OfsClientError, OfferResponse] | ||
def deleteOffer(session: Session, offerId: OfferID): EitherT[F, OfsClientError, OkResponse] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/request/GetOffersRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.github.mmvpm.bot.client.ofs.request | ||
|
||
import com.github.mmvpm.model.OfferID | ||
|
||
case class GetOffersRequest(offerIds: List[OfferID]) |
9 changes: 9 additions & 0 deletions
9
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/request/UpdateOfferRequest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.mmvpm.bot.client.ofs.request | ||
|
||
import com.github.mmvpm.model.Money | ||
|
||
case class UpdateOfferRequest( | ||
name: Option[String] = None, | ||
price: Option[Money] = None, | ||
description: Option[String] = None | ||
) |
5 changes: 5 additions & 0 deletions
5
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/response/OfferResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.github.mmvpm.bot.client.ofs.response | ||
|
||
import com.github.mmvpm.model.Offer | ||
|
||
case class OfferResponse(offer: Offer) |
5 changes: 5 additions & 0 deletions
5
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/response/OffersResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.github.mmvpm.bot.client.ofs.response | ||
|
||
import com.github.mmvpm.model.Offer | ||
|
||
case class OffersResponse(offers: List[Offer]) |
3 changes: 3 additions & 0 deletions
3
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/response/OkResponse.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package com.github.mmvpm.bot.client.ofs.response | ||
|
||
case class OkResponse() |
34 changes: 34 additions & 0 deletions
34
bot/src/main/scala/com/github/mmvpm/bot/client/ofs/util/CirceInstances.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.mmvpm.bot.client.ofs.util | ||
|
||
import com.github.mmvpm.model.OfferStatus.OfferStatus | ||
import com.github.mmvpm.model.UserStatus.UserStatus | ||
import com.github.mmvpm.model._ | ||
import io.circe._ | ||
import io.circe.generic.semiauto._ | ||
|
||
import java.util.UUID | ||
|
||
case object CirceInstances { | ||
|
||
// common | ||
|
||
implicit val decoderUUID: Decoder[UUID] = Decoder[String].map(UUID.fromString) | ||
implicit val encoderUUID: Encoder[UUID] = Encoder[String].contramap(_.toString) | ||
|
||
// model | ||
|
||
implicit val decoderUserStatus: Decoder[UserStatus] = Decoder.decodeEnumeration(UserStatus) | ||
implicit val encoderUserStatus: Encoder[UserStatus] = Encoder.encodeEnumeration(UserStatus) | ||
|
||
implicit val decoderUser: Decoder[User] = deriveDecoder | ||
implicit val encoderUser: Encoder[User] = deriveEncoder | ||
|
||
implicit val decoderOfferStatus: Decoder[OfferStatus] = Decoder.decodeEnumeration(OfferStatus) | ||
implicit val encoderOfferStatus: Encoder[OfferStatus] = Encoder.encodeEnumeration(OfferStatus) | ||
|
||
implicit val decoderOfferDescription: Decoder[OfferDescription] = deriveDecoder | ||
implicit val encoderOfferDescription: Encoder[OfferDescription] = deriveEncoder | ||
|
||
implicit val decoderOffer: Decoder[Offer] = deriveDecoder | ||
implicit val encoderOffer: Encoder[Offer] = deriveEncoder | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.