Advertisement
i_trunker

Untitled

Jan 23rd, 2022
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.75 KB | None | 0 0
  1. class ApiClient {
  2.  
  3.     fun makeRequest(
  4.         path: String,
  5.         token: String = "",
  6.         body: String = "",
  7.         code: Int,
  8.         time: Long = 2000L,
  9.         a: RequestSpecification.() -> Response
  10.     ): ProfileModel.Model {
  11.         val responseData = Given {
  12.             contentType(ContentType.JSON)
  13.             contentType("application/json")
  14.             header("access-token", token)
  15.             body(body)
  16.         } When {
  17.             get(path)
  18.         } Then {
  19.             statusCode(code)
  20.             time(lessThan(time))
  21.         } Extract {
  22.             to<ProfileModel.Model>()
  23.         }
  24.         return responseData
  25.     }
  26.  
  27.     fun a() {
  28.         makeRequest("", "", "", 0, 200) {
  29.             get()
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement