app/services/wallet_addresses_management/associate_address.rb
def create_entries

      #check if the same client has some address associated with it. Update the address if already present
      client_wallet_address = ClientWalletAddress.where(client_id: @client_id, sub_environment: GlobalConstant::Base.sub_environment_name).first

      if client_wallet_address.present?
        #update the new address
        client_wallet_address.address = @owner_address
        client_wallet_address.save!
      else
        ClientWalletAddress.create!(
          client_id: @client_id,
          sub_environment: GlobalConstant::Base.sub_environment_name,
          address: @owner_address.downcase,
          status:GlobalConstant::WalletAddressStatus.active_status
        )
      end

      @token_id = @token_details[:id]

      token_addresses = TokenAddresses.where(
        token_id: @token_id,
        kind: GlobalConstant::TokenAddresses.owner_address_kind
      ).first

      if token_addresses.present?

        if token_addresses[:known_address_id].present?
          request_saas_to_remove_known_address(token_addresses[:known_address_id])
        end

        token_addresses[:address] = @owner_address
        token_addresses[:known_address_id] = nil

        token_addresses.save!
      else
        TokenAddresses.create!(
          token_id: @token_id,
          kind: GlobalConstant::TokenAddresses.owner_address_kind,
          address: @owner_address
        )

      end

      success
    end
# Creates entry in client wallet addresses and token addresses
#
#
# * Author: Ankit
# * Date: 19/01/2019
# * Reviewed By:
#
# @return [Result::Base]
Creates entry in client wallet addresses and token addresses
Author: Ankit
Date: 19/01/2019
Reviewed By.
Creates entry in client wallet addresses and token addresses Author : Ankit Date : 19 / 01 / 2019 Reviewed By .
def create_entries
      client_wallet_address = ClientWalletAddress.where(client_id: @client_id, sub_environment: GlobalConstant::Base.sub_environment_name).first
      if client_wallet_address.present?
        client_wallet_address.address = @owner_address
        client_wallet_address.save!
      else
        ClientWalletAddress.create!(
          client_id: @client_id,
          sub_environment: GlobalConstant::Base.sub_environment_name,
          address: @owner_address.downcase,
          status:GlobalConstant::WalletAddressStatus.active_status
        )
      end
      @token_id = @token_details[:id]
      token_addresses = TokenAddresses.where(
        token_id: @token_id,
        kind: GlobalConstant::TokenAddresses.owner_address_kind
      ).first
      if token_addresses.present?
        if token_addresses[:known_address_id].present?
          request_saas_to_remove_known_address(token_addresses[:known_address_id])
        end
        token_addresses[:address] = @owner_address
        token_addresses[:known_address_id] = nil
        token_addresses.save!
      else
        TokenAddresses.create!(
          token_id: @token_id,
          kind: GlobalConstant::TokenAddresses.owner_address_kind,
          address: @owner_address
        )
      end
      success
    end
def create_entries client_wallet_address = ClientWalletAddress . where ( client_id : @client_id , sub_environment : GlobalConstant :: Base . sub_environment_name ) . first if client_wallet_address . present? client_wallet_address . address = @owner_address client_wallet_address . save! else ClientWalletAddress . create! ( client_id : @client_id , sub_environment : GlobalConstant :: Base . sub_environment_name , address : @owner_address . downcase , status : GlobalConstant :: WalletAddressStatus . active_status ) end @token_id = @token_details [ :id ] token_addresses = TokenAddresses . where ( token_id : @token_id , kind : GlobalConstant :: TokenAddresses . owner_address_kind ) . first if token_addresses . present? if token_addresses [ :known_address_id ] . present? request_saas_to_remove_known_address ( token_addresses [ :known_address_id ] ) end token_addresses [ :address ] = @owner_address token_addresses [ :known_address_id ] = nil token_addresses . save! else TokenAddresses . create! ( token_id : @token_id , kind : GlobalConstant :: TokenAddresses . owner_address_kind , address : @owner_address ) end success end
Creates entry in client wallet addresses and token addresses
 Author: Ankit
 Date: 19/01/2019
 Reviewed By:
Creates entry in client wallet addresses and token addresses Author : Ankit Date : 19 / 01 / 2019 Reviewed By :
#check if the same client has some address associated with it. Update the address if already present #update the new address
None
Result::Base