1
0
mirror of synced 2026-01-05 03:04:38 -05:00
Files
airbyte/airbyte-integrations/connectors/source-chargebee/source_chargebee/components.py
Artem Inzhyyants 52b4ab6ae5 Source Chargebee: Migrate to YAML (#21688)
* Source Chargebee: migrate to YAML

* Source Chargebee: add expected records

* Source Chargebee: fix tests

* Source Chargebee: update docs

* Source Chargebee: update schemas

* Source Chargebee: update expected records;
Remove subscription expected records (field current_term_start updated daily)

* Source Chargebee: fix test

* Source Chargebee: ref

* Source Chargebee: modify Error Handler to ignore product catalog v1.0 streams

* Source Chargebee: fix expected records

* Source Chargebee: fix expected records

* auto-bump connector version

* Source Chargebee: remove extra component

* Source Chargebee: add docs

* Source ChargeBee: update Yaml + expected records

* Source ChargeBee: fix promotional credit stream, increase test timeout

* Source ChargeBee: fix credit note

* Source ChargeBee: Increase timeout

* Source ChargeBee: add allowedHosts

* Source ChargeBee: add comment

* Source ChargeBee: migrate according to beta 0.29.0

* Source ChargeBee: update schemas

* Source ChargeBee: update slicer info

* Source ChargeBee: update manifest

* Source ChargeBee: update test config

* Source ChargeBee: bump version

* Source Amplitude: update low-code

* Source ChargeBee: fix manifest

* Source Chargebee: update expected records; fix manifest

* Source Chargebee: update expected records

* Source Chargebee: update version

* Source Chargebee: pin CDK to version beta 0.29

* Source Chargebee: add backward compatibility

* Source Chargebee: fix expected records

* Source Chargebee: update expected records

* auto-bump connector version

---------

Co-authored-by: Octavia Squidington III <octavia-squidington-iii@users.noreply.github.com>
Co-authored-by: Serhii Lazebnyi <53845333+lazebnyi@users.noreply.github.com>
Co-authored-by: sh4sh <6833405+sh4sh@users.noreply.github.com>
2023-03-01 12:09:43 -05:00

49 lines
1.4 KiB
Python

#
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
#
from dataclasses import dataclass
from typing import Optional
from airbyte_cdk.sources.declarative.transformations.transformation import RecordTransformation
from airbyte_cdk.sources.declarative.types import Config, Record, StreamSlice, StreamState
@dataclass
class CustomFieldTransformation(RecordTransformation):
"""
Add custom field based on condition. Jinja interpolation does not support list comprehension.
https://github.com/airbytehq/airbyte/issues/23134
"""
def transform(
self,
record: Record,
config: Optional[Config] = None,
stream_state: Optional[StreamState] = None,
stream_slice: Optional[StreamSlice] = None,
) -> Record:
"""
Method to detect custom fields that start with 'cf_' from chargbee models.
Args:
record:
{
...
'cf_custom_fields': 'some_value',
...
}
Returns:
record:
{
...
'custom_fields': [{
'name': 'cf_custom_fields',
'value': some_value'
}],
...
}
"""
record["custom_fields"] = [{"name": k, "value": v} for k, v in record.items() if k.startswith("cf_")]
return record