What is the firing order of the methods? Is http_h...
# singer-tap-development
n
What is the firing order of the methods? Is http_headers called before get_url_params ? The reason I am asking is because my http_headers contain a field which signs the URL parameters dict. Few of the values are time values. There are cases when there is a mismatch in the time values being set in these two methods. Is there a way to call get_url_params(self, context, next_page_token) from http_headers(self) ?
v
can you show some code? Link to something?
e
http_headers contain a field which signs the URL parameters dict
I'd advice against introducing those dependencies and instead use the authenticator to sign the request, similar to https://github.com/edgarrmondragon/tap-bitso/blob/ced67abd27315be77b1d7a37fd2ac5f5b53dd9c0/tap_bitso/auth.py#L57-L93
n
I solved this issue by caching time for 60 seconds, so all methods use the same value. I am not sure how authenticator would have worked here. This is what I was working on: https://duo.com/docs/adminapi#authentication So the headers will have:
@property
def http_headers(self) -> dict:
params = {}
params["mintime"] = self.start_time
params["maxtime"] = str(self.end_time)
params["limit"] = str(self.limit)
if self.next_page is not None:
params["next_offset"] = self.next_page
<http://self.logger.info|self.logger.info>(f'Request params: {params}')
headers = super().sign("GET", self.config.get("domain"), self.path,
params, self.config.get("skey"), self.config.get("ikey"))
headers["Host"] = self.config.get("domain").encode('utf-8')
return headers
and get_params will have:
def get_url_params(
self,
context,
next_page_token,
):
params = {}
params["mintime"] = self.start_time
params["maxtime"] = str(self.end_time)
params["limit"] = str(self.limit)
if next_page_token is not None:
self.next_page = next_page_token
params["next_offset"] = self.next_page
Since mintime, maxtime needs to be assigned to both and need to be the same, the only way to maintain consistency was to not update the endtime for 60 seconds.
return params