Files
OpenBB/openbb_platform/providers/ultima/openbb_ultima/utils/helpers.py
Henrique Joaquim 4400cd9a8f Merge provider and core into core (#5774)
* small changes - moving provider inside the core

* uptade readme

* lint

* remove old provider readme

* leftovers

* refactor website examples

* ruff

* fix nox

* relock

* fix fails_to_deliver headers

* fix for tests that have renamed endpoints

* fix discovery

* removed test for renamed endpoint

* fix broken syntax - test_search_financial_attributes

* fix cash/income/balance

* fix derivatives tests

* fix etf tests

* fix news tests

* fix regulators

* black

* wrong test param

* sort equity gainers/losers by percent

* platform markdown generation import

* Hotfix/fix int tests core merge (#5779)

* removing tests on old endpoint

* removing visualization on old endpoint

* fixing equity tests

* fixing examples

* fix news tests

* fix index test

* example

* add comments

* example

---------

Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>

---------

Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
2023-11-22 13:48:01 +00:00

28 lines
753 B
Python

"""Ultima Helpers."""
from typing import Any, Dict
from openbb_core.provider import helpers
def get_data(url: str, **kwargs: Any) -> Dict:
"""Do an API request to Ultima and return the data."""
auth = kwargs.pop("auth", "")
if auth is None or len(auth) == 0:
raise RuntimeError("Ultima API key is required.")
if "Bearer" not in auth:
auth = f"Bearer {auth}"
result = helpers.make_request(
url,
timeout=10,
headers={"accept": "application/json", "Authorization": auth},
**kwargs,
)
if result.status_code != 200:
data = result.json()
message = data.get("message")
raise RuntimeError(f"Error in Ultima request -> {message}")
return result.json()