Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Initial development #2

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions tap_lever/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""REST client handling, including LeverStream base class."""

import requests
from datetime import datetime
from dateutil import parser
from pathlib import Path
from typing import Any, Dict, Optional, Union, List, Iterable

Expand Down Expand Up @@ -40,10 +41,18 @@ def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
"""Return a dictionary of values to be used in URL parameterization."""
params: dict = {}
params = {"limit": 100}
if next_page_token:
params["offset"] = next_page_token
# if self.replication_key:
# params["sort"] = "asc"
# params["order_by"] = self.replication_key
if self.replication_key:
start_value = self.get_starting_replication_key_value(context)
params[f"updated_at_start"] = self._try_timestamp_to_epoch(start_value)
return params

def _try_timestamp_to_epoch(self, ts_value):
"Converts to 13-digit epoch with milliseconds."
try:
parsed = parser.parse(ts_value)
return parsed.strftime("%s%f")[:-3]
except parser.ParserError:
return ts_value
2 changes: 2 additions & 0 deletions tap_lever/schemas/opportunities.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@
th.Property("urls", th.ObjectType()),
th.Property("dataProtection", th.ObjectType()),
th.Property("isAnonymized", th.BooleanType),
th.Property("createdAt", th.IntegerType),
th.Property("updatedAt", th.IntegerType),
).to_dict()
9 changes: 5 additions & 4 deletions tap_lever/schemas/opportunity_applications.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

schema = th.PropertiesList(
th.Property("opportunity_id", th.StringType),
th.Property("opportunityId", th.StringType),
th.Property("id", th.StringType),
th.Property("candidateId", th.StringType),
th.Property("type", th.StringType),
Expand All @@ -10,13 +11,13 @@
th.Property("name", th.StringType),
th.Property("email", th.StringType),
th.Property("createdAt", th.NumberType),
th.Property("phone", th.StringType),
th.Property("phone", th.ObjectType()),
th.Property("company", th.StringType),
th.Property("links", th.StringType),
th.Property("links", th.ArrayType(th.StringType)),
th.Property("comments", th.StringType),
th.Property("resume", th.StringType),
th.Property("customQuestions", th.StringType),
th.Property("archived", th.StringType),
th.Property("customQuestions", th.ArrayType(th.ObjectType())),
th.Property("archived", th.ObjectType()),
th.Property("postingHiringManager", th.StringType),
th.Property("postingOwner", th.StringType),
th.Property("requisitionForHire", th.StringType),
Expand Down
4 changes: 2 additions & 2 deletions tap_lever/schemas/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
th.Property("name", th.StringType),
th.Property("username", th.StringType),
th.Property("email", th.StringType),
th.Property("createdAt", th.StringType),
th.Property("deactivatedAt", th.StringType),
th.Property("createdAt", th.NumberType),
th.Property("deactivatedAt", th.NumberType),
th.Property("accessRole", th.StringType),
th.Property("photo", th.StringType),
th.Property("externalDirectoryId", th.StringType),
Expand Down
3 changes: 1 addition & 2 deletions tap_lever/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class OpportunitiesStream(LeverStream):
name = "opportunities"
path = "/opportunities"
primary_keys = ["id"]
replication_key = None
replication_key = "updatedAt"
schema = schemas.opportunities

def get_child_context(self, record: dict, context: Optional[dict]) -> dict:
Expand All @@ -51,7 +51,6 @@ class PostingsStream(LeverStream):
name = "postings"
path = "/postings"
primary_keys = ["id"]
replication_key = None
schema = schemas.postings


Expand Down