Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/OpenBankProject/OBP-API
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
oldbig committed Mar 11, 2019
2 parents 1f8dce3 + c70587d commit 202f7e2
Show file tree
Hide file tree
Showing 30 changed files with 1,236 additions and 870 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ When naming variables use strict camel case e.g. use myUrl not myURL. This is so
// Now here is the business logic.
// Get The customers related to a user. Process the resonse which might be an Exception
(customers,callContext) <- Connector.connector.vend.getCustomersByUserIdFuture(u.userId, callContext) map {
unboxFullOrFail(_, callContext, ConnectorEmptyResponse, 400)
connectorEmptyResponse(_, callContext)
}
} yield {
// Create the JSON to return. We also return the callContext
Expand Down
2 changes: 2 additions & 0 deletions obp-api/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import code.kycstatuses.MappedKycStatus
import code.loginattempts.MappedBadLoginAttempt
import code.management.ImporterAPI
import code.meetings.MappedMeeting
import code.meetings.MappedMeetingInvitee
import code.metadata.comments.MappedComment
import code.metadata.counterparties.{MappedCounterparty, MappedCounterpartyBespoke, MappedCounterpartyMetadata, MappedCounterpartyWhereTag}
import code.metadata.narrative.MappedNarrative
Expand Down Expand Up @@ -600,6 +601,7 @@ object ToSchemify {
MappedSocialMedia,
MappedTransactionType,
MappedMeeting,
MappedMeetingInvitee,
MappedBankAccountData,
MappedPhysicalCard,
PinReset,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import code.api.cache.Caching
import code.api.util.APIUtil._
import code.api.util.ApiTag._
import code.api.util.ApiRole._
import code.api.util.{APIUtil, ApiVersion, ScannedApiVersion, ScannedApis}
import code.api.util.ApiStandards.{ApiStandards => _, apply => _, _}
import code.api.util._
import code.api.v1_4_0.{APIMethods140, JSONFactory1_4_0, OBPAPI1_4_0}
import code.api.v2_2_0.{APIMethods220, OBPAPI2_2_0}
import code.api.v3_0_0.OBPAPI3_0_0
Expand Down Expand Up @@ -160,39 +161,22 @@ trait ResourceDocsAPIMethods extends MdcLoggable with APIMethods220 with APIMeth
requestedApiVersion match
{
// only `obp` standard show the `localResouceDocs`
case version: ScannedApiVersion if(version.apiStandard =="obp") => activePlusLocalResourceDocs ++= localResourceDocs
case version: ScannedApiVersion if(version.apiStandard == obp.toString) => activePlusLocalResourceDocs ++= localResourceDocs
// all other standards only show their own apis.
case _ => ;
}
// activePlusLocalResourceDocs ++= localResourceDocs


// Add any featured status and special instructions from Props
// Overwrite the requestUrl adding /obp
// TODO We ideally need to return two urls here:
// 1) the implemented in url i.e. the earliest version under which this endpoint is available
// 2) the called url (contains the version we are calling)

val theResourceDocs = for {
x <- activePlusLocalResourceDocs
// This is the "implemented in" url
url = x.implementedInApiVersion match {
case ApiVersion.`apiBuilder` => s"/api-builder/${x.implementedInApiVersion.vDottedApiVersion}${x.requestUrl}"
// We add the /obp/vX prefix here
case version: ScannedApiVersion => s"/${version.urlPrefix}/${x.implementedInApiVersion.vDottedApiVersion}${x.requestUrl}"
case _ => s"/obp/${x.implementedInApiVersion.vDottedApiVersion}${x.requestUrl}"
}
y = x.copy(isFeatured = getIsFeaturedApi(x.partialFunctionName),
specialInstructions = getSpecialInstructions(x.partialFunctionName),
requestUrl = url,
specifiedUrl = x.implementedInApiVersion match {
// We add the /obp/vX prefix here - but this is the requested API version by the resource docs endpoint. i.e. we know this endpoint
// is also available here as well as the requestUrl. See the resource doc for resource doc!
case version: ScannedApiVersion if(version.apiStandard =="obp") => Some(s"/obp/${requestedApiVersion.vDottedApiVersion}${x.requestUrl}")
//for other standard apis, there is no need to map the version. because each version only contains its own apis, do not mix for now.
case _ => Some(url)
}


y = x.copy(
isFeatured = getIsFeaturedApi(x.partialFunctionName),
specialInstructions = getSpecialInstructions(x.partialFunctionName),
requestUrl = s"/${x.implementedInApiVersion.urlPrefix}/${x.implementedInApiVersion.vDottedApiVersion}${x.requestUrl}", // This is the "implemented" in url
specifiedUrl = Some(s"/${x.implementedInApiVersion.urlPrefix}/${requestedApiVersion.vDottedApiVersion}${x.requestUrl}") // This is the "specified" in url when we call the resourceDoc api
)
} yield y

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import code.api.v1_2_1.AmountOfMoneyJsonV121
import code.api.v3_0_0.JSONFactory300.createBranchJsonV300
import code.api.v3_0_0.custom.JSONFactoryCustom300
import code.api.v3_0_0.{LobbyJsonV330, ScopeJson, _}
import code.api.v3_1_0.{BadLoginStatusJson, ObpApiLoopbackJson, _}
import code.api.v3_1_0.{BadLoginStatusJson, ContactDetailsJson, InviteeJson, ObpApiLoopbackJson, _}
import code.branches.Branches.{DriveUpString, _}
import code.common._
import code.sandbox.SandboxData
Expand Down Expand Up @@ -1427,7 +1427,8 @@ object SwaggerDefinitionsJSON {
request_verb = "String",
request_url = "String",
summary = "String",
description = "String",
description = "HTML String",
description_markdown = "Mark_down String",
example_request_body = successMessage, //TODO maybe need fix
success_response_body = successMessage,
error_response_bodies = List("OBP-10001= Incorrect json format."),
Expand Down Expand Up @@ -3130,6 +3131,39 @@ object SwaggerDefinitionsJSON {

val productCollectionJsonTreeV310 = ProductCollectionJsonTreeV310(collection_code = "A", products = List(productJsonV310))

val contactDetailsJson = ContactDetailsJson(
name = "Simon ",
mobile_phone = "+44 07972 444 876",
email_addresse = "[email protected]"
)

val inviteeJson = InviteeJson(
contactDetailsJson,
"String, eg: Good"
)

val createMeetingJsonV310 = CreateMeetingJsonV310(
provider_id = "String, eg: tokbox",
purpose_id = "String, eg: onboarding",
date = DateWithMsExampleObject,
creator = contactDetailsJson,
invitees = List(inviteeJson)
)

val meetingJsonV310 = MeetingJsonV310(
meeting_id = "UUID-String",
provider_id = "String, eg: tokbox",
purpose_id = "String, eg: onboarding",
bank_id = "gh.29.uk",
present = meetingPresentJSON,
keys = meetingKeysJSON,
when = DateWithDayExampleObject,
creator = contactDetailsJson,
invitees = List(inviteeJson)
)

val meetingsJsonV310 = MeetingsJsonV310(List(meetingJsonV310))

//The common error or success format.
//Just some helper format to use in Json
case class NoSupportYet()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object JSONFactory_UKOpenBanking_310 {
LastAvailableDateTime: Date,
)

case class TransactionsJsonUKV200(
case class TransactionsJsonUKV310(
Data: TransactionsInnerJson,
Links: LinksV310,
Meta: MetaInnerJson
Expand All @@ -70,22 +70,82 @@ object JSONFactory_UKOpenBanking_310 {
case class BalanceUKOpenBankingJson(
Amount: AmountOfMoneyJsonV121,
CreditDebitIndicator: String,
Type: String
Type: String = "ClosingAvailable"
)

case class CurrencyExchangeJson(
SourceCurrency: String,
TargetCurrency: String,
UnitCurrency: String,
ExchangeRate: Int,
ContractIdentification: String,
QuotationDate: Date,
InstructedAmount: AmountOfMoneyJsonV121
)

case class CardInstrumentJson(
CardSchemeName: String = "AmericanExpress",
AuthorisationType: String = "ConsumerDevice",
Name: String = "string",
Identification: String = "string"
)

case class MerchantDetailsJson(
MerchantName: String = "String",
MerchantCategoryCode : String = "String"
)

case class PostalAddressJson(
AddressType: String ="Business",
Department: String ="string",
SubDepartment: String ="string",
StreetName: String ="string",
BuildingNumber: String ="string",
PostCode: String ="string",
TownName: String ="string",
CountrySubDivision: String ="string",
Country: String ="string",
AddressLine: List[String]= List("string")
)

case class AgentJson(
SchemeName: List[String] = List("UK.OBIE.BICFI"),
Identification: String = "string",
Name: String = "string",
PostalAddress: PostalAddressJson = PostalAddressJson(),
)

case class TransactionInnerAccountJson(
SchemeName: List[String] = List("UK.OBIE.BBAN"),
Identification: String = "string",
Name: String = "string",
SecondaryIdentification: String = "string",
)

case class TransactionInnerJson(
AccountId: String,
TransactionId: String,
TransactionReference: String,
StatementReference: List[String] = List("String"),
Amount: AmountOfMoneyJsonV121,
CreditDebitIndicator: String,
Status: String,
CreditDebitIndicator: String ="Credit",
Status: String ="Booked",
BookingDateTime: Date,
ValueDateTime: Date,
AddressLine: String = "String",
ChargeAmount: AmountOfMoneyJsonV121,
TransactionInformation: String,
CurrencyExchange:CurrencyExchangeJson,
BankTransactionCode: BankTransactionCodeJson,
ProprietaryBankTransactionCode: TransactionCodeJson,
Balance: BalanceUKOpenBankingJson
CardInstrument: CardInstrumentJson,
SupplementaryData:String = "",//Empty object {}. not sure what does it mean
Balance: BalanceUKOpenBankingJson,
MerchantDetails: MerchantDetailsJson = MerchantDetailsJson(),
CreditorAgent:AgentJson = AgentJson(),
CreditorAccount:TransactionInnerAccountJson = TransactionInnerAccountJson(),
DebtorAgent:AgentJson= AgentJson(),
DebtorAccount:TransactionInnerAccountJson = TransactionInnerAccountJson(),
)

case class TransactionsInnerJson(
Expand Down Expand Up @@ -161,34 +221,42 @@ object JSONFactory_UKOpenBanking_310 {
)
}

def createTransactionsJson(transactions: List[ModeratedTransaction], transactionRequests: List[TransactionRequest]) : TransactionsJsonUKV200 = {
def createTransactionsJson(transactions: List[ModeratedTransaction], transactionRequests: List[TransactionRequest]) : TransactionsJsonUKV310 = {
val accountId = transactions.head.bankAccount.get.accountId.value
val transactionsInnerJson = transactions.map(
transaction=>TransactionInnerJson(
AccountId = accountId,
TransactionId = transaction.id.value,
accountId,
transaction.id.value,
TransactionReference = transaction.description.getOrElse(""),
Amount = AmountOfMoneyJsonV121(
currency = transaction.currency.getOrElse("") ,
amount= transaction.amount.getOrElse(BigDecimal(0)).toString()
),
CreditDebitIndicator = "Credit",
Status = "Booked",
amount= transaction.amount.getOrElse(BigDecimal(0)).toString()),
BookingDateTime = transaction.startDate.get,
ValueDateTime = transaction.finishDate.get,
ChargeAmount = AmountOfMoneyJsonV121(transaction.currency.getOrElse(""),"0"),
TransactionInformation = transaction.description.getOrElse(""),
CurrencyExchange = CurrencyExchangeJson(
SourceCurrency = transaction.bankAccount.map(_.currency).flatten.getOrElse(""),
TargetCurrency = "",//No currency in the otherBankAccount,
UnitCurrency = "",
ExchangeRate = 0,
ContractIdentification = "string",
QuotationDate = new Date(),
InstructedAmount = AmountOfMoneyJsonV121(transaction.bankAccount.map(_.currency).flatten.getOrElse(""),"")),
BankTransactionCode = BankTransactionCodeJson("",""),
ProprietaryBankTransactionCode = TransactionCodeJson("Transfer", "AlphaBank"),
Balance = BalanceUKOpenBankingJson(
CardInstrument = CardInstrumentJson(),
Balance =BalanceUKOpenBankingJson(
Amount = AmountOfMoneyJsonV121(
currency = transaction.currency.getOrElse(""),
amount = transaction.balance
),
CreditDebitIndicator = "Credit",
Type = "InterimBooked"
))
)
)
)
TransactionsJsonUKV200(
TransactionsJsonUKV310(
Data = TransactionsInnerJson(transactionsInnerJson),
Links = LinksV310(
Constant.HostName + s"/open-banking/v3.1/accounts/${accountId}/transactions",
Expand Down
Loading

0 comments on commit 202f7e2

Please sign in to comment.