Class: CcipDirectoryAndConfigurationRestApiV1::TokensApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/ccip_directory_and_configuration_rest_api_v1/apis/tokens_api.rb

Overview

TokensApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from CcipDirectoryAndConfigurationRestApiV1::BaseApi

Instance Method Details

#get_tokens(environment, token_id: nil, chain_id: nil, output_key: OutputKey::CHAINID) ⇒ ApiResponse

Returns information about Cross-Chain Interoperability Protocol (CCIP) supported tokens. The response includes token details organized by token symbol, with chain-specific information nested under each token and indexed by chain ID or selector (depending on the outputKey parameter). environment to query identifier (e.g., “LINK” for Chainlink token, or “LINK,ETH” for multiple tokens) token is supported (e.g., “1” for Ethereum, or “1,56” for Ethereum and BSC) organizing the response data

Parameters:

  • environment (Environment3)

    Required parameter: The network

  • token_id (String) (defaults to: nil)

    Optional parameter: Filter by token canonical

  • chain_id (String) (defaults to: nil)

    Optional parameter: Filter by chain ID where the

  • output_key (OutputKey) (defaults to: OutputKey::CHAINID)

    Optional parameter: Key to use for

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ccip_directory_and_configuration_rest_api_v1/apis/tokens_api.rb', line 24

def get_tokens(environment,
               token_id: nil,
               chain_id: nil,
               output_key: OutputKey::CHAINID)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/tokens',
                                 Server::DEFAULT)
               .query_param(new_parameter(environment, key: 'environment')
                             .is_required(true))
               .query_param(new_parameter(token_id, key: 'token_id'))
               .query_param(new_parameter(chain_id, key: 'chain_id'))
               .query_param(new_parameter(output_key, key: 'outputKey'))
               .header_param(new_parameter('application/json', key: 'accept')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TokenApiResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Invalid request parameters',
                             ErrorResponseException)
                .local_error('500',
                             'Internal server error',
                             ErrorResponseException))
    .execute
end