Advertisement
i_trunker

Untitled

Jan 23rd, 2022
1,093
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ApiClient {
  2.  
  3.     fun makeRequest(
  4.         path: String,
  5.         token: String = "",
  6.         body: String = "",
  7.         code: Int,
  8.         time: Long = 2000L,
  9.         newGet: 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.             newGet()
  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
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement