-
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.
http service request refactoring & fix detekt analyze report
- Loading branch information
1 parent
6c4cb14
commit 402cc8c
Showing
24 changed files
with
82 additions
and
57 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
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
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
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
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 |
---|---|---|
|
@@ -36,4 +36,4 @@ class HttpProtocol( | |
|
||
const val TLS_PROTOCOL = "TLSv1.2" | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,4 @@ data class ProtocolResponse( | |
val ok: Boolean, | ||
val result: RequestStatus? = null, | ||
val error: String = "" | ||
) | ||
) |
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
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/dev/voroby/telegram/gateway/common/service/Http.kt
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,11 @@ | ||
package dev.voroby.telegram.gateway.common.service | ||
|
||
object Http { | ||
|
||
data class Request<Payload>( | ||
val body: Payload, | ||
val serviceName: String, | ||
val accessToken: String, | ||
val host: String? | ||
) | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,4 +11,4 @@ object CheckSendAbility { | |
val gatewayHost: String? = null, | ||
val payload: Request | ||
) | ||
} | ||
} |
11 changes: 7 additions & 4 deletions
11
...in/kotlin/dev/voroby/telegram/gateway/service/checkSendAbility/CheckSendAbilityService.kt
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,18 +1,21 @@ | ||
package dev.voroby.telegram.gateway.service.checkSendAbility | ||
|
||
import dev.voroby.telegram.gateway.common.service.HttpService | ||
import dev.voroby.telegram.gateway.common.service.Http | ||
import dev.voroby.telegram.gateway.common.service.Service | ||
import dev.voroby.telegram.gateway.service.ServiceName.CHECK_SEND_ABILITY | ||
import dev.voroby.telegram.gateway.service.checkSendAbility.CheckSendAbility.ExtendedRequest | ||
|
||
class CheckSendAbilityService(private val httpService: HttpService) : Service<ExtendedRequest> { | ||
class CheckSendAbilityService( | ||
private val httpService: Service<Http.Request<*>> | ||
) : Service<ExtendedRequest> { | ||
|
||
override suspend fun invoke(request: ExtendedRequest) = with(request) { | ||
httpService.execute( | ||
val httpRequest = Http.Request( | ||
body = payload, | ||
serviceName = CHECK_SEND_ABILITY, | ||
accessToken = accessToken, | ||
host = gatewayHost | ||
) | ||
httpService.invoke(httpRequest) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -17,4 +17,4 @@ object CheckVerificationStatus { | |
val gatewayHost: String? = null, | ||
val payload: Request | ||
) | ||
} | ||
} |
11 changes: 7 additions & 4 deletions
11
...voroby/telegram/gateway/service/checkVerificationStatus/CheckVerificationStatusService.kt
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,18 +1,21 @@ | ||
package dev.voroby.telegram.gateway.service.checkVerificationStatus | ||
|
||
import dev.voroby.telegram.gateway.common.service.HttpService | ||
import dev.voroby.telegram.gateway.common.service.Http | ||
import dev.voroby.telegram.gateway.common.service.Service | ||
import dev.voroby.telegram.gateway.service.ServiceName.CHECK_VERIFICATION_STATUS | ||
import dev.voroby.telegram.gateway.service.checkVerificationStatus.CheckVerificationStatus.ExtendedRequest | ||
|
||
class CheckVerificationStatusService(private val httpService: HttpService) : Service<ExtendedRequest> { | ||
class CheckVerificationStatusService( | ||
private val httpService: Service<Http.Request<*>> | ||
) : Service<ExtendedRequest> { | ||
|
||
override suspend fun invoke(request: ExtendedRequest) = with(request) { | ||
httpService.execute( | ||
val httpRequest = Http.Request( | ||
body = payload, | ||
serviceName = CHECK_VERIFICATION_STATUS, | ||
accessToken = accessToken, | ||
host = gatewayHost | ||
) | ||
httpService.invoke(httpRequest) | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -28,4 +28,4 @@ object SendVerificationMessage { | |
val gatewayHost: String? = null, | ||
val payload: Request | ||
) | ||
} | ||
} |
11 changes: 7 additions & 4 deletions
11
...voroby/telegram/gateway/service/sendVerificationMessage/SendVerificationMessageService.kt
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,18 +1,21 @@ | ||
package dev.voroby.telegram.gateway.service.sendVerificationMessage | ||
|
||
import dev.voroby.telegram.gateway.common.service.HttpService | ||
import dev.voroby.telegram.gateway.common.service.Http | ||
import dev.voroby.telegram.gateway.common.service.Service | ||
import dev.voroby.telegram.gateway.service.ServiceName.SEND_VERIFICATION_MESSAGE | ||
import dev.voroby.telegram.gateway.service.sendVerificationMessage.SendVerificationMessage.ExtendedRequest | ||
|
||
class SendVerificationMessageService(private val httpService: HttpService) : Service<ExtendedRequest> { | ||
class SendVerificationMessageService( | ||
private val httpService: Service<Http.Request<*>> | ||
) : Service<ExtendedRequest> { | ||
|
||
override suspend fun invoke(request: ExtendedRequest) = with(request) { | ||
httpService.execute( | ||
val httpRequest = Http.Request( | ||
body = payload, | ||
serviceName = SEND_VERIFICATION_MESSAGE, | ||
accessToken = accessToken, | ||
host = gatewayHost | ||
) | ||
httpService.invoke(httpRequest) | ||
} | ||
} | ||
} |
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,9 +1,6 @@ | ||
package dev.voroby.telegram.gateway.util | ||
|
||
class Http { | ||
object Http { | ||
|
||
companion object { | ||
|
||
const val DEFAULT_GATEWAY_HOST = "gatewayapi.telegram.org" | ||
} | ||
} | ||
const val DEFAULT_GATEWAY_HOST = "gatewayapi.telegram.org" | ||
} |
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