diff --git a/src/main/scala/code/lib/ObpAPI.scala b/src/main/scala/code/lib/ObpAPI.scala index cf328e44..0d600394 100644 --- a/src/main/scala/code/lib/ObpAPI.scala +++ b/src/main/scala/code/lib/ObpAPI.scala @@ -128,7 +128,7 @@ object ObpAPI extends Loggable { // Returns Json containing Resource Docs def getResourceDocsJson(apiVersion : String) : Box[ResourceDocsJson] = { - ObpGet(s"/$apiVersion/resource-docs/obp").flatMap(_.extractOpt[ResourceDocsJson]) + ObpGet(s"/v1.4.0/resource-docs/$apiVersion/obp").flatMap(_.extractOpt[ResourceDocsJson]) } /** @@ -839,11 +839,7 @@ object ObpJson { // Copied from OBP-API JSONFactory1_4_0 // TODO: Import these and others from API jar file? - // Matches OBP-API representation of Resource Docs etc. Used to describe where an API call is implemented - case class ImplementedByJson ( - version : String, // Short hand for the version e.g. "1_4_0" means Implementations1_4_0 - function : String // The val / partial function that implements the call e.g. "getBranches" - ) + // Used to describe the OBP API calls for documentation and API discovery purposes @@ -861,12 +857,28 @@ object ObpJson { // Internal representation of the ResourceDoc (may differ from the OBP API representation (for instance OBP representation does not have id) + + + // Used to describe where an API call is implemented (format from API) + case class ImplementedByJson ( + version : String, // Short hand for the version e.g. "1_4_0" means Implementations1_4_0 + function : String // The val / partial function that implements the call e.g. "getBranches + ) + + // Internal format (currently the same) + case class ImplementedBy ( + version : String, // Short hand for the version e.g. "1_4_0" means Implementations1_4_0 + function : String // The val / partial function that implements the call e.g. "getBranche + ) + + case class ResourceDoc(id: String, verb: String, url: String, summary: String, description: NodeSeq, - example_request_body: JValue) + example_request_body: JValue, + implementedBy: ImplementedBy) case class ResourceDocs (resourceDocs : List[ResourceDoc]) diff --git a/src/main/scala/code/snippet/ApiExplorer.scala b/src/main/scala/code/snippet/ApiExplorer.scala index 5a9af0ad..85ca197a 100644 --- a/src/main/scala/code/snippet/ApiExplorer.scala +++ b/src/main/scala/code/snippet/ApiExplorer.scala @@ -1,7 +1,7 @@ package code.snippet import _root_.net.liftweb._ -import code.lib.ObpJson.{BarebonesAccountJson, BarebonesAccountsJson, ResourceDoc} +import code.lib.ObpJson.{ImplementedBy, BarebonesAccountJson, BarebonesAccountsJson, ResourceDoc} import code.lib._ import net.liftweb.http.js.jquery.JqJsCmds.DisplayMessage @@ -124,7 +124,15 @@ class ApiExplorer extends Loggable { // The overview contains html. Just need to convert it to a NodeSeq so the template will render it as such val resources = for { r <- getResourceDocsJson(apiVersion).map(_.resource_docs).get - } yield ResourceDoc(id = r.operation_id, verb = r.request_verb, url = modifiedRequestUrl(r.request_url, presetBankId, presetAccountId), summary = r.summary, description = stringToNodeSeq(r.description), example_request_body = r.example_request_body) + } yield ResourceDoc( + id = r.operation_id, + verb = r.request_verb, + url = modifiedRequestUrl(r.request_url, presetBankId, presetAccountId), + summary = r.summary, + description = stringToNodeSeq(r.description), + example_request_body = r.example_request_body, + implementedBy = ImplementedBy(r.implemented_by.version, r.implemented_by.function) + ) // Controls when we display the request body. def displayRequestBody(resourceVerb : String) = { @@ -436,7 +444,8 @@ class ApiExplorer extends Loggable { // Replace the type=submit with Javascript that makes the ajax call. "@success_response_body [id]" #> s"success_response_body_${i.id}" & // The button. First argument is the text of the button (GET, POST etc). Second argument is function to call. Arguments to the func could be sent in third argument - "@call_button" #> ajaxSubmit(i.verb, process) + "@call_button" #> ajaxSubmit(i.verb, process) & + ".content-box__available-since *" #> s"Implmented in ${i.implementedBy.version}" } } } \ No newline at end of file diff --git a/src/main/webapp/media/css/style.css b/src/main/webapp/media/css/style.css index 953d9ef6..61d35c37 100644 --- a/src/main/webapp/media/css/style.css +++ b/src/main/webapp/media/css/style.css @@ -319,6 +319,8 @@ a img { float: left; width: 720px; position: relative; + color: #504854; + font-size: 8px; } .default-input {