pull/1/head
Bram van den Heuvel 2023-03-14 16:12:44 +01:00
parent 840b30e6f3
commit 8c473425f2
2 changed files with 18 additions and 4 deletions

View File

@ -1,13 +1,13 @@
module Internal.Api.LoginWithUsernameAndPassword.Main exposing (..) module Internal.Api.LoginWithUsernameAndPassword.Main exposing (..)
import Internal.Api.LoginWithUsernameAndPassword.Api as Api import Internal.Api.LoginWithUsernameAndPassword.Api as Api
import Internal.Tools.Context as Context exposing (Context, VBA) import Internal.Tools.Context as Context exposing (Context, VB)
import Internal.Tools.Exceptions as X import Internal.Tools.Exceptions as X
import Internal.Tools.VersionControl as VC import Internal.Tools.VersionControl as VC
import Task exposing (Task) import Task exposing (Task)
loginWithUsernameAndPassword : Context (VBA a) -> LoginWithUsernameAndPasswordInput -> Task X.Error LoginWithUsernameAndPasswordOutput loginWithUsernameAndPassword : Context (VB a) -> LoginWithUsernameAndPasswordInput -> Task X.Error LoginWithUsernameAndPasswordOutput
loginWithUsernameAndPassword context input = loginWithUsernameAndPassword context input =
VC.withBottomLayer VC.withBottomLayer
{ current = Api.loginWithUsernameAndPasswordV1 { current = Api.loginWithUsernameAndPasswordV1

View File

@ -119,11 +119,11 @@ getUrl : ApiCall a -> String
getUrl (ApiCall { baseUrl, attributes }) = getUrl (ApiCall { baseUrl, attributes }) =
UrlBuilder.crossOrigin UrlBuilder.crossOrigin
baseUrl baseUrl
(getPath attributes |> List.singleton) (getPath attributes)
(getQueryParams attributes) (getQueryParams attributes)
getPath : List ContextAttr -> String getPath : List ContextAttr -> List String
getPath = getPath =
List.foldl List.foldl
(\attr prior -> (\attr prior ->
@ -138,6 +138,19 @@ getPath =
prior prior
) )
"" ""
>> removeStartingSlashes
>> String.split "/"
removeStartingSlashes : String -> String
removeStartingSlashes url =
if String.startsWith "/" url then
url
|> String.dropLeft 1
|> removeStartingSlashes
else
url
getQueryParams : List ContextAttr -> List UrlBuilder.QueryParameter getQueryParams : List ContextAttr -> List UrlBuilder.QueryParameter
@ -177,6 +190,7 @@ withAttributes attrs (ApiCall data) =
accessToken : Attribute { a | accessToken : () } accessToken : Attribute { a | accessToken : () }
accessToken = accessToken =
Context.getAccessToken Context.getAccessToken
>> (++) "Bearer "
>> Http.header "Authorization" >> Http.header "Authorization"
>> Header >> Header