app/services/test_economy_management/activate.rb
# Perform API Call to Demo Mappy Server to register this token
#
# * Author: Puneet
# * Date: 10/04/2019
# * Reviewed By: Sunil
#
# @return [Result::Base]
#
Perform API Call to Demo Mappy Server to register this token
Author: Puneet
Date: 10/04/2019
Reviewed By: Sunil
Perform API Call to Demo Mappy Server to register this token Author : Puneet Date : 10 / 04 / 2019 Reviewed By : Sunil
def perform_registeration_in_mappy_task
      api_keys = KitSaasSharedCacheManagement::ApiCredentials.new([@client_id]).fetch[@client_id]
      last_expiring_api_key = api_keys.first
      return error_with_data(
          'tem_a_3',
          'something_went_wrong',
          GlobalConstant::ErrorAction.default
      ) if last_expiring_api_key.blank?
      company_user_ids = KitSaasSharedCacheManagement::TokenCompanyUser.new([@token_id]).fetch[@token_id]
      return error_with_data(
          'tem_a_4',
          'something_went_wrong',
          GlobalConstant::ErrorAction.default
      ) if company_user_ids.blank?
      r = DemoMappyServerApi.new.send_request_of_type(
          'post',
          'setup/create-token',
          {
              name: @token[:name],
              symbol: @token[:symbol],
              ost_token_id: @token_id,
              conversion_factor: @token[:conversion_factor],
              pc_token_holder_uuid: company_user_ids.first,
              chain_id: @aux_chain_id,
              api_key: last_expiring_api_key[:key],
              api_secret: last_expiring_api_key[:secret],
              api_endpoint: GlobalConstant::SaasApi.api_endpoint_for_current_version,
              url_id: url_id
          }
      )
      unless r.success?
        @error_responses.push(perform_registeration_in_mappy_task: r.to_json)
        return r
      end
      if is_main_sub_env?
        @set_props_arr.push(GlobalConstant::Client.mainnet_registered_in_mappy_server_status)
      else
        @set_props_arr.push(GlobalConstant::Client.sandbox_registered_in_mappy_server_status)
        @set_props_arr.push(GlobalConstant::Client.webhook_registered_in_mappy_server_status)
      end
      update_client_properties
      r = enqueue_job_to_update_in_mappy_server
      return r unless r.success?
      update_campaign_attributes({
                                     entity_id: @client_id,
                                     entity_kind: GlobalConstant::EmailServiceApiCallHook.client_receiver_entity_kind,
                                     attributes: { GlobalConstant::PepoCampaigns.ost_wallet_setup =>  GlobalConstant::PepoCampaigns.attribute_set },
                                     settings: {},
                                     mile_stone: GlobalConstant::PepoCampaigns.ost_wallet_setup
                                 })
      success
    end
def perform_registeration_in_mappy_task api_keys = KitSaasSharedCacheManagement :: ApiCredentials . new ( [ @client_id ] ) . fetch [ @client_id ] last_expiring_api_key = api_keys . first return error_with_data ( 'tem_a_3' , 'something_went_wrong' , GlobalConstant :: ErrorAction . default ) if last_expiring_api_key . blank? company_user_ids = KitSaasSharedCacheManagement :: TokenCompanyUser . new ( [ @token_id ] ) . fetch [ @token_id ] return error_with_data ( 'tem_a_4' , 'something_went_wrong' , GlobalConstant :: ErrorAction . default ) if company_user_ids . blank? r = DemoMappyServerApi . new . send_request_of_type ( 'post' , 'setup/create-token' , { name : @token [ :name ] , symbol : @token [ :symbol ] , ost_token_id : @token_id , conversion_factor : @token [ :conversion_factor ] , pc_token_holder_uuid : company_user_ids . first , chain_id : @aux_chain_id , api_key : last_expiring_api_key [ :key ] , api_secret : last_expiring_api_key [ :secret ] , api_endpoint : GlobalConstant :: SaasApi . api_endpoint_for_current_version , url_id : url_id } ) unless r . success? @error_responses . push ( perform_registeration_in_mappy_task : r . to_json ) return r end if is_main_sub_env? @set_props_arr . push ( GlobalConstant :: Client . mainnet_registered_in_mappy_server_status ) else @set_props_arr . push ( GlobalConstant :: Client . sandbox_registered_in_mappy_server_status ) @set_props_arr . push ( GlobalConstant :: Client . webhook_registered_in_mappy_server_status ) end update_client_properties r = enqueue_job_to_update_in_mappy_server return r unless r . success? update_campaign_attributes ( { entity_id : @client_id , entity_kind : GlobalConstant :: EmailServiceApiCallHook . client_receiver_entity_kind , attributes : { GlobalConstant :: PepoCampaigns . ost_wallet_setup => GlobalConstant :: PepoCampaigns . attribute_set } , settings : { } , mile_stone : GlobalConstant :: PepoCampaigns . ost_wallet_setup } ) success end
Perform API Call to Demo Mappy Server to register this token
 Author: Puneet
 Date: 10/04/2019
 Reviewed By: Sunil
Perform API Call to Demo Mappy Server to register this token Author : Puneet Date : 10 / 04 / 2019 Reviewed By : Sunil
# We do this here because syncApiKeysInDemoMappyJob requires these properties to fetch webhook secret.
None
Result::Base