diff --git a/README.md b/README.md index 1f5849a..af6abeb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/setup.py b/setup.py index cbbc079..cf49714 100644 --- a/setup.py +++ b/setup.py @@ -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, diff --git a/tap_freshdesk/schemas/ticket_fields.json b/tap_freshdesk/schemas/ticket_fields.json new file mode 100644 index 0000000..a67b901 --- /dev/null +++ b/tap_freshdesk/schemas/ticket_fields.json @@ -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": {}, + "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" + } + } +} \ No newline at end of file diff --git a/tap_freshdesk/streams.py b/tap_freshdesk/streams.py index edfd1cc..e58f15d 100644 --- a/tap_freshdesk/streams.py +++ b/tap_freshdesk/streams.py @@ -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, @@ -340,5 +349,6 @@ class TimeEntries(ChildStream): "roles": Roles, "satisfaction_ratings": SatisfactionRatings, "tickets": Tickets, - "time_entries": TimeEntries + "time_entries": TimeEntries, + 'ticket_fields': TicketFields } diff --git a/tests/base.py b/tests/base.py index f250677..96e28cd 100644 --- a/tests/base.py +++ b/tests/base.py @@ -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 + } } ############################# diff --git a/tests/test_freshdesk_pagination.py b/tests/test_freshdesk_pagination.py index 9af1ee8..15aa3d7 100644 --- a/tests/test_freshdesk_pagination.py +++ b/tests/test_freshdesk_pagination.py @@ -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 diff --git a/tests/test_freshdesk_start_date.py b/tests/test_freshdesk_start_date.py index e95363b..1f06c6b 100644 --- a/tests/test_freshdesk_start_date.py +++ b/tests/test_freshdesk_start_date.py @@ -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 @@ -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