Skip to content

Commit 6b4c523

Browse files
jonathanneonatalyjazzviolinsajarinnatalyoctavia-squidington-iii
authored
Source Exchange Rates - Refactor for API Layer (#15884)
* refactor for api layer * changelog * Reverts variable name for backwards compatability tests & sets additionalProperties: true in reference to #14196. * fix: bump dockerfile * fix: update changelog version to match Dockerfile * fix: actually update changelog version to match Dockerfile * auto-bump connector version [ci skip] Co-authored-by: Nataly Merezhuk <[email protected]> Co-authored-by: Sajarin <[email protected]> Co-authored-by: nataly <[email protected]> Co-authored-by: Octavia Squidington III <[email protected]>
1 parent 5ca2ddb commit 6b4c523

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
- name: Exchange Rates Api
257257
sourceDefinitionId: e2b40e36-aa0e-4bed-b41b-bcea6fa348b1
258258
dockerRepository: airbyte/source-exchange-rates
259-
dockerImageTag: 0.2.6
259+
dockerImageTag: 1.2.6
260260
documentationUrl: https://docs.airbyte.io/integrations/sources/exchangeratesapi
261261
icon: exchangeratesapi.svg
262262
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2233,7 +2233,7 @@
22332233
supportsNormalization: false
22342234
supportsDBT: false
22352235
supported_destination_sync_modes: []
2236-
- dockerImage: "airbyte/source-exchange-rates:0.2.6"
2236+
- dockerImage: "airbyte/source-exchange-rates:1.2.6"
22372237
spec:
22382238
documentationUrl: "https://docs.airbyte.io/integrations/sources/exchangeratesapi"
22392239
connectionSpecification:
@@ -2243,7 +2243,7 @@
22432243
required:
22442244
- "start_date"
22452245
- "access_key"
2246-
additionalProperties: false
2246+
additionalProperties: true
22472247
properties:
22482248
start_date:
22492249
type: "string"
@@ -2253,7 +2253,7 @@
22532253
- "YYYY-MM-DD"
22542254
access_key:
22552255
type: "string"
2256-
description: "Your API Access Key. See <a href=\"https://exchangeratesapi.io/documentation/\"\
2256+
description: "Your API Key. See <a href=\"https://apilayer.com/marketplace/exchangerates_data-api\"\
22572257
>here</a>. The key is case sensitive."
22582258
airbyte_secret: true
22592259
base:

airbyte-integrations/connectors/source-exchange-rates/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ RUN pip install .
1616
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1717
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1818

19-
LABEL io.airbyte.version=0.2.6
19+
LABEL io.airbyte.version=1.2.6
2020
LABEL io.airbyte.name=airbyte/source-exchange-rates

airbyte-integrations/connectors/source-exchange-rates/source_exchange_rates/source.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ExchangeRates(HttpStream):
1919
date_field_name = "date"
2020

2121
# HttpStream related fields
22-
url_base = "http://api.exchangeratesapi.io/v1/"
22+
url_base = "https://api.apilayer.com/exchangerates_data/"
2323
cursor_field = date_field_name
2424
primary_key = ""
2525

@@ -39,13 +39,18 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str,
3939
return None
4040

4141
def request_params(self, **kwargs) -> MutableMapping[str, Any]:
42-
params = {"access_key": self.access_key}
42+
params = {}
4343

4444
if self._base is not None:
4545
params["base"] = self._base
4646

4747
return params
4848

49+
def request_headers(self, **kwargs) -> MutableMapping[str, Any]:
50+
headers = {"apikey": self.access_key}
51+
52+
return headers
53+
4954
def parse_response(self, response: requests.Response, **kwargs) -> Iterable[Mapping]:
5055
response_json = response.json()
5156
yield response_json
@@ -82,12 +87,13 @@ def chunk_date_range(start_date: DateTime, ignore_weekends: bool) -> Iterable[Ma
8287
class SourceExchangeRates(AbstractSource):
8388
def check_connection(self, logger: AirbyteLogger, config: Mapping[str, Any]) -> Tuple[bool, Any]:
8489
try:
85-
params = {"access_key": config["access_key"]}
90+
headers = {"apikey": config["access_key"]}
91+
params = {}
8692
base = config.get("base")
8793
if base is not None:
8894
params["base"] = base
8995

90-
resp = requests.get(f"{ExchangeRates.url_base}{config['start_date']}", params=params)
96+
resp = requests.get(f"{ExchangeRates.url_base}{config['start_date']}", params=params, headers=headers)
9197
status = resp.status_code
9298
logger.info(f"Ping response code: {status}")
9399
if status == 200:

airbyte-integrations/connectors/source-exchange-rates/source_exchange_rates/spec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ connectionSpecification:
66
required:
77
- start_date
88
- access_key
9-
additionalProperties: false
9+
additionalProperties: true
1010
properties:
1111
start_date:
1212
type: string
@@ -17,8 +17,8 @@ connectionSpecification:
1717
access_key:
1818
type: string
1919
description: >-
20-
Your API Access Key. See <a
21-
href="https://exchangeratesapi.io/documentation/">here</a>. The key is
20+
Your API Key. See <a
21+
href="https://apilayer.com/marketplace/exchangerates_data-api">here</a>. The key is
2222
case sensitive.
2323
airbyte_secret: true
2424
base:

docs/integrations/sources/exchangeratesapi.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ If you have `free` subscription plan \(you may check it [here](https://manage.ex
4646

4747
| Version | Date | Pull Request | Subject |
4848
|:--------| :--- | :--- | :--- |
49+
| 1.2.6 | 2022-08-23 | [15884](https://github.com/airbytehq/airbyte/pull/15884) | Migrated to new API Layer endpoint |
4950
| 0.2.6 | 2022-04-20 | [12230](https://github.com/airbytehq/airbyte/pull/12230) | Update connector to use a `spec.yaml` |
5051
| 0.2.5 | 2021-11-12 | [7936](https://github.com/airbytehq/airbyte/pull/7936) | Add ignore_weekends boolean option |
5152
| 0.2.4 | 2021-11-08 | [7499](https://github.com/airbytehq/airbyte/pull/7499) | Remove base-python dependencies |

0 commit comments

Comments
 (0)