/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.16.74 * User agent: apibuilder app.apibuilder.io/apicollective/apibuilder-postman-collection-v2-1/0.16.74/http4s_0_15 */ package io.apibuilder.postman.collection.v21.v0.models { sealed trait Items extends _root_.scala.Product with _root_.scala.Serializable { def itemsType: ItemsType } /** * Defines the valid type values for the type Items */ sealed trait ItemsType extends _root_.scala.Product with _root_.scala.Serializable object ItemsType { case object Item extends ItemsType { override def toString = "item" } case object Folder extends ItemsType { override def toString = "folder" } final case class UNDEFINED(override val toString: String) extends ItemsType val all: scala.List[ItemsType] = scala.List(Item, Folder) private val byName: Map[String, ItemsType] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): ItemsType = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[ItemsType] = byName.get(value.toLowerCase) } final case class Auth( `type`: io.apibuilder.postman.collection.v21.v0.models.AuthEnum, basic: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.BasicAuth]] = None ) final case class BasicAuth( key: String, value: String, `type`: _root_.scala.Option[String] = None ) final case class Body( raw: _root_.scala.Option[String] = None, mode: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.BodyMode] = None, urlencoded: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.UrlEncoded]] = None, file: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.File] = None, formdata: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.FormParameter]] = None ) /** * @param info Detailed description of the info block * @param item Items are the basic unit for a Postman collection. You can think of them as * corresponding to a single API endpoint. Each Item has one request and may have * multiple API responses associated with it. * @param event Postman allows you to configure scripts to run when specific events occur. These * scripts are stored here, and can be referenced in the collection by their ID. * @param variable Collection variables allow you to define a set of variables, that are a part of * the collection, as opposed to environments, which are separate entities.Note: * Collection variables must not contain any sensitive information. * @param auth Represents authentication helpers provided by Postman */ final case class Collection( info: io.apibuilder.postman.collection.v21.v0.models.Info, item: Seq[io.apibuilder.postman.collection.v21.v0.models.Items], event: Seq[io.apibuilder.postman.collection.v21.v0.models.Event], variable: Seq[io.apibuilder.postman.collection.v21.v0.models.Variable], auth: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Auth] = None ) /** * @param content The content of the description goes here, as a raw string. * @param `type` Holds the mime type of the raw description content. E.g: 'text/markdown' or * 'text/html'. The type is used to correctly render the description when * generating documentation, or in the Postman app. */ final case class Description( content: _root_.scala.Option[String] = None, `type`: _root_.scala.Option[String] = None ) /** * @param listen Can be set to test or prerequest for test scripts or pre-request scripts * respectively. * @param id A unique identifier for the enclosing event. * @param disabled Indicates whether the event is disabled. If absent, the event is assumed to be * enabled */ final case class Event( listen: io.apibuilder.postman.collection.v21.v0.models.EventType, script: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Script] = None, id: _root_.scala.Option[String] = None, disabled: _root_.scala.Option[Boolean] = None ) final case class File( src: _root_.scala.Option[String] = None, content: _root_.scala.Option[String] = None ) /** * @param name A folder's friendly name is defined by this field. You would want to set this * field to a value that would allow you to easily identify this folder. */ final case class Folder( name: String, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None, variable: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]] = None, item: Seq[io.apibuilder.postman.collection.v21.v0.models.Item], event: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Event]] = None, auth: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Auth] = None ) extends Items { override val itemsType: ItemsType = ItemsType.Folder } final case class FormParameter( key: String, value: _root_.scala.Option[String] = None, disabled: _root_.scala.Option[Boolean] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None, contentType: _root_.scala.Option[String] = None, `type`: _root_.scala.Option[String] = None ) final case class Header( key: String, value: String, disabled: _root_.scala.Option[Boolean] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None ) /** * @param name A collection's friendly name is defined by this field. You would want to set * this field to a value that would allow you to easily identify this collection * among a bunch of other collections, as such outlining its usage or content. * @param postmanId Every collection is identified by the unique value of this field. The value of * this field is usually easiest to generate using a UID generator function. If you * already have a collection, it is recommended that you maintain the same id since * changing the id usually implies that is a different collection than it was * originally.Note: This field exists for compatibility reasons with Collection * Format V1. * @param description A Description can be a raw text, or be an object, which holds the description * along with its format. * @param version Postman allows you to version your collections as they grow, and this field * holds the version number. While optional, it is recommended that you use this * field to its fullest extent! * @param schema This should ideally hold a link to the Postman schema that is used to validate * this collection. E.g: https://schema.getpostman.com/collection/v1 */ final case class Info( name: String, postmanId: _root_.scala.Option[String] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None, version: _root_.scala.Option[String] = None, schema: String ) /** * @param id A unique ID that is used to identify collections internally * @param name A human readable identifier for the current item. * @param description A Description can be a raw text, or be an object, which holds the description * along with its format. * @param variable Collection variables allow you to define a set of variables, that are a part of * the collection, as opposed to environments, which are separate entities. * @param event Postman allows you to configure scripts to run when specific events occur. These * scripts are stored here, and can be referenced in the collection by their ID. */ final case class Item( id: _root_.scala.Option[String] = None, name: _root_.scala.Option[String] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None, variable: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]] = None, event: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Event]] = None, request: io.apibuilder.postman.collection.v21.v0.models.Request, response: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Response]] = None ) extends Items { override val itemsType: ItemsType = ItemsType.Item } final case class QueryParam( key: _root_.scala.Option[String] = None, value: _root_.scala.Option[String] = None, disabled: _root_.scala.Option[Boolean] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None ) final case class Request( url: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Url] = None, auth: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Auth] = None, method: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Method] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None, header: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Header]] = None, body: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Body] = None ) final case class Response( id: _root_.scala.Option[String] = None, name: _root_.scala.Option[String] = None, originalRequest: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Request] = None, responseTime: _root_.scala.Option[String] = None, header: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Header]] = None, body: _root_.scala.Option[String] = None, status: _root_.scala.Option[String] = None, code: _root_.scala.Option[Int] = None ) /** * @param exec Body of the script in lines * @param `type` Type of the script. E.g: 'text/javascript' * @param id A unique, user defined identifier that can be used to refer to this script from * requests. * @param src If object, contains the complete broken-down URL for this request. If string, * contains the literal request URL. * @param name Script name */ final case class Script( exec: Seq[String], `type`: String = "text/javascript", id: _root_.scala.Option[String] = None, src: _root_.scala.Option[String] = None, name: _root_.scala.Option[String] = None ) /** * @param raw The string representation of the request URL, including the protocol, host, * path, hash, query parameter(s) and path variable(s). * @param protocol The protocol_ associated with the request, E.g: 'http' * @param host The host for the URL, E.g: api.yourdomain.com. Can be stored as a string or as * an array of strings. * @param port The port number present in this URL. An empty value implies 80/443 depending on * whether the protocol_ field contains http/https. * @param hash Contains the URL fragment (if any). Usually this is not transmitted over the * network, but it could be useful to store this in some cases. * @param variable Postman supports path variables with the syntax * /path/:variableName/to/somewhere. These variables are stored in this field. */ final case class Url( raw: _root_.scala.Option[String] = None, protocol: _root_.scala.Option[String] = None, host: _root_.scala.Option[Seq[String]] = None, path: _root_.scala.Option[Seq[String]] = None, port: _root_.scala.Option[String] = None, query: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.QueryParam]] = None, hash: _root_.scala.Option[String] = None, variable: _root_.scala.Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]] = None ) final case class UrlEncoded( key: String, value: _root_.scala.Option[String] = None, disabled: _root_.scala.Option[Boolean] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None ) /** * Using variables in your Postman requests eliminates the need to duplicate * requests, which can save a lot of time. Variables can be defined, and referenced * to from any part of a request. * * @param id A variable ID is a unique user-defined value that identifies the variable within * a collection. In traditional terms, this would be a variable name. * @param key A variable key is a human friendly value that identifies the variable within a * collection. In traditional terms, this would be a variable name. * @param value The value that a variable holds in this collection. Ultimately, the variables * will be replaced by this value, when say running a set of requests from a * collection * @param `type` A variable may have multiple types. This field specifies the type of the * variable. * @param name Variable name * @param system When set to true, indicates that this variable has been set by Postman */ final case class Variable( id: _root_.scala.Option[String] = None, key: _root_.scala.Option[String] = None, value: _root_.scala.Option[String] = None, `type`: _root_.scala.Option[String] = None, name: _root_.scala.Option[String] = None, description: _root_.scala.Option[io.apibuilder.postman.collection.v21.v0.models.Description] = None, system: _root_.scala.Option[Boolean] = None, disabled: _root_.scala.Option[Boolean] = None ) /** * Provides future compatibility in clients - in the future, when a type is added * to the union Items, it will need to be handled in the client code. This * implementation will deserialize these future types as an instance of this class. * * @param description Information about the type that we received that is undefined in this version of * the client. */ final case class ItemsUndefinedType( description: String ) extends Items { override val itemsType: ItemsType = ItemsType.UNDEFINED(description) } sealed trait AuthEnum extends _root_.scala.Product with _root_.scala.Serializable object AuthEnum { case object Awsv4 extends AuthEnum { override def toString = "awsv4" } case object Basic extends AuthEnum { override def toString = "basic" } case object Bearer extends AuthEnum { override def toString = "bearer" } case object Digest extends AuthEnum { override def toString = "digest" } case object Hawk extends AuthEnum { override def toString = "hawk" } case object Noauth extends AuthEnum { override def toString = "noauth" } case object Oauth1 extends AuthEnum { override def toString = "oauth1" } case object Oauth2 extends AuthEnum { override def toString = "oauth2" } case object Ntlm extends AuthEnum { override def toString = "ntlm" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends AuthEnum /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[AuthEnum] = scala.List(Awsv4, Basic, Bearer, Digest, Hawk, Noauth, Oauth1, Oauth2, Ntlm) private val byName: Map[String, AuthEnum] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): AuthEnum = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[AuthEnum] = byName.get(value.toLowerCase) } sealed trait BodyMode extends _root_.scala.Product with _root_.scala.Serializable object BodyMode { case object Raw extends BodyMode { override def toString = "raw" } case object Urlencoded extends BodyMode { override def toString = "urlencoded" } case object Formdata extends BodyMode { override def toString = "formdata" } case object File extends BodyMode { override def toString = "file" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends BodyMode /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[BodyMode] = scala.List(Raw, Urlencoded, Formdata, File) private val byName: Map[String, BodyMode] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): BodyMode = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[BodyMode] = byName.get(value.toLowerCase) } sealed trait EventType extends _root_.scala.Product with _root_.scala.Serializable object EventType { case object Test extends EventType { override def toString = "test" } case object Prerequest extends EventType { override def toString = "prerequest" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends EventType /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[EventType] = scala.List(Test, Prerequest) private val byName: Map[String, EventType] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): EventType = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[EventType] = byName.get(value.toLowerCase) } sealed trait Method extends _root_.scala.Product with _root_.scala.Serializable object Method { case object Get extends Method { override def toString = "GET" } case object Put extends Method { override def toString = "PUT" } case object Post extends Method { override def toString = "POST" } case object Patch extends Method { override def toString = "PATCH" } case object Delete extends Method { override def toString = "DELETE" } case object Copy extends Method { override def toString = "COPY" } case object Head extends Method { override def toString = "HEAD" } case object Options extends Method { override def toString = "OPTIONS" } case object Link extends Method { override def toString = "LINK" } case object Unlink extends Method { override def toString = "UNLINK" } case object Purge extends Method { override def toString = "PURGE" } case object Lock extends Method { override def toString = "LOCK" } case object Unlock extends Method { override def toString = "UNLOCK" } case object Propfind extends Method { override def toString = "PROPFIND" } case object View extends Method { override def toString = "VIEW" } /** * UNDEFINED captures values that are sent either in error or * that were added by the server after this library was * generated. We want to make it easy and obvious to users of * this library to handle this case gracefully. * * We use all CAPS for the variable name to avoid collisions * with the camel cased values above. */ final case class UNDEFINED(override val toString: String) extends Method /** * all returns a list of all the valid, known values. We use * lower case to avoid collisions with the camel cased values * above. */ val all: scala.List[Method] = scala.List(Get, Put, Post, Patch, Delete, Copy, Head, Options, Link, Unlink, Purge, Lock, Unlock, Propfind, View) private val byName: Map[String, Method] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): Method = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[Method] = byName.get(value.toLowerCase) } } package io.apibuilder.postman.collection.v21.v0.models { package object json { import io.circe.Decoder._ import io.circe.Encoder._ import scala.language.implicitConversions // See below - Make Scala 2.11 Either monadic import scala.util.Try import io.circe.{Json, JsonObject, Encoder, Decoder, DecodingFailure} import io.circe.syntax._ import io.apibuilder.postman.collection.v21.v0.models.json._ // Make Scala 2.11 Either monadic private[v0] implicit def eitherOps[A,B](e: Either[A,B]) = cats.implicits.catsSyntaxEither(e) private[v0] implicit val decodeUUID: Decoder[_root_.java.util.UUID] = Decoder.decodeString.emapTry(str => Try(_root_.java.util.UUID.fromString(str))) private[v0] implicit val encodeUUID: Encoder[_root_.java.util.UUID] = Encoder.encodeString.contramap[_root_.java.util.UUID](uuid => uuid.toString) private[v0] implicit val decodeInstant: Decoder[_root_.java.time.Instant] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.OffsetDateTime.parse(str).toInstant)) private[v0] implicit val encodeInstant: Encoder[_root_.java.time.Instant] = Encoder.encodeString.contramap[_root_.java.time.Instant](_.toString) private[v0] implicit val decodeLocalDate: Decoder[_root_.java.time.LocalDate] = Decoder.decodeString.emapTry(str => Try(_root_.java.time.LocalDate.parse(str))) private[v0] implicit val encodeLocalDate: Encoder[_root_.java.time.LocalDate] = Encoder.encodeString.contramap[_root_.java.time.LocalDate](_.toString) implicit val jsonDecoderApiBuilderPostmanCollectionV21AuthEnum: Decoder[io.apibuilder.postman.collection.v21.v0.models.AuthEnum] = Decoder.decodeString.map(io.apibuilder.postman.collection.v21.v0.models.AuthEnum(_)) implicit val jsonEncoderApiBuilderPostmanCollectionV21AuthEnum: Encoder[io.apibuilder.postman.collection.v21.v0.models.AuthEnum] = Encoder.encodeString.contramap[io.apibuilder.postman.collection.v21.v0.models.AuthEnum](_.toString) implicit val jsonDecoderApiBuilderPostmanCollectionV21BodyMode: Decoder[io.apibuilder.postman.collection.v21.v0.models.BodyMode] = Decoder.decodeString.map(io.apibuilder.postman.collection.v21.v0.models.BodyMode(_)) implicit val jsonEncoderApiBuilderPostmanCollectionV21BodyMode: Encoder[io.apibuilder.postman.collection.v21.v0.models.BodyMode] = Encoder.encodeString.contramap[io.apibuilder.postman.collection.v21.v0.models.BodyMode](_.toString) implicit val jsonDecoderApiBuilderPostmanCollectionV21EventType: Decoder[io.apibuilder.postman.collection.v21.v0.models.EventType] = Decoder.decodeString.map(io.apibuilder.postman.collection.v21.v0.models.EventType(_)) implicit val jsonEncoderApiBuilderPostmanCollectionV21EventType: Encoder[io.apibuilder.postman.collection.v21.v0.models.EventType] = Encoder.encodeString.contramap[io.apibuilder.postman.collection.v21.v0.models.EventType](_.toString) implicit val jsonDecoderApiBuilderPostmanCollectionV21Method: Decoder[io.apibuilder.postman.collection.v21.v0.models.Method] = Decoder.decodeString.map(io.apibuilder.postman.collection.v21.v0.models.Method(_)) implicit val jsonEncoderApiBuilderPostmanCollectionV21Method: Encoder[io.apibuilder.postman.collection.v21.v0.models.Method] = Encoder.encodeString.contramap[io.apibuilder.postman.collection.v21.v0.models.Method](_.toString) implicit def decodeApiBuilderPostmanCollectionV21Auth: Decoder[Auth] = Decoder.instance { c => for { __type__ <- c.downField("type").as[io.apibuilder.postman.collection.v21.v0.models.AuthEnum] basic <- c.downField("basic").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.BasicAuth]]] } yield { Auth( `type` = __type__, basic = basic ) } } implicit def encodeApiBuilderPostmanCollectionV21Auth: Encoder[Auth] = Encoder.instance { t => Json.fromFields(Seq( Some("type" -> t.`type`.asJson), t.basic.map(t => "basic" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21BasicAuth: Decoder[BasicAuth] = Decoder.instance { c => for { key <- c.downField("key").as[String] value <- c.downField("value").as[String] __type__ <- c.downField("type").as[Option[String]] } yield { BasicAuth( key = key, value = value, `type` = __type__ ) } } implicit def encodeApiBuilderPostmanCollectionV21BasicAuth: Encoder[BasicAuth] = Encoder.instance { t => Json.fromFields(Seq( Some("key" -> t.key.asJson), Some("value" -> t.value.asJson), t.`type`.map(t => "type" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Body: Decoder[Body] = Decoder.instance { c => for { raw <- c.downField("raw").as[Option[String]] mode <- c.downField("mode").as[Option[io.apibuilder.postman.collection.v21.v0.models.BodyMode]] urlencoded <- c.downField("urlencoded").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.UrlEncoded]]] file <- c.downField("file").as[Option[io.apibuilder.postman.collection.v21.v0.models.File]] formdata <- c.downField("formdata").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.FormParameter]]] } yield { Body( raw = raw, mode = mode, urlencoded = urlencoded, file = file, formdata = formdata ) } } implicit def encodeApiBuilderPostmanCollectionV21Body: Encoder[Body] = Encoder.instance { t => Json.fromFields(Seq( t.raw.map(t => "raw" -> t.asJson), t.mode.map(t => "mode" -> t.asJson), t.urlencoded.map(t => "urlencoded" -> t.asJson), t.file.map(t => "file" -> t.asJson), t.formdata.map(t => "formdata" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Collection: Decoder[Collection] = Decoder.instance { c => for { info <- c.downField("info").as[io.apibuilder.postman.collection.v21.v0.models.Info] item <- c.downField("item").as[Seq[io.apibuilder.postman.collection.v21.v0.models.Items]] event <- c.downField("event").as[Seq[io.apibuilder.postman.collection.v21.v0.models.Event]] variable <- c.downField("variable").as[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]] auth <- c.downField("auth").as[Option[io.apibuilder.postman.collection.v21.v0.models.Auth]] } yield { Collection( info = info, item = item, event = event, variable = variable, auth = auth ) } } implicit def encodeApiBuilderPostmanCollectionV21Collection: Encoder[Collection] = Encoder.instance { t => Json.fromFields(Seq( Some("info" -> t.info.asJson), Some("item" -> t.item.asJson), Some("event" -> t.event.asJson), Some("variable" -> t.variable.asJson), t.auth.map(t => "auth" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Description: Decoder[Description] = Decoder.instance { c => for { content <- c.downField("content").as[Option[String]] __type__ <- c.downField("type").as[Option[String]] } yield { Description( content = content, `type` = __type__ ) } } implicit def encodeApiBuilderPostmanCollectionV21Description: Encoder[Description] = Encoder.instance { t => Json.fromFields(Seq( t.content.map(t => "content" -> t.asJson), t.`type`.map(t => "type" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Event: Decoder[Event] = Decoder.instance { c => for { listen <- c.downField("listen").as[io.apibuilder.postman.collection.v21.v0.models.EventType] script <- c.downField("script").as[Option[io.apibuilder.postman.collection.v21.v0.models.Script]] id <- c.downField("id").as[Option[String]] disabled <- c.downField("disabled").as[Option[Boolean]] } yield { Event( listen = listen, script = script, id = id, disabled = disabled ) } } implicit def encodeApiBuilderPostmanCollectionV21Event: Encoder[Event] = Encoder.instance { t => Json.fromFields(Seq( Some("listen" -> t.listen.asJson), t.script.map(t => "script" -> t.asJson), t.id.map(t => "id" -> t.asJson), t.disabled.map(t => "disabled" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21File: Decoder[File] = Decoder.instance { c => for { src <- c.downField("src").as[Option[String]] content <- c.downField("content").as[Option[String]] } yield { File( src = src, content = content ) } } implicit def encodeApiBuilderPostmanCollectionV21File: Encoder[File] = Encoder.instance { t => Json.fromFields(Seq( t.src.map(t => "src" -> t.asJson), t.content.map(t => "content" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Folder: Decoder[Folder] = Decoder.instance { c => for { name <- c.downField("name").as[String] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] variable <- c.downField("variable").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]]] item <- c.downField("item").as[Seq[io.apibuilder.postman.collection.v21.v0.models.Item]] event <- c.downField("event").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Event]]] auth <- c.downField("auth").as[Option[io.apibuilder.postman.collection.v21.v0.models.Auth]] } yield { Folder( name = name, description = description, variable = variable, item = item, event = event, auth = auth ) } } implicit def encodeApiBuilderPostmanCollectionV21Folder: Encoder[Folder] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), t.description.map(t => "description" -> t.asJson), t.variable.map(t => "variable" -> t.asJson), Some("item" -> t.item.asJson), t.event.map(t => "event" -> t.asJson), t.auth.map(t => "auth" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21FormParameter: Decoder[FormParameter] = Decoder.instance { c => for { key <- c.downField("key").as[String] value <- c.downField("value").as[Option[String]] disabled <- c.downField("disabled").as[Option[Boolean]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] contentType <- c.downField("contentType").as[Option[String]] __type__ <- c.downField("type").as[Option[String]] } yield { FormParameter( key = key, value = value, disabled = disabled, description = description, contentType = contentType, `type` = __type__ ) } } implicit def encodeApiBuilderPostmanCollectionV21FormParameter: Encoder[FormParameter] = Encoder.instance { t => Json.fromFields(Seq( Some("key" -> t.key.asJson), t.value.map(t => "value" -> t.asJson), t.disabled.map(t => "disabled" -> t.asJson), t.description.map(t => "description" -> t.asJson), t.contentType.map(t => "contentType" -> t.asJson), t.`type`.map(t => "type" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Header: Decoder[Header] = Decoder.instance { c => for { key <- c.downField("key").as[String] value <- c.downField("value").as[String] disabled <- c.downField("disabled").as[Option[Boolean]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] } yield { Header( key = key, value = value, disabled = disabled, description = description ) } } implicit def encodeApiBuilderPostmanCollectionV21Header: Encoder[Header] = Encoder.instance { t => Json.fromFields(Seq( Some("key" -> t.key.asJson), Some("value" -> t.value.asJson), t.disabled.map(t => "disabled" -> t.asJson), t.description.map(t => "description" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Info: Decoder[Info] = Decoder.instance { c => for { name <- c.downField("name").as[String] postmanId <- c.downField("postman_id").as[Option[String]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] version <- c.downField("version").as[Option[String]] schema <- c.downField("schema").as[String] } yield { Info( name = name, postmanId = postmanId, description = description, version = version, schema = schema ) } } implicit def encodeApiBuilderPostmanCollectionV21Info: Encoder[Info] = Encoder.instance { t => Json.fromFields(Seq( Some("name" -> t.name.asJson), t.postmanId.map(t => "postman_id" -> t.asJson), t.description.map(t => "description" -> t.asJson), t.version.map(t => "version" -> t.asJson), Some("schema" -> t.schema.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Item: Decoder[Item] = Decoder.instance { c => for { id <- c.downField("id").as[Option[String]] name <- c.downField("name").as[Option[String]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] variable <- c.downField("variable").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]]] event <- c.downField("event").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Event]]] request <- c.downField("request").as[io.apibuilder.postman.collection.v21.v0.models.Request] response <- c.downField("response").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Response]]] } yield { Item( id = id, name = name, description = description, variable = variable, event = event, request = request, response = response ) } } implicit def encodeApiBuilderPostmanCollectionV21Item: Encoder[Item] = Encoder.instance { t => Json.fromFields(Seq( t.id.map(t => "id" -> t.asJson), t.name.map(t => "name" -> t.asJson), t.description.map(t => "description" -> t.asJson), t.variable.map(t => "variable" -> t.asJson), t.event.map(t => "event" -> t.asJson), Some("request" -> t.request.asJson), t.response.map(t => "response" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21QueryParam: Decoder[QueryParam] = Decoder.instance { c => for { key <- c.downField("key").as[Option[String]] value <- c.downField("value").as[Option[String]] disabled <- c.downField("disabled").as[Option[Boolean]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] } yield { QueryParam( key = key, value = value, disabled = disabled, description = description ) } } implicit def encodeApiBuilderPostmanCollectionV21QueryParam: Encoder[QueryParam] = Encoder.instance { t => Json.fromFields(Seq( t.key.map(t => "key" -> t.asJson), t.value.map(t => "value" -> t.asJson), t.disabled.map(t => "disabled" -> t.asJson), t.description.map(t => "description" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Request: Decoder[Request] = Decoder.instance { c => for { url <- c.downField("url").as[Option[io.apibuilder.postman.collection.v21.v0.models.Url]] auth <- c.downField("auth").as[Option[io.apibuilder.postman.collection.v21.v0.models.Auth]] method <- c.downField("method").as[Option[io.apibuilder.postman.collection.v21.v0.models.Method]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] header <- c.downField("header").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Header]]] body <- c.downField("body").as[Option[io.apibuilder.postman.collection.v21.v0.models.Body]] } yield { Request( url = url, auth = auth, method = method, description = description, header = header, body = body ) } } implicit def encodeApiBuilderPostmanCollectionV21Request: Encoder[Request] = Encoder.instance { t => Json.fromFields(Seq( t.url.map(t => "url" -> t.asJson), t.auth.map(t => "auth" -> t.asJson), t.method.map(t => "method" -> t.asJson), t.description.map(t => "description" -> t.asJson), t.header.map(t => "header" -> t.asJson), t.body.map(t => "body" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Response: Decoder[Response] = Decoder.instance { c => for { id <- c.downField("id").as[Option[String]] name <- c.downField("name").as[Option[String]] originalRequest <- c.downField("originalRequest").as[Option[io.apibuilder.postman.collection.v21.v0.models.Request]] responseTime <- c.downField("responseTime").as[Option[String]] header <- c.downField("header").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Header]]] body <- c.downField("body").as[Option[String]] status <- c.downField("status").as[Option[String]] code <- c.downField("code").as[Option[Int]] } yield { Response( id = id, name = name, originalRequest = originalRequest, responseTime = responseTime, header = header, body = body, status = status, code = code ) } } implicit def encodeApiBuilderPostmanCollectionV21Response: Encoder[Response] = Encoder.instance { t => Json.fromFields(Seq( t.id.map(t => "id" -> t.asJson), t.name.map(t => "name" -> t.asJson), t.originalRequest.map(t => "originalRequest" -> t.asJson), t.responseTime.map(t => "responseTime" -> t.asJson), t.header.map(t => "header" -> t.asJson), t.body.map(t => "body" -> t.asJson), t.status.map(t => "status" -> t.asJson), t.code.map(t => "code" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Script: Decoder[Script] = Decoder.instance { c => for { exec <- c.downField("exec").as[Seq[String]] __type__ <- c.downField("type").as[String] id <- c.downField("id").as[Option[String]] src <- c.downField("src").as[Option[String]] name <- c.downField("name").as[Option[String]] } yield { Script( exec = exec, `type` = __type__, id = id, src = src, name = name ) } } implicit def encodeApiBuilderPostmanCollectionV21Script: Encoder[Script] = Encoder.instance { t => Json.fromFields(Seq( Some("exec" -> t.exec.asJson), Some("type" -> t.`type`.asJson), t.id.map(t => "id" -> t.asJson), t.src.map(t => "src" -> t.asJson), t.name.map(t => "name" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Url: Decoder[Url] = Decoder.instance { c => for { raw <- c.downField("raw").as[Option[String]] protocol <- c.downField("protocol").as[Option[String]] host <- c.downField("host").as[Option[Seq[String]]] path <- c.downField("path").as[Option[Seq[String]]] port <- c.downField("port").as[Option[String]] query <- c.downField("query").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.QueryParam]]] hash <- c.downField("hash").as[Option[String]] variable <- c.downField("variable").as[Option[Seq[io.apibuilder.postman.collection.v21.v0.models.Variable]]] } yield { Url( raw = raw, protocol = protocol, host = host, path = path, port = port, query = query, hash = hash, variable = variable ) } } implicit def encodeApiBuilderPostmanCollectionV21Url: Encoder[Url] = Encoder.instance { t => Json.fromFields(Seq( t.raw.map(t => "raw" -> t.asJson), t.protocol.map(t => "protocol" -> t.asJson), t.host.map(t => "host" -> t.asJson), t.path.map(t => "path" -> t.asJson), t.port.map(t => "port" -> t.asJson), t.query.map(t => "query" -> t.asJson), t.hash.map(t => "hash" -> t.asJson), t.variable.map(t => "variable" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21UrlEncoded: Decoder[UrlEncoded] = Decoder.instance { c => for { key <- c.downField("key").as[String] value <- c.downField("value").as[Option[String]] disabled <- c.downField("disabled").as[Option[Boolean]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] } yield { UrlEncoded( key = key, value = value, disabled = disabled, description = description ) } } implicit def encodeApiBuilderPostmanCollectionV21UrlEncoded: Encoder[UrlEncoded] = Encoder.instance { t => Json.fromFields(Seq( Some("key" -> t.key.asJson), t.value.map(t => "value" -> t.asJson), t.disabled.map(t => "disabled" -> t.asJson), t.description.map(t => "description" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Variable: Decoder[Variable] = Decoder.instance { c => for { id <- c.downField("id").as[Option[String]] key <- c.downField("key").as[Option[String]] value <- c.downField("value").as[Option[String]] __type__ <- c.downField("type").as[Option[String]] name <- c.downField("name").as[Option[String]] description <- c.downField("description").as[Option[io.apibuilder.postman.collection.v21.v0.models.Description]] system <- c.downField("system").as[Option[Boolean]] disabled <- c.downField("disabled").as[Option[Boolean]] } yield { Variable( id = id, key = key, value = value, `type` = __type__, name = name, description = description, system = system, disabled = disabled ) } } implicit def encodeApiBuilderPostmanCollectionV21Variable: Encoder[Variable] = Encoder.instance { t => Json.fromFields(Seq( t.id.map(t => "id" -> t.asJson), t.key.map(t => "key" -> t.asJson), t.value.map(t => "value" -> t.asJson), t.`type`.map(t => "type" -> t.asJson), t.name.map(t => "name" -> t.asJson), t.description.map(t => "description" -> t.asJson), t.system.map(t => "system" -> t.asJson), t.disabled.map(t => "disabled" -> t.asJson) ).flatten) } implicit def decodeApiBuilderPostmanCollectionV21Items: Decoder[Items] = Decoder.instance { c => c.get[Option[String]]("type") match { case Right(Some(s)) if s == "item" => c.as[io.apibuilder.postman.collection.v21.v0.models.Item] case Right(Some(s)) if s == "folder" => c.as[io.apibuilder.postman.collection.v21.v0.models.Folder] case Right(Some(s)) => Right(io.apibuilder.postman.collection.v21.v0.models.ItemsUndefinedType(s)) case _ => Left(DecodingFailure("Union[Items] requires a discriminator named 'type' - this field was not found in the Json", c.history)) } } implicit def encodeApiBuilderPostmanCollectionV21Items: Encoder[Items] = Encoder.instance { case t: io.apibuilder.postman.collection.v21.v0.models.Item => t.asJson.mapObject(obj => ("type", Json.fromString("item")) +: obj) case t: io.apibuilder.postman.collection.v21.v0.models.Folder => t.asJson.mapObject(obj => ("type", Json.fromString("folder")) +: obj) case other => sys.error(s"The type[${other.getClass.getName}] has no JSON encoder") } } }