Skip to content

Commit

Permalink
Param handling (#348)
Browse files Browse the repository at this point in the history
* replaced params with get_params which is standard

* lint

* refactors

* Bump black from 22.10.0 to 22.12.0 (#346)

Bumps [black](https://github.com/psf/black) from 22.10.0 to 22.12.0.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@22.10.0...22.12.0)

---
updated-dependencies:
- dependency-name: black
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump types-setuptools from 65.6.0.1 to 65.6.0.2 (#347)

* Edge headers (#343)

* removed formatting from docs and unwated comment dupe

* Add headers from options

* Added options parameter to rest api functions.

* handle headers from options

* edge-headers push

* Attempting to use with options

* created response options class

* handle headers from options

* merge headers

* parameter type cleanup and None value handling in request.

* attempting to revert conf.py changes

* added concat_method to baseclient and test for requestoptions

* refactored and introduced more optionals for stricter use

* added type hinting to builder method returns. removed optional from edge_headers method

* removed one example from ./example/launchpad and renamed function

* lint

* Update polygon/rest/base.py

remove redundancy.

* Update examples/launchpad/launchpad.py

Co-authored-by: jbonzo <8647805+jbonzo@users.noreply.github.com>

* param handling and refactor cleanup

* removed named param

* lint

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jbonzo <8647805+jbonzo@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 13, 2022
1 parent 5d33f34 commit 0bad448
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 16 deletions.
5 changes: 0 additions & 5 deletions polygon/rest/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ def _get(
raw: bool = False,
options: Optional[RequestOptionBuilder] = None,
) -> Any:
if params is None:
params = {}
params = {str(k): str(v) for k, v in params.items() if v is not None}
logger.debug("_get %s params %s", path, params)

option = options if options is not None else RequestOptionBuilder()

resp = self.client.request(
Expand Down
9 changes: 3 additions & 6 deletions polygon/rest/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def get_real_time_currency_conversion(
self,
from_: str,
to: str,
amount: float,
amount: Optional[float] = None,
precision: Union[int, Precision] = 2,
params: Optional[Dict[str, Any]] = None,
raw: bool = False,
Expand All @@ -133,13 +133,10 @@ def get_real_time_currency_conversion(
:return: Real-Time Currency Conversion
"""
url = f"/v1/conversion/{from_}/{to}"
if params is None:
params = {}
params["amount"] = amount
params["precision"] = precision

return self._get(
path=url,
params=params,
params=self._get_params(self.get_real_time_currency_conversion, locals()),
deserializer=RealTimeCurrencyConversion.from_dict,
raw=raw,
options=options,
Expand Down
9 changes: 5 additions & 4 deletions polygon/rest/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ def get_ticker_details(

def get_ticker_events(
self,
ticker: Optional[str] = None,
ticker: str,
types: Optional[str] = None,
params: Optional[Dict[str, Any]] = None,
raw: bool = False,
options: Optional[RequestOptionBuilder] = None,
Expand All @@ -169,7 +170,7 @@ def get_ticker_events(

return self._get(
path=url,
params=params,
params=self._get_params(self.get_ticker_events, locals()),
deserializer=TickerChangeResults.from_dict,
result_key="results",
raw=raw,
Expand Down Expand Up @@ -238,7 +239,7 @@ def get_ticker_types(

return self._get(
path=url,
params=params,
params=self._get_params(self.get_ticker_types, locals()),
deserializer=TickerTypes.from_dict,
raw=raw,
result_key="results",
Expand Down Expand Up @@ -451,7 +452,7 @@ def get_exchanges(

return self._get(
path=url,
params=params,
params=self._get_params(self.get_exchanges, locals()),
deserializer=Exchange.from_dict,
raw=raw,
result_key="results",
Expand Down
2 changes: 1 addition & 1 deletion test_rest/test_tickers.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_get_ticker_types(self):
self.assertEqual(types, expected)

def test_get_ticker_events_ticker_change(self):
events = self.c.get_ticker_events(ticker="META")
events = self.c.get_ticker_events(ticker="META", types="ticker_change")
expected = TickerChangeResults(
name="Meta Platforms, Inc. Class A Common Stock",
figi="BBG000MM2P62",
Expand Down

0 comments on commit 0bad448

Please sign in to comment.