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 (..)
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.VersionControl as VC
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 =
VC.withBottomLayer
{ current = Api.loginWithUsernameAndPasswordV1

View File

@ -119,11 +119,11 @@ getUrl : ApiCall a -> String
getUrl (ApiCall { baseUrl, attributes }) =
UrlBuilder.crossOrigin
baseUrl
(getPath attributes |> List.singleton)
(getPath attributes)
(getQueryParams attributes)
getPath : List ContextAttr -> String
getPath : List ContextAttr -> List String
getPath =
List.foldl
(\attr prior ->
@ -138,6 +138,19 @@ getPath =
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
@ -177,6 +190,7 @@ withAttributes attrs (ApiCall data) =
accessToken : Attribute { a | accessToken : () }
accessToken =
Context.getAccessToken
>> (++) "Bearer "
>> Http.header "Authorization"
>> Header