diff --git a/.github/workflows/publish-command.yml b/.github/workflows/publish-command.yml index 7b331cc2839a..b0870162c183 100644 --- a/.github/workflows/publish-command.yml +++ b/.github/workflows/publish-command.yml @@ -67,6 +67,7 @@ jobs: GOOGLE_WORKSPACE_ADMIN_REPORTS_TEST_CREDS: ${{ secrets.GOOGLE_WORKSPACE_ADMIN_REPORTS_TEST_CREDS }} GREENHOUSE_TEST_CREDS: ${{ secrets.GREENHOUSE_TEST_CREDS }} GSHEETS_INTEGRATION_TESTS_CREDS: ${{ secrets.GSHEETS_INTEGRATION_TESTS_CREDS }} + HARVEST_INTEGRATION_TESTS_CREDS: ${{ secrets.HARVEST_INTEGRATION_TESTS_CREDS }} HUBSPOT_INTEGRATION_TESTS_CREDS: ${{ secrets.HUBSPOT_INTEGRATION_TESTS_CREDS }} INSTAGRAM_INTEGRATION_TESTS_CREDS: ${{ secrets.INSTAGRAM_INTEGRATION_TESTS_CREDS }} INTERCOM_INTEGRATION_TEST_CREDS: ${{ secrets.INTERCOM_INTEGRATION_TEST_CREDS }} diff --git a/.github/workflows/test-command.yml b/.github/workflows/test-command.yml index 7fab10040763..cb76c2e42ca5 100644 --- a/.github/workflows/test-command.yml +++ b/.github/workflows/test-command.yml @@ -71,6 +71,7 @@ jobs: GOOGLE_WORKSPACE_ADMIN_REPORTS_TEST_CREDS: ${{ secrets.GOOGLE_WORKSPACE_ADMIN_REPORTS_TEST_CREDS }} GREENHOUSE_TEST_CREDS: ${{ secrets.GREENHOUSE_TEST_CREDS }} GSHEETS_INTEGRATION_TESTS_CREDS: ${{ secrets.GSHEETS_INTEGRATION_TESTS_CREDS }} + HARVEST_INTEGRATION_TESTS_CREDS: ${{ secrets.HARVEST_INTEGRATION_TESTS_CREDS }} HUBSPOT_INTEGRATION_TESTS_CREDS: ${{ secrets.HUBSPOT_INTEGRATION_TESTS_CREDS }} INSTAGRAM_INTEGRATION_TESTS_CREDS: ${{ secrets.INSTAGRAM_INTEGRATION_TESTS_CREDS }} INTERCOM_INTEGRATION_TEST_CREDS: ${{ secrets.INTERCOM_INTEGRATION_TEST_CREDS }} diff --git a/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/fe2b4084-3386-4d3b-9ad6-308f61a6f1e6.json b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/fe2b4084-3386-4d3b-9ad6-308f61a6f1e6.json new file mode 100644 index 000000000000..616389d3697e --- /dev/null +++ b/airbyte-config/init/src/main/resources/config/STANDARD_SOURCE_DEFINITION/fe2b4084-3386-4d3b-9ad6-308f61a6f1e6.json @@ -0,0 +1,7 @@ +{ + "sourceDefinitionId": "fe2b4084-3386-4d3b-9ad6-308f61a6f1e6", + "name": "Harvest", + "dockerRepository": "airbyte/source-harvest", + "dockerImageTag": "0.1.0", + "documentationUrl": "https://hub.docker.com/r/airbyte/source-harvest" +} diff --git a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml index 22ccc72ef201..350e4b200e07 100644 --- a/airbyte-config/init/src/main/resources/seed/source_definitions.yaml +++ b/airbyte-config/init/src/main/resources/seed/source_definitions.yaml @@ -305,4 +305,9 @@ dockerRepository: airbyte/source-recharge dockerImageTag: 0.1.0 documentationUrl: https://hub.docker.com/r/airbyte/source-recharge +- sourceDefinitionId: fe2b4084-3386-4d3b-9ad6-308f61a6f1e6 + name: Harvest + dockerRepository: airbyte/source-harvest + dockerImageTag: 0.1.0 + documentationUrl: https://hub.docker.com/r/airbyte/source-harvest # SOURCE DEFINITION BY CODE GENERATOR diff --git a/airbyte-integrations/connectors/source-harvest/.dockerignore b/airbyte-integrations/connectors/source-harvest/.dockerignore new file mode 100644 index 000000000000..7f4027ee9cb3 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/.dockerignore @@ -0,0 +1,5 @@ +* +!main.py +!source_harvest +!setup.py +!secrets diff --git a/airbyte-integrations/connectors/source-harvest/Dockerfile b/airbyte-integrations/connectors/source-harvest/Dockerfile new file mode 100644 index 000000000000..64582a00fbdf --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.7-slim + +# Bash is installed for more convenient debugging. +RUN apt-get update && apt-get install -y bash && rm -rf /var/lib/apt/lists/* + +WORKDIR /airbyte/integration_code +COPY source_harvest ./source_harvest +COPY main.py ./ +COPY setup.py ./ +RUN pip install . + +ENTRYPOINT ["python", "/airbyte/integration_code/main.py"] + +LABEL io.airbyte.version=0.1.0 +LABEL io.airbyte.name=airbyte/source-harvest diff --git a/airbyte-integrations/connectors/source-harvest/README.md b/airbyte-integrations/connectors/source-harvest/README.md new file mode 100644 index 000000000000..87f00fa3a467 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/README.md @@ -0,0 +1,129 @@ +# Harvest Source + +This is the repository for the Harvest source connector, written in Python. +For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.io/integrations/sources/harvest). + +## Local development + +### Prerequisites +**To iterate on this connector, make sure to complete this prerequisites section.** + +#### Build & Activate Virtual Environment and install dependencies +From this connector directory, create a virtual environment: +``` +python -m venv .venv +``` + +This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your +development environment of choice. To activate it from the terminal, run: +``` +source .venv/bin/activate +pip install -r requirements.txt +``` +If you are in an IDE, follow your IDE's instructions to activate the virtualenv. + +Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is +used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`. +If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything +should work as you expect. + +#### Building via Gradle +You can also build the connector in Gradle. This is typically used in CI and not needed for your development workflow. + +To build using Gradle, from the Airbyte repository root, run: +``` +./gradlew :airbyte-integrations:connectors:source-harvest:build +``` + +#### Create credentials +**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.io/integrations/sources/harvest) +to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_harvest/spec.json` file. +Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information. +See `integration_tests/sample_config.json` for a sample config file. + +**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source harvest test creds` +and place them into `secrets/config.json`. + +### Locally running the connector +``` +python main.py spec +python main.py check --config secrets/config.json +python main.py discover --config secrets/config.json +python main.py read --config secrets/config.json --catalog integration_tests/configured_catalog.json +``` + +### Locally running the connector docker image + +#### Build +First, make sure you build the latest Docker image: +``` +docker build . -t airbyte/source-harvest:dev +``` + +You can also build the connector image via Gradle: +``` +./gradlew :airbyte-integrations:connectors:source-harvest:airbyteDocker +``` +When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in +the Dockerfile. + +#### Run +Then run any of the connector commands as follows: +``` +docker run --rm airbyte/source-harvest:dev spec +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-harvest:dev check --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-harvest:dev discover --config /secrets/config.json +docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-harvest:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.json +``` +## Testing +Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named. +First install test dependencies into your virtual environment: +``` +pip install .[tests] +``` +### Unit Tests +To run unit tests locally, from the connector directory run: +``` +python -m pytest unit_tests +``` + +### Integration Tests +There are two types of integration tests: Acceptance Tests (Airbyte's test suite for all source connectors) and custom integration tests (which are specific to this connector). +#### Custom Integration tests +Place custom tests inside `integration_tests/` folder, then, from the connector root, run +``` +python -m pytest integration_tests +``` +#### Acceptance Tests +Customize `acceptance-test-config.yml` file to configure tests. See [Source Acceptance Tests](source-acceptance-tests.md) for more information. +If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py. +To run your integration tests with acceptance tests, from the connector root, run +``` +python -m pytest integration_tests -p integration_tests.acceptance +``` +To run your integration tests with docker + +### Using gradle to run tests +All commands should be run from airbyte project root. +To run unit tests: +``` +./gradlew :airbyte-integrations:connectors:source-harvest:unitTest +``` +To run acceptance and custom integration tests: +``` +./gradlew :airbyte-integrations:connectors:source-harvest:integrationTest +``` + +## Dependency Management +All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development. +We split dependencies between two groups, dependencies that are: +* required for your connector to work need to go to `MAIN_REQUIREMENTS` list. +* required for the testing need to go to `TEST_REQUIREMENTS` list + +### Publishing a new version of the connector +You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what? +1. Make sure your changes are passing unit and integration tests. +1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use [SemVer](https://semver.org/)). +1. Create a Pull Request. +1. Pat yourself on the back for being an awesome contributor. +1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master. diff --git a/airbyte-integrations/connectors/source-harvest/acceptance-test-config.yml b/airbyte-integrations/connectors/source-harvest/acceptance-test-config.yml new file mode 100644 index 000000000000..d3cc21370440 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/acceptance-test-config.yml @@ -0,0 +1,25 @@ +connector_image: airbyte/source-harvest:dev +tests: + spec: + - spec_path: "source_harvest/spec.json" + connection: + - config_path: "secrets/config.json" + status: "succeed" + - config_path: "integration_tests/invalid_config.json" + status: "failed" + discovery: + - config_path: "secrets/config.json" + basic_read: + - config_path: "secrets/config.json" + configured_catalog_path: "integration_tests/configured_catalog.json" + validate_output_from_all_streams: yes + incremental: + - config_path: "secrets/config.json" + configured_catalog_path: "integration_tests/configured_catalog.json" + state_path: "integration_tests/abnormal_state.json" + cursor_paths: + contacts: ["updated_at"] + expenses_clients: ["to"] + full_refresh: + - config_path: "secrets/config.json" + configured_catalog_path: "integration_tests/configured_catalog.json" diff --git a/airbyte-integrations/connectors/source-harvest/acceptance-test-docker.sh b/airbyte-integrations/connectors/source-harvest/acceptance-test-docker.sh new file mode 100755 index 000000000000..1425ff74f151 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/acceptance-test-docker.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env sh +docker run --rm -it \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v /tmp:/tmp \ + -v $(pwd):/test_input \ + airbyte/source-acceptance-test \ + --acceptance-test-config /test_input diff --git a/airbyte-integrations/connectors/source-harvest/build.gradle b/airbyte-integrations/connectors/source-harvest/build.gradle new file mode 100644 index 000000000000..b2315be59888 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/build.gradle @@ -0,0 +1,13 @@ +plugins { + id 'airbyte-python' + id 'airbyte-docker' + id 'airbyte-source-acceptance-test' +} + +airbytePython { + moduleDirectory 'source_harvest' +} + +dependencies { + implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs) +} diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/__init__.py b/airbyte-integrations/connectors/source-harvest/integration_tests/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/abnormal_state.json b/airbyte-integrations/connectors/source-harvest/integration_tests/abnormal_state.json new file mode 100644 index 000000000000..d5687c658eaf --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/integration_tests/abnormal_state.json @@ -0,0 +1,86 @@ +{ + "contacts": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "clients": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "invoices": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "invoice_messages": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "invoice_payments": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "invoice_item_categories": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "estimates": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "estimate_messages": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "estimate_item_categories": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "expenses": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "expense_categories": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "tasks": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "time_entries": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "user_assignments": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "task_assignments": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "projects": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "roles": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "users": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "project_assignments": { + "updated_at": "2217-06-26T21:20:07Z" + }, + "expenses_clients": { + "to": "22170626" + }, + "expenses_projects": { + "to": "22170626" + }, + "expenses_categories": { + "to": "22170626" + }, + "expenses_team": { + "to": "22170626" + }, + "uninvoiced": { + "to": "22170626" + }, + "time_clients": { + "to": "22170626" + }, + "time_projects": { + "to": "22170626" + }, + "time_tasks": { + "to": "22170626" + }, + "time_team": { + "to": "22170626" + } +} diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/acceptance.py b/airbyte-integrations/connectors/source-harvest/integration_tests/acceptance.py new file mode 100644 index 000000000000..eeb4a2d3e02e --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/integration_tests/acceptance.py @@ -0,0 +1,36 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + +import pytest + +pytest_plugins = ("source_acceptance_test.plugin",) + + +@pytest.fixture(scope="session", autouse=True) +def connector_setup(): + """ This fixture is a placeholder for external resources that acceptance test might require.""" + # TODO: setup test dependencies if needed. otherwise remove the TODO comments + yield + # TODO: clean up test dependencies diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/configured_catalog.json b/airbyte-integrations/connectors/source-harvest/integration_tests/configured_catalog.json new file mode 100644 index 000000000000..1c8f2675fffb --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/integration_tests/configured_catalog.json @@ -0,0 +1,2060 @@ +{ + "streams": [ + { + "stream": { + "name": "clients", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "address": { + "type": ["null", "string"] + }, + "statement_key": { + "type": ["null", "integer"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "currency": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "contacts", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "title": { + "type": ["null", "string"] + }, + "first_name": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + }, + "phone_office": { + "type": ["null", "string"] + }, + "phone_mobile": { + "type": ["null", "string"] + }, + "fax": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "company", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "base_uri": { + "type": ["null", "string"] + }, + "full_domain": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "week_start_day": { + "type": ["null", "string"] + }, + "wants_timestamp_timers": { + "type": ["null", "boolean"] + }, + "time_format": { + "type": ["null", "string"] + }, + "plan_type": { + "type": ["null", "string"] + }, + "expense_feature": { + "type": ["null", "boolean"] + }, + "invoice_feature": { + "type": ["null", "boolean"] + }, + "estimate_feature": { + "type": ["null", "boolean"] + }, + "approval_required": { + "type": ["null", "boolean"] + }, + "clock": { + "type": ["null", "string"] + }, + "decimal_symbol": { + "type": ["null", "string"] + }, + "thousands_separator": { + "type": ["null", "string"] + }, + "color_scheme": { + "type": ["null", "string"] + }, + "weekly_capacity": { + "type": ["null", "integer"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "invoices", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "client_key": { + "type": ["null", "string"] + }, + "number": { + "type": ["null", "string"] + }, + "purchase_order": { + "type": ["null", "string"] + }, + "amount": { + "type": ["null", "number"] + }, + "due_amount": { + "type": ["null", "number"] + }, + "tax": { + "type": ["null", "integer"] + }, + "tax_amount": { + "type": ["null", "number"] + }, + "tax2": { + "type": ["null", "integer"] + }, + "tax2_amount": { + "type": ["null", "number"] + }, + "discount": { + "type": ["null", "integer"] + }, + "discount_amount": { + "type": ["null", "integer"] + }, + "subject": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "period_start": { + "type": ["null", "string"], + "format": "date" + }, + "period_end": { + "type": ["null", "string"], + "format": "date" + }, + "issue_date": { + "type": ["null", "string"], + "format": "date" + }, + "due_date": { + "type": ["null", "string"], + "format": "date" + }, + "payment_term": { + "type": ["null", "string"] + }, + "sent_at": { + "type": ["null", "string"], + "format": "date" + }, + "paid_at": { + "type": ["null", "string"] + }, + "paid_date": { + "type": ["null", "string"] + }, + "closed_at": { + "type": ["null", "string"] + }, + "recurring_invoice_id": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date" + }, + "currency": { + "type": ["null", "string"] + }, + "client": { + "type": ["null", "string"] + }, + "estimate": { + "type": ["null", "string"] + }, + "retainer": { + "type": ["null", "string"] + }, + "creator": { + "type": ["null", "string"] + }, + "line_items": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "kind": { + "type": ["null", "string"] + }, + "description": { + "type": ["null", "string"] + }, + "quantity": { + "type": ["null", "integer"] + }, + "unit_price": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "integer"] + }, + "taxed": { + "type": ["null", "boolean"] + }, + "taxed2": { + "type": ["null", "boolean"] + }, + "project": { + "type": ["null", "string"] + } + } + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "invoice_messages", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "sent_by": { + "type": ["null", "string"] + }, + "sent_by_email": { + "type": ["null", "string"] + }, + "sent_from": { + "type": ["null", "string"] + }, + "sent_from_email": { + "type": ["null", "string"] + }, + "include_link_to_client_invoice": { + "type": ["null", "boolean"] + }, + "send_me_a_copy": { + "type": ["null", "boolean"] + }, + "thank_you": { + "type": ["null", "boolean"] + }, + "reminder": { + "type": ["null", "boolean"] + }, + "send_reminder_on": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date" + }, + "attach_pdf": { + "type": ["null", "boolean"] + }, + "event_type": { + "type": ["null", "string"] + }, + "recipients": { + "type": ["null", "object"], + "properties": { + "name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + } + } + }, + "subject": { + "type": ["null", "string"] + }, + "body": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "invoice_payments", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "integer"] + }, + "paid_at": { + "type": ["null", "string"], + "format": "date" + }, + "paid_date": { + "type": ["null", "string"], + "format": "date" + }, + "recorded_by": { + "type": ["null", "string"] + }, + "recorded_by_email": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "transaction_id": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date" + }, + "payment_gateway": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "invoice_item_categories", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "use_as_service": { + "type": ["null", "boolean"] + }, + "use_as_expense": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "estimates", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "client_key": { + "type": ["null", "string"] + }, + "number": { + "type": ["null", "string"] + }, + "purchase_order": { + "type": ["null", "string"] + }, + "amount": { + "type": ["null", "number"] + }, + "tax": { + "type": ["null", "number"] + }, + "tax_amount": { + "type": ["null", "number"] + }, + "tax2": { + "type": ["null", "number"] + }, + "tax2_amount": { + "type": ["null", "number"] + }, + "discount": { + "type": ["null", "number"] + }, + "discount_amount": { + "type": ["null", "number"] + }, + "subject": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "issue_date": { + "type": ["null", "string"], + "format": "date" + }, + "sent_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "accepted_at": { + "type": ["null", "string"] + }, + "declined_at": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "creator": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "line_items": { + "type": ["null", "array"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "estimate_messages", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "sent_by": { + "type": ["null", "string"] + }, + "sent_by_email": { + "type": ["null", "string"] + }, + "sent_from": { + "type": ["null", "string"] + }, + "sent_from_email": { + "type": ["null", "string"] + }, + "send_me_a_copy": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "recipients": { + "type": ["null", "array"] + }, + "event_type": { + "type": ["null", "string"] + }, + "subject": { + "type": ["null", "string"] + }, + "body": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "estimate_item_categories", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "expenses", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "notes": { + "type": ["null", "string"] + }, + "total_cost": { + "type": ["null", "number"] + }, + "units": { + "type": ["null", "number"] + }, + "is_closed": { + "type": ["null", "boolean"] + }, + "is_locked": { + "type": ["null", "boolean"] + }, + "is_billed": { + "type": ["null", "boolean"] + }, + "locked_reason": { + "type": ["null", "string"] + }, + "spent_date": { + "type": ["null", "string"], + "format": "date" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "billable": { + "type": ["null", "boolean"] + }, + "receipt": { + "type": ["null", "object"], + "properties": { + "url": { + "type": ["null", "string"] + }, + "file_name": { + "type": ["null", "string"] + }, + "file_size": { + "type": ["null", "integer"] + }, + "content_type": { + "type": ["null", "string"] + } + } + }, + "user": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "user_assignment": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + } + } + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "expense_category": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "string"] + }, + "unit_name": { + "type": ["null", "string"] + } + } + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + } + } + }, + "invoice": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "number": { + "type": ["null", "string"] + } + } + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "expense_categories", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "unit_name": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "number"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "tasks", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "billable_by_default": { + "type": ["null", "boolean"] + }, + "default_hourly_rate": { + "type": ["null", "number"] + }, + "is_default": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "time_entries", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "spent_date": { + "type": ["null", "string"], + "format": "date" + }, + "user": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "task": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "user_assignment": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + } + } + }, + "task_assignment": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "billable": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "budget": { + "type": ["null", "string"] + } + } + }, + "hours": { + "type": ["null", "number"] + }, + "rounded_hours": { + "type": ["null", "number"] + }, + "notes": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "is_locked": { + "type": ["null", "boolean"] + }, + "locked_reason": { + "type": ["null", "string"] + }, + "is_closed": { + "type": ["null", "boolean"] + }, + "is_billed": { + "type": ["null", "boolean"] + }, + "timer_started_at": { + "type": ["null", "string"] + }, + "started_time": { + "type": ["null", "string"], + "format": "date-time" + }, + "ended_time": { + "type": ["null", "string"], + "format": "date-time" + }, + "is_running": { + "type": ["null", "boolean"] + }, + "invoice": { + "type": ["null", "string"] + }, + "external_reference": { + "type": ["null", "string"] + }, + "billable": { + "type": ["null", "boolean"] + }, + "budgeted": { + "type": ["null", "boolean"] + }, + "billable_rate": { + "type": ["null", "number"] + }, + "cost_rate": { + "type": ["null", "number"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "user_assignments", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "use_default_rates": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "number"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "user": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "task_assignments", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "billable": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "budget": { + "type": ["null", "string"] + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "task": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "projects", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "bill_by": { + "type": ["null", "string"] + }, + "budget": { + "type": ["null", "number"] + }, + "budget_by": { + "type": ["null", "string"] + }, + "budget_is_monthly": { + "type": ["null", "boolean"] + }, + "notify_when_over_budget": { + "type": ["null", "boolean"] + }, + "over_budget_notification_percentage": { + "type": ["null", "number"] + }, + "over_budget_notification_date": { + "type": ["null", "string"], + "format": "date" + }, + "show_budget_to_all": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "starts_on": { + "type": ["null", "string"], + "format": "date" + }, + "ends_on": { + "type": ["null", "string"] + }, + "is_billable": { + "type": ["null", "boolean"] + }, + "is_fixed_fee": { + "type": ["null", "boolean"] + }, + "notes": { + "type": ["null", "string"] + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + } + } + }, + "cost_budget": { + "type": ["null", "string"] + }, + "cost_budget_include_expenses": { + "type": ["null", "boolean"] + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "fee": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "roles", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "user_ids": { + "type": ["null", "array"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "users", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "first_name": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + }, + "telephone": { + "type": ["null", "string"] + }, + "timezone": { + "type": ["null", "string"] + }, + "has_access_to_all_future_projects": { + "type": ["null", "boolean"] + }, + "is_contractor": { + "type": ["null", "boolean"] + }, + "is_admin": { + "type": ["null", "boolean"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "can_see_rates": { + "type": ["null", "boolean"] + }, + "can_create_projects": { + "type": ["null", "boolean"] + }, + "can_create_invoices": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "weekly_capacity": { + "type": ["null", "integer"] + }, + "default_hourly_rate": { + "type": ["null", "number"] + }, + "cost_rate": { + "type": ["null", "number"] + }, + "roles": { + "type": ["null", "array"] + }, + "avatar_url": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "billable_rates", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "number"] + }, + "start_date": { + "type": ["null", "string"], + "format": "date" + }, + "end_date": { + "type": ["null", "string"], + "format": "date" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "cost_rates", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "number"] + }, + "start_date": { + "type": ["null", "string"], + "format": "date" + }, + "end_date": { + "type": ["null", "string"], + "format": "date" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "project_assignments", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "use_default_rates": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "task_assignments": { + "type": ["null", "array"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["updated_at"] + }, + "sync_mode": "incremental", + "cursor_field": ["updated_at"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "expenses_clients", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "total_amount": { + "type": ["null", "integer"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "expenses_projects", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "total_amount": { + "type": ["null", "number"] + }, + "billable_amount": { + "type": ["null", "number"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "expenses_categories", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "expense_category_id": { + "type": ["null", "integer"] + }, + "expense_category_name": { + "type": ["null", "string"] + }, + "total_amount": { + "type": ["null", "integer"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "expenses_team", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "user_id": { + "type": ["null", "integer"] + }, + "user_name": { + "type": ["null", "string"] + }, + "is_contractor": { + "type": ["null", "boolean"] + }, + "total_amount": { + "type": ["null", "integer"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "uninvoiced", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "integer"] + }, + "uninvoiced_hours": { + "type": ["null", "integer"] + }, + "uninvoiced_expenses": { + "type": ["null", "integer"] + }, + "uninvoiced_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + }, + { + "stream": { + "name": "time_clients", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "number"] + }, + "billable_hours": { + "type": ["null", "number"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "time_projects", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "integer"] + }, + "billable_hours": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "time_tasks", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "task_id": { + "type": ["null", "integer"] + }, + "task_name": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "integer"] + }, + "billable_hours": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "time_team", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "user_id": { + "type": ["null", "integer"] + }, + "user_name": { + "type": ["null", "string"] + }, + "is_contractor": { + "type": ["null", "boolean"] + }, + "total_hours": { + "type": ["null", "number"] + }, + "billable_hours": { + "type": ["null", "number"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh", "incremental"], + "source_defined_cursor": true, + "default_cursor_field": ["to"] + }, + "sync_mode": "incremental", + "cursor_field": ["to"], + "destination_sync_mode": "append" + }, + { + "stream": { + "name": "project_budget", + "json_schema": { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "budget_is_monthly": { + "type": ["null", "boolean"] + }, + "budget_by": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "integer"] + }, + "budget_spent": { + "type": ["null", "integer"] + }, + "budget_remaining": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } + }, + "supported_sync_modes": ["full_refresh"] + }, + "sync_mode": "full_refresh", + "destination_sync_mode": "overwrite" + } + ] +} diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/invalid_config.json b/airbyte-integrations/connectors/source-harvest/integration_tests/invalid_config.json new file mode 100644 index 000000000000..57b07556f3ff --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/integration_tests/invalid_config.json @@ -0,0 +1,5 @@ +{ + "api_token": "1111111.aa.wrong-api-token", + "account_id": "1111111", + "replication_start_date": "1000-06-26T21:20:07Z" +} diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/sample_config.json b/airbyte-integrations/connectors/source-harvest/integration_tests/sample_config.json new file mode 100644 index 000000000000..a9d85c28758b --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/integration_tests/sample_config.json @@ -0,0 +1,5 @@ +{ + "api_token": "", + "account_id": "", + "replication_start_date": "2021-01-01T00:00:00Z" +} diff --git a/airbyte-integrations/connectors/source-harvest/integration_tests/sample_state.json b/airbyte-integrations/connectors/source-harvest/integration_tests/sample_state.json new file mode 100644 index 000000000000..ae4bb37a212e --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/integration_tests/sample_state.json @@ -0,0 +1,86 @@ +{ + "contacts": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "clients": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "invoices": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "invoice_messages": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "invoice_payments": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "invoice_item_categories": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "estimates": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "estimate_messages": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "estimate_item_categories": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "expenses": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "expense_categories": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "tasks": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "time_entries": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "user_assignments": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "task_assignments": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "projects": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "roles": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "users": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "project_assignments": { + "updated_at": "2021-01-01T00:00:00Z" + }, + "expenses_clients": { + "to": "20210101" + }, + "expenses_projects": { + "to": "20210101" + }, + "expenses_categories": { + "to": "20210101" + }, + "expenses_team": { + "to": "20210101" + }, + "uninvoiced": { + "to": "20210101" + }, + "time_clients": { + "to": "20210101" + }, + "time_projects": { + "to": "20210101" + }, + "time_tasks": { + "to": "20210101" + }, + "time_team": { + "to": "20210101" + } +} diff --git a/airbyte-integrations/connectors/source-harvest/main.py b/airbyte-integrations/connectors/source-harvest/main.py new file mode 100644 index 000000000000..24cbed7bada4 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/main.py @@ -0,0 +1,33 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + +import sys + +from airbyte_cdk.entrypoint import launch +from source_harvest import SourceHarvest + +if __name__ == "__main__": + source = SourceHarvest() + launch(source, sys.argv[1:]) diff --git a/airbyte-integrations/connectors/source-harvest/setup.py b/airbyte-integrations/connectors/source-harvest/setup.py new file mode 100644 index 000000000000..681e8e178fd9 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/setup.py @@ -0,0 +1,47 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + +from setuptools import find_packages, setup + +MAIN_REQUIREMENTS = [ + "airbyte-cdk~=0.1", +] + +TEST_REQUIREMENTS = [ + "pytest~=6.1", +] + +setup( + name="source_harvest", + description="Source implementation for Harvest.", + author="Airbyte", + author_email="contact@airbyte.io", + packages=find_packages(), + install_requires=MAIN_REQUIREMENTS, + package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]}, + extras_require={ + "tests": TEST_REQUIREMENTS, + }, +) diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/__init__.py b/airbyte-integrations/connectors/source-harvest/source_harvest/__init__.py new file mode 100644 index 000000000000..0558fdc23880 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/__init__.py @@ -0,0 +1,27 @@ +""" +MIT License + +Copyright (c) 2020 Airbyte + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +""" + +from .source import SourceHarvest + +__all__ = ["SourceHarvest"] diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/auth.py b/airbyte-integrations/connectors/source-harvest/source_harvest/auth.py new file mode 100644 index 000000000000..5a654fd0a1e6 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/auth.py @@ -0,0 +1,37 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +from typing import Any, Mapping + +from airbyte_cdk.sources.streams.http.auth import TokenAuthenticator + + +class HarvestTokenAuthenticator(TokenAuthenticator): + def __init__(self, token: str, account_id: str, account_id_header: str = "Harvest-Account-ID", **kwargs): + super().__init__(token, **kwargs) + self.account_id = account_id + self.account_id_header = account_id_header + + def get_auth_header(self) -> Mapping[str, Any]: + return {**super().get_auth_header(), self.account_id_header: self.account_id} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/billable_rates.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/billable_rates.json new file mode 100644 index 000000000000..cc071925d0ba --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/billable_rates.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "number"] + }, + "start_date": { + "type": ["null", "string"], + "format": "date" + }, + "end_date": { + "type": ["null", "string"], + "format": "date" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/clients.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/clients.json new file mode 100644 index 000000000000..050e85d13bf2 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/clients.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "address": { + "type": ["null", "string"] + }, + "statement_key": { + "type": ["null", "integer"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "currency": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/company.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/company.json new file mode 100644 index 000000000000..704f3d7cb62a --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/company.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "base_uri": { + "type": ["null", "string"] + }, + "full_domain": { + "type": ["null", "string"] + }, + "name": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "week_start_day": { + "type": ["null", "string"] + }, + "wants_timestamp_timers": { + "type": ["null", "boolean"] + }, + "time_format": { + "type": ["null", "string"] + }, + "plan_type": { + "type": ["null", "string"] + }, + "expense_feature": { + "type": ["null", "boolean"] + }, + "invoice_feature": { + "type": ["null", "boolean"] + }, + "estimate_feature": { + "type": ["null", "boolean"] + }, + "approval_required": { + "type": ["null", "boolean"] + }, + "clock": { + "type": ["null", "string"] + }, + "decimal_symbol": { + "type": ["null", "string"] + }, + "thousands_separator": { + "type": ["null", "string"] + }, + "color_scheme": { + "type": ["null", "string"] + }, + "weekly_capacity": { + "type": ["null", "integer"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/contacts.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/contacts.json new file mode 100644 index 000000000000..272d6f40a36e --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/contacts.json @@ -0,0 +1,49 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "title": { + "type": ["null", "string"] + }, + "first_name": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + }, + "phone_office": { + "type": ["null", "string"] + }, + "phone_mobile": { + "type": ["null", "string"] + }, + "fax": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/cost_rates.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/cost_rates.json new file mode 100644 index 000000000000..cc071925d0ba --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/cost_rates.json @@ -0,0 +1,28 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "number"] + }, + "start_date": { + "type": ["null", "string"], + "format": "date" + }, + "end_date": { + "type": ["null", "string"], + "format": "date" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimate_item_categories.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimate_item_categories.json new file mode 100644 index 000000000000..0c6b5ce3dd73 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimate_item_categories.json @@ -0,0 +1,20 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimate_messages.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimate_messages.json new file mode 100644 index 000000000000..2157406a16be --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimate_messages.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "sent_by": { + "type": ["null", "string"] + }, + "sent_by_email": { + "type": ["null", "string"] + }, + "sent_from": { + "type": ["null", "string"] + }, + "sent_from_email": { + "type": ["null", "string"] + }, + "send_me_a_copy": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "recipients": { + "type": ["null", "array"] + }, + "event_type": { + "type": ["null", "string"] + }, + "subject": { + "type": ["null", "string"] + }, + "body": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimates.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimates.json new file mode 100644 index 000000000000..3d995ca072d0 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/estimates.json @@ -0,0 +1,98 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "client_key": { + "type": ["null", "string"] + }, + "number": { + "type": ["null", "string"] + }, + "purchase_order": { + "type": ["null", "string"] + }, + "amount": { + "type": ["null", "number"] + }, + "tax": { + "type": ["null", "number"] + }, + "tax_amount": { + "type": ["null", "number"] + }, + "tax2": { + "type": ["null", "number"] + }, + "tax2_amount": { + "type": ["null", "number"] + }, + "discount": { + "type": ["null", "number"] + }, + "discount_amount": { + "type": ["null", "number"] + }, + "subject": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "issue_date": { + "type": ["null", "string"], + "format": "date" + }, + "sent_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "accepted_at": { + "type": ["null", "string"] + }, + "declined_at": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "creator": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "line_items": { + "type": ["null", "array"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expense_categories.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expense_categories.json new file mode 100644 index 000000000000..332043c1dc24 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expense_categories.json @@ -0,0 +1,29 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "unit_name": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "number"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses.json new file mode 100644 index 000000000000..547c6c54ce9d --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses.json @@ -0,0 +1,157 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "notes": { + "type": ["null", "string"] + }, + "total_cost": { + "type": ["null", "number"] + }, + "units": { + "type": ["null", "number"] + }, + "is_closed": { + "type": ["null", "boolean"] + }, + "is_locked": { + "type": ["null", "boolean"] + }, + "is_billed": { + "type": ["null", "boolean"] + }, + "locked_reason": { + "type": ["null", "string"] + }, + "spent_date": { + "type": ["null", "string"], + "format": "date" + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "billable": { + "type": ["null", "boolean"] + }, + "receipt": { + "type": ["null", "object"], + "properties": { + "url": { + "type": ["null", "string"] + }, + "file_name": { + "type": ["null", "string"] + }, + "file_size": { + "type": ["null", "integer"] + }, + "content_type": { + "type": ["null", "string"] + } + } + }, + "user": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "user_assignment": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + } + } + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "expense_category": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "unit_price": { + "type": ["null", "string"] + }, + "unit_name": { + "type": ["null", "string"] + } + } + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + } + } + }, + "invoice": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "number": { + "type": ["null", "string"] + } + } + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_categories.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_categories.json new file mode 100644 index 000000000000..8a3f3503b69d --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_categories.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "expense_category_id": { + "type": ["null", "integer"] + }, + "expense_category_name": { + "type": ["null", "string"] + }, + "total_amount": { + "type": ["null", "integer"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_clients.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_clients.json new file mode 100644 index 000000000000..c101189f93a0 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_clients.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "total_amount": { + "type": ["null", "integer"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_projects.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_projects.json new file mode 100644 index 000000000000..23d2ee0556bf --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_projects.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "total_amount": { + "type": ["null", "number"] + }, + "billable_amount": { + "type": ["null", "number"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_team.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_team.json new file mode 100644 index 000000000000..e107c3f12509 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/expenses_team.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "user_id": { + "type": ["null", "integer"] + }, + "user_name": { + "type": ["null", "string"] + }, + "is_contractor": { + "type": ["null", "boolean"] + }, + "total_amount": { + "type": ["null", "integer"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_item_categories.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_item_categories.json new file mode 100644 index 000000000000..4ce497f49c51 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_item_categories.json @@ -0,0 +1,26 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "use_as_service": { + "type": ["null", "boolean"] + }, + "use_as_expense": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_messages.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_messages.json new file mode 100644 index 000000000000..eb16f1ae1e8a --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_messages.json @@ -0,0 +1,67 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "sent_by": { + "type": ["null", "string"] + }, + "sent_by_email": { + "type": ["null", "string"] + }, + "sent_from": { + "type": ["null", "string"] + }, + "sent_from_email": { + "type": ["null", "string"] + }, + "include_link_to_client_invoice": { + "type": ["null", "boolean"] + }, + "send_me_a_copy": { + "type": ["null", "boolean"] + }, + "thank_you": { + "type": ["null", "boolean"] + }, + "reminder": { + "type": ["null", "boolean"] + }, + "send_reminder_on": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date" + }, + "attach_pdf": { + "type": ["null", "boolean"] + }, + "event_type": { + "type": ["null", "string"] + }, + "recipients": { + "type": ["null", "object"], + "properties": { + "name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + } + } + }, + "subject": { + "type": ["null", "string"] + }, + "body": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_payments.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_payments.json new file mode 100644 index 000000000000..6b5890eb5aa1 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoice_payments.json @@ -0,0 +1,51 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "integer"] + }, + "paid_at": { + "type": ["null", "string"], + "format": "date" + }, + "paid_date": { + "type": ["null", "string"], + "format": "date" + }, + "recorded_by": { + "type": ["null", "string"] + }, + "recorded_by_email": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "transaction_id": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date" + }, + "payment_gateway": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoices.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoices.json new file mode 100644 index 000000000000..a9bc6037c4e4 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/invoices.json @@ -0,0 +1,141 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "client_key": { + "type": ["null", "string"] + }, + "number": { + "type": ["null", "string"] + }, + "purchase_order": { + "type": ["null", "string"] + }, + "amount": { + "type": ["null", "number"] + }, + "due_amount": { + "type": ["null", "number"] + }, + "tax": { + "type": ["null", "integer"] + }, + "tax_amount": { + "type": ["null", "number"] + }, + "tax2": { + "type": ["null", "integer"] + }, + "tax2_amount": { + "type": ["null", "number"] + }, + "discount": { + "type": ["null", "integer"] + }, + "discount_amount": { + "type": ["null", "integer"] + }, + "subject": { + "type": ["null", "string"] + }, + "notes": { + "type": ["null", "string"] + }, + "state": { + "type": ["null", "string"] + }, + "period_start": { + "type": ["null", "string"], + "format": "date" + }, + "period_end": { + "type": ["null", "string"], + "format": "date" + }, + "issue_date": { + "type": ["null", "string"], + "format": "date" + }, + "due_date": { + "type": ["null", "string"], + "format": "date" + }, + "payment_term": { + "type": ["null", "string"] + }, + "sent_at": { + "type": ["null", "string"], + "format": "date" + }, + "paid_at": { + "type": ["null", "string"] + }, + "paid_date": { + "type": ["null", "string"] + }, + "closed_at": { + "type": ["null", "string"] + }, + "recurring_invoice_id": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date" + }, + "currency": { + "type": ["null", "string"] + }, + "client": { + "type": ["null", "string"] + }, + "estimate": { + "type": ["null", "string"] + }, + "retainer": { + "type": ["null", "string"] + }, + "creator": { + "type": ["null", "string"] + }, + "line_items": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "kind": { + "type": ["null", "string"] + }, + "description": { + "type": ["null", "string"] + }, + "quantity": { + "type": ["null", "integer"] + }, + "unit_price": { + "type": ["null", "integer"] + }, + "amount": { + "type": ["null", "integer"] + }, + "taxed": { + "type": ["null", "boolean"] + }, + "taxed2": { + "type": ["null", "boolean"] + }, + "project": { + "type": ["null", "string"] + } + } + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/project_assignments.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/project_assignments.json new file mode 100644 index 000000000000..eaf7b2b642c4 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/project_assignments.json @@ -0,0 +1,60 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "use_default_rates": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "task_assignments": { + "type": ["null", "array"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/project_budget.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/project_budget.json new file mode 100644 index 000000000000..3742a85771d2 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/project_budget.json @@ -0,0 +1,42 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "budget_is_monthly": { + "type": ["null", "boolean"] + }, + "budget_by": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "integer"] + }, + "budget_spent": { + "type": ["null", "integer"] + }, + "budget_remaining": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/projects.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/projects.json new file mode 100644 index 000000000000..639ea72f6527 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/projects.json @@ -0,0 +1,93 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "bill_by": { + "type": ["null", "string"] + }, + "budget": { + "type": ["null", "number"] + }, + "budget_by": { + "type": ["null", "string"] + }, + "budget_is_monthly": { + "type": ["null", "boolean"] + }, + "notify_when_over_budget": { + "type": ["null", "boolean"] + }, + "over_budget_notification_percentage": { + "type": ["null", "number"] + }, + "over_budget_notification_date": { + "type": ["null", "string"], + "format": "date" + }, + "show_budget_to_all": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "starts_on": { + "type": ["null", "string"], + "format": "date" + }, + "ends_on": { + "type": ["null", "string"] + }, + "is_billable": { + "type": ["null", "boolean"] + }, + "is_fixed_fee": { + "type": ["null", "boolean"] + }, + "notes": { + "type": ["null", "string"] + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + } + } + }, + "cost_budget": { + "type": ["null", "string"] + }, + "cost_budget_include_expenses": { + "type": ["null", "boolean"] + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "fee": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/roles.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/roles.json new file mode 100644 index 000000000000..fce9c76fcf81 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/roles.json @@ -0,0 +1,23 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "user_ids": { + "type": ["null", "array"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/task_assignments.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/task_assignments.json new file mode 100644 index 000000000000..3180d55362bc --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/task_assignments.json @@ -0,0 +1,54 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "billable": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "budget": { + "type": ["null", "string"] + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "task": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/tasks.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/tasks.json new file mode 100644 index 000000000000..465336d3ce25 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/tasks.json @@ -0,0 +1,32 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "billable_by_default": { + "type": ["null", "boolean"] + }, + "default_hourly_rate": { + "type": ["null", "number"] + }, + "is_default": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_clients.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_clients.json new file mode 100644 index 000000000000..43a92dba12ab --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_clients.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "number"] + }, + "billable_hours": { + "type": ["null", "number"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_entries.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_entries.json new file mode 100644 index 000000000000..95acba6cffcd --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_entries.json @@ -0,0 +1,174 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "spent_date": { + "type": ["null", "string"], + "format": "date" + }, + "user": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "client": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "task": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + }, + "user_assignment": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + } + } + }, + "task_assignment": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "billable": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "budget": { + "type": ["null", "string"] + } + } + }, + "hours": { + "type": ["null", "number"] + }, + "rounded_hours": { + "type": ["null", "number"] + }, + "notes": { + "type": ["null", "string"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "is_locked": { + "type": ["null", "boolean"] + }, + "locked_reason": { + "type": ["null", "string"] + }, + "is_closed": { + "type": ["null", "boolean"] + }, + "is_billed": { + "type": ["null", "boolean"] + }, + "timer_started_at": { + "type": ["null", "string"] + }, + "started_time": { + "type": ["null", "string"], + "format": "date-time" + }, + "ended_time": { + "type": ["null", "string"], + "format": "date-time" + }, + "is_running": { + "type": ["null", "boolean"] + }, + "invoice": { + "type": ["null", "string"] + }, + "external_reference": { + "type": ["null", "string"] + }, + "billable": { + "type": ["null", "boolean"] + }, + "budgeted": { + "type": ["null", "boolean"] + }, + "billable_rate": { + "type": ["null", "number"] + }, + "cost_rate": { + "type": ["null", "number"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_projects.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_projects.json new file mode 100644 index 000000000000..7577b038da40 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_projects.json @@ -0,0 +1,36 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "integer"] + }, + "billable_hours": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_tasks.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_tasks.json new file mode 100644 index 000000000000..6c337cbc3749 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_tasks.json @@ -0,0 +1,30 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "task_id": { + "type": ["null", "integer"] + }, + "task_name": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "integer"] + }, + "billable_hours": { + "type": ["null", "integer"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_team.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_team.json new file mode 100644 index 000000000000..4971b00b087d --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/time_team.json @@ -0,0 +1,33 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "user_id": { + "type": ["null", "integer"] + }, + "user_name": { + "type": ["null", "string"] + }, + "is_contractor": { + "type": ["null", "boolean"] + }, + "total_hours": { + "type": ["null", "number"] + }, + "billable_hours": { + "type": ["null", "number"] + }, + "currency": { + "type": ["null", "string"] + }, + "billable_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/uninvoiced.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/uninvoiced.json new file mode 100644 index 000000000000..b124db596ea9 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/uninvoiced.json @@ -0,0 +1,39 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "client_id": { + "type": ["null", "integer"] + }, + "client_name": { + "type": ["null", "string"] + }, + "project_id": { + "type": ["null", "integer"] + }, + "project_name": { + "type": ["null", "string"] + }, + "currency": { + "type": ["null", "string"] + }, + "total_hours": { + "type": ["null", "integer"] + }, + "uninvoiced_hours": { + "type": ["null", "integer"] + }, + "uninvoiced_expenses": { + "type": ["null", "integer"] + }, + "uninvoiced_amount": { + "type": ["null", "integer"] + }, + "from": { + "type": ["null", "string"] + }, + "to": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/user_assignments.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/user_assignments.json new file mode 100644 index 000000000000..c5c87e75a231 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/user_assignments.json @@ -0,0 +1,57 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "use_default_rates": { + "type": ["null", "boolean"] + }, + "budget": { + "type": ["null", "number"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "hourly_rate": { + "type": ["null", "number"] + }, + "project": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + }, + "code": { + "type": ["null", "string"] + } + } + }, + "user": { + "type": ["null", "object"], + "properties": { + "id": { + "type": ["null", "integer"] + }, + "name": { + "type": ["null", "string"] + } + } + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/users.json b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/users.json new file mode 100644 index 000000000000..0a1329308ac8 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/schemas/users.json @@ -0,0 +1,71 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "id": { + "type": ["null", "integer"] + }, + "first_name": { + "type": ["null", "string"] + }, + "last_name": { + "type": ["null", "string"] + }, + "email": { + "type": ["null", "string"] + }, + "telephone": { + "type": ["null", "string"] + }, + "timezone": { + "type": ["null", "string"] + }, + "has_access_to_all_future_projects": { + "type": ["null", "boolean"] + }, + "is_contractor": { + "type": ["null", "boolean"] + }, + "is_admin": { + "type": ["null", "boolean"] + }, + "is_project_manager": { + "type": ["null", "boolean"] + }, + "can_see_rates": { + "type": ["null", "boolean"] + }, + "can_create_projects": { + "type": ["null", "boolean"] + }, + "can_create_invoices": { + "type": ["null", "boolean"] + }, + "is_active": { + "type": ["null", "boolean"] + }, + "created_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "updated_at": { + "type": ["null", "string"], + "format": "date-time" + }, + "weekly_capacity": { + "type": ["null", "integer"] + }, + "default_hourly_rate": { + "type": ["null", "number"] + }, + "cost_rate": { + "type": ["null", "number"] + }, + "roles": { + "type": ["null", "array"] + }, + "avatar_url": { + "type": ["null", "string"] + } + } +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/source.py b/airbyte-integrations/connectors/source-harvest/source_harvest/source.py new file mode 100644 index 000000000000..f53eee3e790b --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/source.py @@ -0,0 +1,127 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + +from typing import Any, List, Mapping, Tuple + +import pendulum +from airbyte_cdk.logger import AirbyteLogger +from airbyte_cdk.models import SyncMode +from airbyte_cdk.sources import AbstractSource +from airbyte_cdk.sources.streams import Stream +from source_harvest.streams import ( + BillableRates, + Clients, + Company, + Contacts, + CostRates, + EstimateItemCategories, + EstimateMessages, + Estimates, + ExpenseCategories, + Expenses, + ExpensesCategories, + ExpensesClients, + ExpensesProjects, + ExpensesTeam, + InvoiceItemCategories, + InvoiceMessages, + InvoicePayments, + Invoices, + ProjectAssignments, + ProjectBudget, + Projects, + Roles, + TaskAssignments, + Tasks, + TimeClients, + TimeEntries, + TimeProjects, + TimeTasks, + TimeTeam, + Uninvoiced, + UserAssignments, + Users, +) + +from .auth import HarvestTokenAuthenticator + + +class SourceHarvest(AbstractSource): + def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]: + try: + auth = HarvestTokenAuthenticator(token=config["api_token"], account_id=config["account_id"]) + replication_start_date = pendulum.parse(config["replication_start_date"]) + users_gen = Users(authenticator=auth, replication_start_date=replication_start_date).read_records( + sync_mode=SyncMode.full_refresh + ) + next(users_gen) + return True, None + except Exception as error: + return False, f"Unable to connect to Harvest API with the provided credentials - {repr(error)}" + + def streams(self, config: Mapping[str, Any]) -> List[Stream]: + """ + :param config: A Mapping of the user input configuration as defined in the connector spec. + """ + auth = HarvestTokenAuthenticator(token=config["api_token"], account_id=config["account_id"]) + replication_start_date = pendulum.parse(config["replication_start_date"]) + from_date = replication_start_date.date() + + streams = [ + Clients(authenticator=auth, replication_start_date=replication_start_date), + Contacts(authenticator=auth, replication_start_date=replication_start_date), + Company(authenticator=auth), + Invoices(authenticator=auth, replication_start_date=replication_start_date), + InvoiceMessages(authenticator=auth, replication_start_date=replication_start_date), + InvoicePayments(authenticator=auth, replication_start_date=replication_start_date), + InvoiceItemCategories(authenticator=auth, replication_start_date=replication_start_date), + Estimates(authenticator=auth, replication_start_date=replication_start_date), + EstimateMessages(authenticator=auth, replication_start_date=replication_start_date), + EstimateItemCategories(authenticator=auth, replication_start_date=replication_start_date), + Expenses(authenticator=auth, replication_start_date=replication_start_date), + ExpenseCategories(authenticator=auth, replication_start_date=replication_start_date), + Tasks(authenticator=auth, replication_start_date=replication_start_date), + TimeEntries(authenticator=auth, replication_start_date=replication_start_date), + UserAssignments(authenticator=auth, replication_start_date=replication_start_date), + TaskAssignments(authenticator=auth, replication_start_date=replication_start_date), + Projects(authenticator=auth, replication_start_date=replication_start_date), + Roles(authenticator=auth, replication_start_date=replication_start_date), + Users(authenticator=auth, replication_start_date=replication_start_date), + BillableRates(authenticator=auth), + CostRates(authenticator=auth), + ProjectAssignments(authenticator=auth, replication_start_date=replication_start_date), + ExpensesClients(authenticator=auth, from_date=from_date), + ExpensesProjects(authenticator=auth, from_date=from_date), + ExpensesCategories(authenticator=auth, from_date=from_date), + ExpensesTeam(authenticator=auth, from_date=from_date), + Uninvoiced(authenticator=auth, from_date=from_date), + TimeClients(authenticator=auth, from_date=from_date), + TimeProjects(authenticator=auth, from_date=from_date), + TimeTasks(authenticator=auth, from_date=from_date), + TimeTeam(authenticator=auth, from_date=from_date), + ProjectBudget(authenticator=auth, from_date=from_date), + ] + + return streams diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/spec.json b/airbyte-integrations/connectors/source-harvest/source_harvest/spec.json new file mode 100644 index 000000000000..adda14af013b --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/spec.json @@ -0,0 +1,33 @@ +{ + "documentationUrl": "https://hub.docker.com/r/airbyte/source-harvest", + "connectionSpecification": { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Harvest Spec", + "type": "object", + "required": ["api_key", "account_id", "replication_start_date"], + "additionalProperties": false, + "properties": { + "api_key": { + "title": "API Key", + "description": "Harvest API Key.", + "airbyte_secret": true, + "type": "string" + }, + "account_id": { + "title": "Account ID", + "description": "Harvest account ID. Required for all Harvest requests in pair with API Key", + "airbyte_secret": true, + "type": "string" + }, + "replication_start_date": { + "title": "Replication Start Date", + "description": "UTC date and time in the format 2017-01-25T00:00:00Z. Any data before this date will not be replicated.", + "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z$", + "examples": ["2017-01-25T00:00:00Z"], + "type": "string" + } + } + }, + "supportsIncremental": true, + "supported_destination_sync_modes": ["append"] +} diff --git a/airbyte-integrations/connectors/source-harvest/source_harvest/streams.py b/airbyte-integrations/connectors/source-harvest/source_harvest/streams.py new file mode 100644 index 000000000000..8e7690c937b2 --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/source_harvest/streams.py @@ -0,0 +1,457 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +from abc import ABC, abstractmethod +from typing import Any, Iterable, Mapping, MutableMapping, Optional +from urllib.parse import parse_qsl, urlparse + +import pendulum +import requests +from airbyte_cdk.models import SyncMode +from airbyte_cdk.sources.streams.http import HttpStream + + +class HarvestStream(HttpStream, ABC): + url_base = "https://api.harvestapp.com/v2/" + per_page = 50 + primary_key = "id" + + @property + def data_field(self) -> str: + """ + :return: Default field name to get data from response + """ + return self.name + + def path(self, **kwargs) -> str: + return self.name + + def next_page_token(self, response: requests.Response) -> Optional[Mapping[str, Any]]: + stream_data = response.json() + if stream_data.get("next_page"): + return { + "page": stream_data["next_page"], + } + + def request_params( + self, + stream_state: Mapping[str, Any], + stream_slice: Mapping[str, Any] = None, + next_page_token: Mapping[str, Any] = None, + ) -> MutableMapping[str, Any]: + params = super().request_params(stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token) + params["per_page"] = self.per_page + if next_page_token: + params.update(**next_page_token) + return params + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + """ + :return an iterable containing each record in the response + """ + stream_data = response.json() + + # depending on stream type we may get either: + # * nested records iterable in response object; + # * not nested records iterable; + # * single object to yield. + if self.data_field: + stream_data = response.json().get(self.data_field, []) + + if isinstance(stream_data, list): + yield from stream_data + else: + yield stream_data + + +class IncrementalHarvestStream(HarvestStream, ABC): + cursor_field = "updated_at" + + def __init__(self, replication_start_date: pendulum.datetime = None, **kwargs): + super().__init__(**kwargs) + self._replication_start_date = replication_start_date + + def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]) -> Mapping[str, Any]: + """ + Return the latest state by comparing the cursor value in the latest record with the stream's most recent state object + and returning an updated state object. + """ + latest_benchmark = latest_record[self.cursor_field] + if current_stream_state.get(self.cursor_field): + return {self.cursor_field: max(latest_benchmark, current_stream_state[self.cursor_field])} + return {self.cursor_field: latest_benchmark} + + def request_params( + self, + stream_state: Mapping[str, Any], + stream_slice: Mapping[str, Any] = None, + next_page_token: Mapping[str, Any] = None, + ) -> MutableMapping[str, Any]: + params = super().request_params(stream_state=stream_state, stream_slice=stream_slice, next_page_token=next_page_token) + replication_start_date = stream_state.get(self.cursor_field) or self._replication_start_date + params.update({"updated_since": replication_start_date}) + return params + + +class HarvestSubStream(HarvestStream): + @property + @abstractmethod + def path_template(self) -> str: + """ + :return: sub stream path template + """ + + @property + @abstractmethod + def parent_stream(self) -> IncrementalHarvestStream: + """ + :return: parent stream class + """ + + def stream_slices(self, **kwargs) -> Iterable[Optional[Mapping[str, any]]]: + items = self.parent_stream(authenticator=self.authenticator) + for item in items.read_records(sync_mode=SyncMode.full_refresh): + yield {"parent_id": item["id"]} + + def path(self, stream_slice: Optional[Mapping[str, Any]] = None, **kwargs) -> str: + return self.path_template.format(parent_id=stream_slice["parent_id"]) + + +class Contacts(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/clients-api/clients/contacts/ + """ + + +class Clients(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/clients-api/clients/clients/ + """ + + +class Company(HarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/company-api/company/company/ + """ + + primary_key = None + data_field = None + + +class Invoices(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/invoices-api/invoices/invoices/ + """ + + +class InvoiceMessages(HarvestSubStream, IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/invoices-api/invoices/invoice-messages/ + """ + + parent_stream = Invoices + path_template = "invoices/{parent_id}/messages" + + +class InvoicePayments(HarvestSubStream, IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/invoices-api/invoices/invoice-payments/ + """ + + parent_stream = Invoices + path_template = "invoices/{parent_id}/payments" + + +class InvoiceItemCategories(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/invoices-api/invoices/invoice-item-categories/ + """ + + +class Estimates(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/estimates-api/estimates/estimates/ + """ + + +class EstimateMessages(HarvestSubStream, IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/estimates-api/estimates/estimate-messages/ + """ + + parent_stream = Estimates + path_template = "estimates/{parent_id}/messages" + + +class EstimateItemCategories(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/estimates-api/estimates/estimate-item-categories/ + """ + + +class Expenses(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/expenses-api/expenses/expenses/ + """ + + +class ExpenseCategories(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/expenses-api/expenses/expense-categories/ + """ + + +class Tasks(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/tasks-api/tasks/tasks/ + """ + + +class TimeEntries(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/ + """ + + +class UserAssignments(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/projects-api/projects/user-assignments/ + """ + + +class TaskAssignments(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/projects-api/projects/task-assignments/ + """ + + +class Projects(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/projects-api/projects/projects/ + """ + + +class Roles(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/roles-api/roles/roles/ + """ + + +class Users(IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/users-api/users/users/ + """ + + +class BillableRates(HarvestSubStream): + """ + Docs: https://help.getharvest.com/api-v2/users-api/users/billable-rates/ + """ + + parent_stream = Users + path_template = "users/{parent_id}/billable_rates" + + +class CostRates(HarvestSubStream): + """ + Docs: https://help.getharvest.com/api-v2/users-api/users/cost-rates/ + """ + + parent_stream = Users + path_template = "users/{parent_id}/cost_rates" + + +class ProjectAssignments(HarvestSubStream, IncrementalHarvestStream): + """ + Docs: https://help.getharvest.com/api-v2/users-api/users/project-assignments/ + """ + + parent_stream = Users + path_template = "users/{parent_id}/project_assignments" + + +class ReportsBase(HarvestStream, ABC): + data_field = "results" + date_param_template = "%Y%m%d" + + @property + @abstractmethod + def report_path(self): + """ + :return: report path suffix + """ + + def __init__(self, from_date: pendulum.date = None, **kwargs): + super().__init__(**kwargs) + + current_date = pendulum.now().date() + self._from_date = from_date or current_date.subtract(years=1) + # `to` date greater than `from` date causes an exception on Harvest + if self._from_date > current_date: + self._to_date = from_date + else: + self._to_date = current_date + + def request_params(self, stream_state, **kwargs) -> MutableMapping[str, Any]: + params = super().request_params(stream_state, **kwargs) + current_date = pendulum.now() + # `from` and `to` params are required for reports calls + # min `from` value is current_date - 1 year + params.update({"from": self._from_date.strftime("%Y%m%d"), "to": current_date.strftime("%Y%m%d")}) + return params + + def path(self, **kwargs) -> str: + return f"reports/{self.report_path}" + + +class IncrementalReportsBase(ReportsBase, ABC): + cursor_field = "to" + + def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]: + parsed_url = urlparse(response.url) + params = dict(parse_qsl(parsed_url.query)) + + records = response.json().get(self.data_field, []) + for record in records: + record.update( + { + "from": params.get("from", self._from_date.strftime(self.date_param_template)), + "to": params.get("to", self._to_date.strftime(self.date_param_template)), + } + ) + yield record + + def request_params(self, stream_state: Mapping[str, Any] = None, **kwargs) -> MutableMapping[str, Any]: + stream_state = stream_state or {} + params = super().request_params(stream_state, **kwargs) + + # subtract `from` date by 1 year to avoid Harvest exception + # `from` date may not be less than `to` - 1 year + if stream_state.get(self.cursor_field): + cursor_date = pendulum.parse(stream_state[self.cursor_field]).date() + dates_diff = cursor_date - self._from_date + if dates_diff.years > 0 or dates_diff.years == 0 and dates_diff.remaining_days > 0: + self._from_date = cursor_date.subtract(years=1) + + # `from` and `to` params are required for reports calls + # min `from` value is current_date - 1 year + params.update( + { + "from": self._from_date.strftime(self.date_param_template), + "to": stream_state.get(self.cursor_field, self._to_date.strftime(self.date_param_template)), + } + ) + return params + + def get_updated_state(self, current_stream_state: MutableMapping[str, Any], latest_record: Mapping[str, Any]): + """ + Return the latest state by comparing the cursor value in the latest record with the stream's most recent state object + and returning an updated state object. + """ + latest_benchmark = latest_record[self.cursor_field] + if current_stream_state.get(self.cursor_field): + return {self.cursor_field: max(latest_benchmark, current_stream_state[self.cursor_field])} + return {self.cursor_field: latest_benchmark} + + +class ExpensesClients(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/expense-reports/#clients-report + """ + + report_path = "expenses/clients" + + +class ExpensesProjects(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/expense-reports/#projects-report + """ + + report_path = "expenses/projects" + + +class ExpensesCategories(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/expense-reports/#expense-categories-report + """ + + report_path = "expenses/categories" + + +class ExpensesTeam(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/expense-reports/#team-report + """ + + report_path = "expenses/team" + + +class Uninvoiced(ReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/uninvoiced-report/ + + TODO: `from`/`to` pagination does not work for `uninvoiced` stream. Look like a bug on Harvest side. Check out later. + """ + + report_path = "uninvoiced" + + +class TimeClients(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/time-reports/#clients-report + """ + + report_path = "time/clients" + + +class TimeProjects(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/time-reports/#projects-report + """ + + report_path = "time/projects" + + +class TimeTasks(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/time-reports/#tasks-report + """ + + report_path = "time/tasks" + + +class TimeTeam(IncrementalReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/time-reports/ (Team Report) + """ + + report_path = "time/team" + + +class ProjectBudget(ReportsBase): + """ + Docs: https://help.getharvest.com/api-v2/reports-api/reports/time-reports/#team-report + """ + + report_path = "project_budget" diff --git a/airbyte-integrations/connectors/source-harvest/unit_tests/unit_test.py b/airbyte-integrations/connectors/source-harvest/unit_tests/unit_test.py new file mode 100644 index 000000000000..b8a8150b507f --- /dev/null +++ b/airbyte-integrations/connectors/source-harvest/unit_tests/unit_test.py @@ -0,0 +1,27 @@ +# +# MIT License +# +# Copyright (c) 2020 Airbyte +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + + +def test_example_method(): + assert True diff --git a/docs/integrations/sources/harvest.md b/docs/integrations/sources/harvest.md new file mode 100644 index 000000000000..7c1d5f80f5a2 --- /dev/null +++ b/docs/integrations/sources/harvest.md @@ -0,0 +1,68 @@ +# Harvest + +## Overview + +The Harvest connector can be used to sync your Harvest data. It supports full refresh sync for all streams and incremental sync for all streams except of Expense Reports streams which are: Clients Report, Projects Report, Categories Report, Team Report. +Incremental sync is also now available for Company stream, but it always has only one record. + +### Output schema + +Several output streams are available from this source: + +* [Client Contacts](https://help.getharvest.com/api-v2/clients-api/clients/contacts/) \(Incremental\) +* [Clients](https://help.getharvest.com/api-v2/clients-api/clients/clients/) \(Incremental\) +* [Company](https://help.getharvest.com/api-v2/company-api/company/company/) +* [Invoice Messages](https://help.getharvest.com/api-v2/invoices-api/invoices/invoice-messages/) \(Incremental\) +* [Invoice Payments](https://help.getharvest.com/api-v2/invoices-api/invoices/invoice-payments/) \(Incremental\) +* [Invoices](https://help.getharvest.com/api-v2/invoices-api/invoices/invoices/) \(Incremental\) +* [Invoice Item Categories](https://help.getharvest.com/api-v2/invoices-api/invoices/invoice-item-categories/) \(Incremental\) +* [Estimate Messages](https://help.getharvest.com/api-v2/estimates-api/estimates/estimate-messages/) \(Incremental\) +* [Estimates](https://help.getharvest.com/api-v2/estimates-api/estimates/estimates/) \(Incremental\) +* [Estimate Item Categories](https://help.getharvest.com/api-v2/estimates-api/estimates/estimate-item-categories/) \(Incremental\) +* [Expenses](https://help.getharvest.com/api-v2/expenses-api/expenses/expenses/) \(Incremental\) +* [Expense Categories](https://help.getharvest.com/api-v2/expenses-api/expenses/expense-categories/) \(Incremental\) +* [Tasks](https://help.getharvest.com/api-v2/tasks-api/tasks/tasks/) \(Incremental\) +* [Time Entries](https://help.getharvest.com/api-v2/timesheets-api/timesheets/time-entries/) \(Incremental\) +* [Project User Assignments](https://help.getharvest.com/api-v2/projects-api/projects/user-assignments/) \(Incremental\) +* [Project Task Assignments](https://help.getharvest.com/api-v2/projects-api/projects/task-assignments/) \(Incremental\) +* [Projects](https://help.getharvest.com/api-v2/projects-api/projects/projects/) \(Incremental\) +* [Roles](https://help.getharvest.com/api-v2/roles-api/roles/roles/) \(Incremental\) +* [User Billable Rates](https://help.getharvest.com/api-v2/users-api/users/billable-rates/) +* [User Cost Rates](https://help.getharvest.com/api-v2/users-api/users/cost-rates/) +* [User Project Assignments](https://help.getharvest.com/api-v2/users-api/users/project-assignments/) \(Incremental\) +* [Expense Reports](https://help.getharvest.com/api-v2/reports-api/reports/expense-reports/) +* [Uninvoiced Report](https://help.getharvest.com/api-v2/reports-api/reports/uninvoiced-report/) +* [Time Reports](https://help.getharvest.com/api-v2/reports-api/reports/time-reports/) +* [Project Budget Report](https://help.getharvest.com/api-v2/reports-api/reports/project-budget-report/) + + +### Features + +| Feature | Supported? | +| :--- | :--- | +| Full Refresh Sync | Yes | +| Incremental Sync | Yes | +| Replicate Incremental Deletes | No | +| SSL connection | Yes | +| Namespaces | No | + +### Performance considerations + +The Harvest connector will gracefully handle rate limits. For more information, see [the Harvest docs for rate limitations](https://help.getharvest.com/api-v2/introduction/overview/general/#rate-limiting). + +## Getting started + +### Requirements + +* Harvest Account +* Harvest Authorized OAuth2 API Client to create Access Token and get account ID + +### Setup guide + +This connector supports only authentication with API Key. To obtain API key follow the instructions below: + +1. Go to Account Settings page; +1. Under Integrations section press Authorized OAuth2 API Clients button; +1. New page will be opened on which you need to click on Create New Personal Access Token button and follow instructions. + +See [docs](https://help.getharvest.com/api-v2/authentication-api/authentication/authentication/) for more details. \ No newline at end of file diff --git a/tools/bin/ci_credentials.sh b/tools/bin/ci_credentials.sh index 50557d978ef8..b3743c42114a 100755 --- a/tools/bin/ci_credentials.sh +++ b/tools/bin/ci_credentials.sh @@ -50,6 +50,7 @@ write_standard_creds source-google-search-console-singer "$GOOGLE_SEARCH_CONSOLE write_standard_creds source-google-sheets "$GSHEETS_INTEGRATION_TESTS_CREDS" "creds.json" write_standard_creds source-google-workspace-admin-reports "$GOOGLE_WORKSPACE_ADMIN_REPORTS_TEST_CREDS" write_standard_creds source-greenhouse "$GREENHOUSE_TEST_CREDS" +write_standard_creds source-harvest "$HARVEST_INTEGRATION_TESTS_CREDS" write_standard_creds source-hubspot "$HUBSPOT_INTEGRATION_TESTS_CREDS" write_standard_creds source-klaviyo "$KLAVIYO_TEST_CREDS" write_standard_creds source-asana "$SOURCE_ASANA_TEST_CREDS"