Coder Social home page Coder Social logo

ost-sdk-ruby's Introduction

OST Server-Side Ruby SDK

Build Status

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

  1. Sign-up on OST Platform and setup your Brand Token.
  2. Obtain your API Key and API Secret from 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:

 gem install ost-sdk-ruby

Usage

  • Require the OST Ruby SDK:

    require('ost-sdk-ruby')
  • Initialize the SDK object.

    # 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.

    users_service = ost_sdk.services.users
  • Create User. This creates a unique identifier for each user.

    create_params = {}
    response = users_service.create(create_params)
  • Get User Detail using the userId obtained in user create.

    # 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.

    # 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.

    devices_service = ost_sdk.services.devices
  • Create a Device for User.

    # 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.

    # 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.

    # 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.

    device_managers_service = ost_sdk.services.device_managers
  • Get Device Manager Detail using userId.

    # 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.

    sessions_service = ost_sdk.services.sessions
  • Get User Session Detail using userId and session address.

    # 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.

    # 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.

    rules_service = ost_sdk.services.rules
  • List Rules.

    get_params = {}
    response = rules_service.get_list(get_params)

Price Points Module

  • Initialize Price Points service object to perform price points specific actions.

    price_points_service = ost_sdk.services.price_points
  • Get Price Points Detail.

    # 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.

    transactions_service = ost_sdk.services.transactions
  • DIRECT-TRANSFERS execute transaction should be used to transfer BTs to your end-users.

    # 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.

    # 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.

    # 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.

    # 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.

    balances_service = ost_sdk.services.balance
  • Get User Balance using userId.

    # 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.

    recovery_owners_service = ost_sdk.services.recovery_owners
  • Get Recovery Owner Detail using userId and recovery owner address.

    # 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.

    tokens_service = ost_sdk.services.tokens
  • Get Token Detail.

    get_params = {}
    response = tokens_service.get(get_params)

Chains Module

  • Initialize Chains service object to perform chains specific actions.

    chains_service = ost_sdk.services.chains
  • Get Chain Detail using chainId.

    # 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.

    base_tokens_service = ost_sdk.services.base_tokens
  • Get Base Tokens Detail.

    get_params = {}
    response = base_tokens_service.get(get_params)

Webhooks Module

  • Initialize Webhooks service object to perform webhooks specific actions.

    webhooks_service = ost_sdk.services.webhooks
  • Create Webhook using the topics and the subscription url.

    # 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.

    # 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.

    # 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.

    # 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.

    # 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.

    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.

    redeemable_skus_service = ost_sdk.services.redeemable_skus
  • Get Redeemable SKU detail using the redeemable sku id.

    # 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.

    # 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.

    redemptions_service = ost_sdk.services.redemptions
  • Get User redemption details using the userId and redemptionId.

    # 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.

    # 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)

ost-sdk-ruby's People

Contributors

aman-barbaria avatar anaghamurtarkar avatar bitsnacker avatar kedarchandrayan avatar mayurpatil888 avatar puneet-khushwani-eth avatar squanto avatar sunilkhedar avatar tejas-sangani avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ost-sdk-ruby's Issues

New transaction issues with raw_calldata

When I do execute transaction I am getting below error. Is this issue with tokenholderadddress?

{"success"=>false, "err"=>{"code"=>"BAD_REQUEST", "msg"=>"At least one parameter is invalid or missing. See "err.error_data" array for more details.", "error_data"=>[{"parameter"=>"raw_calldata", "msg"=>"Invalid parameter raw_calldata. Please ensure the input is well formed or visit https://dev.ost.com/platform/docs/api for details on accepted datatypes for API parameters."}], "internal_id"=>"l_etm_ped_tr_1"}}

Please help me How to build the raw_calldata?

Thanks!

users service request issue

Hi,

I have updated the ost sdk ruby and trying to use the release 2.0 (v2). I am able to connect ostsdk service. but, I am not able to use users service request. When I try the get_list or create, I am getting the below error.

2.5.1 :007 > response = users_service.get_list({})
=> {:success=>false, :err=>{:code=>"SOMETHING_WENT_WRONG", :internal_id=>"SDK(u_hh_2)", :msg=>"GET request Failed", :error_data=>[]}

Please help me on this. What would be or where would be wrong as I am doing.

Regards,
Vivek.

Amount not setting to transactions object

Hello,

I have created the actions using arbitrary_amount = true. My goal is to pass the amount while executing the transaction. But, Transaction is going to succeed. Tokens not setting to amount. amount key always remains nil value. Please check below code and could you please help me to set the amount to the transaction object.

  transaction_object.execute(from_user_id: from, to_user_id: to, 
    action_id: action_id, amount: coins).to_json

Thanks in advance. I would like to get the answer as early as possible.

Regards,
Vivek.

Getting an error..

I'm trying to run this command ostUsersObject = OSTSdk::Saas::Users.new(environment, credentials) and it's pulling back the following error NameError: uninitialized constant OSTSdk::Saas.

Cannot get UUID of Users

user_list_object1 = ostUsersObject.list() # returns an object that includes the list of users
users_list1 = user_list_object1.data["economy_users"] # sets users_list to the array of users from the returned object
people1 = users_list1.select { |u| user_names1.include? u["name"] }.map { |r| {name: r["name"], uuid: r["uuid"] }} # filters for Alice and Bob

If you try this for "User 2", "Alice" or "Bob" , it will work fine.

If you try this for "User 1", "User 0" or any other user, you will get an empty string. not the UUID

Transactions generated using API do not show up on the Dashboard

This probably is a UI issue.

I was able to create a Transaction called "Like" as per the instructions and execute the transaction.
The transaction does execute successfully because the User's Tokens are getting updated in UI.

However, the newly generated Transaction Count does not appear in the graph or the dashboard.

Only name can be edited for transaction types

ost-sdk-ruby 0.9.3
ruby 2.5.1

Hi there!

I've noticed that the API response for setting any of the 5 attributes besides name fail silently - I receive a successful response but when I retrieve the TransactionKind instance I see that the attribute wasn't updated:

ostTransactionKindObject = OSTSdk::Saas::TransactionKind.new(
  OstConfiguration.instance.environment,
  OstConfiguration.instance.credentials
)

# Return value:
<OSTSdk::Saas::TransactionKind:0x00007fc2d0615928
@http_helper= <OSTSdk::Util::HTTPHelper:0x00007fc2d06158d8
  @api_base_url="https://playgroundapi.ost.com",
  @api_key="xxxxxxxxxxx",
  @api_secret="XXXXXXXXXXXXX",
  @api_spec=false>,
  @url_prefix="/transaction-types"
>

Retrieving the Transaction Type

ostTransactionKindObject.list.data['transaction_types'].find {|tt| tt['name'] === 'Reward'}

# Return value:
{
  "id"=>"30304",
  "client_transaction_id"=>"30304",
  "name"=>"Reward",
  "kind"=>"user_to_company",
  "currency_type"=>"USD",
  "currency_value"=>"12.00000",
  "commission_percent"=>"0.05",
  "status"=>"active"
}

Editing the name

ostTransactionKindObject.edit(client_transaction_id: 30304, name: 'Foo')

# Return value:
<OSTSdk::Util::Result:0x00007fc2d3031540
@data=
  {"result_type"=>"transactions",
   "transactions"=>
[{"id"=>"30304", "client_id"=>3271, "name"=>"Foo", "uts"=>1525709131170}]},
@error=nil,
@error_data=nil,
@error_display_heading=nil,
@error_display_text=nil,
@error_message=nil,
@http_code=200,
@message=nil
>

ostTransactionKindObject.list.data['transaction_types'].find {|tt| tt['name'] === 'Foo'}

# Return value:
{
  "id"=>"30304",
  "client_transaction_id"=>"30304",
  "name"=>"Foo", # CHANGED ๐Ÿ˜Ž
  "kind"=>"user_to_company",
  "currency_type"=>"USD",
  "currency_value"=>"12.00000",
  "commission_percent"=>"0.05",
  "status"=>"active"
}

Editing the currency_value

ostTransactionKindObject.edit(client_transaction_id: 30304, currency_value: '13.00000')

# Return value:
<OSTSdk::Util::Result:0x00007fc2d3191458
@data=
  {"result_type"=>"transactions",
   "transactions"=>
[{"id"=>"30304",
  "client_id"=>3271,
  "currency_value"=>"13.00000",
  "uts"=>1525709249821}]},
  @error=nil,
  @error_data=nil,
  @error_display_heading=nil,
  @error_display_text=nil,
  @error_message=nil,
  @http_code=200,
  @message=nil
>

ostTransactionKindObject.list.data['transaction_types'].find {|tt| tt['name'] === 'Foo'}

# Return value:
{
  "id"=>"30304",
  "client_transaction_id"=>"30304",
  "name"=>"Foo",
  "kind"=>"user_to_company",
  "currency_type"=>"USD",
  "currency_value"=>"12.00000", # UNCHANGED! ๐Ÿ˜ฑ
  "commission_percent"=>"0.05",
  "status"=>"active"
}

Using old code getting error in my application

Hi,

I am using old transactions create and transactions execute while trying to execute I am getting the below error
{:success=>false, :err=>{:code=>"400", :msg=>"Non 200 HTTP Status", :display_text=>"", :display_heading=>"", :error_data=>{}}, :data=>{}}

But, Same codebase working in other application. Could you please let me know old api's will work or not

@credentials = OSTSdk::Util::APICredentials.new(api_key, api_secret)

@transaction_object = OSTSdk::Saas::TransactionKind.new(environment, credentials)

Above one, I am using it

Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.