Skip to content

Commit

Permalink
source-google-ads: upgrade to estuary CDK
Browse files Browse the repository at this point in the history
  • Loading branch information
jgraettinger committed Mar 5, 2024
1 parent a489f84 commit cdcdf50
Show file tree
Hide file tree
Showing 66 changed files with 1,096 additions and 1,437 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ jobs:
- connector: source-airtable
connector_type: capture
python: true
- connector: source-google-ads
connector_type: capture
python: true
- connector: source-facebook-marketing
connector_type: capture
python: true
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- "estuary-cdk/**"
- "source-asana/**"
- "source-gladly/**"
- "source-google-ads/**"
- "source-google-sheets-native/**"
- "source-hubspot-native/**"
pull_request:
Expand All @@ -15,6 +16,7 @@ on:
- "estuary-cdk/**"
- "source-asana/**"
- "source-gladly/**"
- "source-google-ads/**"
- "source-google-sheets-native/**"
- "source-hubspot-native/**"

Expand All @@ -38,6 +40,9 @@ jobs:
- name: source-gladly
type: capture
version: v1
- name: source-google-ads
type: capture
version: v2
- name: source-google-sheets-native
type: capture
version: v1
Expand Down
40 changes: 0 additions & 40 deletions source-google-ads/__main__.py

This file was deleted.

1,396 changes: 1,012 additions & 384 deletions source-google-ads/poetry.lock

Large diffs are not rendered by default.

19 changes: 8 additions & 11 deletions source-google-ads/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
[tool.poetry]
name = "source-google-ads-estuary"
name = "source_google_ads"
version = "0.1.0"
description = ""
authors = ["Jonathan Wihl <jonathan@estuary.dev>"]

[tool.poetry.dependencies]
source_google_ads = { path = "source_google_ads", develop = true}
airbyte-cdk = "^0.52"
flow-sdk = {path="../python", develop = true}
jsonlines = "^4.0.0"
mypy = "^1.5"
orjson = "^3.9.7"
pydantic = "1.10.12"
python = ">=3.11,<3.12"
requests = "^2.31.0"
estuary-cdk = {path="../estuary-cdk", develop = true}
freezegun = "^1.4.0"
google-ads = "^23.1.0"
python = ">=3.11,<3.13"
types-requests = "^2.31"
pytest = "^7.4.3"

[tool.poetry.group.dev.dependencies]
debugpy = "^1.8.0"
pytest = "^7.4.3"
pytest-insta = "^0.2.0"
debugpy = "^1.8.0"
requests-mock = "^1.11.0"
pytest-mock = "^3.12.0"

[build-system]
requires = ["poetry-core"]
Expand Down
7 changes: 0 additions & 7 deletions source-google-ads/source_google_ads/.dockerignore

This file was deleted.

25 changes: 0 additions & 25 deletions source-google-ads/source_google_ads/BOOTSTRAP.md

This file was deleted.

17 changes: 0 additions & 17 deletions source-google-ads/source_google_ads/Dockerfile

This file was deleted.

129 changes: 0 additions & 129 deletions source-google-ads/source_google_ads/README.md

This file was deleted.

48 changes: 48 additions & 0 deletions source-google-ads/source_google_ads/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import estuary_cdk.pydantic_polyfill # Must be first.

import asyncio
from estuary_cdk import shim_airbyte_cdk, flow
from source_google_ads import SourceGoogleAds
import json


def wrap_with_braces(body: str, count: int):
opening = "{" * count
closing = "}" * count
return f"{opening}{body}{closing}"


def urlencode_field(field: str):
return f"{wrap_with_braces('#urlencode',2)}{wrap_with_braces(field,3)}{wrap_with_braces('/urlencode',2)}"


accessTokenBody = {
"grant_type": "authorization_code",
"client_id": "{{{ client_id }}}",
"client_secret": "{{{ client_secret }}}",
"redirect_uri": "{{{ redirect_uri }}}",
"code": "{{{ code }}}",
}

asyncio.run(
shim_airbyte_cdk.CaptureShim(
delegate=SourceGoogleAds(),
oauth2=flow.OAuth2Spec(
provider="google",
accessTokenBody=json.dumps(accessTokenBody),
authUrlTemplate=(
f"https://accounts.google.com/o/oauth2/auth?"
f"access_type=offline&"
f"prompt=consent&"
f"client_id={urlencode_field('client_id')}&"
f"redirect_uri={urlencode_field('redirect_uri')}&"
f"response_type=code&"
f"scope=https://www.googleapis.com/auth/adwords&state={urlencode_field('state')}"
),
accessTokenResponseMap={"refresh_token": "/refresh_token"},
accessTokenUrlTemplate="https://oauth2.googleapis.com/token",
accessTokenHeaders={},
),
schema_inference=True,
).serve()
)
Loading

0 comments on commit cdcdf50

Please sign in to comment.