Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dex 208 sdk references #144

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Skyflow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id 'maven-publish'
}
apply plugin: 'kotlin-android'
apply plugin: 'kotlinx-serialization'
//group='com.github.skyflowapi'
//version = rootProject.ext.versionName
ext {
Expand Down Expand Up @@ -143,6 +144,9 @@ dependencies {
testImplementation "org.robolectric:robolectric:4.6.1"
testImplementation 'io.mockk:mockk:1.8.5'
androidTestImplementation "org.robolectric:robolectric:4.6.1"
implementation "org.jetbrains.kotlin:kotlin-reflect:1.6.21"
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.13.3'
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1")
}
publish.dependsOn assemble

14 changes: 11 additions & 3 deletions Skyflow/src/main/kotlin/Skyflow/Callback.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
package Skyflow


@Description("Contains the results of the implementation of callback.")
interface Callback {

fun onSuccess(responseBody: Any)
@Description("Implementation when callback results in success.")
fun onSuccess(
@Description("The success response.")
responseBody: Any
)

fun onFailure(exception: Any)
@Description("Implementation when callback results in failure.")
fun onFailure(
@Description("The failure response.")
exception: Any
)
}
39 changes: 32 additions & 7 deletions Skyflow/src/main/kotlin/Skyflow/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import javax.xml.parsers.DocumentBuilderFactory
import kotlin.Exception
import kotlin.reflect.KClass

@Description("Contains an instance of the Skyflow client.")
class Client internal constructor(
@Description("Skyflow client initialization includes configuration options.")
val configuration: Configuration,
){
internal val tag = Client::class.qualifiedName
Expand All @@ -23,7 +25,16 @@ class Client internal constructor(
configuration.tokenProvider,configuration.options.logLevel)

internal val elementMap = HashMap<String,Any>()
fun insert(records: JSONObject, options: InsertOptions? = InsertOptions(), callback: Callback){

@Description("Inserts data into the vault.")
fun insert(
@Description("Records to insert.")
records: JSONObject,
@Description("Options for the insertion.")
options: InsertOptions? = InsertOptions(),
@Description("Implementation of Skyflow.Callback.")
callback: Callback
){
try {
Utils.checkVaultDetails(configuration)
Logger.info(tag, Messages.INSERTING_RECORDS.getMessage(configuration.vaultID), configuration.options.logLevel)
Expand All @@ -34,7 +45,14 @@ class Client internal constructor(
callback.onFailure(e)
}
}
fun detokenize(records: JSONObject, callback: Callback) {

@Description("Retrieves record the data using tokens.")
fun detokenize(
@Description("Tokens to return values for.")
records: JSONObject,
@Description("Implementation of Skyflow.Callback.")
callback: Callback
) {
try {
Utils.checkVaultDetails(configuration)
this.apiClient.get(records,loggingCallback(callback, Messages.DETOKENIZE_SUCCESS.getMessage()))
Expand All @@ -45,8 +63,13 @@ class Client internal constructor(
}
}

fun getById(records: JSONObject, callback: Callback)
{
@Description("Reveal records by Skyflow ID.")
fun getById(
@Description("Records to fetch.")
records: JSONObject,
@Description("Implementation of Skyflow.Callback.")
callback: Callback
){
Logger.info(tag, Messages.GET_BY_ID_CALLED.getMessage(), configuration.options.logLevel)
try {
Utils.checkVaultDetails(configuration)
Expand Down Expand Up @@ -173,8 +196,11 @@ class Client internal constructor(
return result
}


fun <T:ContainerProtocol> container(type: KClass<T>) : Container<T>{
@Description("Creates a container.")
fun <T:ContainerProtocol> container(
@Description("Type of the container.")
type: KClass<T>
) : Container<T>{
if(type == ContainerType.COLLECT){
Logger.info(tag, Messages.COLLECT_CONTAINER_CREATED.getMessage(), configuration.options.logLevel)
}
Expand All @@ -199,4 +225,3 @@ class Client internal constructor(
}



20 changes: 17 additions & 3 deletions Skyflow/src/main/kotlin/Skyflow/CollectContainer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ import com.Skyflow.core.container.ContainerProtocol
import org.json.JSONObject
import java.util.*


@Description("Contains all the Collect Elements.")
open class CollectContainer : ContainerProtocol {

}

private val tag = CollectContainer::class.qualifiedName


fun Container<CollectContainer>.create(context: Context, input : CollectElementInput, options : CollectElementOptions = CollectElementOptions()) : TextField
@Description("Creates a Collect Element.")
fun Container<CollectContainer>.create(
@Description("Takes an Android Context object.")
context: Context,
@Description("Configuration for a Collect Element.")
input : CollectElementInput,
@Description("Additional options for a Collect Element.")
options : CollectElementOptions = CollectElementOptions()
) : TextField
{
Logger.info(tag, Messages.CREATED_COLLECT_ELEMENT.getMessage(input.label), configuration.options.logLevel)
val collectElement = TextField(context, configuration.options)
Expand All @@ -30,7 +38,13 @@ fun Container<CollectContainer>.create(context: Context, input : CollectElementI
return collectElement
}

fun Container<CollectContainer>.collect(callback: Callback, options: CollectOptions? = CollectOptions()){
@Description("Collects data and inserts it into a vault.")
fun Container<CollectContainer>.collect(
@Description("Implementation of Skyflow.Callback.")
callback: Callback,
@Description("Additional collect options.")
options: CollectOptions? = CollectOptions()
){
try {
Utils.checkVaultDetails(client.configuration)
Logger.info(tag, Messages.VALIDATE_COLLECT_RECORDS.getMessage(), configuration.options.logLevel)
Expand Down
29 changes: 23 additions & 6 deletions Skyflow/src/main/kotlin/Skyflow/CollectElementInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@ package Skyflow

import com.Skyflow.collect.elements.validations.ValidationSet

class CollectElementInput(internal var table: String? = null, internal var column: String? = null, internal var type: SkyflowElementType,
internal var inputStyles: Styles = Styles(), internal var labelStyles:Styles=Styles(), internal var errorTextStyles:Styles=Styles(),
internal var label: String = "",
internal var placeholder: String = "",
@Deprecated("altText parameter is deprecated" , level = DeprecationLevel.WARNING) internal var altText: String = "",
internal var validations : ValidationSet = ValidationSet()
@Description("Configuration for a Collect Element.")
class CollectElementInput(
@Description("Table that the data belongs to.")
internal var table: String? = null,
@Description("Column that the data belongs to.")
internal var column: String? = null,
@Description("Type of the element.")
internal var type: SkyflowElementType,
@Description("Styles for the element.")
internal var inputStyles: Styles = Styles(),
@Description("Styles for the element's label.")
internal var labelStyles:Styles=Styles(),
@Description("Styles for the element's error text.")
internal var errorTextStyles:Styles=Styles(),
@Description("Label for the element.")
internal var label: String = "",
@Description("Placeholder text for the element.")
internal var placeholder: String = "",
@Description("Alt text for the element.")
@Deprecated("altText parameter is deprecated" , level = DeprecationLevel.WARNING)
internal var altText: String = "",
@Description("Input validation rules for the element.")
internal var validations : ValidationSet = ValidationSet()
) {
}
4 changes: 4 additions & 0 deletions Skyflow/src/main/kotlin/Skyflow/CollectElementOptions.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package Skyflow

@Description("Contains the additional options for Collect Element.")
class CollectElementOptions(
@Description("If `true`, the field is required. Defaults to `false`.")
var required:Boolean = false,
@Description("If `true`, enables the card icon. Defaults to `true`.")
var enableCardIcon : Boolean = true,
@Description("Format of the Collect element.")
var format: String = ""
) {
}
10 changes: 9 additions & 1 deletion Skyflow/src/main/kotlin/Skyflow/CollectOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,13 @@ package Skyflow
import org.json.JSONArray
import org.json.JSONObject

class CollectOptions(val token:Boolean = true, val additionalFields: JSONObject? = null, val upsert : JSONArray? = null) {
@Description("Options for a Collect Element.")
class CollectOptions(
@Description("If `true`, returns tokens for the collected data. Defaults to `true`.")
val token:Boolean = true,
@Description("Additional, non-sensitive data to insert into the vault. Uses the format of a [`records`](https://docs.skyflow.com/record/#RecordService_InsertRecord) object.")
val additionalFields: JSONObject? = null,
@Description("Upsert configuration for the element.")
val upsert : JSONArray? = null
) {
}
6 changes: 5 additions & 1 deletion Skyflow/src/main/kotlin/Skyflow/Configuration.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package Skyflow



@Description("Parameters to initialize a Skyflow client.")
class Configuration(
@Description("ID of the vault to connect to.")
val vaultID: String = "",
@Description("URL of the vault to connect to.")
var vaultURL: String = "",
@Description("An implementation of the token provider interface.")
val tokenProvider: TokenProvider,
@Description("Additional options for configuration.")
val options: Options = Options(),
){
init {
Expand Down
1 change: 1 addition & 0 deletions Skyflow/src/main/kotlin/Skyflow/ContainerType.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Skyflow

@Description("Skyflow container types.")
class ContainerType {
companion object{
val COLLECT = CollectContainer::class;
Expand Down
3 changes: 3 additions & 0 deletions Skyflow/src/main/kotlin/Skyflow/Description.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package Skyflow

annotation class Description(val text: String)
1 change: 1 addition & 0 deletions Skyflow/src/main/kotlin/Skyflow/ElementType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Type(var formatPattern:String, var regex: String,

}

@Description("Skyflow Element types.")
enum class SkyflowElementType {


Expand Down
1 change: 1 addition & 0 deletions Skyflow/src/main/kotlin/Skyflow/Env.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package Skyflow

@Description("Supported environments.")
enum class Env {
DEV,
PROD
Expand Down
Loading