forked from loafle/openapi-generator-original
parent
34abedeb8a
commit
172448fa28
@ -130,7 +130,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"Byte",
|
"Byte",
|
||||||
"DateOnly",
|
"DateOnly",
|
||||||
"DateTime")
|
"DateTime",
|
||||||
|
"Uuid")
|
||||||
);
|
);
|
||||||
|
|
||||||
instantiationTypes.clear();
|
instantiationTypes.clear();
|
||||||
@ -153,6 +154,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("ByteArray", "Byte");
|
typeMapping.put("ByteArray", "Byte");
|
||||||
typeMapping.put("file", "String");
|
typeMapping.put("file", "String");
|
||||||
typeMapping.put("binary", "String");
|
typeMapping.put("binary", "String");
|
||||||
|
typeMapping.put("UUID", "Uuid");
|
||||||
|
|
||||||
importMapping.clear();
|
importMapping.clear();
|
||||||
|
|
||||||
@ -675,31 +677,31 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
private void addEncoderAndDecoder(final Map<String, Object> vendorExtensions, final String dataType, final DataTypeExposure dataTypeExposure) {
|
private void addEncoderAndDecoder(final Map<String, Object> vendorExtensions, final String dataType, final DataTypeExposure dataTypeExposure) {
|
||||||
final String baseName = org.openapitools.codegen.utils.StringUtils.camelize(dataType, true);
|
final String baseName = org.openapitools.codegen.utils.StringUtils.camelize(dataType, true);
|
||||||
String encoderName;
|
String encodeName;
|
||||||
String decoderName;
|
String decoderName;
|
||||||
switch (dataTypeExposure) {
|
switch (dataTypeExposure) {
|
||||||
case EXPOSED:
|
case EXPOSED:
|
||||||
decoderName = "decoder";
|
decoderName = "decoder";
|
||||||
encoderName = "encoder";
|
encodeName = "encode";
|
||||||
break;
|
break;
|
||||||
case INTERNAL:
|
case INTERNAL:
|
||||||
encoderName = baseName + "Encoder";
|
encodeName = "encode" + StringUtils.capitalize(baseName);
|
||||||
decoderName = baseName + "Decoder";
|
decoderName = baseName + "Decoder";
|
||||||
break;
|
break;
|
||||||
case EXTERNAL:
|
case EXTERNAL:
|
||||||
encoderName = dataType + ".encoder";
|
encodeName = dataType + ".encode";
|
||||||
decoderName = dataType + ".decoder";
|
decoderName = dataType + ".decoder";
|
||||||
break;
|
break;
|
||||||
case PRIMITIVE:
|
case PRIMITIVE:
|
||||||
encoderName = "Encode." + baseName;
|
encodeName = "Encode." + baseName;
|
||||||
decoderName = "Decode." + baseName;
|
decoderName = "Decode." + baseName;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
encoderName = "";
|
encodeName = "";
|
||||||
decoderName = "";
|
decoderName = "";
|
||||||
}
|
}
|
||||||
if (!vendorExtensions.containsKey(ENCODER)) {
|
if (!vendorExtensions.containsKey(ENCODER)) {
|
||||||
vendorExtensions.put(ENCODER, encoderName);
|
vendorExtensions.put(ENCODER, encodeName);
|
||||||
}
|
}
|
||||||
if (!vendorExtensions.containsKey(DECODER)) {
|
if (!vendorExtensions.containsKey(DECODER)) {
|
||||||
vendorExtensions.put(DECODER, decoderName);
|
vendorExtensions.put(DECODER, decoderName);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Byte exposing (Byte, decoder, encoder)
|
module Byte exposing (Byte, decoder, encode)
|
||||||
|
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
@ -13,6 +13,6 @@ decoder =
|
|||||||
Decode.string
|
Decode.string
|
||||||
|
|
||||||
|
|
||||||
encoder : Byte -> Encode.Value
|
encode : Byte -> Encode.Value
|
||||||
encoder model =
|
encode model =
|
||||||
Encode.string model
|
Encode.string model
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateOnly exposing (DateOnly, decoder, encoder, toString)
|
module DateOnly exposing (DateOnly, decoder, encode, toString)
|
||||||
|
|
||||||
import Iso8601
|
import Iso8601
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateOnly -> Encode.Value
|
encode : DateOnly -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateOnly exposing (DateOnly, decoder, encoder, toString)
|
module DateOnly exposing (DateOnly, decoder, encode, toString)
|
||||||
|
|
||||||
import Date
|
import Date
|
||||||
import Date.Extra exposing (fromIsoString, toFormattedString)
|
import Date.Extra exposing (fromIsoString, toFormattedString)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateOnly -> Encode.Value
|
encode : DateOnly -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateTime exposing (DateTime, decoder, encoder, toString)
|
module DateTime exposing (DateTime, decoder, encode, toString)
|
||||||
|
|
||||||
import Iso8601
|
import Iso8601
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateTime -> Encode.Value
|
encode : DateTime -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateTime exposing (DateTime, decoder, encoder, toString)
|
module DateTime exposing (DateTime, decoder, encode, toString)
|
||||||
|
|
||||||
import Date
|
import Date
|
||||||
import Date.Extra exposing (fromIsoString, toIsoString)
|
import Date.Extra exposing (fromIsoString, toIsoString)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateTime -> Encode.Value
|
encode : DateTime -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
|
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
|
||||||
|
"danyx23/elm-uuid": "2.0.2 <= v < 2.1.1",
|
||||||
"elm-lang/core": "5.1.1 <= v < 6.0.0",
|
"elm-lang/core": "5.1.1 <= v < 6.0.0",
|
||||||
"elm-lang/html": "2.0.0 <= v < 3.0.0",
|
"elm-lang/html": "2.0.0 <= v < 3.0.0",
|
||||||
"elm-lang/http": "1.0.0 <= v < 2.0.0",
|
"elm-lang/http": "1.0.0 <= v < 2.0.0",
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"direct": {
|
"direct": {
|
||||||
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
|
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
|
||||||
|
"danyx23/elm-uuid": "2.1.2",
|
||||||
"elm/browser": "1.0.1",
|
"elm/browser": "1.0.1",
|
||||||
"elm/core": "1.0.2",
|
"elm/core": "1.0.2",
|
||||||
"elm/html": "1.0.0",
|
"elm/html": "1.0.0",
|
||||||
@ -20,6 +21,8 @@
|
|||||||
"elm/bytes": "1.0.5",
|
"elm/bytes": "1.0.5",
|
||||||
"elm/file": "1.0.1",
|
"elm/file": "1.0.1",
|
||||||
"elm/parser": "1.1.0",
|
"elm/parser": "1.1.0",
|
||||||
|
"elm/random": "1.0.0",
|
||||||
|
"elm/regex": "1.0.0",
|
||||||
"elm/virtual-dom": "1.0.2"
|
"elm/virtual-dom": "1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{{>licenseInfo}}
|
{{>licenseInfo}}
|
||||||
|
|
||||||
module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmCustomType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encoder{{/model}}{{/models}})
|
module Data.{{classname}} exposing ({{#models}}{{#model}}{{classname}}{{#hasChildren}}(..){{/hasChildren}}{{#isEnum}}(..){{/isEnum}}{{^isEnum}}{{#vars}}{{#isEnum}}, {{vendorExtensions.elmCustomType}}(..){{/isEnum}}{{/vars}}{{/isEnum}}, decoder, encode{{/model}}{{/models}})
|
||||||
|
|
||||||
{{>imports}}import Dict exposing (Dict)
|
{{>imports}}import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
|
@ -7,6 +7,6 @@ decoder =
|
|||||||
Decode.list {{vendorExtensions.elmDecoder}}
|
Decode.list {{vendorExtensions.elmDecoder}}
|
||||||
|
|
||||||
|
|
||||||
encoder : {{classname}} -> Encode.Value
|
encode : {{classname}} -> Encode.Value
|
||||||
encoder items =
|
encode items =
|
||||||
Encode.list {{#isElm018}}(List.map {{/isElm018}}{{vendorExtensions.elmEncoder}} items{{#isElm018}}){{/isElm018}}
|
Encode.list {{#isElm018}}(List.map {{/isElm018}}{{vendorExtensions.elmEncoder}} items{{#isElm018}}){{/isElm018}}
|
||||||
|
@ -22,8 +22,8 @@ decoder =
|
|||||||
Decode.fail <| "Trying to decode {{classname}}, but {{{discriminatorName}}} " ++ tag ++ " is not supported."
|
Decode.fail <| "Trying to decode {{classname}}, but {{{discriminatorName}}} " ++ tag ++ " is not supported."
|
||||||
|
|
||||||
|
|
||||||
encoder : {{classname}} -> Encode.Value
|
encode : {{classname}} -> Encode.Value
|
||||||
encoder model =
|
encode model =
|
||||||
case model of
|
case model of
|
||||||
{{#mappedModels}}
|
{{#mappedModels}}
|
||||||
{{modelName}}Type subModel ->
|
{{modelName}}Type subModel ->
|
||||||
|
@ -7,6 +7,6 @@ decoder =
|
|||||||
{{vendorExtensions.elmDecoder}}
|
{{vendorExtensions.elmDecoder}}
|
||||||
|
|
||||||
|
|
||||||
encoder : {{classname}} -> Encode.Value
|
encode : {{classname}} -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
{{vendorExtensions.elmEncoder}}
|
{{vendorExtensions.elmEncoder}}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
encoder : {{#vendorExtensions.discriminatorName}}String -> {{/vendorExtensions.discriminatorName}}{{classname}} -> Encode.Value
|
encode : {{#vendorExtensions.discriminatorName}}String -> {{/vendorExtensions.discriminatorName}}{{classname}} -> Encode.Value
|
||||||
encoder {{#vendorExtensions.discriminatorName}}tag {{/vendorExtensions.discriminatorName}}model =
|
encode {{#vendorExtensions.discriminatorName}}tag {{/vendorExtensions.discriminatorName}}model =
|
||||||
Encode.object
|
Encode.object
|
||||||
{{#allVars}}
|
{{#allVars}}
|
||||||
{{#-first}}[{{/-first}}{{^-first}},{{/-first}} {{>recordFieldEncoder}}
|
{{#-first}}[{{/-first}}{{^-first}},{{/-first}} {{>recordFieldEncoder}}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
"exposed-modules": [],
|
"exposed-modules": [],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
|
"NoRedInk/elm-decode-pipeline": "3.0.0 <= v < 4.0.0",
|
||||||
|
"danyx23/elm-uuid": "2.0.2 <= v < 2.1.1",
|
||||||
"elm-lang/core": "5.1.1 <= v < 6.0.0",
|
"elm-lang/core": "5.1.1 <= v < 6.0.0",
|
||||||
"elm-lang/html": "2.0.0 <= v < 3.0.0",
|
"elm-lang/html": "2.0.0 <= v < 3.0.0",
|
||||||
"elm-lang/http": "1.0.0 <= v < 2.0.0",
|
"elm-lang/http": "1.0.0 <= v < 2.0.0",
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Byte exposing (Byte, decoder, encoder)
|
module Byte exposing (Byte, decoder, encode)
|
||||||
|
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
@ -13,6 +13,6 @@ decoder =
|
|||||||
Decode.string
|
Decode.string
|
||||||
|
|
||||||
|
|
||||||
encoder : Byte -> Encode.Value
|
encode : Byte -> Encode.Value
|
||||||
encoder model =
|
encode model =
|
||||||
Encode.string model
|
Encode.string model
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.ApiResponse exposing (ApiResponse, decoder, encoder)
|
module Data.ApiResponse exposing (ApiResponse, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,9 +21,9 @@ import Json.Encode as Encode
|
|||||||
{-| Describes the result of uploading an image resource
|
{-| Describes the result of uploading an image resource
|
||||||
-}
|
-}
|
||||||
type alias ApiResponse =
|
type alias ApiResponse =
|
||||||
{ code : Maybe (Int)
|
{ code : Maybe Int
|
||||||
, type_ : Maybe (String)
|
, type_ : Maybe String
|
||||||
, message : Maybe (String)
|
, message : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -35,14 +35,10 @@ decoder =
|
|||||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : ApiResponse -> Encode.Value
|
||||||
encoder : ApiResponse -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Category exposing (Category, decoder, encoder)
|
module Data.Category exposing (Category, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
|||||||
{-| A category for a pet
|
{-| A category for a pet
|
||||||
-}
|
-}
|
||||||
type alias Category =
|
type alias Category =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, name : Maybe (String)
|
, name : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,13 +33,9 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : Category -> Encode.Value
|
||||||
encoder : Category -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Order_ exposing (Order_, Status(..), decoder, encoder)
|
module Data.Order_ exposing (Order_, Status(..), decoder, encode)
|
||||||
|
|
||||||
import DateTime exposing (DateTime)
|
import DateTime exposing (DateTime)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
@ -22,12 +22,12 @@ import Json.Encode as Encode
|
|||||||
{-| An order for a pets from the pet store
|
{-| An order for a pets from the pet store
|
||||||
-}
|
-}
|
||||||
type alias Order_ =
|
type alias Order_ =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, petId : Maybe (Int)
|
, petId : Maybe Int
|
||||||
, quantity : Maybe (Int)
|
, quantity : Maybe Int
|
||||||
, shipDate : Maybe (DateTime)
|
, shipDate : Maybe DateTime
|
||||||
, status : Maybe (Status)
|
, status : Maybe Status
|
||||||
, complete : Maybe (Bool)
|
, complete : Maybe Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +37,6 @@ type Status
|
|||||||
| Delivered
|
| Delivered
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Order_
|
decoder : Decoder Order_
|
||||||
decoder =
|
decoder =
|
||||||
decode Order_
|
decode Order_
|
||||||
@ -49,21 +48,18 @@ decoder =
|
|||||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||||
|
|
||||||
|
|
||||||
|
encode : Order_ -> Encode.Value
|
||||||
encoder : Order_ -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encoder model.shipDate) )
|
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -84,9 +80,8 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
encodeStatus : Status -> Encode.Value
|
||||||
statusEncoder : Status -> Encode.Value
|
encodeStatus model =
|
||||||
statusEncoder model =
|
|
||||||
case model of
|
case model of
|
||||||
Placed ->
|
Placed ->
|
||||||
Encode.string "placed"
|
Encode.string "placed"
|
||||||
@ -96,6 +91,3 @@ statusEncoder model =
|
|||||||
|
|
||||||
Delivered ->
|
Delivered ->
|
||||||
Encode.string "delivered"
|
Encode.string "delivered"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Pet exposing (Pet, Status(..), decoder, encoder)
|
module Data.Pet exposing (Pet, Status(..), decoder, encode)
|
||||||
|
|
||||||
import Data.Category as Category exposing (Category)
|
import Data.Category as Category exposing (Category)
|
||||||
import Data.Tag as Tag exposing (Tag)
|
import Data.Tag as Tag exposing (Tag)
|
||||||
@ -23,12 +23,12 @@ import Json.Encode as Encode
|
|||||||
{-| A pet for sale in the pet store
|
{-| A pet for sale in the pet store
|
||||||
-}
|
-}
|
||||||
type alias Pet =
|
type alias Pet =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, category : Maybe (Category)
|
, category : Maybe Category
|
||||||
, name : String
|
, name : String
|
||||||
, photoUrls : (List String)
|
, photoUrls : List String
|
||||||
, tags : Maybe ((List Tag))
|
, tags : Maybe (List Tag)
|
||||||
, status : Maybe (Status)
|
, status : Maybe Status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ type Status
|
|||||||
| Sold
|
| Sold
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Pet
|
decoder : Decoder Pet
|
||||||
decoder =
|
decoder =
|
||||||
decode Pet
|
decode Pet
|
||||||
@ -50,21 +49,18 @@ decoder =
|
|||||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : Pet -> Encode.Value
|
||||||
encoder : Pet -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encoder model.category) )
|
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||||
, ( "name", Encode.string model.name )
|
, ( "name", Encode.string model.name )
|
||||||
, ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls )
|
, ( "photoUrls", (Encode.list << List.map Encode.string) model.photoUrls )
|
||||||
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list << List.map Tag.encoder) model.tags) )
|
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list << List.map Tag.encode) model.tags) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -85,9 +81,8 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
encodeStatus : Status -> Encode.Value
|
||||||
statusEncoder : Status -> Encode.Value
|
encodeStatus model =
|
||||||
statusEncoder model =
|
|
||||||
case model of
|
case model of
|
||||||
Available ->
|
Available ->
|
||||||
Encode.string "available"
|
Encode.string "available"
|
||||||
@ -97,6 +92,3 @@ statusEncoder model =
|
|||||||
|
|
||||||
Sold ->
|
Sold ->
|
||||||
Encode.string "sold"
|
Encode.string "sold"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Tag exposing (Tag, decoder, encoder)
|
module Data.Tag exposing (Tag, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
|||||||
{-| A tag for a pet
|
{-| A tag for a pet
|
||||||
-}
|
-}
|
||||||
type alias Tag =
|
type alias Tag =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, name : Maybe (String)
|
, name : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,13 +33,9 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : Tag -> Encode.Value
|
||||||
encoder : Tag -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.User exposing (User, decoder, encoder)
|
module Data.User exposing (User, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,14 +21,14 @@ import Json.Encode as Encode
|
|||||||
{-| A User who is purchasing from the pet store
|
{-| A User who is purchasing from the pet store
|
||||||
-}
|
-}
|
||||||
type alias User =
|
type alias User =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, username : Maybe (String)
|
, username : Maybe String
|
||||||
, firstName : Maybe (String)
|
, firstName : Maybe String
|
||||||
, lastName : Maybe (String)
|
, lastName : Maybe String
|
||||||
, email : Maybe (String)
|
, email : Maybe String
|
||||||
, password : Maybe (String)
|
, password : Maybe String
|
||||||
, phone : Maybe (String)
|
, phone : Maybe String
|
||||||
, userStatus : Maybe (Int)
|
, userStatus : Maybe Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,9 +45,8 @@ decoder =
|
|||||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : User -> Encode.Value
|
||||||
encoder : User -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||||
@ -57,7 +56,4 @@ encoder model =
|
|||||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateOnly exposing (DateOnly, decoder, encoder, toString)
|
module DateOnly exposing (DateOnly, decoder, encode, toString)
|
||||||
|
|
||||||
import Date
|
import Date
|
||||||
import Date.Extra exposing (fromIsoString, toFormattedString)
|
import Date.Extra exposing (fromIsoString, toFormattedString)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateOnly -> Encode.Value
|
encode : DateOnly -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateTime exposing (DateTime, decoder, encoder, toString)
|
module DateTime exposing (DateTime, decoder, encode, toString)
|
||||||
|
|
||||||
import Date
|
import Date
|
||||||
import Date.Extra exposing (fromIsoString, toIsoString)
|
import Date.Extra exposing (fromIsoString, toIsoString)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateTime -> Encode.Value
|
encode : DateTime -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
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.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||||
|
import Data.Pet as Pet exposing (Pet)
|
||||||
import Dict
|
import Dict
|
||||||
import Http
|
import Http
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
@ -29,7 +29,7 @@ addPet model =
|
|||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, url = basePath ++ "/pet"
|
, url = basePath ++ "/pet"
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| Pet.encoder model
|
, body = Http.jsonBody <| Pet.encode model
|
||||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
@ -100,7 +100,7 @@ updatePet model =
|
|||||||
{ method = "PUT"
|
{ method = "PUT"
|
||||||
, url = basePath ++ "/pet"
|
, url = basePath ++ "/pet"
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| Pet.encoder model
|
, body = Http.jsonBody <| Pet.encode model
|
||||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
|
@ -73,7 +73,7 @@ placeOrder model =
|
|||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, url = basePath ++ "/store/order"
|
, url = basePath ++ "/store/order"
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| Order_.encoder model
|
, body = Http.jsonBody <| Order_.encode model
|
||||||
, expect = Http.expectJson Order_.decoder
|
, expect = Http.expectJson Order_.decoder
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
|
@ -30,7 +30,7 @@ createUser model =
|
|||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, url = basePath ++ "/user"
|
, url = basePath ++ "/user"
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| User.encoder model
|
, body = Http.jsonBody <| User.encode model
|
||||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
@ -43,7 +43,7 @@ createUsersWithArrayInput model =
|
|||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, url = basePath ++ "/user/createWithArray"
|
, url = basePath ++ "/user/createWithArray"
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| User.encoder model
|
, body = Http.jsonBody <| User.encode model
|
||||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
@ -56,7 +56,7 @@ createUsersWithListInput model =
|
|||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, url = basePath ++ "/user/createWithList"
|
, url = basePath ++ "/user/createWithList"
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| User.encoder model
|
, body = Http.jsonBody <| User.encode model
|
||||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
@ -125,7 +125,7 @@ updateUser username model =
|
|||||||
{ method = "PUT"
|
{ method = "PUT"
|
||||||
, url = basePath ++ "/user/" ++ username
|
, url = basePath ++ "/user/" ++ username
|
||||||
, headers = []
|
, headers = []
|
||||||
, body = Http.jsonBody <| User.encoder model
|
, body = Http.jsonBody <| User.encode model
|
||||||
, expect = Http.expectStringResponse (\_ -> Ok ())
|
, expect = Http.expectStringResponse (\_ -> Ok ())
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, withCredentials = False
|
, withCredentials = False
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"direct": {
|
"direct": {
|
||||||
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
|
"NoRedInk/elm-json-decode-pipeline": "1.0.0",
|
||||||
|
"danyx23/elm-uuid": "2.1.2",
|
||||||
"elm/browser": "1.0.1",
|
"elm/browser": "1.0.1",
|
||||||
"elm/core": "1.0.2",
|
"elm/core": "1.0.2",
|
||||||
"elm/html": "1.0.0",
|
"elm/html": "1.0.0",
|
||||||
@ -20,6 +21,8 @@
|
|||||||
"elm/bytes": "1.0.5",
|
"elm/bytes": "1.0.5",
|
||||||
"elm/file": "1.0.1",
|
"elm/file": "1.0.1",
|
||||||
"elm/parser": "1.1.0",
|
"elm/parser": "1.1.0",
|
||||||
|
"elm/random": "1.0.0",
|
||||||
|
"elm/regex": "1.0.0",
|
||||||
"elm/virtual-dom": "1.0.2"
|
"elm/virtual-dom": "1.0.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module Byte exposing (Byte, decoder, encoder)
|
module Byte exposing (Byte, decoder, encode)
|
||||||
|
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
import Json.Encode as Encode
|
import Json.Encode as Encode
|
||||||
@ -13,6 +13,6 @@ decoder =
|
|||||||
Decode.string
|
Decode.string
|
||||||
|
|
||||||
|
|
||||||
encoder : Byte -> Encode.Value
|
encode : Byte -> Encode.Value
|
||||||
encoder model =
|
encode model =
|
||||||
Encode.string model
|
Encode.string model
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.ApiResponse exposing (ApiResponse, decoder, encoder)
|
module Data.ApiResponse exposing (ApiResponse, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,9 +21,9 @@ import Json.Encode as Encode
|
|||||||
{-| Describes the result of uploading an image resource
|
{-| Describes the result of uploading an image resource
|
||||||
-}
|
-}
|
||||||
type alias ApiResponse =
|
type alias ApiResponse =
|
||||||
{ code : Maybe (Int)
|
{ code : Maybe Int
|
||||||
, type_ : Maybe (String)
|
, type_ : Maybe String
|
||||||
, message : Maybe (String)
|
, message : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -35,14 +35,10 @@ decoder =
|
|||||||
|> optional "message" (Decode.nullable Decode.string) Nothing
|
|> optional "message" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : ApiResponse -> Encode.Value
|
||||||
encoder : ApiResponse -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
[ ( "code", Maybe.withDefault Encode.null (Maybe.map Encode.int model.code) )
|
||||||
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
, ( "type", Maybe.withDefault Encode.null (Maybe.map Encode.string model.type_) )
|
||||||
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
, ( "message", Maybe.withDefault Encode.null (Maybe.map Encode.string model.message) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Category exposing (Category, decoder, encoder)
|
module Data.Category exposing (Category, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
|||||||
{-| A category for a pet
|
{-| A category for a pet
|
||||||
-}
|
-}
|
||||||
type alias Category =
|
type alias Category =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, name : Maybe (String)
|
, name : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,13 +33,9 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : Category -> Encode.Value
|
||||||
encoder : Category -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Order_ exposing (Order_, Status(..), decoder, encoder)
|
module Data.Order_ exposing (Order_, Status(..), decoder, encode)
|
||||||
|
|
||||||
import DateTime exposing (DateTime)
|
import DateTime exposing (DateTime)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
@ -22,12 +22,12 @@ import Json.Encode as Encode
|
|||||||
{-| An order for a pets from the pet store
|
{-| An order for a pets from the pet store
|
||||||
-}
|
-}
|
||||||
type alias Order_ =
|
type alias Order_ =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, petId : Maybe (Int)
|
, petId : Maybe Int
|
||||||
, quantity : Maybe (Int)
|
, quantity : Maybe Int
|
||||||
, shipDate : Maybe (DateTime)
|
, shipDate : Maybe DateTime
|
||||||
, status : Maybe (Status)
|
, status : Maybe Status
|
||||||
, complete : Maybe (Bool)
|
, complete : Maybe Bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -37,7 +37,6 @@ type Status
|
|||||||
| Delivered
|
| Delivered
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Order_
|
decoder : Decoder Order_
|
||||||
decoder =
|
decoder =
|
||||||
Decode.succeed Order_
|
Decode.succeed Order_
|
||||||
@ -49,21 +48,18 @@ decoder =
|
|||||||
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
|> optional "complete" (Decode.nullable Decode.bool) (Just False)
|
||||||
|
|
||||||
|
|
||||||
|
encode : Order_ -> Encode.Value
|
||||||
encoder : Order_ -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
, ( "petId", Maybe.withDefault Encode.null (Maybe.map Encode.int model.petId) )
|
||||||
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
, ( "quantity", Maybe.withDefault Encode.null (Maybe.map Encode.int model.quantity) )
|
||||||
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encoder model.shipDate) )
|
, ( "shipDate", Maybe.withDefault Encode.null (Maybe.map DateTime.encode model.shipDate) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
, ( "complete", Maybe.withDefault Encode.null (Maybe.map Encode.bool model.complete) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -84,9 +80,8 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
encodeStatus : Status -> Encode.Value
|
||||||
statusEncoder : Status -> Encode.Value
|
encodeStatus model =
|
||||||
statusEncoder model =
|
|
||||||
case model of
|
case model of
|
||||||
Placed ->
|
Placed ->
|
||||||
Encode.string "placed"
|
Encode.string "placed"
|
||||||
@ -96,6 +91,3 @@ statusEncoder model =
|
|||||||
|
|
||||||
Delivered ->
|
Delivered ->
|
||||||
Encode.string "delivered"
|
Encode.string "delivered"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Pet exposing (Pet, Status(..), decoder, encoder)
|
module Data.Pet exposing (Pet, Status(..), decoder, encode)
|
||||||
|
|
||||||
import Data.Category as Category exposing (Category)
|
import Data.Category as Category exposing (Category)
|
||||||
import Data.Tag as Tag exposing (Tag)
|
import Data.Tag as Tag exposing (Tag)
|
||||||
@ -23,12 +23,12 @@ import Json.Encode as Encode
|
|||||||
{-| A pet for sale in the pet store
|
{-| A pet for sale in the pet store
|
||||||
-}
|
-}
|
||||||
type alias Pet =
|
type alias Pet =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, category : Maybe (Category)
|
, category : Maybe Category
|
||||||
, name : String
|
, name : String
|
||||||
, photoUrls : (List String)
|
, photoUrls : List String
|
||||||
, tags : Maybe ((List Tag))
|
, tags : Maybe (List Tag)
|
||||||
, status : Maybe (Status)
|
, status : Maybe Status
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ type Status
|
|||||||
| Sold
|
| Sold
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
decoder : Decoder Pet
|
decoder : Decoder Pet
|
||||||
decoder =
|
decoder =
|
||||||
Decode.succeed Pet
|
Decode.succeed Pet
|
||||||
@ -50,21 +49,18 @@ decoder =
|
|||||||
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
|> optional "status" (Decode.nullable statusDecoder) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : Pet -> Encode.Value
|
||||||
encoder : Pet -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encoder model.category) )
|
, ( "category", Maybe.withDefault Encode.null (Maybe.map Category.encode model.category) )
|
||||||
, ( "name", Encode.string model.name )
|
, ( "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.encoder) model.tags) )
|
, ( "tags", Maybe.withDefault Encode.null (Maybe.map (Encode.list Tag.encode) model.tags) )
|
||||||
, ( "status", Maybe.withDefault Encode.null (Maybe.map statusEncoder model.status) )
|
, ( "status", Maybe.withDefault Encode.null (Maybe.map encodeStatus model.status) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
statusDecoder : Decoder Status
|
statusDecoder : Decoder Status
|
||||||
statusDecoder =
|
statusDecoder =
|
||||||
Decode.string
|
Decode.string
|
||||||
@ -85,9 +81,8 @@ statusDecoder =
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
encodeStatus : Status -> Encode.Value
|
||||||
statusEncoder : Status -> Encode.Value
|
encodeStatus model =
|
||||||
statusEncoder model =
|
|
||||||
case model of
|
case model of
|
||||||
Available ->
|
Available ->
|
||||||
Encode.string "available"
|
Encode.string "available"
|
||||||
@ -97,6 +92,3 @@ statusEncoder model =
|
|||||||
|
|
||||||
Sold ->
|
Sold ->
|
||||||
Encode.string "sold"
|
Encode.string "sold"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.Tag exposing (Tag, decoder, encoder)
|
module Data.Tag exposing (Tag, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,8 +21,8 @@ import Json.Encode as Encode
|
|||||||
{-| A tag for a pet
|
{-| A tag for a pet
|
||||||
-}
|
-}
|
||||||
type alias Tag =
|
type alias Tag =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, name : Maybe (String)
|
, name : Maybe String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,13 +33,9 @@ decoder =
|
|||||||
|> optional "name" (Decode.nullable Decode.string) Nothing
|
|> optional "name" (Decode.nullable Decode.string) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : Tag -> Encode.Value
|
||||||
encoder : Tag -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
, ( "name", Maybe.withDefault Encode.null (Maybe.map Encode.string model.name) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
|
|
||||||
module Data.User exposing (User, decoder, encoder)
|
module Data.User exposing (User, decoder, encode)
|
||||||
|
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -21,14 +21,14 @@ import Json.Encode as Encode
|
|||||||
{-| A User who is purchasing from the pet store
|
{-| A User who is purchasing from the pet store
|
||||||
-}
|
-}
|
||||||
type alias User =
|
type alias User =
|
||||||
{ id : Maybe (Int)
|
{ id : Maybe Int
|
||||||
, username : Maybe (String)
|
, username : Maybe String
|
||||||
, firstName : Maybe (String)
|
, firstName : Maybe String
|
||||||
, lastName : Maybe (String)
|
, lastName : Maybe String
|
||||||
, email : Maybe (String)
|
, email : Maybe String
|
||||||
, password : Maybe (String)
|
, password : Maybe String
|
||||||
, phone : Maybe (String)
|
, phone : Maybe String
|
||||||
, userStatus : Maybe (Int)
|
, userStatus : Maybe Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,9 +45,8 @@ decoder =
|
|||||||
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
|> optional "userStatus" (Decode.nullable Decode.int) Nothing
|
||||||
|
|
||||||
|
|
||||||
|
encode : User -> Encode.Value
|
||||||
encoder : User -> Encode.Value
|
encode model =
|
||||||
encoder model =
|
|
||||||
Encode.object
|
Encode.object
|
||||||
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
[ ( "id", Maybe.withDefault Encode.null (Maybe.map Encode.int model.id) )
|
||||||
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
, ( "username", Maybe.withDefault Encode.null (Maybe.map Encode.string model.username) )
|
||||||
@ -57,7 +56,4 @@ encoder model =
|
|||||||
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
, ( "password", Maybe.withDefault Encode.null (Maybe.map Encode.string model.password) )
|
||||||
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
, ( "phone", Maybe.withDefault Encode.null (Maybe.map Encode.string model.phone) )
|
||||||
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
, ( "userStatus", Maybe.withDefault Encode.null (Maybe.map Encode.int model.userStatus) )
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateOnly exposing (DateOnly, decoder, encoder, toString)
|
module DateOnly exposing (DateOnly, decoder, encode, toString)
|
||||||
|
|
||||||
import Iso8601
|
import Iso8601
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateOnly -> Encode.Value
|
encode : DateOnly -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
module DateTime exposing (DateTime, decoder, encoder, toString)
|
module DateTime exposing (DateTime, decoder, encode, toString)
|
||||||
|
|
||||||
import Iso8601
|
import Iso8601
|
||||||
import Json.Decode as Decode exposing (Decoder)
|
import Json.Decode as Decode exposing (Decoder)
|
||||||
@ -17,8 +17,8 @@ decoder =
|
|||||||
|> Decode.andThen decodeIsoString
|
|> Decode.andThen decodeIsoString
|
||||||
|
|
||||||
|
|
||||||
encoder : DateTime -> Encode.Value
|
encode : DateTime -> Encode.Value
|
||||||
encoder =
|
encode =
|
||||||
Encode.string << toString
|
Encode.string << toString
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
|
|
||||||
module Request.Pet exposing (addPet, deletePet, findPetsByStatus, findPetsByTags, getPetById, updatePet, updatePetWithForm, uploadFile)
|
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.ApiResponse as ApiResponse exposing (ApiResponse)
|
||||||
|
import Data.Pet as Pet exposing (Pet)
|
||||||
import Dict
|
import Dict
|
||||||
import Http
|
import Http
|
||||||
import Json.Decode as Decode
|
import Json.Decode as Decode
|
||||||
@ -28,18 +28,17 @@ basePath =
|
|||||||
addPet :
|
addPet :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
, body : Pet
|
, body : Pet
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
addPet params =
|
addPet params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet"]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| Pet.encoder params.body
|
, body = Http.jsonBody <| Pet.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
@ -48,17 +47,16 @@ addPet params =
|
|||||||
|
|
||||||
deletePet :
|
deletePet :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
|
|
||||||
, petId : Int
|
, petId : Int
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
deletePet params =
|
deletePet params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "DELETE"
|
{ method = "DELETE"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet", String.fromInt params.petId ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -71,8 +69,6 @@ deletePet params =
|
|||||||
-}
|
-}
|
||||||
findPetsByStatus :
|
findPetsByStatus :
|
||||||
{ onSend : Result Http.Error (List Pet) -> msg
|
{ onSend : Result Http.Error (List Pet) -> msg
|
||||||
|
|
||||||
|
|
||||||
, status : List String
|
, status : List String
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
@ -80,9 +76,10 @@ findPetsByStatus params =
|
|||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", "findByStatus"]
|
Url.crossOrigin basePath
|
||||||
(List.filterMap identity [Just (Url.string "status" <| String.join "," params.status)])
|
[ "pet", "findByStatus" ]
|
||||||
|
(List.filterMap identity [ Just (Url.string "status" <| String.join "," params.status) ])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
@ -94,8 +91,6 @@ findPetsByStatus params =
|
|||||||
-}
|
-}
|
||||||
findPetsByTags :
|
findPetsByTags :
|
||||||
{ onSend : Result Http.Error (List Pet) -> msg
|
{ onSend : Result Http.Error (List Pet) -> msg
|
||||||
|
|
||||||
|
|
||||||
, tags : List String
|
, tags : List String
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
@ -103,9 +98,10 @@ findPetsByTags params =
|
|||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", "findByTags"]
|
Url.crossOrigin basePath
|
||||||
(List.filterMap identity [Just (Url.string "tags" <| String.join "," params.tags)])
|
[ "pet", "findByTags" ]
|
||||||
|
(List.filterMap identity [ Just (Url.string "tags" <| String.join "," params.tags) ])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
, expect = Http.expectJson params.onSend (Decode.list Pet.decoder)
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
@ -117,17 +113,16 @@ findPetsByTags params =
|
|||||||
-}
|
-}
|
||||||
getPetById :
|
getPetById :
|
||||||
{ onSend : Result Http.Error Pet -> msg
|
{ onSend : Result Http.Error Pet -> msg
|
||||||
|
|
||||||
, petId : Int
|
, petId : Int
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
getPetById params =
|
getPetById params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet", String.fromInt params.petId ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend Pet.decoder
|
, expect = Http.expectJson params.onSend Pet.decoder
|
||||||
@ -139,18 +134,17 @@ getPetById params =
|
|||||||
updatePet :
|
updatePet :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
, body : Pet
|
, body : Pet
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
updatePet params =
|
updatePet params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "PUT"
|
{ method = "PUT"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet"]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| Pet.encoder params.body
|
, body = Http.jsonBody <| Pet.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
@ -159,17 +153,16 @@ updatePet params =
|
|||||||
|
|
||||||
updatePetWithForm :
|
updatePetWithForm :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
|
|
||||||
, petId : Int
|
, petId : Int
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
updatePetWithForm params =
|
updatePetWithForm params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet", String.fromInt params.petId ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -180,17 +173,16 @@ updatePetWithForm params =
|
|||||||
|
|
||||||
uploadFile :
|
uploadFile :
|
||||||
{ onSend : Result Http.Error ApiResponse -> msg
|
{ onSend : Result Http.Error ApiResponse -> msg
|
||||||
|
|
||||||
, petId : Int
|
, petId : Int
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
uploadFile params =
|
uploadFile params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["pet", String.fromInt params.petId, "uploadImage"]
|
Url.crossOrigin basePath
|
||||||
|
[ "pet", String.fromInt params.petId, "uploadImage" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend ApiResponse.decoder
|
, expect = Http.expectJson params.onSend ApiResponse.decoder
|
||||||
|
@ -28,17 +28,16 @@ basePath =
|
|||||||
-}
|
-}
|
||||||
deleteOrder :
|
deleteOrder :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
|
|
||||||
, orderId : String
|
, orderId : String
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
deleteOrder params =
|
deleteOrder params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "DELETE"
|
{ method = "DELETE"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "order", params.orderId]
|
Url.crossOrigin basePath
|
||||||
|
[ "store", "order", params.orderId ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -51,17 +50,15 @@ deleteOrder params =
|
|||||||
-}
|
-}
|
||||||
getInventory :
|
getInventory :
|
||||||
{ onSend : Result Http.Error (Dict.Dict String Int) -> msg
|
{ onSend : Result Http.Error (Dict.Dict String Int) -> msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
getInventory params =
|
getInventory params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "inventory"]
|
Url.crossOrigin basePath
|
||||||
|
[ "store", "inventory" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend (Decode.dict Decode.int)
|
, expect = Http.expectJson params.onSend (Decode.dict Decode.int)
|
||||||
@ -74,17 +71,16 @@ getInventory params =
|
|||||||
-}
|
-}
|
||||||
getOrderById :
|
getOrderById :
|
||||||
{ onSend : Result Http.Error Order_ -> msg
|
{ onSend : Result Http.Error Order_ -> msg
|
||||||
|
|
||||||
, orderId : Int
|
, orderId : Int
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
getOrderById params =
|
getOrderById params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "order", String.fromInt params.orderId]
|
Url.crossOrigin basePath
|
||||||
|
[ "store", "order", String.fromInt params.orderId ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend Order_.decoder
|
, expect = Http.expectJson params.onSend Order_.decoder
|
||||||
@ -96,18 +92,17 @@ getOrderById params =
|
|||||||
placeOrder :
|
placeOrder :
|
||||||
{ onSend : Result Http.Error Order_ -> msg
|
{ onSend : Result Http.Error Order_ -> msg
|
||||||
, body : Order_
|
, body : Order_
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
placeOrder params =
|
placeOrder params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["store", "order"]
|
Url.crossOrigin basePath
|
||||||
|
[ "store", "order" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| Order_.encoder params.body
|
, body = Http.jsonBody <| Order_.encode params.body
|
||||||
, expect = Http.expectJson params.onSend Order_.decoder
|
, expect = Http.expectJson params.onSend Order_.decoder
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
|
@ -29,18 +29,17 @@ basePath =
|
|||||||
createUser :
|
createUser :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
, body : User
|
, body : User
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
createUser params =
|
createUser params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encoder params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
@ -50,18 +49,17 @@ createUser params =
|
|||||||
createUsersWithArrayInput :
|
createUsersWithArrayInput :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
, body : User
|
, body : User
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
createUsersWithArrayInput params =
|
createUsersWithArrayInput params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "createWithArray"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", "createWithArray" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encoder params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
@ -71,18 +69,17 @@ createUsersWithArrayInput params =
|
|||||||
createUsersWithListInput :
|
createUsersWithListInput :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
, body : User
|
, body : User
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
createUsersWithListInput params =
|
createUsersWithListInput params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "POST"
|
{ method = "POST"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "createWithList"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", "createWithList" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encoder params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
@ -93,17 +90,16 @@ createUsersWithListInput params =
|
|||||||
-}
|
-}
|
||||||
deleteUser :
|
deleteUser :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
|
|
||||||
, username : String
|
, username : String
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
deleteUser params =
|
deleteUser params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "DELETE"
|
{ method = "DELETE"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", params.username]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", params.username ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -114,17 +110,16 @@ deleteUser params =
|
|||||||
|
|
||||||
getUserByName :
|
getUserByName :
|
||||||
{ onSend : Result Http.Error User -> msg
|
{ onSend : Result Http.Error User -> msg
|
||||||
|
|
||||||
, username : String
|
, username : String
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
getUserByName params =
|
getUserByName params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", params.username]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", params.username ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend User.decoder
|
, expect = Http.expectJson params.onSend User.decoder
|
||||||
@ -135,18 +130,18 @@ getUserByName params =
|
|||||||
|
|
||||||
loginUser :
|
loginUser :
|
||||||
{ onSend : Result Http.Error String -> msg
|
{ onSend : Result Http.Error String -> msg
|
||||||
|
, username : String
|
||||||
|
, password : String
|
||||||
, username : String , password : String
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
loginUser params =
|
loginUser params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "login"]
|
Url.crossOrigin basePath
|
||||||
(List.filterMap identity [Just (Url.string "username" <| params.username), Just (Url.string "password" <| params.password)])
|
[ "user", "login" ]
|
||||||
|
(List.filterMap identity [ Just (Url.string "username" <| params.username), Just (Url.string "password" <| params.password) ])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectJson params.onSend Decode.string
|
, expect = Http.expectJson params.onSend Decode.string
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
@ -156,17 +151,15 @@ loginUser params =
|
|||||||
|
|
||||||
logoutUser :
|
logoutUser :
|
||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
logoutUser params =
|
logoutUser params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "GET"
|
{ method = "GET"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", "logout"]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", "logout" ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.emptyBody
|
, body = Http.emptyBody
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
@ -181,17 +174,17 @@ updateUser :
|
|||||||
{ onSend : Result Http.Error () -> msg
|
{ onSend : Result Http.Error () -> msg
|
||||||
, body : User
|
, body : User
|
||||||
, username : String
|
, username : String
|
||||||
|
|
||||||
}
|
}
|
||||||
-> Cmd msg
|
-> Cmd msg
|
||||||
updateUser params =
|
updateUser params =
|
||||||
Http.request
|
Http.request
|
||||||
{ method = "PUT"
|
{ method = "PUT"
|
||||||
, headers = []
|
, headers = []
|
||||||
, url = Url.crossOrigin basePath
|
, url =
|
||||||
["user", params.username]
|
Url.crossOrigin basePath
|
||||||
|
[ "user", params.username ]
|
||||||
(List.filterMap identity [])
|
(List.filterMap identity [])
|
||||||
, body = Http.jsonBody <| User.encoder params.body
|
, body = Http.jsonBody <| User.encode params.body
|
||||||
, expect = Http.expectWhatever params.onSend
|
, expect = Http.expectWhatever params.onSend
|
||||||
, timeout = Just 30000
|
, timeout = Just 30000
|
||||||
, tracker = Nothing
|
, tracker = Nothing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user