From 8a907241758fb81cfe3a53f248cfaedfc5d89c2f Mon Sep 17 00:00:00 2001 From: kevinfs510 Date: Fri, 21 Feb 2020 18:03:52 +0100 Subject: [PATCH 1/4] antora docs setup --- docs/antora.yml | 5 +++++ docs/modules/ROOT/_attributes.adoc | 0 docs/modules/ROOT/assets/attachments/.gitkeep | 0 docs/modules/ROOT/assets/images/.gitkeep | 0 docs/modules/ROOT/examples/.gitkeep | 0 docs/modules/ROOT/nav.adoc | 0 docs/modules/ROOT/pages/_attributes.adoc | 0 docs/modules/ROOT/pages/_partials/.gitkeep | 0 docs/modules/ROOT/pages/index.adoc | 0 9 files changed, 5 insertions(+) create mode 100644 docs/antora.yml create mode 100644 docs/modules/ROOT/_attributes.adoc create mode 100644 docs/modules/ROOT/assets/attachments/.gitkeep create mode 100644 docs/modules/ROOT/assets/images/.gitkeep create mode 100644 docs/modules/ROOT/examples/.gitkeep create mode 100644 docs/modules/ROOT/nav.adoc create mode 100644 docs/modules/ROOT/pages/_attributes.adoc create mode 100644 docs/modules/ROOT/pages/_partials/.gitkeep create mode 100644 docs/modules/ROOT/pages/index.adoc diff --git a/docs/antora.yml b/docs/antora.yml new file mode 100644 index 0000000..04f1fe2 --- /dev/null +++ b/docs/antora.yml @@ -0,0 +1,5 @@ +name: ost_wallet_sdk_ios +title: Ost Wallet SDK iOS +version: '1.0' +nav: +- modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/_attributes.adoc b/docs/modules/ROOT/_attributes.adoc new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/assets/attachments/.gitkeep b/docs/modules/ROOT/assets/attachments/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/assets/images/.gitkeep b/docs/modules/ROOT/assets/images/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/examples/.gitkeep b/docs/modules/ROOT/examples/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/pages/_attributes.adoc b/docs/modules/ROOT/pages/_attributes.adoc new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/pages/_partials/.gitkeep b/docs/modules/ROOT/pages/_partials/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc new file mode 100644 index 0000000..e69de29 From 4ec1ec7a9493b1658938a634e58fcd0854df4565 Mon Sep 17 00:00:00 2001 From: kevinfs510 Date: Sun, 23 Feb 2020 17:00:51 +0100 Subject: [PATCH 2/4] antora docs setup --- docs/antora.yml | 4 ++-- docs/modules/ROOT/nav.adoc | 1 + docs/modules/ROOT/pages/index.adoc | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/antora.yml b/docs/antora.yml index 04f1fe2..c477b61 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -1,5 +1,5 @@ -name: ost_wallet_sdk_ios -title: Ost Wallet SDK iOS +name: server-sdk-ruby +title: Ost Server SDK Ruby version: '1.0' nav: - modules/ROOT/nav.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index e69de29..59a7257 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -0,0 +1 @@ +* xref:index.adoc[Overview] \ No newline at end of file diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index e69de29..88d04fb 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -0,0 +1,3 @@ +This is the index.adoc page for OST-SDK-RUBY + +This is a test :) \ No newline at end of file From b3cb30e2e1209db3292616edbf062e1a7b94add0 Mon Sep 17 00:00:00 2001 From: kevinfs510 Date: Thu, 12 Mar 2020 16:24:00 +0100 Subject: [PATCH 3/4] docs setup step #2 --- docs/modules/ROOT/pages/CHANGELOG.md.adoc | 39 + docs/modules/ROOT/pages/README.md.adoc | 879 ++++++++++++++++++++++ 2 files changed, 918 insertions(+) create mode 100644 docs/modules/ROOT/pages/CHANGELOG.md.adoc create mode 100644 docs/modules/ROOT/pages/README.md.adoc diff --git a/docs/modules/ROOT/pages/CHANGELOG.md.adoc b/docs/modules/ROOT/pages/CHANGELOG.md.adoc new file mode 100644 index 0000000..f5c7ab5 --- /dev/null +++ b/docs/modules/ROOT/pages/CHANGELOG.md.adoc @@ -0,0 +1,39 @@ +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v2.2.3[OST Ruby SDK v2.2.3] + +* Added redemptions module to call redemptions management OST APIs. +* Added redeemable sku module to call redeemable sku management OST APIs. + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v2.2.2[OST Ruby SDK v2.2.2] + +* Readme changes for documenting new parameters in transactions module. +These parameters can help to get data between specific time interval. + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v2.2.0[OST Ruby SDK v2.2.0] + +* Added webhooks module to call webhook management OST APIs. +* Support for verify webhook signature. + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v2.1.0[OST Ruby SDK v2.1.0] + +* Added base tokens module to V2 API's + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v2.0.0[OST Ruby SDK v2.0.0] + +* OST API V2 interaction layer implementation. +* Removed API V0 and V1 support. +* xref:README.adoc[README.adoc] has API V2 usage instructions + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v1.1.0[OST Ruby SDK v1.1.0] + +* Added user balances module to V1 API's +* Added transaction ledger module to V1 API's + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v1.0.0[OST Ruby SDK v1.0.0] + +* Added support for interacting with V1 API along with V0 +* xref:README.adoc[README.adoc] has API V1 usage instructions +* xref:README.adoc[README_V0.adoc] has API V0 usage instructions + +== https://github.com/ostdotcom/ost-sdk-ruby/tree/v0.9.2[OST Ruby SDK v0.9.2] + +Initial release of the official OST Ruby SDK + This release has the OST API V0 interaction layer implementation. diff --git a/docs/modules/ROOT/pages/README.md.adoc b/docs/modules/ROOT/pages/README.md.adoc new file mode 100644 index 0000000..8eb3e94 --- /dev/null +++ b/docs/modules/ROOT/pages/README.md.adoc @@ -0,0 +1,879 @@ += OST Server-Side Ruby SDK + +image::https://travis-ci.org/ostdotcom/ost-sdk-ruby.svg?branch=develop[Build Status,link=https://travis-ci.org/ostdotcom/ost-sdk-ruby] + +https://dev.ost.com/[OST] Platform SDK for Ruby. + +== Introduction + +OST is a complete technology solution enabling mainstream businesses to easily launch blockchain based economies without requiring blockchain development. + +Brand Tokens (BTs) are white-label cryptocurrency tokens with utility representations running on highly-scalable Ethereum-based utility blockchains, backed by value token (such as OST, USDC) staked on Ethereum mainnet. +Within a business`s token economy, BTs can only be transferred to whitelisted user addresses. +This ensures that they stay within the token economy. + +The OST technology stack is designed to give businesses everything they need to integrate, test, and deploy BTs. +Within the OST suite of products, developers can use OST Platform to create, test, and launch Brand Tokens. + +OST APIs and server-side SDKs make it simple and easy for developers to integrate blockchain tokens into their apps. + +For documentation, visit https://dev.ost.com/ + +== Getting Started + +=== Setup Brand Token + +. Sign-up on https://platform.ost.com[OST Platform] and setup your Brand Token. +. Obtain your API Key and API Secret from https://platform.ost.com/mainnet/developer[developers page]. + +=== Installation + +The preferred way to install the OST Ruby SDK is to use the RubyGems package manager for Ruby. +Simply type the following into a terminal window: + +[source,bash] +---- + gem install ost-sdk-ruby +---- + +== Usage + +* Require the OST Ruby SDK: ++ +[source,ruby] +---- + require('ost-sdk-ruby') +---- + +* Initialize the SDK object. ++ +[source,ruby] +---- + # Declare connection parameters. + + # Mandatory API parameters. + + api_key = '__abc'; # OBTAINED FROM DEVELOPER PAGE + api_secret = '_xyz'; # OBTAINED FROM DEVELOPER PAGE + + # The valid API endpoints are: + # 1. Mainnet: "https://api.ost.com/mainnet/v2/" + # 2. Testnet: "https://api.ost.com/testnet/v2/" + api_base_url = 'https://api.ost.com/testnet/v2/' + + # Optional API parameters. + + # This is the timeout in seconds for which the socket connection will remain open. + timeout_in_seconds = '' + options = {timeout: timeout_in_seconds} + + # OST server side sdk object. + ost_sdk = OSTSdk::Saas::Services.new({api_key: api_key, api_secret: api_secret, api_base_url: api_base_url, config: options}) +---- + +=== Users Module + +* Initialize Users service object to perform user specific actions. ++ +[source,ruby] +---- + users_service = ost_sdk.services.users +---- + +* Create User. +This creates a unique identifier for each user. ++ +[source,ruby] +---- + create_params = {} + response = users_service.create(create_params) +---- + +* Get User Detail using the userId obtained in user create. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom user details needs to be fetched. + user_id = '912___' + + get_params = {} + get_params[:user_id] = user_id + response = users_service.get(get_params) +---- + +* Get Users List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + # No mandatory parameters. + + # Optional API parameters + + # Array of userIds for which data needs to be fetched. + ids_array = ['c2c___', 'd2c6___'] + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'e77y___' + + # Limit. + limit = 10 + + get_params = {} + get_params[:ids] = ids_array + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = users_service.get_list(get_params) +---- + +=== Devices Module + +* Initialize Devices service object to perform device specific actions. ++ +[source,ruby] +---- + devices_service = ost_sdk.services.devices +---- + +* Create a Device for User. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device needs to be created. + user_id = 'c2c6___' + + # Device address of user's device. + device_address = '0x1Ea___' + + # Device API signer address. + api_signer_address = '0x5F8___' + + create_params = {} + create_params[:user_id] = user_id + create_params[:address] = device_address + create_params[:api_signer_address] = api_signer_address + response = devices_service.create(create_params) +---- + +* Get User Device Detail using userId and deviceAddress. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device details needs to be fetched. + user_id = 'c2c6f___' + + # Device address of user's device. + device_address = '0x1Ea___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:device_address] = device_address + response = devices_service.get(get_params) +---- + +* Get User Devices List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device details needs to be fetched. + user_id = 'c2c6___' + + # Optional API parameters + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJs___' + + # Array of device addresses of end user. + device_addresses_array = ['0x590___','0xab___'] + + # Limit. + limit = 10 + + get_params = {} + get_params[:user_id] = user_id + get_params[:pagination_identifier] = pagination_identifier + get_params[:addresses] = device_addresses_array + get_params[:limit] = limit + response = devices_service.get_list(get_params) +---- + +=== Device Managers Module + +* Initialize Device Manager service object to perform device manager specific actions. ++ +[source,ruby] +---- + device_managers_service = ost_sdk.services.device_managers +---- + +* Get Device Manager Detail using userId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device manager details needs to be fetched. + user_id = 'c2c___' + + get_params = {} + get_params[:user_id] = user_id + response = device_managers_service.get(get_params) +---- + +=== Sessions Module + +* Initialize Sessions service object to perform session specific actions. ++ +[source,ruby] +---- + sessions_service = ost_sdk.services.sessions +---- + +* Get User Session Detail using userId and session address. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device manager details needs to be fetched. + user_id = 'c2c___' + + # Session address of user for which details needs to be fetched. + session_address = '0x5F8___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:session_address] = session_address + response = sessions_service.get(get_params) +---- + +* Get User Sessions List using userId. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom session details needs to be fetched. + user_id = 'c2c6___' + + # Optional API parameters + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJsY___' + + # Array of session addresses of end user. + session_addresses_array = ['0x59___','0xab___'] + + # Limit. + limit = 10 + + get_params = {} + get_params[:user_id] = user_id + get_params[:pagination_identifier] = pagination_identifier + get_params[:addresses] = session_addresses_array + get_params[:limit] = limit + response = sessions_service.get_list(get_params) +---- + +=== Executing Transactions + +For executing transactions, you need to understand the 4 modules described below. + +==== Rules Module + +* Initialize Rules service object to perform rules specific actions. ++ +[source,ruby] +---- + rules_service = ost_sdk.services.rules +---- + +* List Rules. ++ +[source,ruby] +---- + get_params = {} + response = rules_service.get_list(get_params) +---- + +==== Price Points Module + +* Initialize Price Points service object to perform price points specific actions. ++ +[source,ruby] +---- + price_points_service = ost_sdk.services.price_points +---- + +* Get Price Points Detail. ++ +[source,ruby] +---- + # Mandatory API parameters + + chain_id = 2000 + + get_params = {} + get_params[:chain_id] = chain_id + response = price_points_service.get(get_params) +---- + +==== Transactions Module + +* Initialize Transactions service object to perform transaction specific actions. ++ +[source,ruby] +---- + transactions_service = ost_sdk.services.transactions +---- + +* DIRECT-TRANSFERS execute transaction should be used to transfer BTs to your end-users. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Token holder address of receiver. + transfer_to_address = '0x4e___' + + # Amount of tokens to be transferred. + transfer_amount = '1' + + # Parameters required for rule execution. + raw_calldata = {} + raw_calldata[:method] = 'directTransfers' # Rule name which needs to be passed as-is. + raw_calldata[:parameters] = [[transfer_to_address],[transfer_amount]] + + # Company userId. + company_user_id = 'ee8___' + + # Address of DirectTransfer rule. Use list rules API of Rules module to get the address of rules. + # In the rules array which you will get in response, use the address having name "Direct Transfer". + direct_transfer_rule_address = '0xe37___' + + # Optional API parameters + + # Name of the transaction. Eg. 'like', 'download', etc. + # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) + transaction_name = 'like' + + # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. + transaction_type = 'company_to_user' + + # Some extra information about transaction. + # NOTE: Max length 125 characters (Allowed characters: [A-Za-z0-9_/s]) + details = 'lorem_ipsum' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + meta_property = { + name: transaction_name, + type: transaction_type, + details: details + } + + execute_params = {} + execute_params[:user_id] = company_user_id + execute_params[:to] = direct_transfer_rule_address + execute_params[:raw_calldata] = raw_calldata.to_json + execute_params[:meta_property] = meta_property + response = transactions_service.execute(execute_params) +---- + +* PAY Execute Transaction should be used when transactions of BTs equivalent to some fiat amount need to be executed. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Token holder address of receiver. + transfer_to_address = '0x4e___' + + # Company holder address of sender. + company_token_holder_address= '0x34r___' + + # Pay currency code. Supported currency codes are 'USD', 'EUR' and 'GBP'. + pay_currency_code = 'USD' + + # In pay transaction, the transfer amounts are in pay currency (fiat currency like USD) which then are converted + # into tokens. Use get price point detail API of Price Points module to get this value. + price_point = 0.020606673 + + # Price point needs to be passed in atto. Multiply the price point with 10^18. Also, this value should be a string. + intended_price_point_in_atto = "%.f" % ((price_point * 10**18)) + + # Amount of Fiat to be transferred. + transfer_amount_in_fiat = 0.1 + + # Transfer amount in wei needs to be passed in atto. Multiply the fiat transfer amount with 10^18. Also, this value should be a string. + fiat_transfer_amount_in_atto = "%.f" % (transfer_amount_in_fiat * 10**18) + + # Parameters required for rule execution. + raw_calldata = {} + raw_calldata[:method] = 'pay' # Rule name which needs to be passed as-is. + raw_calldata[:parameters] = [company_token_holder_address, [transfer_to_address],[fiat_transfer_amount_in_atto], pay_currency_code, intended_price_point_in_atto] + + # Company userId. + company_user_id = 'ee8___' + + # Address of Pay rule. Use list rules API of Rules module to get the address of rules. + # In the rules array which you will get in response, use the address having name "Pricer". + pay_rule_address = '0xe37___' + + # Optional API parameters + + # Name of the transaction. Eg. 'like', 'download', etc. + # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) + transaction_name = 'like' + + # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. + transaction_type = 'company_to_user' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + details = 'lorem_ipsum' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + meta_property = { + name: transaction_name, + type: transaction_type, + details: details + } + + execute_params = {} + execute_params[:user_id] = company_user_id + execute_params[:to] = pay_rule_address + execute_params[:raw_calldata] = raw_calldata.to_json + execute_params[:meta_property] = meta_property + response = transactions_service.execute(execute_params) +---- + +* Get Transaction Detail using userId and transactionId. ++ +[source,ruby] +---- + # Mandatory parameters + + # UserId of end-user. + user_id = 'e50___' + + # Unique identifier of the transaction to be retrieved. + transaction_id = 't43___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:transaction_id] = transaction_id + response = transactions_service.get(get_params) +---- + +* Get User Transactions using userId. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory parameters + + # UserId of end-user. + user_id = 'e502___' + + # Optional API parameters + + # Array of status values. + statuses_array = ['CREATED', 'SUBMITTED', 'SUCCESS', 'FAILED'] + + # To get transactions between a specific time interval, add start timestamp and end timestamp. + start_time = 1563260786 + end_time = 1563280786 + + # Name of the transaction. Eg. 'like', 'download', etc. + # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) + transaction_name = 'like' + + # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. + transaction_type = 'company_to_user' + + # NOTE: Max length 125 characters (Allowed characters: [A-Za-z0-9_/s]) + details = 'lorem_ipsum' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + meta_properties = [{ + name: transaction_name, + type: transaction_type, + details: details + }] + + # Limit. + limit = 10 + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJsY___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:statuses] = statuses_array + get_params[:start_time] = start_time + get_params[:end_time] = end_time + get_params[:meta_properties] = meta_properties.to_json + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = transactions_service.get_list(get_params) +---- + +==== Balances Module + +* Initialize Balances service object to perform balances specific actions. ++ +[source,ruby] +---- + balances_service = ost_sdk.services.balance +---- + +* Get User Balance using userId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId for whom balance needs to be fetched. + user_id = '987w___' + + get_params = {} + get_params[:user_id] = user_id + response = balances_service.get(get_params) +---- + +=== Recovery Owners Module + +* Initialize Recovery Owners service object to perform recovery owners specific actions. ++ +[source,ruby] +---- + recovery_owners_service = ost_sdk.services.recovery_owners +---- + +* Get Recovery Owner Detail using userId and recovery owner address. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId for whom recovery details needs to be fetched. + user_id = '987w___' + + # Recovery address of user. + recovery_owner_address = '0x54e___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:recovery_owner_address] = recovery_owner_address + response = recovery_owners_service.get(get_params) +---- + +=== Tokens Module + +* Initialize Tokens service object to perform tokens specific actions. ++ +[source,ruby] +---- + tokens_service = ost_sdk.services.tokens +---- + +* Get Token Detail. ++ +[source,ruby] +---- + get_params = {} + response = tokens_service.get(get_params) +---- + +=== Chains Module + +* Initialize Chains service object to perform chains specific actions. ++ +[source,ruby] +---- + chains_service = ost_sdk.services.chains +---- + +* Get Chain Detail using chainId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # ChainId for which details needs to be fetched. Only origin chainId and OST-specific auxiliary chainIds are allowed. + chain_id = 2000 + + get_params = {} + get_params[:chain_id] = chain_id + response = chains_service.get(get_params) +---- + +=== Base Tokens Module + +* Initialize Base Tokens service object to perform base tokens specific actions. ++ +[source,ruby] +---- + base_tokens_service = ost_sdk.services.base_tokens +---- + +* Get Base Tokens Detail. ++ +[source,ruby] +---- + get_params = {} + response = base_tokens_service.get(get_params) +---- + +=== Webhooks Module + +* Initialize Webhooks service object to perform webhooks specific actions. ++ +[source,ruby] +---- + webhooks_service = ost_sdk.services.webhooks +---- + +* Create Webhook using the topics and the subscription url. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Array of topics. + topic_params = ['transactions/initiate', 'transactions/success'] + + # URL where you want to receive the event notifications. + url = 'https://www.testingWebhooks.com' + + # Optional API parameters + + # Status of a webhook. Possible values are 'active' and 'inactive'. + status = 'active' + + create_params = {} + create_params[:topics] = topic_params + create_params[:url] = url + create_params[:status] = status + response = webhooks_service.create(create_params) +---- + +* Update existing Webhook using a webhookId and an array of topics. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Array of topics. + topic_params = ['transactions/initiate', 'transactions/success'] + + # Unique identifier for a webhook. + webhook_id = 'a743___' + + # Optional API parameters + + # Status of a webhook. Possible values are 'active' and 'inactive'. + status = 'active' + + update_params = {} + update_params[:webhook_id] = webhook_id + update_params[:topics] = topic_params + update_params[:status] = status + response = webhooks_service.update(update_params) +---- + +* Get Webhook using webhookId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Unique identifier for a webhook. + webhook_id = 'a743___' + + get_params = {} + get_params[:webhook_id] = webhook_id + response = webhooks_service.get(get_params) +---- + +* Get Webhook List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + # No mandatory parameters. + + # Optional API parameters + + # Limit. + limit = 10 + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJwY___' + + get_params = {} + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = webhooks_service.get_list(get_params) +---- + +* Delete Webhook using webhookId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Unique identifier for a webhook. + webhook_id = 'a743___' + + delete_params = {} + delete_params[:webhook_id] = webhook_id + response = webhooks_service.delete(delete_params) +---- + +* Verify webhook request signature. +This can be used to validate if the webhook received at your end from OST platform is correctly signed. ++ +[source,ruby] +---- + signature_params = {} + + # Webhook data obtained. + webhook_event_data = {"id":"54e3cd1c-afd7-4dcf-9c78-137c56a53582","topic":"transactions/success","created_at":1560838772,"webhook_id":"0823a4ea-5d87-44cf-8ca8-1e5a31bf8e46","version":"v2","data":{"result_type":"transaction","transaction":{"id":"ddebe817-b94f-4b51-9227-f543fae4715a","transaction_hash":"0x7ee737db22b58dc4da3f4ea4830ca709b388d84f31e77106cb79ee09fc6448f9","from":"0x69a581096dbddf6d1e0fff7ebc1254bb7a2647c6","to":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","nonce":3,"value":"0","gas_price":"1000000000","gas_used":120558,"transaction_fee":"120558000000000","block_confirmation":24,"status":"SUCCESS","updated_timestamp":1560838699,"block_timestamp":1560838698,"block_number":1554246,"rule_name":"Pricer","meta_property":{},"transfers":[{"from":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","from_user_id":"acfdea7d-278e-4ffc-aacb-4a21398a280c","to":"0x0a754aaab96d634337aac6556312de396a0ca46a","to_user_id":"7bc8e0bd-6761-4604-8f8e-e33f86f81309","amount":"112325386","kind":"transfer"}]}}} + signature_params[:stringified_data] = webhook_event_data.to_json + + # Get webhoook version from webhook events data. + signature_params[:version] = "v2" + + # Get ost-timestamp from the response received in event. + signature_params[:request_timestamp] = '1559902637' + + # Get signature from the response received in event. + signature_params[:signature] = '2c56c143550c603a6ff47054803f03ee4755c9c707986ae27f7ca1dd1c92a824' + + signature_params[:webhook_secret] = 'mySecret' + response = webhooks_service.verify_signature(signature_params) +---- + +=== Redemption Modules + +Two modules of redemption, "Redeemable SKUs" and "User Redemptions", are described below. + +==== Redeemable SKUs Module + +* Initialize Redeemable SKUs service object to perform redeemable skus specific actions. ++ +[source,ruby] +---- + redeemable_skus_service = ost_sdk.services.redeemable_skus +---- + +* Get Redeemable SKU detail using the redeemable sku id. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Fetch details of following redeemable sku. + redeemable_sku_id = '1' + + get_params = {} + get_params[:redeemable_sku_id] = redeemable_sku_id + response = redeemable_skus_service.get(get_params) +---- + +* Get Redeemable SKUs List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + # NOTE: No mandatory parameters. + + # Optional API parameters + + # Limit. + limit = 10 + + # Array of redeemable SKU ids. + redeemable_sku_ids = ['1001', '1002'] + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJwY___' + + get_params = {} + get_params[:redeemable_sku_ids] = redeemable_sku_ids + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = redeemable_skus_service.get_list(get_params) +---- ++ +==== User Redemptions Module + +* Initialize Redemptions service object to perform user redemption specific actions. ++ +[source,ruby] +---- + redemptions_service = ost_sdk.services.redemptions +---- + +* Get User redemption details using the userId and redemptionId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom redemption details needs to be fetched. + user_id = 'ee8___' + + # Unique identifier of the redemption of user. + redemption_id = 'r43___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:redemption_id] = redemption_id + + response = redemptions_service.get(get_params) +---- + +* Get User Redemptions List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + user_id = 'ee8___' + + # Optional API parameters + + # Limit. + limit = 10 + + # Array of user redemption uuids. + redemption_ids = ['a743___', 'a743___'] + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJwY___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:redemption_ids] = redemption_ids + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = redemptions_service.get_list(get_params) +---- From f96b4dc68bf389c4bb165d235e9547bf32043b0b Mon Sep 17 00:00:00 2001 From: kevinfs510 Date: Thu, 12 Mar 2020 17:27:23 +0100 Subject: [PATCH 4/4] docs setup step #3 --- docs/modules/ROOT/nav.adoc | 3 +- .../{CHANGELOG.md.adoc => CHANGELOG.adoc} | 0 docs/modules/ROOT/pages/README.md.adoc | 879 ----------------- docs/modules/ROOT/pages/index.adoc | 880 +++++++++++++++++- 4 files changed, 880 insertions(+), 882 deletions(-) rename docs/modules/ROOT/pages/{CHANGELOG.md.adoc => CHANGELOG.adoc} (100%) delete mode 100644 docs/modules/ROOT/pages/README.md.adoc diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index 59a7257..df24086 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -1 +1,2 @@ -* xref:index.adoc[Overview] \ No newline at end of file +* xref:index.adoc[Overview] +* xref:CHANGELOG.adoc[Change Log] \ No newline at end of file diff --git a/docs/modules/ROOT/pages/CHANGELOG.md.adoc b/docs/modules/ROOT/pages/CHANGELOG.adoc similarity index 100% rename from docs/modules/ROOT/pages/CHANGELOG.md.adoc rename to docs/modules/ROOT/pages/CHANGELOG.adoc diff --git a/docs/modules/ROOT/pages/README.md.adoc b/docs/modules/ROOT/pages/README.md.adoc deleted file mode 100644 index 8eb3e94..0000000 --- a/docs/modules/ROOT/pages/README.md.adoc +++ /dev/null @@ -1,879 +0,0 @@ -= OST Server-Side Ruby SDK - -image::https://travis-ci.org/ostdotcom/ost-sdk-ruby.svg?branch=develop[Build Status,link=https://travis-ci.org/ostdotcom/ost-sdk-ruby] - -https://dev.ost.com/[OST] Platform SDK for Ruby. - -== Introduction - -OST is a complete technology solution enabling mainstream businesses to easily launch blockchain based economies without requiring blockchain development. - -Brand Tokens (BTs) are white-label cryptocurrency tokens with utility representations running on highly-scalable Ethereum-based utility blockchains, backed by value token (such as OST, USDC) staked on Ethereum mainnet. -Within a business`s token economy, BTs can only be transferred to whitelisted user addresses. -This ensures that they stay within the token economy. - -The OST technology stack is designed to give businesses everything they need to integrate, test, and deploy BTs. -Within the OST suite of products, developers can use OST Platform to create, test, and launch Brand Tokens. - -OST APIs and server-side SDKs make it simple and easy for developers to integrate blockchain tokens into their apps. - -For documentation, visit https://dev.ost.com/ - -== Getting Started - -=== Setup Brand Token - -. Sign-up on https://platform.ost.com[OST Platform] and setup your Brand Token. -. Obtain your API Key and API Secret from https://platform.ost.com/mainnet/developer[developers page]. - -=== Installation - -The preferred way to install the OST Ruby SDK is to use the RubyGems package manager for Ruby. -Simply type the following into a terminal window: - -[source,bash] ----- - gem install ost-sdk-ruby ----- - -== Usage - -* Require the OST Ruby SDK: -+ -[source,ruby] ----- - require('ost-sdk-ruby') ----- - -* Initialize the SDK object. -+ -[source,ruby] ----- - # Declare connection parameters. - - # Mandatory API parameters. - - api_key = '__abc'; # OBTAINED FROM DEVELOPER PAGE - api_secret = '_xyz'; # OBTAINED FROM DEVELOPER PAGE - - # The valid API endpoints are: - # 1. Mainnet: "https://api.ost.com/mainnet/v2/" - # 2. Testnet: "https://api.ost.com/testnet/v2/" - api_base_url = 'https://api.ost.com/testnet/v2/' - - # Optional API parameters. - - # This is the timeout in seconds for which the socket connection will remain open. - timeout_in_seconds = '' - options = {timeout: timeout_in_seconds} - - # OST server side sdk object. - ost_sdk = OSTSdk::Saas::Services.new({api_key: api_key, api_secret: api_secret, api_base_url: api_base_url, config: options}) ----- - -=== Users Module - -* Initialize Users service object to perform user specific actions. -+ -[source,ruby] ----- - users_service = ost_sdk.services.users ----- - -* Create User. -This creates a unique identifier for each user. -+ -[source,ruby] ----- - create_params = {} - response = users_service.create(create_params) ----- - -* Get User Detail using the userId obtained in user create. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom user details needs to be fetched. - user_id = '912___' - - get_params = {} - get_params[:user_id] = user_id - response = users_service.get(get_params) ----- - -* Get Users List. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory API parameters - # No mandatory parameters. - - # Optional API parameters - - # Array of userIds for which data needs to be fetched. - ids_array = ['c2c___', 'd2c6___'] - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'e77y___' - - # Limit. - limit = 10 - - get_params = {} - get_params[:ids] = ids_array - get_params[:limit] = limit - get_params[:pagination_identifier] = pagination_identifier - response = users_service.get_list(get_params) ----- - -=== Devices Module - -* Initialize Devices service object to perform device specific actions. -+ -[source,ruby] ----- - devices_service = ost_sdk.services.devices ----- - -* Create a Device for User. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom device needs to be created. - user_id = 'c2c6___' - - # Device address of user's device. - device_address = '0x1Ea___' - - # Device API signer address. - api_signer_address = '0x5F8___' - - create_params = {} - create_params[:user_id] = user_id - create_params[:address] = device_address - create_params[:api_signer_address] = api_signer_address - response = devices_service.create(create_params) ----- - -* Get User Device Detail using userId and deviceAddress. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom device details needs to be fetched. - user_id = 'c2c6f___' - - # Device address of user's device. - device_address = '0x1Ea___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:device_address] = device_address - response = devices_service.get(get_params) ----- - -* Get User Devices List. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom device details needs to be fetched. - user_id = 'c2c6___' - - # Optional API parameters - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'eyJs___' - - # Array of device addresses of end user. - device_addresses_array = ['0x590___','0xab___'] - - # Limit. - limit = 10 - - get_params = {} - get_params[:user_id] = user_id - get_params[:pagination_identifier] = pagination_identifier - get_params[:addresses] = device_addresses_array - get_params[:limit] = limit - response = devices_service.get_list(get_params) ----- - -=== Device Managers Module - -* Initialize Device Manager service object to perform device manager specific actions. -+ -[source,ruby] ----- - device_managers_service = ost_sdk.services.device_managers ----- - -* Get Device Manager Detail using userId. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom device manager details needs to be fetched. - user_id = 'c2c___' - - get_params = {} - get_params[:user_id] = user_id - response = device_managers_service.get(get_params) ----- - -=== Sessions Module - -* Initialize Sessions service object to perform session specific actions. -+ -[source,ruby] ----- - sessions_service = ost_sdk.services.sessions ----- - -* Get User Session Detail using userId and session address. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom device manager details needs to be fetched. - user_id = 'c2c___' - - # Session address of user for which details needs to be fetched. - session_address = '0x5F8___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:session_address] = session_address - response = sessions_service.get(get_params) ----- - -* Get User Sessions List using userId. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom session details needs to be fetched. - user_id = 'c2c6___' - - # Optional API parameters - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'eyJsY___' - - # Array of session addresses of end user. - session_addresses_array = ['0x59___','0xab___'] - - # Limit. - limit = 10 - - get_params = {} - get_params[:user_id] = user_id - get_params[:pagination_identifier] = pagination_identifier - get_params[:addresses] = session_addresses_array - get_params[:limit] = limit - response = sessions_service.get_list(get_params) ----- - -=== Executing Transactions - -For executing transactions, you need to understand the 4 modules described below. - -==== Rules Module - -* Initialize Rules service object to perform rules specific actions. -+ -[source,ruby] ----- - rules_service = ost_sdk.services.rules ----- - -* List Rules. -+ -[source,ruby] ----- - get_params = {} - response = rules_service.get_list(get_params) ----- - -==== Price Points Module - -* Initialize Price Points service object to perform price points specific actions. -+ -[source,ruby] ----- - price_points_service = ost_sdk.services.price_points ----- - -* Get Price Points Detail. -+ -[source,ruby] ----- - # Mandatory API parameters - - chain_id = 2000 - - get_params = {} - get_params[:chain_id] = chain_id - response = price_points_service.get(get_params) ----- - -==== Transactions Module - -* Initialize Transactions service object to perform transaction specific actions. -+ -[source,ruby] ----- - transactions_service = ost_sdk.services.transactions ----- - -* DIRECT-TRANSFERS execute transaction should be used to transfer BTs to your end-users. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Token holder address of receiver. - transfer_to_address = '0x4e___' - - # Amount of tokens to be transferred. - transfer_amount = '1' - - # Parameters required for rule execution. - raw_calldata = {} - raw_calldata[:method] = 'directTransfers' # Rule name which needs to be passed as-is. - raw_calldata[:parameters] = [[transfer_to_address],[transfer_amount]] - - # Company userId. - company_user_id = 'ee8___' - - # Address of DirectTransfer rule. Use list rules API of Rules module to get the address of rules. - # In the rules array which you will get in response, use the address having name "Direct Transfer". - direct_transfer_rule_address = '0xe37___' - - # Optional API parameters - - # Name of the transaction. Eg. 'like', 'download', etc. - # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) - transaction_name = 'like' - - # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. - transaction_type = 'company_to_user' - - # Some extra information about transaction. - # NOTE: Max length 125 characters (Allowed characters: [A-Za-z0-9_/s]) - details = 'lorem_ipsum' - - # Additional transaction information. There is no dependency between any of the metaProperty keys. - # However, if a key is present, its value cannot be null or undefined. - meta_property = { - name: transaction_name, - type: transaction_type, - details: details - } - - execute_params = {} - execute_params[:user_id] = company_user_id - execute_params[:to] = direct_transfer_rule_address - execute_params[:raw_calldata] = raw_calldata.to_json - execute_params[:meta_property] = meta_property - response = transactions_service.execute(execute_params) ----- - -* PAY Execute Transaction should be used when transactions of BTs equivalent to some fiat amount need to be executed. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Token holder address of receiver. - transfer_to_address = '0x4e___' - - # Company holder address of sender. - company_token_holder_address= '0x34r___' - - # Pay currency code. Supported currency codes are 'USD', 'EUR' and 'GBP'. - pay_currency_code = 'USD' - - # In pay transaction, the transfer amounts are in pay currency (fiat currency like USD) which then are converted - # into tokens. Use get price point detail API of Price Points module to get this value. - price_point = 0.020606673 - - # Price point needs to be passed in atto. Multiply the price point with 10^18. Also, this value should be a string. - intended_price_point_in_atto = "%.f" % ((price_point * 10**18)) - - # Amount of Fiat to be transferred. - transfer_amount_in_fiat = 0.1 - - # Transfer amount in wei needs to be passed in atto. Multiply the fiat transfer amount with 10^18. Also, this value should be a string. - fiat_transfer_amount_in_atto = "%.f" % (transfer_amount_in_fiat * 10**18) - - # Parameters required for rule execution. - raw_calldata = {} - raw_calldata[:method] = 'pay' # Rule name which needs to be passed as-is. - raw_calldata[:parameters] = [company_token_holder_address, [transfer_to_address],[fiat_transfer_amount_in_atto], pay_currency_code, intended_price_point_in_atto] - - # Company userId. - company_user_id = 'ee8___' - - # Address of Pay rule. Use list rules API of Rules module to get the address of rules. - # In the rules array which you will get in response, use the address having name "Pricer". - pay_rule_address = '0xe37___' - - # Optional API parameters - - # Name of the transaction. Eg. 'like', 'download', etc. - # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) - transaction_name = 'like' - - # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. - transaction_type = 'company_to_user' - - # Additional transaction information. There is no dependency between any of the metaProperty keys. - # However, if a key is present, its value cannot be null or undefined. - details = 'lorem_ipsum' - - # Additional transaction information. There is no dependency between any of the metaProperty keys. - # However, if a key is present, its value cannot be null or undefined. - meta_property = { - name: transaction_name, - type: transaction_type, - details: details - } - - execute_params = {} - execute_params[:user_id] = company_user_id - execute_params[:to] = pay_rule_address - execute_params[:raw_calldata] = raw_calldata.to_json - execute_params[:meta_property] = meta_property - response = transactions_service.execute(execute_params) ----- - -* Get Transaction Detail using userId and transactionId. -+ -[source,ruby] ----- - # Mandatory parameters - - # UserId of end-user. - user_id = 'e50___' - - # Unique identifier of the transaction to be retrieved. - transaction_id = 't43___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:transaction_id] = transaction_id - response = transactions_service.get(get_params) ----- - -* Get User Transactions using userId. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory parameters - - # UserId of end-user. - user_id = 'e502___' - - # Optional API parameters - - # Array of status values. - statuses_array = ['CREATED', 'SUBMITTED', 'SUCCESS', 'FAILED'] - - # To get transactions between a specific time interval, add start timestamp and end timestamp. - start_time = 1563260786 - end_time = 1563280786 - - # Name of the transaction. Eg. 'like', 'download', etc. - # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) - transaction_name = 'like' - - # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. - transaction_type = 'company_to_user' - - # NOTE: Max length 125 characters (Allowed characters: [A-Za-z0-9_/s]) - details = 'lorem_ipsum' - - # Additional transaction information. There is no dependency between any of the metaProperty keys. - # However, if a key is present, its value cannot be null or undefined. - meta_properties = [{ - name: transaction_name, - type: transaction_type, - details: details - }] - - # Limit. - limit = 10 - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'eyJsY___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:statuses] = statuses_array - get_params[:start_time] = start_time - get_params[:end_time] = end_time - get_params[:meta_properties] = meta_properties.to_json - get_params[:limit] = limit - get_params[:pagination_identifier] = pagination_identifier - response = transactions_service.get_list(get_params) ----- - -==== Balances Module - -* Initialize Balances service object to perform balances specific actions. -+ -[source,ruby] ----- - balances_service = ost_sdk.services.balance ----- - -* Get User Balance using userId. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId for whom balance needs to be fetched. - user_id = '987w___' - - get_params = {} - get_params[:user_id] = user_id - response = balances_service.get(get_params) ----- - -=== Recovery Owners Module - -* Initialize Recovery Owners service object to perform recovery owners specific actions. -+ -[source,ruby] ----- - recovery_owners_service = ost_sdk.services.recovery_owners ----- - -* Get Recovery Owner Detail using userId and recovery owner address. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId for whom recovery details needs to be fetched. - user_id = '987w___' - - # Recovery address of user. - recovery_owner_address = '0x54e___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:recovery_owner_address] = recovery_owner_address - response = recovery_owners_service.get(get_params) ----- - -=== Tokens Module - -* Initialize Tokens service object to perform tokens specific actions. -+ -[source,ruby] ----- - tokens_service = ost_sdk.services.tokens ----- - -* Get Token Detail. -+ -[source,ruby] ----- - get_params = {} - response = tokens_service.get(get_params) ----- - -=== Chains Module - -* Initialize Chains service object to perform chains specific actions. -+ -[source,ruby] ----- - chains_service = ost_sdk.services.chains ----- - -* Get Chain Detail using chainId. -+ -[source,ruby] ----- - # Mandatory API parameters - - # ChainId for which details needs to be fetched. Only origin chainId and OST-specific auxiliary chainIds are allowed. - chain_id = 2000 - - get_params = {} - get_params[:chain_id] = chain_id - response = chains_service.get(get_params) ----- - -=== Base Tokens Module - -* Initialize Base Tokens service object to perform base tokens specific actions. -+ -[source,ruby] ----- - base_tokens_service = ost_sdk.services.base_tokens ----- - -* Get Base Tokens Detail. -+ -[source,ruby] ----- - get_params = {} - response = base_tokens_service.get(get_params) ----- - -=== Webhooks Module - -* Initialize Webhooks service object to perform webhooks specific actions. -+ -[source,ruby] ----- - webhooks_service = ost_sdk.services.webhooks ----- - -* Create Webhook using the topics and the subscription url. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Array of topics. - topic_params = ['transactions/initiate', 'transactions/success'] - - # URL where you want to receive the event notifications. - url = 'https://www.testingWebhooks.com' - - # Optional API parameters - - # Status of a webhook. Possible values are 'active' and 'inactive'. - status = 'active' - - create_params = {} - create_params[:topics] = topic_params - create_params[:url] = url - create_params[:status] = status - response = webhooks_service.create(create_params) ----- - -* Update existing Webhook using a webhookId and an array of topics. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Array of topics. - topic_params = ['transactions/initiate', 'transactions/success'] - - # Unique identifier for a webhook. - webhook_id = 'a743___' - - # Optional API parameters - - # Status of a webhook. Possible values are 'active' and 'inactive'. - status = 'active' - - update_params = {} - update_params[:webhook_id] = webhook_id - update_params[:topics] = topic_params - update_params[:status] = status - response = webhooks_service.update(update_params) ----- - -* Get Webhook using webhookId. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Unique identifier for a webhook. - webhook_id = 'a743___' - - get_params = {} - get_params[:webhook_id] = webhook_id - response = webhooks_service.get(get_params) ----- - -* Get Webhook List. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory API parameters - # No mandatory parameters. - - # Optional API parameters - - # Limit. - limit = 10 - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'eyJwY___' - - get_params = {} - get_params[:limit] = limit - get_params[:pagination_identifier] = pagination_identifier - response = webhooks_service.get_list(get_params) ----- - -* Delete Webhook using webhookId. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Unique identifier for a webhook. - webhook_id = 'a743___' - - delete_params = {} - delete_params[:webhook_id] = webhook_id - response = webhooks_service.delete(delete_params) ----- - -* Verify webhook request signature. -This can be used to validate if the webhook received at your end from OST platform is correctly signed. -+ -[source,ruby] ----- - signature_params = {} - - # Webhook data obtained. - webhook_event_data = {"id":"54e3cd1c-afd7-4dcf-9c78-137c56a53582","topic":"transactions/success","created_at":1560838772,"webhook_id":"0823a4ea-5d87-44cf-8ca8-1e5a31bf8e46","version":"v2","data":{"result_type":"transaction","transaction":{"id":"ddebe817-b94f-4b51-9227-f543fae4715a","transaction_hash":"0x7ee737db22b58dc4da3f4ea4830ca709b388d84f31e77106cb79ee09fc6448f9","from":"0x69a581096dbddf6d1e0fff7ebc1254bb7a2647c6","to":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","nonce":3,"value":"0","gas_price":"1000000000","gas_used":120558,"transaction_fee":"120558000000000","block_confirmation":24,"status":"SUCCESS","updated_timestamp":1560838699,"block_timestamp":1560838698,"block_number":1554246,"rule_name":"Pricer","meta_property":{},"transfers":[{"from":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","from_user_id":"acfdea7d-278e-4ffc-aacb-4a21398a280c","to":"0x0a754aaab96d634337aac6556312de396a0ca46a","to_user_id":"7bc8e0bd-6761-4604-8f8e-e33f86f81309","amount":"112325386","kind":"transfer"}]}}} - signature_params[:stringified_data] = webhook_event_data.to_json - - # Get webhoook version from webhook events data. - signature_params[:version] = "v2" - - # Get ost-timestamp from the response received in event. - signature_params[:request_timestamp] = '1559902637' - - # Get signature from the response received in event. - signature_params[:signature] = '2c56c143550c603a6ff47054803f03ee4755c9c707986ae27f7ca1dd1c92a824' - - signature_params[:webhook_secret] = 'mySecret' - response = webhooks_service.verify_signature(signature_params) ----- - -=== Redemption Modules - -Two modules of redemption, "Redeemable SKUs" and "User Redemptions", are described below. - -==== Redeemable SKUs Module - -* Initialize Redeemable SKUs service object to perform redeemable skus specific actions. -+ -[source,ruby] ----- - redeemable_skus_service = ost_sdk.services.redeemable_skus ----- - -* Get Redeemable SKU detail using the redeemable sku id. -+ -[source,ruby] ----- - # Mandatory API parameters - - # Fetch details of following redeemable sku. - redeemable_sku_id = '1' - - get_params = {} - get_params[:redeemable_sku_id] = redeemable_sku_id - response = redeemable_skus_service.get(get_params) ----- - -* Get Redeemable SKUs List. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory API parameters - # NOTE: No mandatory parameters. - - # Optional API parameters - - # Limit. - limit = 10 - - # Array of redeemable SKU ids. - redeemable_sku_ids = ['1001', '1002'] - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'eyJwY___' - - get_params = {} - get_params[:redeemable_sku_ids] = redeemable_sku_ids - get_params[:limit] = limit - get_params[:pagination_identifier] = pagination_identifier - response = redeemable_skus_service.get_list(get_params) ----- -+ -==== User Redemptions Module - -* Initialize Redemptions service object to perform user redemption specific actions. -+ -[source,ruby] ----- - redemptions_service = ost_sdk.services.redemptions ----- - -* Get User redemption details using the userId and redemptionId. -+ -[source,ruby] ----- - # Mandatory API parameters - - # UserId of user for whom redemption details needs to be fetched. - user_id = 'ee8___' - - # Unique identifier of the redemption of user. - redemption_id = 'r43___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:redemption_id] = redemption_id - - response = redemptions_service.get(get_params) ----- - -* Get User Redemptions List. -Pagination is supported by this API. -+ -[source,ruby] ----- - # Mandatory API parameters - user_id = 'ee8___' - - # Optional API parameters - - # Limit. - limit = 10 - - # Array of user redemption uuids. - redemption_ids = ['a743___', 'a743___'] - - # Pagination identifier from the previous API call response. Not needed for page one. - pagination_identifier = 'eyJwY___' - - get_params = {} - get_params[:user_id] = user_id - get_params[:redemption_ids] = redemption_ids - get_params[:limit] = limit - get_params[:pagination_identifier] = pagination_identifier - response = redemptions_service.get_list(get_params) ----- diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index 88d04fb..8eb3e94 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -1,3 +1,879 @@ -This is the index.adoc page for OST-SDK-RUBY += OST Server-Side Ruby SDK -This is a test :) \ No newline at end of file +image::https://travis-ci.org/ostdotcom/ost-sdk-ruby.svg?branch=develop[Build Status,link=https://travis-ci.org/ostdotcom/ost-sdk-ruby] + +https://dev.ost.com/[OST] Platform SDK for Ruby. + +== Introduction + +OST is a complete technology solution enabling mainstream businesses to easily launch blockchain based economies without requiring blockchain development. + +Brand Tokens (BTs) are white-label cryptocurrency tokens with utility representations running on highly-scalable Ethereum-based utility blockchains, backed by value token (such as OST, USDC) staked on Ethereum mainnet. +Within a business`s token economy, BTs can only be transferred to whitelisted user addresses. +This ensures that they stay within the token economy. + +The OST technology stack is designed to give businesses everything they need to integrate, test, and deploy BTs. +Within the OST suite of products, developers can use OST Platform to create, test, and launch Brand Tokens. + +OST APIs and server-side SDKs make it simple and easy for developers to integrate blockchain tokens into their apps. + +For documentation, visit https://dev.ost.com/ + +== Getting Started + +=== Setup Brand Token + +. Sign-up on https://platform.ost.com[OST Platform] and setup your Brand Token. +. Obtain your API Key and API Secret from https://platform.ost.com/mainnet/developer[developers page]. + +=== Installation + +The preferred way to install the OST Ruby SDK is to use the RubyGems package manager for Ruby. +Simply type the following into a terminal window: + +[source,bash] +---- + gem install ost-sdk-ruby +---- + +== Usage + +* Require the OST Ruby SDK: ++ +[source,ruby] +---- + require('ost-sdk-ruby') +---- + +* Initialize the SDK object. ++ +[source,ruby] +---- + # Declare connection parameters. + + # Mandatory API parameters. + + api_key = '__abc'; # OBTAINED FROM DEVELOPER PAGE + api_secret = '_xyz'; # OBTAINED FROM DEVELOPER PAGE + + # The valid API endpoints are: + # 1. Mainnet: "https://api.ost.com/mainnet/v2/" + # 2. Testnet: "https://api.ost.com/testnet/v2/" + api_base_url = 'https://api.ost.com/testnet/v2/' + + # Optional API parameters. + + # This is the timeout in seconds for which the socket connection will remain open. + timeout_in_seconds = '' + options = {timeout: timeout_in_seconds} + + # OST server side sdk object. + ost_sdk = OSTSdk::Saas::Services.new({api_key: api_key, api_secret: api_secret, api_base_url: api_base_url, config: options}) +---- + +=== Users Module + +* Initialize Users service object to perform user specific actions. ++ +[source,ruby] +---- + users_service = ost_sdk.services.users +---- + +* Create User. +This creates a unique identifier for each user. ++ +[source,ruby] +---- + create_params = {} + response = users_service.create(create_params) +---- + +* Get User Detail using the userId obtained in user create. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom user details needs to be fetched. + user_id = '912___' + + get_params = {} + get_params[:user_id] = user_id + response = users_service.get(get_params) +---- + +* Get Users List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + # No mandatory parameters. + + # Optional API parameters + + # Array of userIds for which data needs to be fetched. + ids_array = ['c2c___', 'd2c6___'] + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'e77y___' + + # Limit. + limit = 10 + + get_params = {} + get_params[:ids] = ids_array + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = users_service.get_list(get_params) +---- + +=== Devices Module + +* Initialize Devices service object to perform device specific actions. ++ +[source,ruby] +---- + devices_service = ost_sdk.services.devices +---- + +* Create a Device for User. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device needs to be created. + user_id = 'c2c6___' + + # Device address of user's device. + device_address = '0x1Ea___' + + # Device API signer address. + api_signer_address = '0x5F8___' + + create_params = {} + create_params[:user_id] = user_id + create_params[:address] = device_address + create_params[:api_signer_address] = api_signer_address + response = devices_service.create(create_params) +---- + +* Get User Device Detail using userId and deviceAddress. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device details needs to be fetched. + user_id = 'c2c6f___' + + # Device address of user's device. + device_address = '0x1Ea___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:device_address] = device_address + response = devices_service.get(get_params) +---- + +* Get User Devices List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device details needs to be fetched. + user_id = 'c2c6___' + + # Optional API parameters + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJs___' + + # Array of device addresses of end user. + device_addresses_array = ['0x590___','0xab___'] + + # Limit. + limit = 10 + + get_params = {} + get_params[:user_id] = user_id + get_params[:pagination_identifier] = pagination_identifier + get_params[:addresses] = device_addresses_array + get_params[:limit] = limit + response = devices_service.get_list(get_params) +---- + +=== Device Managers Module + +* Initialize Device Manager service object to perform device manager specific actions. ++ +[source,ruby] +---- + device_managers_service = ost_sdk.services.device_managers +---- + +* Get Device Manager Detail using userId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device manager details needs to be fetched. + user_id = 'c2c___' + + get_params = {} + get_params[:user_id] = user_id + response = device_managers_service.get(get_params) +---- + +=== Sessions Module + +* Initialize Sessions service object to perform session specific actions. ++ +[source,ruby] +---- + sessions_service = ost_sdk.services.sessions +---- + +* Get User Session Detail using userId and session address. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom device manager details needs to be fetched. + user_id = 'c2c___' + + # Session address of user for which details needs to be fetched. + session_address = '0x5F8___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:session_address] = session_address + response = sessions_service.get(get_params) +---- + +* Get User Sessions List using userId. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom session details needs to be fetched. + user_id = 'c2c6___' + + # Optional API parameters + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJsY___' + + # Array of session addresses of end user. + session_addresses_array = ['0x59___','0xab___'] + + # Limit. + limit = 10 + + get_params = {} + get_params[:user_id] = user_id + get_params[:pagination_identifier] = pagination_identifier + get_params[:addresses] = session_addresses_array + get_params[:limit] = limit + response = sessions_service.get_list(get_params) +---- + +=== Executing Transactions + +For executing transactions, you need to understand the 4 modules described below. + +==== Rules Module + +* Initialize Rules service object to perform rules specific actions. ++ +[source,ruby] +---- + rules_service = ost_sdk.services.rules +---- + +* List Rules. ++ +[source,ruby] +---- + get_params = {} + response = rules_service.get_list(get_params) +---- + +==== Price Points Module + +* Initialize Price Points service object to perform price points specific actions. ++ +[source,ruby] +---- + price_points_service = ost_sdk.services.price_points +---- + +* Get Price Points Detail. ++ +[source,ruby] +---- + # Mandatory API parameters + + chain_id = 2000 + + get_params = {} + get_params[:chain_id] = chain_id + response = price_points_service.get(get_params) +---- + +==== Transactions Module + +* Initialize Transactions service object to perform transaction specific actions. ++ +[source,ruby] +---- + transactions_service = ost_sdk.services.transactions +---- + +* DIRECT-TRANSFERS execute transaction should be used to transfer BTs to your end-users. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Token holder address of receiver. + transfer_to_address = '0x4e___' + + # Amount of tokens to be transferred. + transfer_amount = '1' + + # Parameters required for rule execution. + raw_calldata = {} + raw_calldata[:method] = 'directTransfers' # Rule name which needs to be passed as-is. + raw_calldata[:parameters] = [[transfer_to_address],[transfer_amount]] + + # Company userId. + company_user_id = 'ee8___' + + # Address of DirectTransfer rule. Use list rules API of Rules module to get the address of rules. + # In the rules array which you will get in response, use the address having name "Direct Transfer". + direct_transfer_rule_address = '0xe37___' + + # Optional API parameters + + # Name of the transaction. Eg. 'like', 'download', etc. + # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) + transaction_name = 'like' + + # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. + transaction_type = 'company_to_user' + + # Some extra information about transaction. + # NOTE: Max length 125 characters (Allowed characters: [A-Za-z0-9_/s]) + details = 'lorem_ipsum' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + meta_property = { + name: transaction_name, + type: transaction_type, + details: details + } + + execute_params = {} + execute_params[:user_id] = company_user_id + execute_params[:to] = direct_transfer_rule_address + execute_params[:raw_calldata] = raw_calldata.to_json + execute_params[:meta_property] = meta_property + response = transactions_service.execute(execute_params) +---- + +* PAY Execute Transaction should be used when transactions of BTs equivalent to some fiat amount need to be executed. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Token holder address of receiver. + transfer_to_address = '0x4e___' + + # Company holder address of sender. + company_token_holder_address= '0x34r___' + + # Pay currency code. Supported currency codes are 'USD', 'EUR' and 'GBP'. + pay_currency_code = 'USD' + + # In pay transaction, the transfer amounts are in pay currency (fiat currency like USD) which then are converted + # into tokens. Use get price point detail API of Price Points module to get this value. + price_point = 0.020606673 + + # Price point needs to be passed in atto. Multiply the price point with 10^18. Also, this value should be a string. + intended_price_point_in_atto = "%.f" % ((price_point * 10**18)) + + # Amount of Fiat to be transferred. + transfer_amount_in_fiat = 0.1 + + # Transfer amount in wei needs to be passed in atto. Multiply the fiat transfer amount with 10^18. Also, this value should be a string. + fiat_transfer_amount_in_atto = "%.f" % (transfer_amount_in_fiat * 10**18) + + # Parameters required for rule execution. + raw_calldata = {} + raw_calldata[:method] = 'pay' # Rule name which needs to be passed as-is. + raw_calldata[:parameters] = [company_token_holder_address, [transfer_to_address],[fiat_transfer_amount_in_atto], pay_currency_code, intended_price_point_in_atto] + + # Company userId. + company_user_id = 'ee8___' + + # Address of Pay rule. Use list rules API of Rules module to get the address of rules. + # In the rules array which you will get in response, use the address having name "Pricer". + pay_rule_address = '0xe37___' + + # Optional API parameters + + # Name of the transaction. Eg. 'like', 'download', etc. + # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) + transaction_name = 'like' + + # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. + transaction_type = 'company_to_user' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + details = 'lorem_ipsum' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + meta_property = { + name: transaction_name, + type: transaction_type, + details: details + } + + execute_params = {} + execute_params[:user_id] = company_user_id + execute_params[:to] = pay_rule_address + execute_params[:raw_calldata] = raw_calldata.to_json + execute_params[:meta_property] = meta_property + response = transactions_service.execute(execute_params) +---- + +* Get Transaction Detail using userId and transactionId. ++ +[source,ruby] +---- + # Mandatory parameters + + # UserId of end-user. + user_id = 'e50___' + + # Unique identifier of the transaction to be retrieved. + transaction_id = 't43___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:transaction_id] = transaction_id + response = transactions_service.get(get_params) +---- + +* Get User Transactions using userId. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory parameters + + # UserId of end-user. + user_id = 'e502___' + + # Optional API parameters + + # Array of status values. + statuses_array = ['CREATED', 'SUBMITTED', 'SUCCESS', 'FAILED'] + + # To get transactions between a specific time interval, add start timestamp and end timestamp. + start_time = 1563260786 + end_time = 1563280786 + + # Name of the transaction. Eg. 'like', 'download', etc. + # NOTE: Max length 25 characters (Allowed characters: [A-Za-z0-9_/s]) + transaction_name = 'like' + + # Transaction type. Possible values: 'company_to_user', 'user_to_user', 'user_to_company'. + transaction_type = 'company_to_user' + + # NOTE: Max length 125 characters (Allowed characters: [A-Za-z0-9_/s]) + details = 'lorem_ipsum' + + # Additional transaction information. There is no dependency between any of the metaProperty keys. + # However, if a key is present, its value cannot be null or undefined. + meta_properties = [{ + name: transaction_name, + type: transaction_type, + details: details + }] + + # Limit. + limit = 10 + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJsY___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:statuses] = statuses_array + get_params[:start_time] = start_time + get_params[:end_time] = end_time + get_params[:meta_properties] = meta_properties.to_json + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = transactions_service.get_list(get_params) +---- + +==== Balances Module + +* Initialize Balances service object to perform balances specific actions. ++ +[source,ruby] +---- + balances_service = ost_sdk.services.balance +---- + +* Get User Balance using userId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId for whom balance needs to be fetched. + user_id = '987w___' + + get_params = {} + get_params[:user_id] = user_id + response = balances_service.get(get_params) +---- + +=== Recovery Owners Module + +* Initialize Recovery Owners service object to perform recovery owners specific actions. ++ +[source,ruby] +---- + recovery_owners_service = ost_sdk.services.recovery_owners +---- + +* Get Recovery Owner Detail using userId and recovery owner address. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId for whom recovery details needs to be fetched. + user_id = '987w___' + + # Recovery address of user. + recovery_owner_address = '0x54e___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:recovery_owner_address] = recovery_owner_address + response = recovery_owners_service.get(get_params) +---- + +=== Tokens Module + +* Initialize Tokens service object to perform tokens specific actions. ++ +[source,ruby] +---- + tokens_service = ost_sdk.services.tokens +---- + +* Get Token Detail. ++ +[source,ruby] +---- + get_params = {} + response = tokens_service.get(get_params) +---- + +=== Chains Module + +* Initialize Chains service object to perform chains specific actions. ++ +[source,ruby] +---- + chains_service = ost_sdk.services.chains +---- + +* Get Chain Detail using chainId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # ChainId for which details needs to be fetched. Only origin chainId and OST-specific auxiliary chainIds are allowed. + chain_id = 2000 + + get_params = {} + get_params[:chain_id] = chain_id + response = chains_service.get(get_params) +---- + +=== Base Tokens Module + +* Initialize Base Tokens service object to perform base tokens specific actions. ++ +[source,ruby] +---- + base_tokens_service = ost_sdk.services.base_tokens +---- + +* Get Base Tokens Detail. ++ +[source,ruby] +---- + get_params = {} + response = base_tokens_service.get(get_params) +---- + +=== Webhooks Module + +* Initialize Webhooks service object to perform webhooks specific actions. ++ +[source,ruby] +---- + webhooks_service = ost_sdk.services.webhooks +---- + +* Create Webhook using the topics and the subscription url. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Array of topics. + topic_params = ['transactions/initiate', 'transactions/success'] + + # URL where you want to receive the event notifications. + url = 'https://www.testingWebhooks.com' + + # Optional API parameters + + # Status of a webhook. Possible values are 'active' and 'inactive'. + status = 'active' + + create_params = {} + create_params[:topics] = topic_params + create_params[:url] = url + create_params[:status] = status + response = webhooks_service.create(create_params) +---- + +* Update existing Webhook using a webhookId and an array of topics. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Array of topics. + topic_params = ['transactions/initiate', 'transactions/success'] + + # Unique identifier for a webhook. + webhook_id = 'a743___' + + # Optional API parameters + + # Status of a webhook. Possible values are 'active' and 'inactive'. + status = 'active' + + update_params = {} + update_params[:webhook_id] = webhook_id + update_params[:topics] = topic_params + update_params[:status] = status + response = webhooks_service.update(update_params) +---- + +* Get Webhook using webhookId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Unique identifier for a webhook. + webhook_id = 'a743___' + + get_params = {} + get_params[:webhook_id] = webhook_id + response = webhooks_service.get(get_params) +---- + +* Get Webhook List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + # No mandatory parameters. + + # Optional API parameters + + # Limit. + limit = 10 + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJwY___' + + get_params = {} + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = webhooks_service.get_list(get_params) +---- + +* Delete Webhook using webhookId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Unique identifier for a webhook. + webhook_id = 'a743___' + + delete_params = {} + delete_params[:webhook_id] = webhook_id + response = webhooks_service.delete(delete_params) +---- + +* Verify webhook request signature. +This can be used to validate if the webhook received at your end from OST platform is correctly signed. ++ +[source,ruby] +---- + signature_params = {} + + # Webhook data obtained. + webhook_event_data = {"id":"54e3cd1c-afd7-4dcf-9c78-137c56a53582","topic":"transactions/success","created_at":1560838772,"webhook_id":"0823a4ea-5d87-44cf-8ca8-1e5a31bf8e46","version":"v2","data":{"result_type":"transaction","transaction":{"id":"ddebe817-b94f-4b51-9227-f543fae4715a","transaction_hash":"0x7ee737db22b58dc4da3f4ea4830ca709b388d84f31e77106cb79ee09fc6448f9","from":"0x69a581096dbddf6d1e0fff7ebc1254bb7a2647c6","to":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","nonce":3,"value":"0","gas_price":"1000000000","gas_used":120558,"transaction_fee":"120558000000000","block_confirmation":24,"status":"SUCCESS","updated_timestamp":1560838699,"block_timestamp":1560838698,"block_number":1554246,"rule_name":"Pricer","meta_property":{},"transfers":[{"from":"0xc2f0dde92f6f3a3cb13bfff43e2bd136f7dcfe47","from_user_id":"acfdea7d-278e-4ffc-aacb-4a21398a280c","to":"0x0a754aaab96d634337aac6556312de396a0ca46a","to_user_id":"7bc8e0bd-6761-4604-8f8e-e33f86f81309","amount":"112325386","kind":"transfer"}]}}} + signature_params[:stringified_data] = webhook_event_data.to_json + + # Get webhoook version from webhook events data. + signature_params[:version] = "v2" + + # Get ost-timestamp from the response received in event. + signature_params[:request_timestamp] = '1559902637' + + # Get signature from the response received in event. + signature_params[:signature] = '2c56c143550c603a6ff47054803f03ee4755c9c707986ae27f7ca1dd1c92a824' + + signature_params[:webhook_secret] = 'mySecret' + response = webhooks_service.verify_signature(signature_params) +---- + +=== Redemption Modules + +Two modules of redemption, "Redeemable SKUs" and "User Redemptions", are described below. + +==== Redeemable SKUs Module + +* Initialize Redeemable SKUs service object to perform redeemable skus specific actions. ++ +[source,ruby] +---- + redeemable_skus_service = ost_sdk.services.redeemable_skus +---- + +* Get Redeemable SKU detail using the redeemable sku id. ++ +[source,ruby] +---- + # Mandatory API parameters + + # Fetch details of following redeemable sku. + redeemable_sku_id = '1' + + get_params = {} + get_params[:redeemable_sku_id] = redeemable_sku_id + response = redeemable_skus_service.get(get_params) +---- + +* Get Redeemable SKUs List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + # NOTE: No mandatory parameters. + + # Optional API parameters + + # Limit. + limit = 10 + + # Array of redeemable SKU ids. + redeemable_sku_ids = ['1001', '1002'] + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJwY___' + + get_params = {} + get_params[:redeemable_sku_ids] = redeemable_sku_ids + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = redeemable_skus_service.get_list(get_params) +---- ++ +==== User Redemptions Module + +* Initialize Redemptions service object to perform user redemption specific actions. ++ +[source,ruby] +---- + redemptions_service = ost_sdk.services.redemptions +---- + +* Get User redemption details using the userId and redemptionId. ++ +[source,ruby] +---- + # Mandatory API parameters + + # UserId of user for whom redemption details needs to be fetched. + user_id = 'ee8___' + + # Unique identifier of the redemption of user. + redemption_id = 'r43___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:redemption_id] = redemption_id + + response = redemptions_service.get(get_params) +---- + +* Get User Redemptions List. +Pagination is supported by this API. ++ +[source,ruby] +---- + # Mandatory API parameters + user_id = 'ee8___' + + # Optional API parameters + + # Limit. + limit = 10 + + # Array of user redemption uuids. + redemption_ids = ['a743___', 'a743___'] + + # Pagination identifier from the previous API call response. Not needed for page one. + pagination_identifier = 'eyJwY___' + + get_params = {} + get_params[:user_id] = user_id + get_params[:redemption_ids] = redemption_ids + get_params[:limit] = limit + get_params[:pagination_identifier] = pagination_identifier + response = redemptions_service.get_list(get_params) +----