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

Enable more detailed configuration of tickets view creation #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1,574 changes: 830 additions & 744 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tap-gorgias"
version = "0.0.2"
version = "0.0.4"
description = "`tap-gorgias` is a Singer tap for Gorgias, built with the Meltano SDK for Singer Taps."
authors = ["Niall Woodward"]
keywords = [
Expand All @@ -10,9 +10,9 @@ keywords = [
license = "Apache 2.0"

[tool.poetry.dependencies]
python = ">=3.7.1,<3.10"
python = ">=3.9,<3.12"
requests = "^2.25.1"
singer-sdk = "^0.14.0"
singer-sdk = "^0.33.0"

[tool.poetry.dev-dependencies]
pytest = "^6.2.5"
Expand Down
2 changes: 1 addition & 1 deletion tap-gorgias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ TOML_DIR=$(dirname "$0")

cd "$TOML_DIR" || exit
poetry install 1>&2
poetry run tap-gorgias $*
poetry run tap-gorgias --config=.secrets/config.json
2 changes: 1 addition & 1 deletion tap_gorgias/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ def response_error_message(self, response: requests.Response) -> str:
f"full path:{full_path}"
f"{response.status_code} {error_type} Error: "
f"{response.reason} for path: {full_path}"
)
)
12 changes: 10 additions & 2 deletions tap_gorgias/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,23 @@ def get_current_user_id(self) -> int:
def create_ticket_view(self, sync_start_datetime: datetime) -> int:
headers = self.get_headers()
current_user_id = self.get_current_user_id()
shared_with_users = [current_user_id] + self.config.get("view_shared_with_users")
payload = {
"category": "user",
"order_by": "updated_datetime",
"order_dir": "asc",
"visibility": "private",
"shared_with_users": [current_user_id],
"visibility": self.config.get("view_visibility"),
"shared_with_users": shared_with_users,
"type": "ticket-list",
"slug": "could-be-anything",
"name": self.config.get("view_name"),
}

# When visibility is public, API will not accept `shared_with_users`
# nor `shared_with_groups`
if self.config.get("view_visibility") == "public":
del payload["shared_with_users"]

if sync_start_datetime:
payload.update(
{
Expand Down
18 changes: 18 additions & 0 deletions tap_gorgias/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,24 @@ class TapGorgias(Tap):
default=100,
description="The page size for each list endpoint call",
),
th.Property(
"view_visibility",
th.StringType,
default="private",
allowed_values=["private", "public", "shared"],
description="Visilibity for tickets view. One of `private`, `public`, or `shared`",
),
th.Property(
"view_name",
th.StringType,
description="Optional name for tickets view that is created",
),
th.Property(
"view_shared_with_users",
th.ArrayType(th.IntegerType),
default=[],
description="Optional list of user IDs to additionally share the tickets view with",
),
).to_dict()

def discover_streams(self) -> List[Stream]:
Expand Down