Skip to content

Commit

Permalink
fixed accounts stream
Browse files Browse the repository at this point in the history
  • Loading branch information
jlloyd-widen committed Apr 3, 2024
1 parent ea704fb commit 0b4b2c8
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 24 deletions.
34 changes: 34 additions & 0 deletions plugins/loaders/target-jsonl--andyh1203.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"plugin_type": "loaders",
"name": "target-jsonl",
"namespace": "target_jsonl",
"variant": "andyh1203",
"label": "JSON Lines (JSONL)",
"docs": "https://hub.meltano.com/loaders/target-jsonl--andyh1203",
"repo": "https://github.com/andyh1203/target-jsonl",
"pip_url": "target-jsonl",
"description": "JSONL loader",
"logo_url": "https://hub.meltano.com/assets/logos/loaders/jsonl.png",
"settings": [
{
"name": "destination_path",
"kind": "string",
"value": "output",
"label": "Destination Path",
"description": "Sets the destination path the JSONL files are written to, relative\nto the project root.\n\nThe directory needs to exist already, it will not be created\nautomatically.\n\nTo write JSONL files to the project root, set an empty string (`\"\"`).\n"
},
{
"name": "do_timestamp_file",
"kind": "boolean",
"value": false,
"label": "Include Timestamp in File Names",
"description": "Specifies if the files should get timestamped.\n\nBy default, the resulting file will not have a timestamp in the file name (i.e. `exchange_rate.jsonl`).\n\nIf this option gets set to `true`, the resulting file will have a timestamp associated with it (i.e. `exchange_rate-{timestamp}.jsonl`).\n"
},
{
"name": "custom_name",
"kind": "string",
"label": "Custom File Name Override",
"description": "Specifies a custom name for the filename, instead of the stream name.\n\nThe file name will be `{custom_name}-{timestamp}.jsonl`, if `do_timestamp_file` is `true`.\nOtherwise the file name will be `{custom_name}.jsonl`.\n\nIf custom name is not provided, the stream name will be used.\n"
}
]
}
46 changes: 22 additions & 24 deletions tap_gainsightpx/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,38 @@ class AccountsStream(GainsightPXStream):
primary_keys = ["id"]
replication_key = "lastModifiedDate"
schema = th.PropertiesList(
th.Property("id", th.StringType),
th.Property("name", th.StringType),
th.Property("trackedSubscriptionId", th.StringType),
th.Property("sfdcId", th.StringType),
th.Property("lastSeenDate", th.IntegerType),
th.Property("createDate", th.IntegerType),
th.Property("customAttributes", th.ObjectType()),
th.Property("dunsNumber", th.StringType),
th.Property("id", th.StringType),
th.Property("industry", th.StringType),
th.Property("numberOfEmployees", th.IntegerType),
th.Property("sicCode", th.StringType),
th.Property("website", th.StringType),
th.Property("naicsCode", th.StringType),
th.Property("plan", th.StringType),
th.Property("lastModifiedDate", th.IntegerType),
th.Property("lastSeenDate", th.IntegerType),
th.Property("location", th.ObjectType()),
th.Property("naicsCode", th.StringType),
th.Property("name", th.StringType),
th.Property("numberOfEmployees", th.IntegerType),
th.Property("numberOfUsers", th.IntegerType),
th.Property("propertyKeys", th.ArrayType(th.StringType)),
th.Property("createDate", th.IntegerType),
th.Property("lastModifiedDate", th.IntegerType),
th.Property("customAttributes", th.ObjectType()),
th.Property("parentGroupId", th.StringType),
th.Property("plan", th.StringType),
th.Property("propertyKeys", th.ArrayType(th.StringType)),
th.Property("sfdcId", th.StringType),
th.Property("sicCode", th.StringType),
th.Property("trackedSubscriptionId", th.StringType),
th.Property("website", th.StringType),
).to_dict()

def add_more_url_params(
self, params: dict, next_page_token: Optional[Any]
def get_url_params(
self, context: Optional[dict], next_page_token: Optional[Any]
) -> Dict[str, Any]:
"""Add more params specific to the stream."""
"""Return a dictionary of values to be used in URL parameterization."""
params: dict = {"pageSize": 100}

if self.replication_key:
params["sort"] = self.replication_key
if next_page_token:
params["scrollId"] = next_page_token
params["scrollID"] = next_page_token

# todo: enable replication key method
# bookmarks = self.stream_state['bookmarks']
# replication_key_value = bookmarks[self.name]['replication_key_value']
# params["filter"] = ";".join([
# f"{self.replication_key}>{replication_key_value}",
# ])
return params


Expand Down
4 changes: 4 additions & 0 deletions tap_gainsightpx/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def test_standard_tap_tests(requests_mock):
"https://api.example.com/v1/feature?pageSize=200",
json=json_resp(),
)
requests_mock.get(
"https://api.example.com/v1/accounts?pageSize=100&sort=lastModifiedDate",
json=json_resp(),
)
requests_mock.get(
"https://api.example.com/v1/events/pageView?pageSize=500&sort=date&filter="
"date%3E%3D2022-01-01T00%3A00%3A00Z%3B"
Expand Down

0 comments on commit 0b4b2c8

Please sign in to comment.