Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-delighted: Unix changed to normal timestamp #13439

Merged
merged 11 commits into from
Jun 10, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from airbyte_cdk.sources.streams.http import HttpStream
from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator

import datetime

# Basic full refresh stream
class DelightedStream(HttpStream, ABC):
Expand Down Expand Up @@ -145,6 +146,13 @@ def _get_authenticator(self, config):
token = base64.b64encode(f"{config['api_key']}:".encode("utf-8")).decode("utf-8")
return TokenAuthenticator(token=token, auth_method="Basic")

#Function to covert a timestamp to UNIX time format
def toUnix (self,config):
timeDate = config["since"]
dateFormat = datetime.datetime.strptime(timeDate, "%m-%d-%Y,%H:%M:%S")
unixDate = datetime.datetime.timestamp(dateFormat)
return unixDate

michael-c-nguyen marked this conversation as resolved.
Show resolved Hide resolved
def check_connection(self, logger, config) -> Tuple[bool, any]:
"""

Expand All @@ -157,7 +165,7 @@ def check_connection(self, logger, config) -> Tuple[bool, any]:

try:
auth = self._get_authenticator(config)
args = {"authenticator": auth, "since": config["since"]}
args = {"authenticator": auth, "since": self.toUnix(config)}
michael-c-nguyen marked this conversation as resolved.
Show resolved Hide resolved
stream = SurveyResponses(**args)
records = stream.read_records(sync_mode=SyncMode.full_refresh)
next(records)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"additionalProperties": false,
"properties": {
"since": {
"type": "integer",
"description": "An Unix timestamp to retrieve records created on or after this time.",
"examples": [1625328167]
"type": "string",
"description": "A timestamp to retrieve records created on or after this time.",
michael-c-nguyen marked this conversation as resolved.
Show resolved Hide resolved
"examples": ["2022-05-30,04:50:23"],
"pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2},([0-9]{2}:[0-9]{2}:[0-9]{2})?$"
},
"api_key": {
"type": "string",
Expand Down