Data Revealing
Start session
VGS Show SDK requires vault id and environment. To create a VGSShow
for your application you need to get your vault Id
and specify Environment
. For example:
val id = "<VAULT_ID>"
val environment = VGSEnvironment.Sandbox()
val vgsShow = VGSShow(context, id, environment)
Multiple Data Regions
Please use the following configuration to set up a specific data region if needed.
val id = "<VAULT_ID>"
val environment = VGSEnvironment.Sandbox("eu-1")
val vgsShow = VGSShow(context, id, environment)
Add a Custom Hostname
When integrated with VGS, by default, the traffic is passed via the VGS proxy, which has tntxxxxx.sandbox.verygoodproxy.com
format where tntxxxxx
is your Vault identifier. Show SDK allows you to set your own hostname and make requests to a non-VGS domain name or localhost on your local machine.
Before adding a new Hostname, you should create a CNAME record for your existing domain in your DNS provider’s account that should point to <VAULT_ID>.<ENVIRONMENT>.verygoodproxy.com
.
** Learn more about Custom Hostnames**.
To specify your hostname, you have to initializethe Show SDK using Builder
class:
val vgsForm: VGSShow = VGSShow.Builder(this, "<VAULT_ID>")
.setEnvironment(VGSEnvironment.Sandbox())
.setHostname("www.customdomain.com")
.build()
• When the hostname is not valid or not registered in VGS system, it will be ignored by SDK and all the traffic will be passed via VGS proxy directly. • Only https scheme is supported.\
Data subscribing
It allows VGSShow to bind to the field and deliver and deliver response to user.
val infoField = findViewById<VGSTextView>(R.id.infoField)
vgsShow.subscribe(infoField)
Reveal information
Show SDK provides several ways to reveal information. Reveal can be made in synchronous or asynchronous ways, and can also receive different parameters.
Synchronous request
To make a request in synchronous way you should call request()
function.
val request = VGSRequest.Builder("/post", VGSHttpMethod.POST)
.build()
vgsShow.request(request)
Asynchronous request
val request = VGSRequest.Builder("/post", VGSHttpMethod.POST)
.build()
vgsShow.requestAsync(request)
Headers
SDK provides two options to define headers in request: static and dynamic.
Static headers
Static headers could be set for all requests during session. Use setCustomHeader()
to set one.
vgsShow.setCustomHeader("<HEADER-NAME>", "<HEADER_VALUE>")
Dynamic headers
Dynamic headers are set for one specific request. You can set them using VGSRequest.Builder
val request = VGSRequest.Builder("/post", VGSHttpMethod.POST)
.headers(mapOf("<HEADER-NAME>" to "<HEADER_VALUE>"))
.build()
vgsShow.request(request)
Payload
To get the revealed data, you should specify the payload in json
with <CONTENT_PATH>
and related <alias>
. Example payload: "sensitive_info : "ton_qwerty12345567890""
.
val keyValue = mapOf("sensitive_info" to "ton_qwerty12345567890")\n
val payload = JSONObject(keyValue)
val request = VGSRequest.Builder("/post", VGSHttpMethod.POST)
.body(payload, VGSHttpBodyFormat.JSON)
.build()
vgsShow.requestAsync(request)
Also, you can add any additional/extra data to the payload:
val keyValue = mapOf(
"sensitive_info" to "ton_qwerty12345567890",
"extraData" to mapOf("someKey" to "someValue")
)
val payload = JSONObject(keyValue)
val request = VGSRequest.Builder("/post", VGSHttpMethod.POST)
.body(payload, VGSHttpBodyFormat.JSON)
.build()
vgsShow.requestAsync(request)
Handling responses from asynchronous requests
Interface definition for a callback to be invoked when VGSShow receives a response from the Server.
The developer can receive a local or HTTP response code in a callback. List of current response codes:
Code
Description
100 - 600
Http response status code
1401
When response data format is not supported
1404
When payload is invalid
1480
When VGS configuration URL is not valid
1481
When internet permission not added to AndroidManifest.xml
1482
When device is not connected to internet
1483
When network request is executing to long
vgsShow.addResponseListener(object : VgsShowResponseListener {\n
override fun onResponse(response: VGSResponse) {
when (response) {
is VGSResponse.Success -> {
val successCode = response.code
}
is VGSResponse.Error -> {
val errorCode = response.code
val message = response.message
}
}
}
})
Apply previous response
VGSResponse.Success
can be applied again by calling VGSShow.applyResponse
function with the previous response as a parameter.
End session
Clear all information collected before by VGSCollect and cancel all requests. Call onDestroy
inside the Android onDestroy callback.
override fun onDestroy() {
vgsShow.onDestroy()
super.onDestroy()
}
Last updated