Skip to content

Commit

Permalink
antor docs set-up step #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinfs510 committed Mar 12, 2020
1 parent e8d180e commit a2cbdc0
Show file tree
Hide file tree
Showing 7 changed files with 539 additions and 338 deletions.
238 changes: 238 additions & 0 deletions docs/modules/ROOT/pages/OstJsonApi.md.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ OST JSON APIs are a set of _asynchronous_ methods that make API calls to OST Pla
*** <<usage-4,Usage>>
*** <<sample-response-4,Sample Response>>
*** <<sample-error,Sample Error>>
** <<get-redeemable-sku-details,Get Redeemable Sku Details>>
*** <<usage-8,Usage>>
*** <<sample-response-8,Sample Response>>
* <<list-api,List API>>
** <<get-transactions,Get Transactions>>
*** <<usage-5,Usage>>
*** <<sample-response-5,Sample Response>>
** <<get-devices,Get Devices>>
*** <<usage-6,Usage>>
*** <<sample-response-6,Sample Response>>
** <<get-redeemable-skus,Get Redeemable Skus>>
*** <<usage-7,Usage>>
*** <<sample-response-7,Sample Response>>

+++<a id="before-we-begin">++++++</a>+++

Expand Down Expand Up @@ -393,6 +399,147 @@ The `getPendingRecoveryForUserId` API will respond with `UNPROCESSABLE_ENTITY` A
}
----

+++<a id="get-redeemable-sku-details">++++++</a>+++

=== Get Redeemable Sku Details

API to get redeemable sku details.

+++<a id="usage-8">++++++</a>+++

.Usage
[source,javascript]
----
/*
Please update userId as per your needs.
Since this userId does not belong to your economy, you will get an error if you do not change it.
*/
let userId = "71c59448-ff77-484c-99d8-abea8a419836";
let skuDetailId = "2";
let extraParams = {};
/**
* Api to get redeemable skus
* @param {String} userId - Ost User id
* @param {String} skuDetailId - Sku detail id got from list of Redeemable skus
* @param {Object} extraParams (@nullable).
* @param {function} Success callback with success data
* @param {function} Failure callback with error and failure response
* @public
*/
OstJsonApi.getRedeemableSkuDetails(userId, skuDetailId ,extraParams, (response) => {
console.log(response);
}, (error)=> {
console.log("An error has occurred while fetching redeemable sku details.");
console.log( error );
});
----

+++<a id="sample-response-8">++++++</a>+++

.Sample Response
[source,json]
----
{
"result_type":"redemption_product",
"redemption_product":{
"status":"active",
"images":{
"detail":{
"original":{
"size":90821,
"url":"https://dxwfxs8b4lg24.cloudfront.net/ost-platform/rskus/stag-starbucks-d-original.png",
"width":150,
"height":150
}
},
"cover":{
"original":{
"size":193141,
"url":"https://dxwfxs8b4lg24.cloudfront.net/ost-platform/rskus/stag-starbucks-c-original.png",
"width":320,
"height":320
}
}
},
"availability":[
{
"country_iso_code":"USA",
"country":"USA",
"currency_iso_code":"USD",
"denominations":[
{
"amount_in_wei":"49938358",
"amount_in_fiat":5
},
{
"amount_in_wei":"99876717",
"amount_in_fiat":10
},
...
]
},
{
"country_iso_code":"CAN",
"country":"Canada",
"currency_iso_code":"CAD",
"denominations":[
{
"amount_in_wei":"37547638",
"amount_in_fiat":5
},
{
"amount_in_wei":"75095276",
"amount_in_fiat":10
},
...
]
},
{
"country_iso_code":"GBR",
"country":"United Kingdom",
"currency_iso_code":"GBP",
"denominations":[
{
"amount_in_wei":"64855011",
"amount_in_fiat":5
},
{
"amount_in_wei":"129710022",
"amount_in_fiat":10
},
...
]
},
{
"country_iso_code":"IND",
"country":"India",
"currency_iso_code":"INR",
"denominations":[
{
"amount_in_wei":"1396",
"amount_in_fiat":0.01
},
{
"amount_in_wei":"139609",
"amount_in_fiat":1
},
...
]
}
],
"id":"2",
"updated_timestamp":1582024811,
"description":{
"text":null
},
"name":"Starbucks"
}
}
----

+++<a id="list-api">++++++</a>+++

== List API
Expand Down Expand Up @@ -613,3 +760,94 @@ OstJsonApi.getDeviceListForUserId(userId, nextPagePayload,
"result_type": "devices"
}
----

+++<a id="get-redeemable-skus">++++++</a>+++

=== Get Redeemable Skus

API to get redeemable skus.

+++<a id="usage-7">++++++</a>+++

.Usage
[source,javascript]
----
/*
Please update userId as per your needs.
Since this userId does not belong to your economy, you will get an error if you do not change it.
*/
let userId = "71c59448-ff77-484c-99d8-abea8a419836";
let nextPagePayload = null;
/**
* Api to get redeemable skus
* @param {String} userId - Ost User id
* @param {Object} nextPagePayload (@nullable). Pass null to get first page.
* @param {function} Success callback with success data
* @param {function} Failure callback with error and failure response
* @public
*/
OstJsonApi.getRedeemableSkus(userId, nextPagePayload , (respones) => {
console.log(response);
// Let's check if more pages of data is available.
if ( response.meta ) {
let nextPagePayloadFromResponse = response.meta.next_page_payload || {};
if ( Object.keys(nextPagePayloadFromResponse).length > 0 ) {
// Next page is available.
// Update nextPagePayload
nextPagePayload = nextPagePayloadFromResponse;
// To fetch the next page, pass the updated nextPagePayload.
}
}
}, (error)=> {
console.log("An error has occurred while fetching redeemable skus.");
console.log( error );
});
----

+++<a id="sample-response-7">++++++</a>+++

.Sample Response
[source,json]
----
{
"meta":{
"next_page_payload":{
}
},
"result_type":"redemption_products",
"redemption_products":[
{
"status":"active",
"updated_timestamp":1582024811,
"id":"2",
"description":{
"text":null
},
"images":{
"detail":{
"original":{
"size":90821,
"url":"https://dxwfxs8b4lg24.cloudfront.net/ost-platform/rskus/stag-starbucks-d-original.png",
"width":150,
"height":150
}
},
"cover":{
"original":{
"size":193141,
"url":"https://dxwfxs8b4lg24.cloudfront.net/ost-platform/rskus/stag-starbucks-c-original.png",
"width":320,
"height":320
}
}
},
"name":"Starbucks"
},
...
...
]
}
----
68 changes: 68 additions & 0 deletions docs/modules/ROOT/pages/OstRedemptionConfig.md.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
= OstWallet Redemption Config

== Introduction

App developers can configure the text shown on redemption page.

To configure the content, the sdk needs to be provided with https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON[JSON object].

== Dictionary Data Structure

Here is the small sample json representation of the configuration.

[source,json]
----
{
"common": {
"walletIcon": null,
"storeIcon": null
},
"skuListScreen": {
"navHeader": null,
"header": null,
"description": null
},
"skuDetailsScreen": {
"navHeader": null
}
}
----

In the above example:

* The key `common` includes options to configure the wallet icon in header and the store icon.
* The key `skuListScreen` allows to configure the navigation header and the header and description shown on the redemption store list page.
* The key `skuDetailsScreen` allows to configure the navigation header shown on the redemption store details page.

== Redemption Config

The following are the customizable options provided.
These can be set in the above config.

|===
| customizable component | Config Keys | Config Type

| Wallet icon
| - walletIcon
| Custom icon Image to be rendered.

| Store icon
| - storeIcon
| Custom icon Image to be rendered.

| Skulist Header
| - skuListScreen.header
| String

| Skulist Description
| - skuListScreen.description
| String

| SkuDetails Screen Navigation header
| - skuDetailsScreen.navHeader
| String

| Skulist Screen Navigation header
| - skuListScreen.navHeader
| String
|===
65 changes: 65 additions & 0 deletions docs/modules/ROOT/pages/OstRedemptionFlow.md.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
= OstRedemption Flow

== Introduction

OstRedemption component is a pre-built UI component available exclusively in `ost-wallet-sdk-react-native` SDK.
It consist two pages - one displaying redeemable product list and another displaying product details and redemption options.
It can be used by end-users to integrate redemption flow into their app.

____
*IMPORTANT:* This feature requires application to use https://reactnavigation.org/docs/en/getting-started.html[React Navigation] package.
____

== Usage

=== Create Redemption Flow stack navigation

[source,js]
----
import {OstRedeemableSkus, OstRedeemableSkuDetails } from '@ostdotcom/ost-wallet-sdk-react-native';
let redemptionStack = createStackNavigator(
{
RedeemableSkusScreen: OstRedeemableSkus,
RedeemableSkuDetails: OstRedeemableSkuDetails
}
);
----

=== Navigate to settings page

`ostUserId` and `ostWalletUIWorkflowCallback` are mandetory parameters that need to be passed as params to the `RedeemableSkusScreen` screen.

[source,js]
----
const ostUserId = <APPLICATION-USER-OST-USER-ID>
const delegate = new OstWalletUIWorkflowCallback(ostUserId, {})
this.props.navigation.push("RedeemableSkusScreen", {'ostUserId': ostUserId ,
'ostWalletUIWorkflowCallback': delegate,
'navTitle': 'My Store'});
----

____
*Note* + Developer needs to create a class extends from `OstWalletUIWorkflowCallback` and write logic to get passphrase prefix from their application server.
Please refer link:OstWalletUI.md#setup-your-passphrase-prefix-delegate[this] section for documentation.
____

== UI Customization

Developer can customize Redemption flow by updating respective properties mentioned in image.
OstTheme config shown link:./configs/ost-sdk-theme-config.js[here]

image::images/redemptionFlow.png[copy-framework-file]

== Redemption Content

Developer can make various modifications in redemption flow component.
To modify contet, xref:./OstRedemptionConfig.adoc[refer here].

[source,js]
----
import ost_sdk_redemption_config from "../../theme/ostsdk/ost-sdk-redemption-config";
import { OstRedemableCustomConfig } from '@ostdotcom/ost-wallet-sdk-react-native';
OstRedemableCustomConfig.setConfig(ost_sdk_redemption_config);
----
Loading

0 comments on commit a2cbdc0

Please sign in to comment.