Skip to content

Commit

Permalink
✨ Source Freshsales : Migrate Python CDK to Low-code CDK (#31685)
Browse files Browse the repository at this point in the history
Co-authored-by: Marcos Marx <[email protected]>
Co-authored-by: marcosmarxm <[email protected]>
  • Loading branch information
3 people authored Nov 13, 2023
1 parent 53bbac8 commit 855d6a4
Show file tree
Hide file tree
Showing 25 changed files with 409 additions and 408 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ COPY source_freshsales ./source_freshsales
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.4
LABEL io.airbyte.version=1.0.0
LABEL io.airbyte.name=airbyte/source-freshsales
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,3 @@ You've checked out the repo, implemented a million dollar feature, and you're re
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
6. Pat yourself on the back for being an awesome contributor.
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.

3 changes: 3 additions & 0 deletions airbyte-integrations/connectors/source-freshsales/__int__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_strictness_level: high
acceptance_tests:
spec:
tests:
- spec_path: "source_freshsales/spec.json"
- spec_path: "source_freshsales/spec.yaml"
connection:
tests:
- config_path: "secrets/config.json"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ data:
connectorSubtype: api
connectorType: source
definitionId: eca08d79-7b92-4065-b7f3-79c14836ebe7
dockerImageTag: 0.1.4
dockerImageTag: 1.0.0
releases:
breakingChanges:
1.0.0:
message: "Large update in schema data types. Need refresh data"
upgradeDeadline: "2023-11-23"
dockerRepository: airbyte/source-freshsales
documentationUrl: https://docs.airbyte.com/integrations/sources/freshsales
githubIssueLabel: source-freshsales
Expand All @@ -23,5 +28,5 @@ data:
releaseStage: beta
supportLevel: community
tags:
- language:python
- language:low-code
metadataSpecVersion: "1.0"
12 changes: 6 additions & 6 deletions airbyte-integrations/connectors/source-freshsales/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
from setuptools import find_packages, setup

MAIN_REQUIREMENTS = [
"airbyte-cdk",
"airbyte-cdk~=0.1",
]

TEST_REQUIREMENTS = [
"requests-mock~=1.9.3",
"pytest",
"pytest-mock",
"pytest~=6.2",
"pytest-mock~=3.6.1",
]

setup(
name="source_freshsales",
description="Source implementation for Freshsales.",
author="Tuan Nguyen",
author_email="[email protected]",
author="Airbyte",
author_email="[email protected]",
packages=find_packages(),
install_requires=MAIN_REQUIREMENTS,
package_data={"": ["*.json", "schemas/*.json", "schemas/shared/*.json"]},
package_data={"": ["*.json", "*.yaml", "schemas/*.json", "schemas/shared/*.json"]},
extras_require={
"tests": TEST_REQUIREMENTS,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,286 @@
version: 0.51.16

type: DeclarativeSource
check:
type: CheckStream
stream_names:
- contacts
definitions:
schema_loader:
type: JsonFileSchemaLoader
file_path: "./source_freshsales/schemas/{{ parameters['name'] }}.json"
selector:
type: RecordSelector
extractor:
type: DpathExtractor
field_path: []
basic_requester:
type: HttpRequester
url_base: "https://{{ config['domain_name'] }}/crm/sales/api/"
http_method: "GET"
authenticator:
type: ApiKeyAuthenticator
header: "Authorization"
api_token: "Token token={{ config['api_key'] }}"
requester:
$ref: "#/definitions/basic_requester"
request_parameters:
page: "{{ parameters.get('page', None) }}"
filter: "{{ parameters.get('filter', None) }}"
sort_type: "asc"
sort: "updated_at"
default_paginator:
type: "DefaultPaginator"
page_size_option:
type: "RequestOption"
inject_into: "request_parameter"
field_name: "per_page"
pagination_strategy:
type: "PageIncrement"
page_size: 50
start_from_page: 1
inject_on_first_request: true
page_token_option:
type: "RequestOption"
inject_into: "request_parameter"
field_name: "page"
retriever:
type: SimpleRetriever
record_selector:
$ref: "#/definitions/selector"
requester:
$ref: "#/definitions/requester"
paginator:
$ref: "#/definitions/default_paginator"
base_stream:
primary_key: "id"
retriever:
$ref: "#/definitions/retriever"
contacts_filters_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "contact_filters"
path: "contacts/filters"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/basic_requester"
record_selector:
type: RecordSelector
extractor:
field_path:
- filters
record_filter:
condition: "{{ record['name'] == parameters['filter'] }}"
contacts_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "contacts"
filter: "All Contacts"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/requester"
path: "contacts/view/{{ stream_slice.view_id }}"
record_selector:
type: RecordSelector
extractor:
field_path:
- contacts
partition_router:
type: SubstreamPartitionRouter
parent_stream_configs:
- stream: "#/definitions/contacts_filters_stream"
parent_key: "id"
partition_field: "view_id"
accounts_filters_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "sales_accounts_filter"
path: "sales_accounts/filters"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/basic_requester"
record_selector:
type: RecordSelector
extractor:
field_path:
- filters
record_filter:
condition: "{{ record['name'] == parameters['filter'] }}"
accounts_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "accounts"
filter: "All Accounts"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/requester"
path: "sales_accounts/view/{{ stream_slice.view_id }}"
record_selector:
type: RecordSelector
extractor:
field_path:
- sales_accounts
partition_router:
type: SubstreamPartitionRouter
parent_stream_configs:
- stream: "#/definitions/accounts_filters_stream"
parent_key: "id"
partition_field: "view_id"
deals_filters_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "deals_filter"
path: "deals/filters"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/basic_requester"
record_selector:
type: RecordSelector
extractor:
field_path:
- filters
record_filter:
condition: "{{ record['name'] == parameters['filter'] }}"
open_deals_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "open_deals"
filter: "Open Deals"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/requester"
path: "deals/view/{{ stream_slice.view_id }}"
record_selector:
type: RecordSelector
extractor:
field_path:
- deals
partition_router:
type: SubstreamPartitionRouter
parent_stream_configs:
- stream: "#/definitions/deals_filters_stream"
parent_key: "id"
partition_field: "view_id"
transformations:
- type: RemoveFields
field_pointers:
- ["fc_widget_collaboration"]
won_deals_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "won_deals"
filter: "Won Deals"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/requester"
path: "deals/view/{{ stream_slice.view_id }}"
record_selector:
type: RecordSelector
extractor:
field_path:
- deals
partition_router:
type: SubstreamPartitionRouter
parent_stream_configs:
- stream: "#/definitions/deals_filters_stream"
parent_key: "id"
partition_field: "view_id"
transformations:
- type: RemoveFields
field_pointers:
- ["fc_widget_collaboration"]
lost_deals_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "lost_deals"
filter: "Lost Deals"
retriever:
$ref: "#/definitions/retriever"
requester:
$ref: "#/definitions/requester"
path: "deals/view/{{ stream_slice.view_id }}"
record_selector:
type: RecordSelector
extractor:
field_path:
- deals
partition_router:
type: SubstreamPartitionRouter
parent_stream_configs:
- stream: "#/definitions/deals_filters_stream"
parent_key: "id"
partition_field: "view_id"
transformations:
- type: RemoveFields
field_pointers:
- ["fc_widget_collaboration"]
open_tasks_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "open_tasks"
path: "tasks"
filter: "open"
retriever:
$ref: "#/definitions/retriever"
record_selector:
type: RecordSelector
extractor:
field_path:
- tasks
completed_tasks_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "completed_tasks"
path: "tasks"
filter: "completed"
retriever:
$ref: "#/definitions/retriever"
record_selector:
type: RecordSelector
extractor:
field_path:
- tasks
past_appointments_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "past_appointments"
path: "appointments"
filter: "past"
retriever:
$ref: "#/definitions/retriever"
record_selector:
type: RecordSelector
extractor:
field_path:
- appointments
upcoming_appointments_stream:
$ref: "#/definitions/base_stream"
$parameters:
name: "upcoming_appointments"
path: "appointments"
filter: "upcoming"
retriever:
$ref: "#/definitions/retriever"
record_selector:
type: RecordSelector
extractor:
field_path:
- appointments

streams:
- "#/definitions/contacts_stream"
- "#/definitions/accounts_stream"
- "#/definitions/open_deals_stream"
- "#/definitions/won_deals_stream"
- "#/definitions/lost_deals_stream"
- "#/definitions/open_tasks_stream"
- "#/definitions/completed_tasks_stream"
- "#/definitions/past_appointments_stream"
- "#/definitions/upcoming_appointments_stream"
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
"last_seen": { "type": ["null", "string"] },
"lead_score": { "type": ["null", "integer"] },
"last_contacted": { "type": ["null", "string"] },
"open_deals_amount": { "type": ["null", "number"] },
"won_deals_amount": { "type": ["null", "number"] },
"open_deals_amount": { "type": ["null", "string"] },
"won_deals_amount": { "type": ["null", "string"] },
"links": { "type": ["null", "object"] },
"last_contacted_sales_activity_mode": { "type": ["null", "string"] },
"custom_field": { "type": ["null", "object"] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"targetable_type": { "type": ["null", "string"] },
"Possible": { "type": ["null", "string"] },
"owner_id": { "type": ["null", "integer"] },
"status": { "type": ["null", "string"] },
"status": { "type": ["null", "integer"] },
"creater_id": { "type": ["null", "integer"] },
"created_at": { "type": ["null", "string"] },
"updated_at": { "type": ["null", "string"] },
"outcome_id": { "type": ["null", "integer"] },
"task_type_id": { "type": ["null", "integer"] },
"updater_id": { "type": ["null", "integer"] },
"targetables": { "type": ["null", "string"] },
"targetables": { "type": ["null", "array"] },
"completed_date": { "type": ["null", "string"] }
}
}
Loading

0 comments on commit 855d6a4

Please sign in to comment.