Skip to content

Commit

Permalink
Batch transaction details (#21)
Browse files Browse the repository at this point in the history
* Make batch requests for transaction details stream.

* Black formatting.
  • Loading branch information
xacadil authored Apr 29, 2024
1 parent 85cc8c2 commit 56c58fa
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 73 deletions.
25 changes: 11 additions & 14 deletions tap_restaurant365/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@

from __future__ import annotations

from pathlib import Path
from typing import Any, Callable, Iterable, Optional
from datetime import timedelta, datetime
from dateutil import parser

from datetime import timedelta
from http import HTTPStatus
from typing import Any, Callable

import requests
from dateutil import parser
from singer_sdk.authenticators import BasicAuthenticator
from singer_sdk.helpers.jsonpath import extract_jsonpath
from singer_sdk.exceptions import FatalAPIError, RetriableAPIError
from singer_sdk.pagination import BaseAPIPaginator # noqa: TCH002
from singer_sdk.streams import RESTStream
from singer_sdk.exceptions import FatalAPIError, RetriableAPIError
from http import HTTPStatus

_Auth = Callable[[requests.PreparedRequest], requests.PreparedRequest]


class Restaurant365Stream(RESTStream):
"""Restaurant365 stream class."""

skip = 0
days_delta = 10

@property
def url_base(self) -> str:
"""Return the API URL root, configurable via tap settings."""
return "https://odata.restaurant365.net/api/v2/views"

records_jsonpath = "$.value[*]"

records_jsonpath = "$.value[*]"

@property
def authenticator(self) -> BasicAuthenticator:
Expand Down Expand Up @@ -62,9 +61,7 @@ def get_new_paginator(self) -> BaseAPIPaginator:
# else:
# params


return super().get_new_paginator()


def get_starting_time(self, context):
start_date = self.config.get("start_date")
Expand All @@ -90,11 +87,11 @@ def get_url_params(

params: dict = {}
if self.replication_key:
start_date = self.get_starting_time(context).strftime('%Y-%m-%dT%H:%M:%SZ')
start_date = self.get_starting_time(context).strftime("%Y-%m-%dT%H:%M:%SZ")
params["$filter"] = f"{self.replication_key} ge {start_date}"

return params

def validate_response(self, response: requests.Response) -> None:
if (
response.status_code in self.extra_retry_statuses
Expand Down
Loading

0 comments on commit 56c58fa

Please sign in to comment.