/** * Generated by API Builder - https://www.apibuilder.io * Service version: 0.0.2-dev * User agent: apibuilder app.apibuilder.io/mard/mard2p-api/0.0.2-dev/http4s_0_18 */ package payp.mard2p.api.v0.models { /** * Account is defined by the app specifically to manage users transactions. * * @param accountid Internal unique identifier for this account. * @param ownerid The username registered in the application * @param totalAmount The amount specific to the debit and sold account. This field allows the process * transactions. * @param currency The currency specific to location. * @param sold The amount specific to the balance account. This field allows the process * transactions. * @param debit The amount specific to the money merchant have to collect and pay. This field * allows the process transactions. */ final case class Account( accountid: Long, ownerid: String, totalAmount: Double, currency: String, sold: Double, debit: Double ) /** * @param accountid Internal unique identifier for this account. * @param ownerid The username registered in the application. * @param totalAmount The amount specific to the debit and sold account. This field allows the process * transactions. * @param sold The amount specific to the balance account. This field allows the process * transactions. * @param debit The amount specific to the money merchant have to collect and pay. This field * allows the process transactions. * @param currency The currency specific to location. */ final case class AccountForm( accountid: Long, ownerid: String, totalAmount: _root_.scala.Option[Double] = None, sold: Double, debit: _root_.scala.Option[Double] = None, currency: String ) /** * Deposit describes a way a payment is handled. It depends of Payment Resource * * @param depid Internal unique identifier for this account. * @param paymentid The added paymentid used to proceed the deposit transaction. */ final case class Deposit( depid: Long, paymentid: Long ) /** * Payment is defined by the app specifically to emit users transactions. * * @param payid Internal unique identifier for this payment. * @param actorid The username registered in the application * @param amount The amount to send. This field allowed the processing transactions. * @param refAccountid The accountid to use to send money to the specific account. * @param paymentMethod The type of payment to use [Mobile Money or Credit Card]. * @param operatorid The operator specified the type of payment if Mobile Money. * @param phone The phone identifying specific account of consumer. * @param pin The code used to validate the transaction. * @param currency The phone identifying specific account of consumer. * @param paymentContext This field specify the type of transaction [Buying, Deposit, Withdraw]. */ final case class Payment( payid: Long, actorid: String, amount: Double, refAccountid: Long, paymentMethod: String, operatorid: String, phone: Long, pin: Int, currency: String, paymentContext: String ) /** * @param payid Internal unique identifier for this payment. * @param actorid The username registered in the application * @param amount The amount to send. This field allowed the processing transactions. * @param refAccountid The accountid to use to send money to the specific account. * @param paymentMethod The type of payment to use [Mobile Money or Credit Card]. * @param operatorid The operator specified the type of payment if Mobile Money. * @param phone The phone identifying specific account of consumer. * @param pin The code used to validate the transaction. * @param currency The phone identifying specific account of consumer. * @param paymentContext This field specify the type of transaction [Buying, Deposit, Withdraw]. */ final case class PaymentForm( payid: Long, actorid: String, amount: Double, refAccountid: Long, paymentMethod: String, operatorid: String, phone: Long, pin: Int, currency: String, paymentContext: String ) /** * Transfer is defined by the app specifically to manage users transactions * (sending and receiving). * * @param transferid Internal unique identifier for this account. * @param senderid The username registered in the application * @param amount The amount to be send. This field allows the process transactions. * @param refAccountidReceiver The accountid to use to send money and referencing the receiver. * @param refAccountidSender The accountid to use to send money and referencing the sender. * @param currency The currency specific to a country. */ final case class Transfer( transferid: Long, senderid: String, amount: Double, refAccountidReceiver: Long, refAccountidSender: Long, currency: String ) /** * @param transferid Internal unique identifier for this account. * @param senderid The username registered in the application. * @param amount The amount to be send. This field allows the process transactions. * @param refAccountidReceiver The accountid to use to send money and referencing the receiver. * @param refAccountidSender The accountid to use to send money and referencing the sender. * @param currency The currency specific to a country. */ final case class TransferForm( transferid: Long, senderid: String, amount: Double, refAccountidReceiver: Long, refAccountidSender: Long, currency: String ) /** * Used only to validate json files - used as a resource where http status code * defines success * * @param valid If true, the json schema is valid. If false, there is at least one validation * error. * @param errors Contains any validation errors that result from parsing the json document. If * empty, the document is valid. */ final case class Validation( valid: Boolean, errors: Seq[String] = Nil ) /** * Withdraw describes a way a payment is handled. It depends of Payment Resource * * @param wdwid Internal unique identifier for this account. * @param paymentid The added paymentid used to proceed the deposit transaction. */ final case class Withdraw( wdwid: Long, paymentid: Long ) sealed trait AppSortBy extends _root_.scala.Product with _root_.scala.Serializable object AppSortBy { case object Created extends AppSortBy { override def toString = "created" } case object Edited extends AppSortBy { override def toString = "edited" } /** * 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 AppSortBy /** * 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[AppSortBy] = scala.List(Created, Edited) private val byName: Map[String, AppSortBy] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): AppSortBy = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[AppSortBy] = byName.get(value.toLowerCase) } sealed trait OriginalType extends _root_.scala.Product with _root_.scala.Serializable object OriginalType { /** * The original is in the api.json format */ case object ApiJson extends OriginalType { override def toString = "api_json" } /** * 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 OriginalType /** * 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[OriginalType] = scala.List(ApiJson) private val byName: Map[String, OriginalType] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): OriginalType = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[OriginalType] = byName.get(value.toLowerCase) } /** * A publication represents something that a user can subscribe to. An example * would be subscribing to an email alert whenever a new version of an application * is created. */ sealed trait Publication extends _root_.scala.Product with _root_.scala.Serializable object Publication { /** * For organizations for which I am an administrator, email me whenever a user * applies to join the org. */ case object MembershipRequestsCreate extends Publication { override def toString = "membership_requests.create" } /** * For organizations for which I am a member, email me whenever a user joins the * org. */ case object MembershipsCreate extends Publication { override def toString = "memberships.create" } /** * For organizations for which I am a member, email me whenever an application is * created. */ case object ApplicationsCreate extends Publication { override def toString = "applications.create" } /** * For applications that I watch, email me whenever a version is created. */ case object VersionsCreate extends Publication { override def toString = "versions.create" } /** * 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 Publication /** * 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[Publication] = scala.List(MembershipRequestsCreate, MembershipsCreate, ApplicationsCreate, VersionsCreate) private val byName: Map[String, Publication] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): Publication = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[Publication] = byName.get(value.toLowerCase) } sealed trait SortOrder extends _root_.scala.Product with _root_.scala.Serializable object SortOrder { case object Asc extends SortOrder { override def toString = "asc" } case object Desc extends SortOrder { override def toString = "desc" } /** * 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 SortOrder /** * 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[SortOrder] = scala.List(Asc, Desc) private val byName: Map[String, SortOrder] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): SortOrder = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[SortOrder] = byName.get(value.toLowerCase) } /** * Controls who is able to view this version */ sealed trait Visibility extends _root_.scala.Product with _root_.scala.Serializable object Visibility { /** * Anybody, including non logged in users, can view this application */ case object Public extends Visibility { override def toString = "public" } /** * 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 Visibility /** * 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[Visibility] = scala.List(Public) private val byName: Map[String, Visibility] = all.map(x => x.toString.toLowerCase -> x).toMap def apply(value: String): Visibility = fromString(value).getOrElse(UNDEFINED(value)) def fromString(value: String): _root_.scala.Option[Visibility] = byName.get(value.toLowerCase) } } package payp.mard2p.api.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.common.v0.models.json._ import io.apibuilder.generator.v0.models.json._ import io.apibuilder.spec.v0.models.json._ import payp.mard2p.api.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 jsonDecoderMard2pAPIAppSortBy: Decoder[payp.mard2p.api.v0.models.AppSortBy] = Decoder.decodeString.map(payp.mard2p.api.v0.models.AppSortBy(_)) implicit val jsonEncoderMard2pAPIAppSortBy: Encoder[payp.mard2p.api.v0.models.AppSortBy] = Encoder.encodeString.contramap[payp.mard2p.api.v0.models.AppSortBy](_.toString) implicit val jsonDecoderMard2pAPIOriginalType: Decoder[payp.mard2p.api.v0.models.OriginalType] = Decoder.decodeString.map(payp.mard2p.api.v0.models.OriginalType(_)) implicit val jsonEncoderMard2pAPIOriginalType: Encoder[payp.mard2p.api.v0.models.OriginalType] = Encoder.encodeString.contramap[payp.mard2p.api.v0.models.OriginalType](_.toString) implicit val jsonDecoderMard2pAPIPublication: Decoder[payp.mard2p.api.v0.models.Publication] = Decoder.decodeString.map(payp.mard2p.api.v0.models.Publication(_)) implicit val jsonEncoderMard2pAPIPublication: Encoder[payp.mard2p.api.v0.models.Publication] = Encoder.encodeString.contramap[payp.mard2p.api.v0.models.Publication](_.toString) implicit val jsonDecoderMard2pAPISortOrder: Decoder[payp.mard2p.api.v0.models.SortOrder] = Decoder.decodeString.map(payp.mard2p.api.v0.models.SortOrder(_)) implicit val jsonEncoderMard2pAPISortOrder: Encoder[payp.mard2p.api.v0.models.SortOrder] = Encoder.encodeString.contramap[payp.mard2p.api.v0.models.SortOrder](_.toString) implicit val jsonDecoderMard2pAPIVisibility: Decoder[payp.mard2p.api.v0.models.Visibility] = Decoder.decodeString.map(payp.mard2p.api.v0.models.Visibility(_)) implicit val jsonEncoderMard2pAPIVisibility: Encoder[payp.mard2p.api.v0.models.Visibility] = Encoder.encodeString.contramap[payp.mard2p.api.v0.models.Visibility](_.toString) implicit def decodeMard2pAPIAccount: Decoder[Account] = Decoder.instance { c => for { accountid <- c.downField("accountid").as[Long] ownerid <- c.downField("ownerid").as[String] totalAmount <- c.downField("total_amount").as[Double] currency <- c.downField("currency").as[String] sold <- c.downField("sold").as[Double] debit <- c.downField("debit").as[Double] } yield { Account( accountid = accountid, ownerid = ownerid, totalAmount = totalAmount, currency = currency, sold = sold, debit = debit ) } } implicit def encodeMard2pAPIAccount: Encoder[Account] = Encoder.instance { t => Json.fromFields(Seq( Some("accountid" -> t.accountid.asJson), Some("ownerid" -> t.ownerid.asJson), Some("total_amount" -> t.totalAmount.asJson), Some("currency" -> t.currency.asJson), Some("sold" -> t.sold.asJson), Some("debit" -> t.debit.asJson) ).flatten) } implicit def decodeMard2pAPIAccountForm: Decoder[AccountForm] = Decoder.instance { c => for { accountid <- c.downField("accountid").as[Long] ownerid <- c.downField("ownerid").as[String] totalAmount <- c.downField("total_amount").as[Option[Double]] sold <- c.downField("sold").as[Double] debit <- c.downField("debit").as[Option[Double]] currency <- c.downField("currency").as[String] } yield { AccountForm( accountid = accountid, ownerid = ownerid, totalAmount = totalAmount, sold = sold, debit = debit, currency = currency ) } } implicit def encodeMard2pAPIAccountForm: Encoder[AccountForm] = Encoder.instance { t => Json.fromFields(Seq( Some("accountid" -> t.accountid.asJson), Some("ownerid" -> t.ownerid.asJson), t.totalAmount.map(t => "total_amount" -> t.asJson), Some("sold" -> t.sold.asJson), t.debit.map(t => "debit" -> t.asJson), Some("currency" -> t.currency.asJson) ).flatten) } implicit def decodeMard2pAPIDeposit: Decoder[Deposit] = Decoder.instance { c => for { depid <- c.downField("depid").as[Long] paymentid <- c.downField("paymentid").as[Long] } yield { Deposit( depid = depid, paymentid = paymentid ) } } implicit def encodeMard2pAPIDeposit: Encoder[Deposit] = Encoder.instance { t => Json.fromFields(Seq( Some("depid" -> t.depid.asJson), Some("paymentid" -> t.paymentid.asJson) ).flatten) } implicit def decodeMard2pAPIPayment: Decoder[Payment] = Decoder.instance { c => for { payid <- c.downField("payid").as[Long] actorid <- c.downField("actorid").as[String] amount <- c.downField("amount").as[Double] refAccountid <- c.downField("ref_accountid").as[Long] paymentMethod <- c.downField("payment_method").as[String] operatorid <- c.downField("operatorid").as[String] phone <- c.downField("phone").as[Long] pin <- c.downField("pin").as[Int] currency <- c.downField("currency").as[String] paymentContext <- c.downField("payment_context").as[String] } yield { Payment( payid = payid, actorid = actorid, amount = amount, refAccountid = refAccountid, paymentMethod = paymentMethod, operatorid = operatorid, phone = phone, pin = pin, currency = currency, paymentContext = paymentContext ) } } implicit def encodeMard2pAPIPayment: Encoder[Payment] = Encoder.instance { t => Json.fromFields(Seq( Some("payid" -> t.payid.asJson), Some("actorid" -> t.actorid.asJson), Some("amount" -> t.amount.asJson), Some("ref_accountid" -> t.refAccountid.asJson), Some("payment_method" -> t.paymentMethod.asJson), Some("operatorid" -> t.operatorid.asJson), Some("phone" -> t.phone.asJson), Some("pin" -> t.pin.asJson), Some("currency" -> t.currency.asJson), Some("payment_context" -> t.paymentContext.asJson) ).flatten) } implicit def decodeMard2pAPIPaymentForm: Decoder[PaymentForm] = Decoder.instance { c => for { payid <- c.downField("payid").as[Long] actorid <- c.downField("actorid").as[String] amount <- c.downField("amount").as[Double] refAccountid <- c.downField("ref_accountid").as[Long] paymentMethod <- c.downField("payment_method").as[String] operatorid <- c.downField("operatorid").as[String] phone <- c.downField("phone").as[Long] pin <- c.downField("pin").as[Int] currency <- c.downField("currency").as[String] paymentContext <- c.downField("payment_context").as[String] } yield { PaymentForm( payid = payid, actorid = actorid, amount = amount, refAccountid = refAccountid, paymentMethod = paymentMethod, operatorid = operatorid, phone = phone, pin = pin, currency = currency, paymentContext = paymentContext ) } } implicit def encodeMard2pAPIPaymentForm: Encoder[PaymentForm] = Encoder.instance { t => Json.fromFields(Seq( Some("payid" -> t.payid.asJson), Some("actorid" -> t.actorid.asJson), Some("amount" -> t.amount.asJson), Some("ref_accountid" -> t.refAccountid.asJson), Some("payment_method" -> t.paymentMethod.asJson), Some("operatorid" -> t.operatorid.asJson), Some("phone" -> t.phone.asJson), Some("pin" -> t.pin.asJson), Some("currency" -> t.currency.asJson), Some("payment_context" -> t.paymentContext.asJson) ).flatten) } implicit def decodeMard2pAPITransfer: Decoder[Transfer] = Decoder.instance { c => for { transferid <- c.downField("transferid").as[Long] senderid <- c.downField("senderid").as[String] amount <- c.downField("amount").as[Double] refAccountidReceiver <- c.downField("ref_accountid_receiver").as[Long] refAccountidSender <- c.downField("ref_accountid_sender").as[Long] currency <- c.downField("currency").as[String] } yield { Transfer( transferid = transferid, senderid = senderid, amount = amount, refAccountidReceiver = refAccountidReceiver, refAccountidSender = refAccountidSender, currency = currency ) } } implicit def encodeMard2pAPITransfer: Encoder[Transfer] = Encoder.instance { t => Json.fromFields(Seq( Some("transferid" -> t.transferid.asJson), Some("senderid" -> t.senderid.asJson), Some("amount" -> t.amount.asJson), Some("ref_accountid_receiver" -> t.refAccountidReceiver.asJson), Some("ref_accountid_sender" -> t.refAccountidSender.asJson), Some("currency" -> t.currency.asJson) ).flatten) } implicit def decodeMard2pAPITransferForm: Decoder[TransferForm] = Decoder.instance { c => for { transferid <- c.downField("transferid").as[Long] senderid <- c.downField("senderid").as[String] amount <- c.downField("amount").as[Double] refAccountidReceiver <- c.downField("ref_accountid_receiver").as[Long] refAccountidSender <- c.downField("ref_accountid_sender").as[Long] currency <- c.downField("currency").as[String] } yield { TransferForm( transferid = transferid, senderid = senderid, amount = amount, refAccountidReceiver = refAccountidReceiver, refAccountidSender = refAccountidSender, currency = currency ) } } implicit def encodeMard2pAPITransferForm: Encoder[TransferForm] = Encoder.instance { t => Json.fromFields(Seq( Some("transferid" -> t.transferid.asJson), Some("senderid" -> t.senderid.asJson), Some("amount" -> t.amount.asJson), Some("ref_accountid_receiver" -> t.refAccountidReceiver.asJson), Some("ref_accountid_sender" -> t.refAccountidSender.asJson), Some("currency" -> t.currency.asJson) ).flatten) } implicit def decodeMard2pAPIValidation: Decoder[Validation] = Decoder.instance { c => for { valid <- c.downField("valid").as[Boolean] errors <- c.downField("errors").as[Seq[String]] } yield { Validation( valid = valid, errors = errors ) } } implicit def encodeMard2pAPIValidation: Encoder[Validation] = Encoder.instance { t => Json.fromFields(Seq( Some("valid" -> t.valid.asJson), Some("errors" -> t.errors.asJson) ).flatten) } implicit def decodeMard2pAPIWithdraw: Decoder[Withdraw] = Decoder.instance { c => for { wdwid <- c.downField("wdwid").as[Long] paymentid <- c.downField("paymentid").as[Long] } yield { Withdraw( wdwid = wdwid, paymentid = paymentid ) } } implicit def encodeMard2pAPIWithdraw: Encoder[Withdraw] = Encoder.instance { t => Json.fromFields(Seq( Some("wdwid" -> t.wdwid.asJson), Some("paymentid" -> t.paymentid.asJson) ).flatten) } } }