mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2025-12-21 13:23:05 +01:00
Fixed user agent and slight refactoring
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
dependencies {
|
||||
compile project(':common')
|
||||
|
||||
compile group: "org.scalaj", name: "scalaj-http_2.12", version: "2.3.0"
|
||||
compile group: "org.scalaj", name: "scalaj-http_2.12", version: "2.4.1"
|
||||
compile group: "org.json4s", name: "json4s-jackson_2.12", version: "3.6.0-M3"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,11 @@
|
||||
package com.lbs.api
|
||||
|
||||
import com.lbs.api.http.headers._
|
||||
import scalaj.http.{Http, HttpRequest}
|
||||
import scalaj.http.{BaseHttp, HttpRequest}
|
||||
|
||||
object ApiHttp extends BaseHttp(
|
||||
userAgent = "PatientPortal/3.10.0 (pl.luxmed.pp.LUX-MED; build:401; iOS 12.1.0) Alamofire/4.5.1"
|
||||
)
|
||||
|
||||
trait ApiBase {
|
||||
private val CommonHeaders =
|
||||
@@ -11,12 +15,11 @@ trait ApiBase {
|
||||
Accept -> "*/*",
|
||||
Connection -> "keep-alive",
|
||||
`Accept-Encoding` -> "gzip;q=1.0, compress;q=0.5",
|
||||
`User-Agent` -> "PatientPortal/3.10.0 (pl.luxmed.pp.LUX-MED; build:401; iOS 12.1.0) Alamofire/4.5.1",
|
||||
`Accept-Language` -> "en-PL;q=1.0, ru-PL;q=0.9, pl-PL;q=0.8, uk-PL;q=0.7"
|
||||
)
|
||||
|
||||
|
||||
protected def http(url: String): HttpRequest = {
|
||||
Http(s"https://portalpacjenta.luxmed.pl/PatientPortalMobileAPI/api/$url").headers(CommonHeaders)
|
||||
ApiHttp(s"https://portalpacjenta.luxmed.pl/PatientPortalMobileAPI/api/$url").headers(CommonHeaders)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ class Book(val userId: UserId, bot: Bot, apiService: ApiService, dataService: Da
|
||||
case Left(ex) =>
|
||||
warn(s"Service [${bookingData.serviceId.name}] is already booked. Ask to update term", ex)
|
||||
bot.sendMessage(userId.source, lang.visitAlreadyExists,
|
||||
inlineKeyboard = createInlineKeyboard(Seq(Button(lang.yes, Tags.RebookYes), Button(lang.no, Tags.RebookNo))))
|
||||
inlineKeyboard = createInlineKeyboard(Seq(Button(lang.no, Tags.RebookNo), Button(lang.yes, Tags.RebookYes))))
|
||||
goto(awaitRebookDecision) using bookingData.copy(term = Some(term))
|
||||
case Right((temporaryReservation, valuations)) =>
|
||||
bot.sendMessage(userId.source, lang.confirmAppointment(term, valuations),
|
||||
@@ -233,7 +233,7 @@ class Book(val userId: UserId, bot: Bot, apiService: ApiService, dataService: Da
|
||||
private def askMonitoringRebookOption: Step =
|
||||
ask { _ =>
|
||||
bot.sendMessage(userId.source, lang.rebookIfExists,
|
||||
inlineKeyboard = createInlineKeyboard(Seq(Button(lang.yes, Tags.RebookYes), Button(lang.no, Tags.RebookNo))))
|
||||
inlineKeyboard = createInlineKeyboard(Seq(Button(lang.no, Tags.RebookNo), Button(lang.yes, Tags.RebookYes))))
|
||||
} onReply {
|
||||
case Msg(CallbackCommand(BooleanString(rebookIfExists)), bookingData: BookingData) =>
|
||||
goto(createMonitoring) using bookingData.copy(rebookIfExists = rebookIfExists)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
package com.lbs.server.exception
|
||||
|
||||
case class UserNotFoundException(chatId: Long) extends Exception(s"Luxmed username for char with id $chatId")
|
||||
case class UserNotFoundException(chatId: Long) extends Exception(s"Luxmed username for chat with id $chatId")
|
||||
|
||||
@@ -324,14 +324,6 @@ object En extends Lang {
|
||||
|
||||
override def bugHasBeenCreated(bugId: Long): String = s"✅ Thank you for submitting bug <b>#$bugId</b>!"
|
||||
|
||||
override def afterFive: String = "After 17:00"
|
||||
|
||||
override def nineToFive: String = "From 09:00 to 17:00"
|
||||
|
||||
override def beforeNine: String = "Before 09:00"
|
||||
|
||||
override def allDay: String = "All day"
|
||||
|
||||
override def deleteAccount: String = "➖ Delete account"
|
||||
|
||||
override def addAccount: String = "➕ Add account"
|
||||
|
||||
@@ -212,14 +212,6 @@ trait Lang {
|
||||
|
||||
def enterIssueDetails: String
|
||||
|
||||
def afterFive: String
|
||||
|
||||
def nineToFive: String
|
||||
|
||||
def beforeNine: String
|
||||
|
||||
def allDay: String
|
||||
|
||||
def deleteAccount: String
|
||||
|
||||
def addAccount: String
|
||||
|
||||
@@ -323,14 +323,6 @@ object Ua extends Lang {
|
||||
|
||||
override def bugHasBeenCreated(bugId: Long): String = s"✅ Дякуємо за відправлений баг <b>#$bugId</b>!"
|
||||
|
||||
override def afterFive: String = "Після 17:00"
|
||||
|
||||
override def nineToFive: String = "Від 09:00 до 17:00"
|
||||
|
||||
override def beforeNine: String = "До 09:00"
|
||||
|
||||
override def allDay: String = "Весь день"
|
||||
|
||||
override def deleteAccount: String = "➖ Видалити акаунт"
|
||||
|
||||
override def addAccount: String = "➕ Додати акаунт"
|
||||
|
||||
@@ -160,11 +160,4 @@ package object util {
|
||||
}
|
||||
}
|
||||
|
||||
implicit class RichEither[T](either: Either[Throwable, T]) {
|
||||
def toTry: Try[T] = either match {
|
||||
case Left(ex) => throw ex
|
||||
case Right(v) => Try(v)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user