Class: OpenfigiRuby::Client
- Inherits:
-
Object
- Object
- OpenfigiRuby::Client
- Defined in:
- lib/openfigi_ruby/client.rb
Overview
HTTP client for the OpenFIGI V3 API.
Instantiate with an optional API key override, or configure globally via configure and call +Client.new+ with no arguments.
Constant Summary collapse
- MAPPING_VALUE_KEYS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Valid field names accepted by #mapping_values.
%w[idType exchCode micCode currency marketSecDes securityType securityType2].freeze
Instance Method Summary collapse
-
#filter(query: nil, start: nil, **filters) ⇒ FilterResult
Filters FIGIs with alphabetical ordering and a total count (POST /v3/filter).
-
#initialize(api_key: OpenfigiRuby.configuration.api_key, open_timeout: OpenfigiRuby.configuration.open_timeout, read_timeout: OpenfigiRuby.configuration.read_timeout) ⇒ Client
constructor
A new instance of Client.
-
#mapping(jobs) ⇒ Array<MappingResult>
Maps third-party identifiers to FIGIs (POST /v3/mapping).
-
#mapping_values(key) ⇒ Array<String>
Returns the set of valid values for a filterable field (GET /v3/mapping/values/:key).
-
#search(query:, start: nil, **filters) ⇒ SearchResult
Searches for FIGIs by keyword (POST /v3/search).
Constructor Details
#initialize(api_key: OpenfigiRuby.configuration.api_key, open_timeout: OpenfigiRuby.configuration.open_timeout, read_timeout: OpenfigiRuby.configuration.read_timeout) ⇒ Client
Returns a new instance of Client.
20 21 22 23 24 25 26 27 28 |
# File 'lib/openfigi_ruby/client.rb', line 20 def initialize( api_key: OpenfigiRuby.configuration.api_key, open_timeout: OpenfigiRuby.configuration.open_timeout, read_timeout: OpenfigiRuby.configuration.read_timeout ) @api_key = api_key @open_timeout = open_timeout @read_timeout = read_timeout end |
Instance Method Details
#filter(query: nil, start: nil, **filters) ⇒ FilterResult
Filters FIGIs with alphabetical ordering and a total count (POST /v3/filter).
90 91 92 93 94 95 96 97 |
# File 'lib/openfigi_ruby/client.rb', line 90 def filter(query: nil, start: nil, **filters) body = {} body["query"] = query if query body["start"] = start if start body.merge!(serialize(filters)) response = post("/filter", body) parse_filter_result(response) end |
#mapping(jobs) ⇒ Array<MappingResult>
Maps third-party identifiers to FIGIs (POST /v3/mapping).
44 45 46 47 48 |
# File 'lib/openfigi_ruby/client.rb', line 44 def mapping(jobs) body = jobs.map { |job| serialize(job) } response = post("/mapping", body) response.map { |item| parse_mapping_result(item) } end |
#mapping_values(key) ⇒ Array<String>
Returns the set of valid values for a filterable field (GET /v3/mapping/values/:key).
59 60 61 62 63 |
# File 'lib/openfigi_ruby/client.rb', line 59 def mapping_values(key) api_key = camelize(key.to_s) response = get("/mapping/values/#{api_key}") response["values"] end |
#search(query:, start: nil, **filters) ⇒ SearchResult
Searches for FIGIs by keyword (POST /v3/search).
76 77 78 79 80 81 82 |
# File 'lib/openfigi_ruby/client.rb', line 76 def search(query:, start: nil, **filters) body = { "query" => query } body["start"] = start if start body.merge!(serialize(filters)) response = post("/search", body) parse_search_result(response) end |