/** * 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/play_2_x_scala_3_json */ 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 play.api.libs.json.__ import play.api.libs.json.JsString import play.api.libs.json.Writes import play.api.libs.functional.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._ private[v0] implicit val jsonReadsUUID: play.api.libs.json.Reads[_root_.java.util.UUID] = __.read[String].map { str => _root_.java.util.UUID.fromString(str) } private[v0] implicit val jsonWritesUUID: play.api.libs.json.Writes[_root_.java.util.UUID] = (x: _root_.java.util.UUID) => play.api.libs.json.JsString(x.toString) private[v0] implicit val jsonReadsJodaDateTime: play.api.libs.json.Reads[_root_.org.joda.time.DateTime] = __.read[String].map { str => _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(str) } private[v0] implicit val jsonWritesJodaDateTime: play.api.libs.json.Writes[_root_.org.joda.time.DateTime] = (x: _root_.org.joda.time.DateTime) => { play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(x)) } private[v0] implicit val jsonReadsJodaLocalDate: play.api.libs.json.Reads[_root_.org.joda.time.LocalDate] = __.read[String].map { str => _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(str) } private[v0] implicit val jsonWritesJodaLocalDate: play.api.libs.json.Writes[_root_.org.joda.time.LocalDate] = (x: _root_.org.joda.time.LocalDate) => { play.api.libs.json.JsString(_root_.org.joda.time.format.ISODateTimeFormat.date.print(x)) } implicit val jsonReadsMard2pAPIAppSortBy: play.api.libs.json.Reads[payp.mard2p.api.v0.models.AppSortBy] = new play.api.libs.json.Reads[payp.mard2p.api.v0.models.AppSortBy] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[payp.mard2p.api.v0.models.AppSortBy] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.AppSortBy(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.AppSortBy(v)) case _: play.api.libs.json.JsError => (js \ "app_sort_by").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.AppSortBy(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesMard2pAPIAppSortBy(obj: payp.mard2p.api.v0.models.AppSortBy) = { play.api.libs.json.JsString(obj.toString) } def jsObjectAppSortBy(obj: payp.mard2p.api.v0.models.AppSortBy) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesMard2pAPIAppSortBy: play.api.libs.json.Writes[AppSortBy] = { (obj: payp.mard2p.api.v0.models.AppSortBy) => { payp.mard2p.api.v0.models.json.jsonWritesMard2pAPIAppSortBy(obj) } } implicit val jsonReadsMard2pAPIOriginalType: play.api.libs.json.Reads[payp.mard2p.api.v0.models.OriginalType] = new play.api.libs.json.Reads[payp.mard2p.api.v0.models.OriginalType] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[payp.mard2p.api.v0.models.OriginalType] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.OriginalType(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.OriginalType(v)) case _: play.api.libs.json.JsError => (js \ "original_type").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.OriginalType(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesMard2pAPIOriginalType(obj: payp.mard2p.api.v0.models.OriginalType) = { play.api.libs.json.JsString(obj.toString) } def jsObjectOriginalType(obj: payp.mard2p.api.v0.models.OriginalType) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesMard2pAPIOriginalType: play.api.libs.json.Writes[OriginalType] = { (obj: payp.mard2p.api.v0.models.OriginalType) => { payp.mard2p.api.v0.models.json.jsonWritesMard2pAPIOriginalType(obj) } } implicit val jsonReadsMard2pAPIPublication: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Publication] = new play.api.libs.json.Reads[payp.mard2p.api.v0.models.Publication] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[payp.mard2p.api.v0.models.Publication] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.Publication(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.Publication(v)) case _: play.api.libs.json.JsError => (js \ "publication").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.Publication(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesMard2pAPIPublication(obj: payp.mard2p.api.v0.models.Publication) = { play.api.libs.json.JsString(obj.toString) } def jsObjectPublication(obj: payp.mard2p.api.v0.models.Publication) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesMard2pAPIPublication: play.api.libs.json.Writes[Publication] = { (obj: payp.mard2p.api.v0.models.Publication) => { payp.mard2p.api.v0.models.json.jsonWritesMard2pAPIPublication(obj) } } implicit val jsonReadsMard2pAPISortOrder: play.api.libs.json.Reads[payp.mard2p.api.v0.models.SortOrder] = new play.api.libs.json.Reads[payp.mard2p.api.v0.models.SortOrder] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[payp.mard2p.api.v0.models.SortOrder] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.SortOrder(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.SortOrder(v)) case _: play.api.libs.json.JsError => (js \ "sort_order").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.SortOrder(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesMard2pAPISortOrder(obj: payp.mard2p.api.v0.models.SortOrder) = { play.api.libs.json.JsString(obj.toString) } def jsObjectSortOrder(obj: payp.mard2p.api.v0.models.SortOrder) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesMard2pAPISortOrder: play.api.libs.json.Writes[SortOrder] = { (obj: payp.mard2p.api.v0.models.SortOrder) => { payp.mard2p.api.v0.models.json.jsonWritesMard2pAPISortOrder(obj) } } implicit val jsonReadsMard2pAPIVisibility: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Visibility] = new play.api.libs.json.Reads[payp.mard2p.api.v0.models.Visibility] { def reads(js: play.api.libs.json.JsValue): play.api.libs.json.JsResult[payp.mard2p.api.v0.models.Visibility] = { js match { case v: play.api.libs.json.JsString => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.Visibility(v.value)) case _ => { (js \ "value").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.Visibility(v)) case _: play.api.libs.json.JsError => (js \ "visibility").validate[String] match { case play.api.libs.json.JsSuccess(v, _) => play.api.libs.json.JsSuccess(payp.mard2p.api.v0.models.Visibility(v)) case err: play.api.libs.json.JsError => err } } } } } } def jsonWritesMard2pAPIVisibility(obj: payp.mard2p.api.v0.models.Visibility) = { play.api.libs.json.JsString(obj.toString) } def jsObjectVisibility(obj: payp.mard2p.api.v0.models.Visibility) = { play.api.libs.json.Json.obj("value" -> play.api.libs.json.JsString(obj.toString)) } implicit def jsonWritesMard2pAPIVisibility: play.api.libs.json.Writes[Visibility] = { (obj: payp.mard2p.api.v0.models.Visibility) => { payp.mard2p.api.v0.models.json.jsonWritesMard2pAPIVisibility(obj) } } implicit def jsonReadsMard2pAPIAccount: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Account] = { for { accountid <- (__ \ "accountid").read[Long] ownerid <- (__ \ "ownerid").read[String] totalAmount <- (__ \ "total_amount").read[Double] currency <- (__ \ "currency").read[String] sold <- (__ \ "sold").read[Double] debit <- (__ \ "debit").read[Double] } yield Account(accountid, ownerid, totalAmount, currency, sold, debit) } def jsObjectAccount(obj: payp.mard2p.api.v0.models.Account): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "accountid" -> play.api.libs.json.JsNumber(obj.accountid), "ownerid" -> play.api.libs.json.JsString(obj.ownerid), "total_amount" -> play.api.libs.json.JsNumber(obj.totalAmount), "currency" -> play.api.libs.json.JsString(obj.currency), "sold" -> play.api.libs.json.JsNumber(obj.sold), "debit" -> play.api.libs.json.JsNumber(obj.debit) ) } implicit def jsonWritesMard2pAPIAccount: play.api.libs.json.Writes[Account] = { (obj: payp.mard2p.api.v0.models.Account) => { payp.mard2p.api.v0.models.json.jsObjectAccount(obj) } } implicit def jsonReadsMard2pAPIAccountForm: play.api.libs.json.Reads[payp.mard2p.api.v0.models.AccountForm] = { for { accountid <- (__ \ "accountid").read[Long] ownerid <- (__ \ "ownerid").read[String] totalAmount <- (__ \ "total_amount").readNullable[Double] sold <- (__ \ "sold").read[Double] debit <- (__ \ "debit").readNullable[Double] currency <- (__ \ "currency").read[String] } yield AccountForm(accountid, ownerid, totalAmount, sold, debit, currency) } def jsObjectAccountForm(obj: payp.mard2p.api.v0.models.AccountForm): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "accountid" -> play.api.libs.json.JsNumber(obj.accountid), "ownerid" -> play.api.libs.json.JsString(obj.ownerid), "sold" -> play.api.libs.json.JsNumber(obj.sold), "currency" -> play.api.libs.json.JsString(obj.currency) ) ++ (obj.totalAmount match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("total_amount" -> play.api.libs.json.JsNumber(x)) }) ++ (obj.debit match { case None => play.api.libs.json.Json.obj() case Some(x) => play.api.libs.json.Json.obj("debit" -> play.api.libs.json.JsNumber(x)) }) } implicit def jsonWritesMard2pAPIAccountForm: play.api.libs.json.Writes[AccountForm] = { (obj: payp.mard2p.api.v0.models.AccountForm) => { payp.mard2p.api.v0.models.json.jsObjectAccountForm(obj) } } implicit def jsonReadsMard2pAPIDeposit: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Deposit] = { for { depid <- (__ \ "depid").read[Long] paymentid <- (__ \ "paymentid").read[Long] } yield Deposit(depid, paymentid) } def jsObjectDeposit(obj: payp.mard2p.api.v0.models.Deposit): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "depid" -> play.api.libs.json.JsNumber(obj.depid), "paymentid" -> play.api.libs.json.JsNumber(obj.paymentid) ) } implicit def jsonWritesMard2pAPIDeposit: play.api.libs.json.Writes[Deposit] = { (obj: payp.mard2p.api.v0.models.Deposit) => { payp.mard2p.api.v0.models.json.jsObjectDeposit(obj) } } implicit def jsonReadsMard2pAPIPayment: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Payment] = { for { payid <- (__ \ "payid").read[Long] actorid <- (__ \ "actorid").read[String] amount <- (__ \ "amount").read[Double] refAccountid <- (__ \ "ref_accountid").read[Long] paymentMethod <- (__ \ "payment_method").read[String] operatorid <- (__ \ "operatorid").read[String] phone <- (__ \ "phone").read[Long] pin <- (__ \ "pin").read[Int] currency <- (__ \ "currency").read[String] paymentContext <- (__ \ "payment_context").read[String] } yield Payment(payid, actorid, amount, refAccountid, paymentMethod, operatorid, phone, pin, currency, paymentContext) } def jsObjectPayment(obj: payp.mard2p.api.v0.models.Payment): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "payid" -> play.api.libs.json.JsNumber(obj.payid), "actorid" -> play.api.libs.json.JsString(obj.actorid), "amount" -> play.api.libs.json.JsNumber(obj.amount), "ref_accountid" -> play.api.libs.json.JsNumber(obj.refAccountid), "payment_method" -> play.api.libs.json.JsString(obj.paymentMethod), "operatorid" -> play.api.libs.json.JsString(obj.operatorid), "phone" -> play.api.libs.json.JsNumber(obj.phone), "pin" -> play.api.libs.json.JsNumber(obj.pin), "currency" -> play.api.libs.json.JsString(obj.currency), "payment_context" -> play.api.libs.json.JsString(obj.paymentContext) ) } implicit def jsonWritesMard2pAPIPayment: play.api.libs.json.Writes[Payment] = { (obj: payp.mard2p.api.v0.models.Payment) => { payp.mard2p.api.v0.models.json.jsObjectPayment(obj) } } implicit def jsonReadsMard2pAPIPaymentForm: play.api.libs.json.Reads[payp.mard2p.api.v0.models.PaymentForm] = { for { payid <- (__ \ "payid").read[Long] actorid <- (__ \ "actorid").read[String] amount <- (__ \ "amount").read[Double] refAccountid <- (__ \ "ref_accountid").read[Long] paymentMethod <- (__ \ "payment_method").read[String] operatorid <- (__ \ "operatorid").read[String] phone <- (__ \ "phone").read[Long] pin <- (__ \ "pin").read[Int] currency <- (__ \ "currency").read[String] paymentContext <- (__ \ "payment_context").read[String] } yield PaymentForm(payid, actorid, amount, refAccountid, paymentMethod, operatorid, phone, pin, currency, paymentContext) } def jsObjectPaymentForm(obj: payp.mard2p.api.v0.models.PaymentForm): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "payid" -> play.api.libs.json.JsNumber(obj.payid), "actorid" -> play.api.libs.json.JsString(obj.actorid), "amount" -> play.api.libs.json.JsNumber(obj.amount), "ref_accountid" -> play.api.libs.json.JsNumber(obj.refAccountid), "payment_method" -> play.api.libs.json.JsString(obj.paymentMethod), "operatorid" -> play.api.libs.json.JsString(obj.operatorid), "phone" -> play.api.libs.json.JsNumber(obj.phone), "pin" -> play.api.libs.json.JsNumber(obj.pin), "currency" -> play.api.libs.json.JsString(obj.currency), "payment_context" -> play.api.libs.json.JsString(obj.paymentContext) ) } implicit def jsonWritesMard2pAPIPaymentForm: play.api.libs.json.Writes[PaymentForm] = { (obj: payp.mard2p.api.v0.models.PaymentForm) => { payp.mard2p.api.v0.models.json.jsObjectPaymentForm(obj) } } implicit def jsonReadsMard2pAPITransfer: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Transfer] = { for { transferid <- (__ \ "transferid").read[Long] senderid <- (__ \ "senderid").read[String] amount <- (__ \ "amount").read[Double] refAccountidReceiver <- (__ \ "ref_accountid_receiver").read[Long] refAccountidSender <- (__ \ "ref_accountid_sender").read[Long] currency <- (__ \ "currency").read[String] } yield Transfer(transferid, senderid, amount, refAccountidReceiver, refAccountidSender, currency) } def jsObjectTransfer(obj: payp.mard2p.api.v0.models.Transfer): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "transferid" -> play.api.libs.json.JsNumber(obj.transferid), "senderid" -> play.api.libs.json.JsString(obj.senderid), "amount" -> play.api.libs.json.JsNumber(obj.amount), "ref_accountid_receiver" -> play.api.libs.json.JsNumber(obj.refAccountidReceiver), "ref_accountid_sender" -> play.api.libs.json.JsNumber(obj.refAccountidSender), "currency" -> play.api.libs.json.JsString(obj.currency) ) } implicit def jsonWritesMard2pAPITransfer: play.api.libs.json.Writes[Transfer] = { (obj: payp.mard2p.api.v0.models.Transfer) => { payp.mard2p.api.v0.models.json.jsObjectTransfer(obj) } } implicit def jsonReadsMard2pAPITransferForm: play.api.libs.json.Reads[payp.mard2p.api.v0.models.TransferForm] = { for { transferid <- (__ \ "transferid").read[Long] senderid <- (__ \ "senderid").read[String] amount <- (__ \ "amount").read[Double] refAccountidReceiver <- (__ \ "ref_accountid_receiver").read[Long] refAccountidSender <- (__ \ "ref_accountid_sender").read[Long] currency <- (__ \ "currency").read[String] } yield TransferForm(transferid, senderid, amount, refAccountidReceiver, refAccountidSender, currency) } def jsObjectTransferForm(obj: payp.mard2p.api.v0.models.TransferForm): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "transferid" -> play.api.libs.json.JsNumber(obj.transferid), "senderid" -> play.api.libs.json.JsString(obj.senderid), "amount" -> play.api.libs.json.JsNumber(obj.amount), "ref_accountid_receiver" -> play.api.libs.json.JsNumber(obj.refAccountidReceiver), "ref_accountid_sender" -> play.api.libs.json.JsNumber(obj.refAccountidSender), "currency" -> play.api.libs.json.JsString(obj.currency) ) } implicit def jsonWritesMard2pAPITransferForm: play.api.libs.json.Writes[TransferForm] = { (obj: payp.mard2p.api.v0.models.TransferForm) => { payp.mard2p.api.v0.models.json.jsObjectTransferForm(obj) } } implicit def jsonReadsMard2pAPIValidation: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Validation] = { for { valid <- (__ \ "valid").read[Boolean] errors <- (__ \ "errors").read[Seq[String]] } yield Validation(valid, errors) } def jsObjectValidation(obj: payp.mard2p.api.v0.models.Validation): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "valid" -> play.api.libs.json.JsBoolean(obj.valid), "errors" -> play.api.libs.json.Json.toJson(obj.errors) ) } implicit def jsonWritesMard2pAPIValidation: play.api.libs.json.Writes[Validation] = { (obj: payp.mard2p.api.v0.models.Validation) => { payp.mard2p.api.v0.models.json.jsObjectValidation(obj) } } implicit def jsonReadsMard2pAPIWithdraw: play.api.libs.json.Reads[payp.mard2p.api.v0.models.Withdraw] = { for { wdwid <- (__ \ "wdwid").read[Long] paymentid <- (__ \ "paymentid").read[Long] } yield Withdraw(wdwid, paymentid) } def jsObjectWithdraw(obj: payp.mard2p.api.v0.models.Withdraw): play.api.libs.json.JsObject = { play.api.libs.json.Json.obj( "wdwid" -> play.api.libs.json.JsNumber(obj.wdwid), "paymentid" -> play.api.libs.json.JsNumber(obj.paymentid) ) } implicit def jsonWritesMard2pAPIWithdraw: play.api.libs.json.Writes[Withdraw] = { (obj: payp.mard2p.api.v0.models.Withdraw) => { payp.mard2p.api.v0.models.json.jsObjectWithdraw(obj) } } } } package payp.mard2p.api.v0 { object Bindables { import play.api.mvc.{PathBindable, QueryStringBindable} // import models directly for backwards compatibility with prior versions of the generator import Core._ import Models._ object Core { implicit def pathBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.DateTime] = ApibuilderPathBindable(ApibuilderTypes.dateTimeIso8601) implicit def queryStringBindableDateTimeIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.DateTime] = ApibuilderQueryStringBindable(ApibuilderTypes.dateTimeIso8601) implicit def pathBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): PathBindable[_root_.org.joda.time.LocalDate] = ApibuilderPathBindable(ApibuilderTypes.dateIso8601) implicit def queryStringBindableDateIso8601(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[_root_.org.joda.time.LocalDate] = ApibuilderQueryStringBindable(ApibuilderTypes.dateIso8601) } object Models { import payp.mard2p.api.v0.models._ val appSortByConverter: ApibuilderTypeConverter[payp.mard2p.api.v0.models.AppSortBy] = new ApibuilderTypeConverter[payp.mard2p.api.v0.models.AppSortBy] { override def convert(value: String): payp.mard2p.api.v0.models.AppSortBy = payp.mard2p.api.v0.models.AppSortBy(value) override def convert(value: payp.mard2p.api.v0.models.AppSortBy): String = value.toString override def example: payp.mard2p.api.v0.models.AppSortBy = payp.mard2p.api.v0.models.AppSortBy.Created override def validValues: Seq[payp.mard2p.api.v0.models.AppSortBy] = payp.mard2p.api.v0.models.AppSortBy.all } implicit def pathBindableAppSortBy(implicit stringBinder: QueryStringBindable[String]): PathBindable[payp.mard2p.api.v0.models.AppSortBy] = ApibuilderPathBindable(appSortByConverter) implicit def queryStringBindableAppSortBy(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[payp.mard2p.api.v0.models.AppSortBy] = ApibuilderQueryStringBindable(appSortByConverter) val originalTypeConverter: ApibuilderTypeConverter[payp.mard2p.api.v0.models.OriginalType] = new ApibuilderTypeConverter[payp.mard2p.api.v0.models.OriginalType] { override def convert(value: String): payp.mard2p.api.v0.models.OriginalType = payp.mard2p.api.v0.models.OriginalType(value) override def convert(value: payp.mard2p.api.v0.models.OriginalType): String = value.toString override def example: payp.mard2p.api.v0.models.OriginalType = payp.mard2p.api.v0.models.OriginalType.ApiJson override def validValues: Seq[payp.mard2p.api.v0.models.OriginalType] = payp.mard2p.api.v0.models.OriginalType.all } implicit def pathBindableOriginalType(implicit stringBinder: QueryStringBindable[String]): PathBindable[payp.mard2p.api.v0.models.OriginalType] = ApibuilderPathBindable(originalTypeConverter) implicit def queryStringBindableOriginalType(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[payp.mard2p.api.v0.models.OriginalType] = ApibuilderQueryStringBindable(originalTypeConverter) val publicationConverter: ApibuilderTypeConverter[payp.mard2p.api.v0.models.Publication] = new ApibuilderTypeConverter[payp.mard2p.api.v0.models.Publication] { override def convert(value: String): payp.mard2p.api.v0.models.Publication = payp.mard2p.api.v0.models.Publication(value) override def convert(value: payp.mard2p.api.v0.models.Publication): String = value.toString override def example: payp.mard2p.api.v0.models.Publication = payp.mard2p.api.v0.models.Publication.MembershipRequestsCreate override def validValues: Seq[payp.mard2p.api.v0.models.Publication] = payp.mard2p.api.v0.models.Publication.all } implicit def pathBindablePublication(implicit stringBinder: QueryStringBindable[String]): PathBindable[payp.mard2p.api.v0.models.Publication] = ApibuilderPathBindable(publicationConverter) implicit def queryStringBindablePublication(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[payp.mard2p.api.v0.models.Publication] = ApibuilderQueryStringBindable(publicationConverter) val sortOrderConverter: ApibuilderTypeConverter[payp.mard2p.api.v0.models.SortOrder] = new ApibuilderTypeConverter[payp.mard2p.api.v0.models.SortOrder] { override def convert(value: String): payp.mard2p.api.v0.models.SortOrder = payp.mard2p.api.v0.models.SortOrder(value) override def convert(value: payp.mard2p.api.v0.models.SortOrder): String = value.toString override def example: payp.mard2p.api.v0.models.SortOrder = payp.mard2p.api.v0.models.SortOrder.Asc override def validValues: Seq[payp.mard2p.api.v0.models.SortOrder] = payp.mard2p.api.v0.models.SortOrder.all } implicit def pathBindableSortOrder(implicit stringBinder: QueryStringBindable[String]): PathBindable[payp.mard2p.api.v0.models.SortOrder] = ApibuilderPathBindable(sortOrderConverter) implicit def queryStringBindableSortOrder(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[payp.mard2p.api.v0.models.SortOrder] = ApibuilderQueryStringBindable(sortOrderConverter) val visibilityConverter: ApibuilderTypeConverter[payp.mard2p.api.v0.models.Visibility] = new ApibuilderTypeConverter[payp.mard2p.api.v0.models.Visibility] { override def convert(value: String): payp.mard2p.api.v0.models.Visibility = payp.mard2p.api.v0.models.Visibility(value) override def convert(value: payp.mard2p.api.v0.models.Visibility): String = value.toString override def example: payp.mard2p.api.v0.models.Visibility = payp.mard2p.api.v0.models.Visibility.Public override def validValues: Seq[payp.mard2p.api.v0.models.Visibility] = payp.mard2p.api.v0.models.Visibility.all } implicit def pathBindableVisibility(implicit stringBinder: QueryStringBindable[String]): PathBindable[payp.mard2p.api.v0.models.Visibility] = ApibuilderPathBindable(visibilityConverter) implicit def queryStringBindableVisibility(implicit stringBinder: QueryStringBindable[String]): QueryStringBindable[payp.mard2p.api.v0.models.Visibility] = ApibuilderQueryStringBindable(visibilityConverter) } trait ApibuilderTypeConverter[T] { def convert(value: String): T def convert(value: T): String def example: T def validValues: Seq[T] = Nil def errorMessage(key: String, value: String, ex: java.lang.Exception): String = { val base = s"Invalid value '$value' for parameter '$key'. " validValues.toList match { case Nil => base + "Ex: " + convert(example) case values => base + ". Valid values are: " + values.mkString("'", "', '", "'") } } } object ApibuilderTypes { val dateTimeIso8601: ApibuilderTypeConverter[_root_.org.joda.time.DateTime] = new ApibuilderTypeConverter[_root_.org.joda.time.DateTime] { override def convert(value: String): _root_.org.joda.time.DateTime = _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseDateTime(value) override def convert(value: _root_.org.joda.time.DateTime): String = _root_.org.joda.time.format.ISODateTimeFormat.dateTime.print(value) override def example: _root_.org.joda.time.DateTime = _root_.org.joda.time.DateTime.now } val dateIso8601: ApibuilderTypeConverter[_root_.org.joda.time.LocalDate] = new ApibuilderTypeConverter[_root_.org.joda.time.LocalDate] { override def convert(value: String): _root_.org.joda.time.LocalDate = _root_.org.joda.time.format.ISODateTimeFormat.dateTimeParser.parseLocalDate(value) override def convert(value: _root_.org.joda.time.LocalDate): String = _root_.org.joda.time.format.ISODateTimeFormat.date.print(value) override def example: _root_.org.joda.time.LocalDate = _root_.org.joda.time.LocalDate.now } } final case class ApibuilderQueryStringBindable[T]( converters: ApibuilderTypeConverter[T] ) extends QueryStringBindable[T] { override def bind(key: String, params: Map[String, Seq[String]]): _root_.scala.Option[_root_.scala.Either[String, T]] = { params.getOrElse(key, Nil).headOption.map { v => try { Right( converters.convert(v) ) } catch { case ex: java.lang.Exception => Left( converters.errorMessage(key, v, ex) ) } } } override def unbind(key: String, value: T): String = { s"$key=${converters.convert(value)}" } } final case class ApibuilderPathBindable[T]( converters: ApibuilderTypeConverter[T] ) extends PathBindable[T] { override def bind(key: String, value: String): _root_.scala.Either[String, T] = { try { Right( converters.convert(value) ) } catch { case ex: java.lang.Exception => Left( converters.errorMessage(key, value, ex) ) } } override def unbind(key: String, value: T): String = { converters.convert(value) } } } }