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

Tdl 12262 add ticket fields stream #52

Open
wants to merge 13 commits into
base: TDL-20356-update-function-based-to-class-based
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 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This tap:
- [Satisfaction Ratings](https://developer.freshdesk.com/api/#satisfaction-ratings)
- [Tickets](https://developer.freshdesk.com/api/#tickets)
- [Time Entries](https://developer.freshdesk.com/api/#time-entries)
- [Ticket Fields](https://developer.freshdesk.com/api/#ticket-fields)
- Outputs the schema for each resource
- Incrementally pulls data based on the input state

Expand Down
12 changes: 2 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@
''',
packages=['tap_freshdesk'],
package_data = {
'tap_freshdesk/schemas': [
'agents.json',
'companies.json',
'contacts.json',
'conversations.json',
'groups.json',
'roles.json',
'satisfaction_ratings.json',
'tickets.json',
'time_entries.json',
'tap_freshdesk': [
'schemas/*.json'
],
},
include_package_data=True,
Expand Down
79 changes: 79 additions & 0 deletions tap_freshdesk/schemas/ticket_fields.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"type": "object",
"properties": {
"id": {
"type": ["null", "integer"]
},
"default": {
"type": ["null", "boolean"]
},
"description": {
"type": ["null", "string"]
},
"label": {
"type": ["null", "string"]
},
"name": {
"type": ["null", "string"]
},
"position": {
"type": ["null", "integer"]
},
"required_for_closure": {
"type": ["null", "boolean"]
},
"type": {
"type": ["null", "string"]
},
"required_for_agents": {
"type": ["null", "boolean"]
},
"required_for_customers": {
"type": ["null", "boolean"]
},
"label_for_customers": {
"type": ["null", "string"]
},
"customers_can_edit": {
"type": ["null", "boolean"]
},
"displayed_to_customers": {
"type": ["null", "boolean"]
},
"portal_cc": {
"type": ["null", "boolean"]
},
"portal_cc_to": {
"type": ["null", "string"]
},
"choices": {},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the type is not mentioned for choices?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the Freshdesk API documentation, choices is the list of values. But, in the actual response, we observed different types of values including a list of strings, plain object(dict), an object of the list, etc. That's why due to uncertainty in the value of this field, we kept {} as datatype and generally we keep {} in such cases.

"is_fsm": {
"type": ["null", "boolean"]
},
"field_update_in_progress": {
"type": ["null", "boolean"]
},
"dependent_fields": {
"type": ["null", "array"],
"items": {
"type": ["null", "object"],
"properties": {}
}
},
"section_mappings": {
"type": ["null", "array"],
"items": {
"type": ["null", "object"],
"properties": {}
}
},
"created_at": {
"type": ["null", "string"],
"format": "date-time"
},
"updated_at": {
"type": ["null", "string"],
"format": "date-time"
}
}
}
12 changes: 11 additions & 1 deletion tap_freshdesk/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,15 @@ class TimeEntries(ChildStream):
path = 'tickets/{}/time_entries'
parent = 'tickets'

class TicketFields(Stream):
"""
https://developer.freshdesk.com/api/#list_all_ticket_fields
"""
tap_stream_id = 'ticket_fields'
key_properties = ['id']
replication_keys = ['updated_at']
replication_method = 'INCREMENTAL'
path = 'ticket_fields'

STREAMS = {
"agents": Agents,
Expand All @@ -340,5 +349,6 @@ class TimeEntries(ChildStream):
"roles": Roles,
"satisfaction_ratings": SatisfactionRatings,
"tickets": Tickets,
"time_entries": TimeEntries
"time_entries": TimeEntries,
'ticket_fields': TicketFields
}
6 changes: 6 additions & 0 deletions tests/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def expected_metadata(self):
self.REPLICATION_KEYS: {"updated_at"},
self.OBEYS_START_DATE: True
},
"ticket_fields": {
self.PRIMARY_KEYS: {"id"},
self.REPLICATION_METHOD: self.INCREMENTAL,
self.REPLICATION_KEYS: {"updated_at"},
self.OBEYS_START_DATE: True
}
}

#############################
Expand Down
2 changes: 1 addition & 1 deletion tests/test_freshdesk_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def test_run(self):
"""

# For roles stream data present in test account is limited. So, adding configurable page_size "2"
streams_to_test_1 = {"roles"}
streams_to_test_1 = {"roles", "ticket_fields"}
self.run_test(streams_to_test_1, 2)

streams_to_test_2 = self.expected_streams(only_trial_account_streams=True) - streams_to_test_1
Expand Down
17 changes: 16 additions & 1 deletion tests/test_freshdesk_start_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ def name():
return "tap_tester_freshdesk_start_date_test"

def test_run(self):
"""
Run start date test with corresponding start_date according to data availability for each stream.
"""
# To collect "time_entries", "satisfaction_ratings" pro account is needed. Skipping them for now.
expected_streams = self.expected_streams() - {'satisfaction_ratings', 'time_entries'}

# Running start_date_test for `ticket_fields` stream
expected_stream_1 = {"ticket_fields"}
self.run_start_date(expected_stream_1, "2019-07-19T00:00:00Z")

# Running start_date_test for rest of the streams
expected_streams = expected_streams - expected_stream_1
self.run_start_date(expected_streams, "2022-07-19T00:00:00Z")

def run_start_date(self, expected_streams, new_start_date):
"""
• Verify that a sync with a later start date has at least one record synced
and less records than the 1st sync with a previous start date
Expand All @@ -25,7 +40,7 @@ def test_run(self):
"""

self.start_date_1 = self.get_properties().get('start_date')
self.start_date_2 = "2022-07-19T00:00:00Z"
self.start_date_2 = new_start_date

self.start_date = self.start_date_1

Expand Down