1 /*
2  *  Make.org Core API
3  *  Copyright (C) 2021 Make.org
4  *
5  * This program is free software: you can redistribute it and/or modify
6  *  it under the terms of the GNU Affero General Public License as
7  *  published by the Free Software Foundation, either version 3 of the
8  *  License, or (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU Affero General Public License for more details.
14  *
15  *  You should have received a copy of the GNU Affero General Public License
16  *  along with this program.  If not, see <https://www.gnu.org/licenses/>.
17  *
18  */
19 
20 package org.make.api.question
21 
22 import io.circe.Codec
23 import io.circe.generic.semiauto.deriveCodec
24 import io.swagger.annotations.ApiModelProperty
25 import org.make.core.tag.TagId
26 
27 import scala.annotation.meta.field
28 
29 final case class PopularTagResponse(
30   @(ApiModelProperty @field)(dataType = "string", example = "11111111-2222-3333-4444-555555555555", required = true)
31   tagId: TagId,
32   label: String,
33   proposalCount: Long
34 )
35 
36 object PopularTagResponse {
37 
38   implicit val codec: Codec[PopularTagResponse] = deriveCodec
39 }
Line Stmt Id Pos Tree Symbol Tests Code
38 8784 1249 - 1260 ApplyToImplicitArgs io.circe.generic.semiauto.deriveCodec org.make.api.question.questionapitest io.circe.generic.semiauto.deriveCodec[org.make.api.question.PopularTagResponse]({ val inst$macro$16: io.circe.generic.codec.DerivedAsObjectCodec[org.make.api.question.PopularTagResponse] = { final class anon$lazy$macro$15 extends AnyRef with Serializable { def <init>(): anon$lazy$macro$15 = { anon$lazy$macro$15.super.<init>(); () }; <stable> <accessor> lazy val inst$macro$1: io.circe.generic.codec.DerivedAsObjectCodec[org.make.api.question.PopularTagResponse] = codec.this.DerivedAsObjectCodec.deriveCodec[org.make.api.question.PopularTagResponse, shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](shapeless.this.LabelledGeneric.materializeProduct[org.make.api.question.PopularTagResponse, (Symbol @@ String("tagId")) :: (Symbol @@ String("label")) :: (Symbol @@ String("proposalCount")) :: shapeless.HNil, org.make.core.tag.TagId :: String :: Long :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](DefaultSymbolicLabelling.instance[org.make.api.question.PopularTagResponse, (Symbol @@ String("tagId")) :: (Symbol @@ String("label")) :: (Symbol @@ String("proposalCount")) :: shapeless.HNil](::.apply[Symbol @@ String("tagId"), (Symbol @@ String("label")) :: (Symbol @@ String("proposalCount")) :: shapeless.HNil.type](scala.Symbol.apply("tagId").asInstanceOf[Symbol @@ String("tagId")], ::.apply[Symbol @@ String("label"), (Symbol @@ String("proposalCount")) :: shapeless.HNil.type](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")], ::.apply[Symbol @@ String("proposalCount"), shapeless.HNil.type](scala.Symbol.apply("proposalCount").asInstanceOf[Symbol @@ String("proposalCount")], HNil)))), Generic.instance[org.make.api.question.PopularTagResponse, org.make.core.tag.TagId :: String :: Long :: shapeless.HNil](((x0$3: org.make.api.question.PopularTagResponse) => x0$3 match { case (tagId: org.make.core.tag.TagId, label: String, proposalCount: Long): org.make.api.question.PopularTagResponse((tagId$macro$11 @ _), (label$macro$12 @ _), (proposalCount$macro$13 @ _)) => ::.apply[org.make.core.tag.TagId, String :: Long :: shapeless.HNil.type](tagId$macro$11, ::.apply[String, Long :: shapeless.HNil.type](label$macro$12, ::.apply[Long, shapeless.HNil.type](proposalCount$macro$13, HNil))).asInstanceOf[org.make.core.tag.TagId :: String :: Long :: shapeless.HNil] }), ((x0$4: org.make.core.tag.TagId :: String :: Long :: shapeless.HNil) => x0$4 match { case (head: org.make.core.tag.TagId, tail: String :: Long :: shapeless.HNil): org.make.core.tag.TagId :: String :: Long :: shapeless.HNil((tagId$macro$8 @ _), (head: String, tail: Long :: shapeless.HNil): String :: Long :: shapeless.HNil((label$macro$9 @ _), (head: Long, tail: shapeless.HNil): Long :: shapeless.HNil((proposalCount$macro$10 @ _), HNil))) => question.this.PopularTagResponse.apply(tagId$macro$8, label$macro$9, proposalCount$macro$10) })), hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("tagId"), org.make.core.tag.TagId, (Symbol @@ String("label")) :: (Symbol @@ String("proposalCount")) :: shapeless.HNil, String :: Long :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("label"), String, (Symbol @@ String("proposalCount")) :: shapeless.HNil, Long :: shapeless.HNil, shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hconsZipWithKeys[Symbol @@ String("proposalCount"), Long, shapeless.HNil, shapeless.HNil, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out](hlist.this.ZipWithKeys.hnilZipWithKeys, Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("proposalCount")]](scala.Symbol.apply("proposalCount").asInstanceOf[Symbol @@ String("proposalCount")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("proposalCount")]])), Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("label")]](scala.Symbol.apply("label").asInstanceOf[Symbol @@ String("label")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("label")]])), Witness.mkWitness[Symbol with shapeless.tag.Tagged[String("tagId")]](scala.Symbol.apply("tagId").asInstanceOf[Symbol @@ String("tagId")].asInstanceOf[Symbol with shapeless.tag.Tagged[String("tagId")]])), scala.this.<:<.refl[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]), shapeless.Lazy.apply[io.circe.generic.codec.ReprAsObjectCodec[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]](anon$lazy$macro$15.this.inst$macro$14)).asInstanceOf[io.circe.generic.codec.DerivedAsObjectCodec[org.make.api.question.PopularTagResponse]]; <stable> <accessor> lazy val inst$macro$14: io.circe.generic.codec.ReprAsObjectCodec[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ({ final class $anon extends io.circe.generic.codec.ReprAsObjectCodec[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] { def <init>(): <$anon: io.circe.generic.codec.ReprAsObjectCodec[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]> = { $anon.super.<init>(); () }; private[this] val circeGenericDecoderFortagId: io.circe.Decoder[org.make.core.tag.TagId] = tag.this.TagId.tagIdDecoder; private[this] val circeGenericDecoderForlabel: io.circe.Decoder[String] = circe.this.Decoder.decodeString; private[this] val circeGenericDecoderForproposalCount: io.circe.Decoder[Long] = circe.this.Decoder.decodeLong; private[this] val circeGenericEncoderFortagId: io.circe.Encoder[org.make.core.tag.TagId] = tag.this.TagId.tagIdEncoder; private[this] val circeGenericEncoderForlabel: io.circe.Encoder[String] = circe.this.Encoder.encodeString; private[this] val circeGenericEncoderForproposalCount: io.circe.Encoder[Long] = circe.this.Encoder.encodeLong; final def encodeObject(a: shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out): io.circe.JsonObject = a match { case (head: shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId], tail: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out): shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out((circeGenericHListBindingFortagId @ _), (head: shapeless.labelled.FieldType[Symbol @@ String("label"),String], tail: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out): shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out((circeGenericHListBindingForlabel @ _), (head: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long], tail: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out): shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out((circeGenericHListBindingForproposalCount @ _), shapeless.HNil))) => io.circe.JsonObject.fromIterable(scala.collection.immutable.Vector.apply[(String, io.circe.Json)](scala.Tuple2.apply[String, io.circe.Json]("tagId", $anon.this.circeGenericEncoderFortagId.apply(circeGenericHListBindingFortagId)), scala.Tuple2.apply[String, io.circe.Json]("label", $anon.this.circeGenericEncoderForlabel.apply(circeGenericHListBindingForlabel)), scala.Tuple2.apply[String, io.circe.Json]("proposalCount", $anon.this.circeGenericEncoderForproposalCount.apply(circeGenericHListBindingForproposalCount)))) }; final def apply(c: io.circe.HCursor): io.circe.Decoder.Result[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("tagId"), org.make.core.tag.TagId, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderFortagId.tryDecode(c.downField("tagId")), ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForlabel.tryDecode(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.Result, Symbol @@ String("proposalCount"), Long, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForproposalCount.tryDecode(c.downField("proposalCount")), ReprDecoder.hnilResult)(io.circe.Decoder.resultInstance))(io.circe.Decoder.resultInstance))(io.circe.Decoder.resultInstance); final override def decodeAccumulating(c: io.circe.HCursor): io.circe.Decoder.AccumulatingResult[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out] = ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("tagId"), org.make.core.tag.TagId, shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderFortagId.tryDecodeAccumulating(c.downField("tagId")), ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("label"), String, shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForlabel.tryDecodeAccumulating(c.downField("label")), ReprDecoder.consResults[io.circe.Decoder.AccumulatingResult, Symbol @@ String("proposalCount"), Long, shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]($anon.this.circeGenericDecoderForproposalCount.tryDecodeAccumulating(c.downField("proposalCount")), ReprDecoder.hnilResultAccumulating)(io.circe.Decoder.accumulatingResultInstance))(io.circe.Decoder.accumulatingResultInstance))(io.circe.Decoder.accumulatingResultInstance) }; new $anon() }: io.circe.generic.codec.ReprAsObjectCodec[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]).asInstanceOf[io.circe.generic.codec.ReprAsObjectCodec[shapeless.labelled.FieldType[Symbol @@ String("tagId"),org.make.core.tag.TagId] :: shapeless.labelled.FieldType[Symbol @@ String("label"),String] :: shapeless.labelled.FieldType[Symbol @@ String("proposalCount"),Long] :: shapeless.ops.hlist.ZipWithKeys.hnilZipWithKeys.Out]] }; new anon$lazy$macro$15().inst$macro$1 }; shapeless.Lazy.apply[io.circe.generic.codec.DerivedAsObjectCodec[org.make.api.question.PopularTagResponse]](inst$macro$16) })