Last active
February 17, 2021 07:09
-
-
Save ivancorrales/23452e3460d6fee1b1060d8e92a4d8f7 to your computer and use it in GitHub Desktop.
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
vars { | |
mediaJson = "application/json" | |
} | |
func signUp { | |
input { | |
arg baseApi { | |
description = "URL base of the API" | |
} | |
arg user { | |
description = "entity with attributes fullName, username & password" | |
} | |
} | |
body { | |
http post { | |
request { | |
baseUrl = baseApi | |
path = "/account" | |
headers { | |
Content-Type = mediaJson | |
} | |
payload json { | |
data = user | |
} | |
} | |
response { | |
httpResponse = { | |
statusCode = _.http.statusCode | |
body = json(_.http.body) | |
} | |
} | |
} | |
} | |
return { | |
value = httpResponse | |
} | |
} | |
func signIn { | |
input { | |
arg baseApi { | |
description = "URL base of the API" | |
} | |
arg credentials { | |
description = "entity with attributes username & password" | |
} | |
} | |
body { | |
http post { | |
request { | |
baseUrl = baseApi | |
path = "/session" | |
headers { | |
Content-Type = mediaJson | |
} | |
payload json { | |
data = credentials | |
} | |
} | |
response { | |
httpResponse = { | |
statusCode = _.http.statusCode | |
body = json(_.http.body) | |
} | |
} | |
} | |
} | |
return { | |
value = httpResponse | |
} | |
} | |
func showProfile { | |
input { | |
arg baseApi { | |
description = "URL base of the API" | |
} | |
arg token { | |
description = "a valid JWT" | |
} | |
} | |
body { | |
http get { | |
request { | |
baseUrl = baseApi | |
path = "/me" | |
headers { | |
x-access-token = token | |
} | |
} | |
response { | |
httpResponse = { | |
statusCode = _.http.statusCode | |
body = json(_.http.body) | |
} | |
} | |
} | |
} | |
return { | |
value = httpResponse | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment