Skip to content

Commit 0bad448

Browse files
antdjohnsdependabot[bot]jbonzo
authored
Param handling (#348)
* 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] <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> 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 <[email protected]> * param handling and refactor cleanup * removed named param * lint Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: jbonzo <[email protected]>
1 parent 5d33f34 commit 0bad448

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

polygon/rest/base.py

-5
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ def _get(
7474
raw: bool = False,
7575
options: Optional[RequestOptionBuilder] = None,
7676
) -> Any:
77-
if params is None:
78-
params = {}
79-
params = {str(k): str(v) for k, v in params.items() if v is not None}
80-
logger.debug("_get %s params %s", path, params)
81-
8277
option = options if options is not None else RequestOptionBuilder()
8378

8479
resp = self.client.request(

polygon/rest/quotes.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def get_real_time_currency_conversion(
115115
self,
116116
from_: str,
117117
to: str,
118-
amount: float,
118+
amount: Optional[float] = None,
119119
precision: Union[int, Precision] = 2,
120120
params: Optional[Dict[str, Any]] = None,
121121
raw: bool = False,
@@ -133,13 +133,10 @@ def get_real_time_currency_conversion(
133133
:return: Real-Time Currency Conversion
134134
"""
135135
url = f"/v1/conversion/{from_}/{to}"
136-
if params is None:
137-
params = {}
138-
params["amount"] = amount
139-
params["precision"] = precision
136+
140137
return self._get(
141138
path=url,
142-
params=params,
139+
params=self._get_params(self.get_real_time_currency_conversion, locals()),
143140
deserializer=RealTimeCurrencyConversion.from_dict,
144141
raw=raw,
145142
options=options,

polygon/rest/reference.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ def get_ticker_details(
152152

153153
def get_ticker_events(
154154
self,
155-
ticker: Optional[str] = None,
155+
ticker: str,
156+
types: Optional[str] = None,
156157
params: Optional[Dict[str, Any]] = None,
157158
raw: bool = False,
158159
options: Optional[RequestOptionBuilder] = None,
@@ -169,7 +170,7 @@ def get_ticker_events(
169170

170171
return self._get(
171172
path=url,
172-
params=params,
173+
params=self._get_params(self.get_ticker_events, locals()),
173174
deserializer=TickerChangeResults.from_dict,
174175
result_key="results",
175176
raw=raw,
@@ -238,7 +239,7 @@ def get_ticker_types(
238239

239240
return self._get(
240241
path=url,
241-
params=params,
242+
params=self._get_params(self.get_ticker_types, locals()),
242243
deserializer=TickerTypes.from_dict,
243244
raw=raw,
244245
result_key="results",
@@ -451,7 +452,7 @@ def get_exchanges(
451452

452453
return self._get(
453454
path=url,
454-
params=params,
455+
params=self._get_params(self.get_exchanges, locals()),
455456
deserializer=Exchange.from_dict,
456457
raw=raw,
457458
result_key="results",

test_rest/test_tickers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_get_ticker_types(self):
239239
self.assertEqual(types, expected)
240240

241241
def test_get_ticker_events_ticker_change(self):
242-
events = self.c.get_ticker_events(ticker="META")
242+
events = self.c.get_ticker_events(ticker="META", types="ticker_change")
243243
expected = TickerChangeResults(
244244
name="Meta Platforms, Inc. Class A Common Stock",
245245
figi="BBG000MM2P62",

0 commit comments

Comments
 (0)