Updating url to get resource docs

This commit is contained in:
Simon Redfern 2016-01-18 13:00:58 +01:00
parent 8a2cfefcd2
commit affda93036
3 changed files with 33 additions and 10 deletions

View File

@ -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])

View File

@ -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}"
}
}
}

View File

@ -319,6 +319,8 @@ a img {
float: left;
width: 720px;
position: relative;
color: #504854;
font-size: 8px;
}
.default-input {