forked from loafle/openapi-generator-original
Fix NPE in Elm path parameter (#4116)
* fix NPE in elm path parameter * replace paramName with baseName * install elm format in circleci * switch to /usr/bin/env
This commit is contained in:
parent
ceb021cc54
commit
3141e483ef
@ -21,6 +21,9 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
||||
echo "Running node $NODE_INDEX to test ensure-up-to-date"
|
||||
java -version
|
||||
|
||||
# install elm-format
|
||||
npm install -g elm-format
|
||||
|
||||
./bin/utils/ensure-up-to-date
|
||||
fi
|
||||
#elif [ "$NODE_INDEX" = "3" ]; then
|
||||
|
@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
# auto format elm code using elm-format
|
||||
export ELM_POST_PROCESS_FILE="/usr/local/bin/elm-format --elm-version=0.18 --yes"
|
||||
export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.18 --yes"
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
@ -26,7 +26,7 @@ then
|
||||
fi
|
||||
|
||||
# auto format elm code using elm-format
|
||||
export ELM_POST_PROCESS_FILE="/usr/local/bin/elm-format --elm-version=0.19 --yes"
|
||||
export ELM_POST_PROCESS_FILE="/usr/bin/env elm-format --elm-version=0.19 --yes"
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
@ -68,7 +68,7 @@ declare -a scripts=(
|
||||
"./bin/dart-petstore.sh"
|
||||
"./bin/dart2-petstore.sh"
|
||||
"./bin/java-play-framework-petstore-server-all.sh"
|
||||
#"./bin/elm-petstore-all.sh"
|
||||
"./bin/elm-petstore-all.sh"
|
||||
"./bin/meta-codegen.sh"
|
||||
# OTHERS
|
||||
"./bin/utils/export_docs_generators.sh"
|
||||
|
@ -381,8 +381,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
final String propertyName = cm.discriminator.getPropertyName();
|
||||
final List<CodegenProperty> allVars = child.allVars.stream()
|
||||
.filter(var -> !var.baseName.equals(propertyName))
|
||||
.collect(Collectors.toList());
|
||||
.filter(var -> !var.baseName.equals(propertyName))
|
||||
.collect(Collectors.toList());
|
||||
child.allVars.clear();
|
||||
child.allVars.addAll(allVars);
|
||||
|
||||
@ -415,17 +415,17 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
private static boolean anyOperationParam(final List<CodegenOperation> operations, final Predicate<CodegenParameter> predicate) {
|
||||
return operations.stream()
|
||||
.flatMap(operation -> Stream.of(
|
||||
operation.bodyParams.stream(),
|
||||
operation.queryParams.stream(),
|
||||
operation.pathParams.stream(),
|
||||
operation.headerParams.stream()
|
||||
))
|
||||
.flatMap(a -> a)
|
||||
.filter(predicate)
|
||||
.findAny()
|
||||
.isPresent();
|
||||
return operations.stream()
|
||||
.flatMap(operation -> Stream.of(
|
||||
operation.bodyParams.stream(),
|
||||
operation.queryParams.stream(),
|
||||
operation.pathParams.stream(),
|
||||
operation.headerParams.stream()
|
||||
))
|
||||
.flatMap(a -> a)
|
||||
.filter(predicate)
|
||||
.findAny()
|
||||
.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -437,23 +437,23 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
final Set<String> dependencies = new HashSet<>();
|
||||
|
||||
for (CodegenOperation op : ops) {
|
||||
if (ElmVersion.ELM_018.equals(elmVersion)) {
|
||||
if (ElmVersion.ELM_018.equals(elmVersion)) { // elm 0.18
|
||||
String path = op.path;
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
final String var = paramToString("params", param, false, null);
|
||||
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
|
||||
path = path.replace("{" + param.baseName + "}", "\" ++ " + var + " ++ \"");
|
||||
}
|
||||
op.path = ("\"" + path + "\"").replaceAll(" \\+\\+ \"\"", "");
|
||||
} else {
|
||||
} else { // elm 0.19 or later
|
||||
final List<Object> pathParams = Arrays.asList(op.path.substring(1).split("/")).stream()
|
||||
.map(str -> {
|
||||
if (str.startsWith("{") && str.endsWith("}")) {
|
||||
return op.pathParams.stream().filter(p -> str.equals("{" + p.paramName + "}")).findFirst().orElse(null);
|
||||
} else {
|
||||
return "\"" + str + "\"";
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
.map(str -> {
|
||||
if (str.startsWith("{") && str.endsWith("}")) {
|
||||
return op.pathParams.stream().filter(p -> str.equals("{" + p.baseName + "}")).findFirst().orElse(null);
|
||||
} else {
|
||||
return "\"" + str + "\"";
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
op.vendorExtensions.put("pathParams", pathParams);
|
||||
}
|
||||
|
||||
@ -737,10 +737,10 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
private enum DataTypeExposure {
|
||||
EXPOSED,
|
||||
INTERNAL,
|
||||
EXTERNAL,
|
||||
PRIMITIVE
|
||||
EXPOSED,
|
||||
INTERNAL,
|
||||
EXTERNAL,
|
||||
PRIMITIVE
|
||||
}
|
||||
|
||||
private static class ElmImport {
|
||||
|
@ -1 +1 @@
|
||||
4.1.3-SNAPSHOT
|
||||
4.2.0-SNAPSHOT
|
@ -21,9 +21,9 @@ import Json.Encode as Encode
|
||||
{-| Describes the result of uploading an image resource
|
||||
-}
|
||||
type alias ApiResponse =
|
||||
{ code : Maybe (Int)
|
||||
, type_ : Maybe (String)
|
||||
, message : Maybe (String)
|
||||
{ code : Maybe Int
|
||||
, type_ : Maybe String
|
||||
, message : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -35,22 +35,15 @@ decoder =
|
||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
encode : ApiResponse -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : ApiResponse -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A category for a pet
|
||||
-}
|
||||
type alias Category =
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -33,21 +33,14 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Category -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Category -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -22,12 +22,12 @@ import Json.Encode as Encode
|
||||
{-| An order for a pets from the pet store
|
||||
-}
|
||||
type alias Order_ =
|
||||
{ id : Maybe (Int)
|
||||
, petId : Maybe (Int)
|
||||
, quantity : Maybe (Int)
|
||||
, shipDate : Maybe (DateTime)
|
||||
, status : Maybe (Status)
|
||||
, complete : Maybe (Bool)
|
||||
{ id : Maybe Int
|
||||
, petId : Maybe Int
|
||||
, quantity : Maybe Int
|
||||
, shipDate : Maybe DateTime
|
||||
, status : Maybe Status
|
||||
, complete : Maybe Bool
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ type Status
|
||||
| Delivered
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Order_
|
||||
decoder =
|
||||
decode Order_
|
||||
@ -49,7 +48,6 @@ decoder =
|
||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -59,18 +57,14 @@ encode model =
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Order_ -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -91,7 +85,6 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -103,7 +96,3 @@ encodeStatus model =
|
||||
|
||||
Delivered ->
|
||||
Encode.string "delivered"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -23,12 +23,12 @@ import Json.Encode as Encode
|
||||
{-| A pet for sale in the pet store
|
||||
-}
|
||||
type alias Pet =
|
||||
{ id : Maybe (Int)
|
||||
, category : Maybe (Category)
|
||||
{ id : Maybe Int
|
||||
, category : Maybe Category
|
||||
, name : String
|
||||
, photoUrls : (List String)
|
||||
, tags : Maybe ((List Tag))
|
||||
, status : Maybe (Status)
|
||||
, photoUrls : List String
|
||||
, tags : Maybe (List Tag)
|
||||
, status : Maybe Status
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,6 @@ type Status
|
||||
| Sold
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Pet
|
||||
decoder =
|
||||
decode Pet
|
||||
@ -50,7 +49,6 @@ decoder =
|
||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Pet -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -60,18 +58,14 @@ encode model =
|
||||
, ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls )
|
||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list << List.map Tag.encode) model.tags) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Pet -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -92,7 +86,6 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -104,7 +97,3 @@ encodeStatus model =
|
||||
|
||||
Sold ->
|
||||
Encode.string "sold"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A tag for a pet
|
||||
-}
|
||||
type alias Tag =
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -33,21 +33,14 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Tag -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Tag -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,14 +21,14 @@ import Json.Encode as Encode
|
||||
{-| A User who is purchasing from the pet store
|
||||
-}
|
||||
type alias User =
|
||||
{ id : Maybe (Int)
|
||||
, username : Maybe (String)
|
||||
, firstName : Maybe (String)
|
||||
, lastName : Maybe (String)
|
||||
, email : Maybe (String)
|
||||
, password : Maybe (String)
|
||||
, phone : Maybe (String)
|
||||
, userStatus : Maybe (Int)
|
||||
{ id : Maybe Int
|
||||
, username : Maybe String
|
||||
, firstName : Maybe String
|
||||
, lastName : Maybe String
|
||||
, email : Maybe String
|
||||
, password : Maybe String
|
||||
, phone : Maybe String
|
||||
, userStatus : Maybe Int
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@ decoder =
|
||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -57,15 +56,9 @@ encode model =
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : User -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
@ -40,7 +40,7 @@ addPet model =
|
||||
deletePet : Int -> Http.Request ()
|
||||
deletePet petId =
|
||||
{ method = "DELETE"
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -85,7 +85,7 @@ findPetsByTags =
|
||||
getPetById : Int -> Http.Request Pet
|
||||
getPetById petId =
|
||||
{ method = "GET"
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson Pet.decoder
|
||||
@ -111,7 +111,7 @@ updatePet model =
|
||||
updatePetWithForm : Int -> Http.Request ()
|
||||
updatePetWithForm petId =
|
||||
{ method = "POST"
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, url = basePath ++ "/pet/" ++ toString petId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -124,7 +124,7 @@ updatePetWithForm petId =
|
||||
uploadFile : Int -> Http.Request ApiResponse
|
||||
uploadFile petId =
|
||||
{ method = "POST"
|
||||
, url = basePath ++ "/pet/" ++ toString petId ++ "/uploadImage"
|
||||
, url = basePath ++ "/pet/" ++ toString petId ++ "/uploadImage"
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson ApiResponse.decoder
|
||||
|
@ -28,7 +28,7 @@ basePath =
|
||||
deleteOrder : String -> Http.Request ()
|
||||
deleteOrder orderId =
|
||||
{ method = "DELETE"
|
||||
, url = basePath ++ "/store/order/" ++ orderId
|
||||
, url = basePath ++ "/store/order/" ++ orderId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -58,7 +58,7 @@ getInventory =
|
||||
getOrderById : Int -> Http.Request Order_
|
||||
getOrderById orderId =
|
||||
{ method = "GET"
|
||||
, url = basePath ++ "/store/order/" ++ toString orderId
|
||||
, url = basePath ++ "/store/order/" ++ toString orderId
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson Order_.decoder
|
||||
|
@ -69,7 +69,7 @@ createUsersWithListInput model =
|
||||
deleteUser : String -> Http.Request ()
|
||||
deleteUser username =
|
||||
{ method = "DELETE"
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
@ -82,7 +82,7 @@ deleteUser username =
|
||||
getUserByName : String -> Http.Request User
|
||||
getUserByName username =
|
||||
{ method = "GET"
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, headers = []
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson User.decoder
|
||||
@ -123,7 +123,7 @@ logoutUser =
|
||||
updateUser : String -> User -> Http.Request ()
|
||||
updateUser username model =
|
||||
{ method = "PUT"
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, url = basePath ++ "/user/" ++ username
|
||||
, headers = []
|
||||
, body = Http.jsonBody <| User.encode model
|
||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||
|
@ -1 +1 @@
|
||||
4.1.3-SNAPSHOT
|
||||
4.2.0-SNAPSHOT
|
@ -21,9 +21,9 @@ import Json.Encode as Encode
|
||||
{-| Describes the result of uploading an image resource
|
||||
-}
|
||||
type alias ApiResponse =
|
||||
{ code : Maybe (Int)
|
||||
, type_ : Maybe (String)
|
||||
, message : Maybe (String)
|
||||
{ code : Maybe Int
|
||||
, type_ : Maybe String
|
||||
, message : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -35,22 +35,15 @@ decoder =
|
||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
encode : ApiResponse -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : ApiResponse -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A category for a pet
|
||||
-}
|
||||
type alias Category =
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -33,21 +33,14 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Category -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Category -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -22,12 +22,12 @@ import Json.Encode as Encode
|
||||
{-| An order for a pets from the pet store
|
||||
-}
|
||||
type alias Order_ =
|
||||
{ id : Maybe (Int)
|
||||
, petId : Maybe (Int)
|
||||
, quantity : Maybe (Int)
|
||||
, shipDate : Maybe (DateTime)
|
||||
, status : Maybe (Status)
|
||||
, complete : Maybe (Bool)
|
||||
{ id : Maybe Int
|
||||
, petId : Maybe Int
|
||||
, quantity : Maybe Int
|
||||
, shipDate : Maybe DateTime
|
||||
, status : Maybe Status
|
||||
, complete : Maybe Bool
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,6 @@ type Status
|
||||
| Delivered
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Order_
|
||||
decoder =
|
||||
Decode.succeed Order_
|
||||
@ -49,7 +48,6 @@ decoder =
|
||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||
|
||||
|
||||
|
||||
encode : Order_ -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -59,18 +57,14 @@ encode model =
|
||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Order_ -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -91,7 +85,6 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -103,7 +96,3 @@ encodeStatus model =
|
||||
|
||||
Delivered ->
|
||||
Encode.string "delivered"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -23,12 +23,12 @@ import Json.Encode as Encode
|
||||
{-| A pet for sale in the pet store
|
||||
-}
|
||||
type alias Pet =
|
||||
{ id : Maybe (Int)
|
||||
, category : Maybe (Category)
|
||||
{ id : Maybe Int
|
||||
, category : Maybe Category
|
||||
, name : String
|
||||
, photoUrls : (List String)
|
||||
, tags : Maybe ((List Tag))
|
||||
, status : Maybe (Status)
|
||||
, photoUrls : List String
|
||||
, tags : Maybe (List Tag)
|
||||
, status : Maybe Status
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,6 @@ type Status
|
||||
| Sold
|
||||
|
||||
|
||||
|
||||
decoder : Decoder Pet
|
||||
decoder =
|
||||
Decode.succeed Pet
|
||||
@ -50,28 +49,23 @@ decoder =
|
||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Pet -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||
, ( "name", Encode.string model.name )
|
||||
, ( "photoUrls", (Encode.list Encode.string) model.photoUrls )
|
||||
, ( "photoUrls", Encode.list Encode.string model.photoUrls )
|
||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Pet -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
statusDecoder : Decoder Status
|
||||
statusDecoder =
|
||||
Decode.string
|
||||
@ -92,7 +86,6 @@ statusDecoder =
|
||||
)
|
||||
|
||||
|
||||
|
||||
encodeStatus : Status -> Encode.Value
|
||||
encodeStatus model =
|
||||
case model of
|
||||
@ -104,7 +97,3 @@ encodeStatus model =
|
||||
|
||||
Sold ->
|
||||
Encode.string "sold"
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
||||
{-| A tag for a pet
|
||||
-}
|
||||
type alias Tag =
|
||||
{ id : Maybe (Int)
|
||||
, name : Maybe (String)
|
||||
{ id : Maybe Int
|
||||
, name : Maybe String
|
||||
}
|
||||
|
||||
|
||||
@ -33,21 +33,14 @@ decoder =
|
||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||
|
||||
|
||||
|
||||
encode : Tag -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : Tag -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -21,14 +21,14 @@ import Json.Encode as Encode
|
||||
{-| A User who is purchasing from the pet store
|
||||
-}
|
||||
type alias User =
|
||||
{ id : Maybe (Int)
|
||||
, username : Maybe (String)
|
||||
, firstName : Maybe (String)
|
||||
, lastName : Maybe (String)
|
||||
, email : Maybe (String)
|
||||
, password : Maybe (String)
|
||||
, phone : Maybe (String)
|
||||
, userStatus : Maybe (Int)
|
||||
{ id : Maybe Int
|
||||
, username : Maybe String
|
||||
, firstName : Maybe String
|
||||
, lastName : Maybe String
|
||||
, email : Maybe String
|
||||
, password : Maybe String
|
||||
, phone : Maybe String
|
||||
, userStatus : Maybe Int
|
||||
}
|
||||
|
||||
|
||||
@ -45,7 +45,6 @@ decoder =
|
||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||
|
||||
|
||||
|
||||
encode : User -> Encode.Value
|
||||
encode model =
|
||||
Encode.object
|
||||
@ -57,15 +56,9 @@ encode model =
|
||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||
|
||||
]
|
||||
|
||||
|
||||
|
||||
toString : User -> String
|
||||
toString =
|
||||
Encode.encode 0 << encode
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,10 +10,10 @@
|
||||
-}
|
||||
|
||||
|
||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, Status(..), findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
module Request.Pet exposing (Status(..), addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
||||
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Data.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||
import Data.Pet as Pet exposing (Pet)
|
||||
import Dict
|
||||
import Http
|
||||
import Json.Decode as Decode
|
||||
@ -25,6 +25,7 @@ type Status
|
||||
| Pending
|
||||
| Sold
|
||||
|
||||
|
||||
stringifyStatus : Status -> String
|
||||
stringifyStatus value =
|
||||
case value of
|
||||
@ -38,9 +39,6 @@ stringifyStatus value =
|
||||
"sold"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
@ -48,20 +46,17 @@ basePath =
|
||||
|
||||
addPet :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : Pet
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
addPet params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -70,23 +65,21 @@ addPet params =
|
||||
|
||||
|
||||
deletePet :
|
||||
{ apiKey : Maybe (String)
|
||||
} ->
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
{ apiKey : Maybe String
|
||||
}
|
||||
->
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
, petId : Int
|
||||
}
|
||||
-> Cmd msg
|
||||
deletePet headers params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = List.filterMap identity [Maybe.map (Http.header "api_key" << identity) headers.apiKey]
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
(List.filterMap identity [])
|
||||
, headers = List.filterMap identity [ Maybe.map (Http.header "api_key" << identity) headers.apiKey ]
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -98,10 +91,6 @@ deletePet headers params =
|
||||
-}
|
||||
findPetsByStatus :
|
||||
{ onSend : Result Http.Error (List Pet) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, status : List Status
|
||||
}
|
||||
-> Cmd msg
|
||||
@ -109,9 +98,10 @@ findPetsByStatus params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByStatus"]
|
||||
(List.filterMap identity [(Just << Url.string "status" << String.join "," << List.map stringifyStatus) params.status])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", "findByStatus" ]
|
||||
(List.filterMap identity [ (Just << Url.string "status" << String.join "," << List.map stringifyStatus) params.status ])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
@ -123,10 +113,6 @@ findPetsByStatus params =
|
||||
-}
|
||||
findPetsByTags :
|
||||
{ onSend : Result Http.Error (List Pet) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, tags : List String
|
||||
}
|
||||
-> Cmd msg
|
||||
@ -134,9 +120,10 @@ findPetsByTags params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", "findByTags"]
|
||||
(List.filterMap identity [(Just << Url.string "tags" << String.join "," << List.map identity) params.tags])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", "findByTags" ]
|
||||
(List.filterMap identity [ (Just << Url.string "tags" << String.join "," << List.map identity) params.tags ])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||
, timeout = Just 30000
|
||||
@ -148,20 +135,17 @@ findPetsByTags params =
|
||||
-}
|
||||
getPetById :
|
||||
{ onSend : Result Http.Error Pet -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getPetById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Pet.decoder
|
||||
, timeout = Just 30000
|
||||
@ -171,20 +155,17 @@ getPetById params =
|
||||
|
||||
updatePet :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : Pet
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updatePet params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| Pet.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -194,20 +175,17 @@ updatePet params =
|
||||
|
||||
updatePetWithForm :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updatePetWithForm params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -217,20 +195,17 @@ updatePetWithForm params =
|
||||
|
||||
uploadFile :
|
||||
{ onSend : Result Http.Error ApiResponse -> msg
|
||||
|
||||
|
||||
|
||||
, petId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
uploadFile params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["pet", String.fromInt params.petId, "uploadImage"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "pet", String.fromInt params.petId, "uploadImage" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend ApiResponse.decoder
|
||||
, timeout = Just 30000
|
||||
|
@ -19,8 +19,6 @@ import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
@ -30,20 +28,17 @@ basePath =
|
||||
-}
|
||||
deleteOrder :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, orderId : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deleteOrder params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", identity params.orderId]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "order", identity params.orderId ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -55,20 +50,16 @@ deleteOrder params =
|
||||
-}
|
||||
getInventory :
|
||||
{ onSend : Result Http.Error (Dict.Dict String Int) -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getInventory params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "inventory"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "inventory" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend (Decode.dict Decode.int)
|
||||
, timeout = Just 30000
|
||||
@ -80,20 +71,17 @@ getInventory params =
|
||||
-}
|
||||
getOrderById :
|
||||
{ onSend : Result Http.Error Order_ -> msg
|
||||
|
||||
|
||||
|
||||
, orderId : Int
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getOrderById params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order", String.fromInt params.orderId]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "order", String.fromInt params.orderId ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
@ -103,20 +91,17 @@ getOrderById params =
|
||||
|
||||
placeOrder :
|
||||
{ onSend : Result Http.Error Order_ -> msg
|
||||
|
||||
|
||||
, body : Order_
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
placeOrder params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["store", "order"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "store", "order" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| Order_.encode params.body
|
||||
, expect = Http.expectJson params.onSend Order_.decoder
|
||||
, timeout = Just 30000
|
||||
|
@ -19,8 +19,6 @@ import Json.Decode as Decode
|
||||
import Url.Builder as Url
|
||||
|
||||
|
||||
|
||||
|
||||
basePath : String
|
||||
basePath =
|
||||
"http://petstore.swagger.io/v2"
|
||||
@ -30,20 +28,17 @@ basePath =
|
||||
-}
|
||||
createUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUser params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -53,20 +48,17 @@ createUser params =
|
||||
|
||||
createUsersWithArrayInput :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUsersWithArrayInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithArray"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "createWithArray" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -76,20 +68,17 @@ createUsersWithArrayInput params =
|
||||
|
||||
createUsersWithListInput :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
createUsersWithListInput params =
|
||||
Http.request
|
||||
{ method = "POST"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "createWithList"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "createWithList" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -101,20 +90,17 @@ createUsersWithListInput params =
|
||||
-}
|
||||
deleteUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
deleteUser params =
|
||||
Http.request
|
||||
{ method = "DELETE"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", identity params.username]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", identity params.username ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -124,20 +110,17 @@ deleteUser params =
|
||||
|
||||
getUserByName :
|
||||
{ onSend : Result Http.Error User -> msg
|
||||
|
||||
|
||||
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
getUserByName params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", identity params.username]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", identity params.username ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend User.decoder
|
||||
, timeout = Just 30000
|
||||
@ -147,20 +130,18 @@ getUserByName params =
|
||||
|
||||
loginUser :
|
||||
{ onSend : Result Http.Error String -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
, username : String , password : String
|
||||
, username : String
|
||||
, password : String
|
||||
}
|
||||
-> Cmd msg
|
||||
loginUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "login"]
|
||||
(List.filterMap identity [(Just << Url.string "username" << identity) params.username, (Just << Url.string "password" << identity) params.password])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "login" ]
|
||||
(List.filterMap identity [ (Just << Url.string "username" << identity) params.username, (Just << Url.string "password" << identity) params.password ])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectJson params.onSend Decode.string
|
||||
, timeout = Just 30000
|
||||
@ -170,20 +151,16 @@ loginUser params =
|
||||
|
||||
logoutUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
logoutUser params =
|
||||
Http.request
|
||||
{ method = "GET"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", "logout"]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", "logout" ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.emptyBody
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
@ -195,20 +172,18 @@ logoutUser params =
|
||||
-}
|
||||
updateUser :
|
||||
{ onSend : Result Http.Error () -> msg
|
||||
|
||||
|
||||
, body : User
|
||||
, username : String
|
||||
|
||||
}
|
||||
-> Cmd msg
|
||||
updateUser params =
|
||||
Http.request
|
||||
{ method = "PUT"
|
||||
, headers = List.filterMap identity []
|
||||
, url = Url.crossOrigin basePath
|
||||
["user", identity params.username]
|
||||
(List.filterMap identity [])
|
||||
, url =
|
||||
Url.crossOrigin basePath
|
||||
[ "user", identity params.username ]
|
||||
(List.filterMap identity [])
|
||||
, body = Http.jsonBody <| User.encode params.body
|
||||
, expect = Http.expectWhatever params.onSend
|
||||
, timeout = Just 30000
|
||||
|
Loading…
x
Reference in New Issue
Block a user