elm.operation.mustache Maven / Gradle / Ivy
{{>licenseInfo}}
module Api.Request.{{classname}} exposing
{{#operations}}{{#operation}} {{#-first}}( {{/-first}}{{^-first}}, {{/-first}}{{operationId}}{{#allParams}}{{#isEnum}}, {{enumName}}(..), {{#lambda.camelcase}}{{enumName}}{{/lambda.camelcase}}Variants{{/isEnum}}{{/allParams}}
{{/operation}}{{/operations}} )
import Api
import Api.Data exposing (..){{#includeTime}}
import Api.Time exposing (Posix){{/includeTime}}
import Dict
import Http
import Json.Decode
import Json.Encode{{#includeUuid}}
import Uuid exposing (Uuid){{/includeUuid}}{{#includeFile}}
import File exposing (File){{/includeFile}}
{{#operations}}
{{#operation}}
{{#allParams}}
{{#isEnum}}
{{>customType}}
{{>customTypeToString}}
{{/isEnum}}
{{/allParams}}
{{/operation}}
{{/operations}}
{{#operations}}
{{#operation}}
{{#notes}}
{-| {{{notes}}}
-}
{{/notes}}
{{#lambda.removeWhitespace}}
{{operationId}} : {{#allParams}}{{>operationParameter}} -> {{/allParams}}
{{#authMethods}}{{#isBasicBearer}}String -> {{/isBasicBearer}}{{/authMethods}}Api.Request
{{#responses}} {{!-- This iterates through all different responses, some might not be 200 }}
{{#-first}} {{!-- We have no way to handle multiple return types today so we just handle the first }}
{{#is2xx}}
{{^dataType}}(){{/dataType}}
{{#isMap}}(Dict.Dict String {{/isMap}}
{{#isArray}}(List {{#items}}{{#isModel}}Api.Data.{{/isModel}}{{/items}}{{/isArray}}{{^isArray}}{{^primitiveType}}{{^isUuid}}{{^isFile}}Api.Data.{{/isFile}}{{/isUuid}}{{/primitiveType}}{{/isArray}}{{dataType}}{{#isArray}}){{/isArray}}{{#isMap}}){{/isMap}}
{{/is2xx}}
{{^is2xx}}(){{/is2xx}}
{{/-first}}
{{/responses}}
{{/lambda.removeWhitespace}}
{{operationId}}{{#allParams}} {{>paramName}}{{/allParams}}{{#authMethods}}{{#isBasicBearer}} auth_token{{/isBasicBearer}}{{/authMethods}} =
Api.request
"{{httpMethod}}"
"{{path}}"
[{{#pathParams}} ( "{{paramName}}", {{>paramToString}} {{>paramName}} ){{#-last}} {{/-last}}{{^-last}},{{/-last}}{{/pathParams}}]
[{{#queryParams}} ( "{{baseName}}", {{#required}}Just <| {{/required}}{{^required}}Maybe.map {{/required}}{{>paramToString}} {{>paramName}} ){{#-last}} {{/-last}}{{^-last}},{{/-last}}{{/queryParams}}]
[{{#headerParams}} ( "{{baseName}}", {{#required}}Just <| {{/required}}{{^required}}Maybe.map {{/required}}{{>paramToString}} {{>paramName}} ){{#-last}} {{/-last}}{{^-last}},{{/-last}}{{/headerParams}}]
{{#bodyParam}}
(Maybe.map Http.jsonBody ({{#required}}Just ({{/required}}{{^required}}Maybe.map {{/required}}{{#isModel}}Api.Data.{{/isModel}}{{>recordFieldValueEncoder}} {{>paramName}}{{#required}}){{/required}}))
{{/bodyParam}}
{{#formParams.0}}
(Just <| Http.multipartBody <| List.filterMap identity [ {{#formParams}}{{>formParamEncoder}}{{^-last}}, {{/-last}}{{/formParams}} ])
{{/formParams.0}}
{{^bodyParam}}
{{^formParams}}
Nothing
{{/formParams}}
{{/bodyParam}}
{{#responses}}{{#-first}}{{#is2xx}}{{^dataType}}(Json.Decode.succeed ()){{/dataType}}{{#dataType}}{{>recordFieldValueDecoder}}{{/dataType}}{{/is2xx}}{{^is2xx}}(Json.Decode.succeed ()){{/is2xx}}{{/-first}}{{/responses}}{{^responses}}(Json.Decode.succeed ()){{/responses}}
{{#authMethods}}{{#isBasicBearer}} |> Api.withBearerToken auth_token{{/isBasicBearer}}{{/authMethods}}
{{/operation}}
{{/operations}}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy