Skip to content

Commit 2ecc7a6

Browse files
authored
🎉 Sendgrind add single send stats (#5910)
* Sendgrind source: add single send stream
1 parent 6041f3d commit 2ecc7a6

File tree

9 files changed

+331
-1
lines changed

9 files changed

+331
-1
lines changed

airbyte-integrations/connectors/source-sendgrid/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.2.6
15+
LABEL io.airbyte.version=0.2.7
1616
LABEL io.airbyte.name=airbyte/source-sendgrid

airbyte-integrations/connectors/source-sendgrid/acceptance-test-config.yml

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ tests:
1212
basic_read:
1313
- config_path: "secrets/config.json"
1414
configured_catalog_path: "sample_files/no_spam_reports_configured_catalog.json"
15+
expect_records:
16+
path: "integration_tests/expected_records.txt"
17+
extra_fields: no
18+
exact_order: no
19+
extra_records: yes
1520
incremental:
1621
- config_path: "secrets/config.json"
1722
configured_catalog_path: "sample_files/no_spam_reports_configured_catalog.json"

airbyte-integrations/connectors/source-sendgrid/integration_tests/configured_catalog.json

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
"sync_mode": "full_refresh",
4646
"destination_sync_mode": "overwrite"
4747
},
48+
{
49+
"stream": {
50+
"name": "single_sends",
51+
"json_schema": {},
52+
"supported_sync_modes": ["full_refresh"]
53+
},
54+
"sync_mode": "full_refresh",
55+
"destination_sync_mode": "overwrite"
56+
},
4857
{
4958
"stream": {
5059
"name": "templates",

airbyte-integrations/connectors/source-sendgrid/integration_tests/expected_records.txt

+230
Large diffs are not rendered by default.

airbyte-integrations/connectors/source-sendgrid/sample_files/no_spam_reports_configured_catalog.json

+9
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@
4545
"sync_mode": "full_refresh",
4646
"destination_sync_mode": "overwrite"
4747
},
48+
{
49+
"stream": {
50+
"name": "single_sends",
51+
"json_schema": {},
52+
"supported_sync_modes": ["full_refresh"]
53+
},
54+
"sync_mode": "full_refresh",
55+
"destination_sync_mode": "overwrite"
56+
},
4857
{
4958
"stream": {
5059
"name": "templates",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"type": "object",
4+
"properties": {
5+
"id": {
6+
"type": "string",
7+
"format": "uuid"
8+
},
9+
"ab_phase": {
10+
"type": "string"
11+
},
12+
"ab_variation": {
13+
"type": "string"
14+
},
15+
"aggregation": {
16+
"type": "string"
17+
},
18+
"stats": {
19+
"type": "object",
20+
"properties": {
21+
"bounce_drops": {
22+
"type": "integer"
23+
},
24+
"bounces": {
25+
"type": "integer"
26+
},
27+
"clicks": {
28+
"type": "integer"
29+
},
30+
"unique_clicks": {
31+
"type": "integer"
32+
},
33+
"delivered": {
34+
"type": "integer"
35+
},
36+
"invalid_emails": {
37+
"type": "integer"
38+
},
39+
"opens": {
40+
"type": "integer"
41+
},
42+
"unique_opens": {
43+
"type": "integer"
44+
},
45+
"requests": {
46+
"type": "integer"
47+
},
48+
"spam_report_drops": {
49+
"type": "integer"
50+
},
51+
"spam_reports": {
52+
"type": "integer"
53+
},
54+
"unsubscribes": {
55+
"type": "integer"
56+
}
57+
}
58+
}
59+
}
60+
}

airbyte-integrations/connectors/source-sendgrid/source_sendgrid/source.py

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
Lists,
4040
Scopes,
4141
Segments,
42+
SingleSends,
4243
SpamReports,
4344
StatsAutomations,
4445
SuppressionGroupMembers,
@@ -66,6 +67,7 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
6667
Contacts(authenticator=authenticator),
6768
StatsAutomations(authenticator=authenticator),
6869
Segments(authenticator=authenticator),
70+
SingleSends(authenticator=authenticator),
6971
Templates(authenticator=authenticator),
7072
GlobalSuppressions(authenticator=authenticator, start_time=config["start_time"]),
7173
SuppressionGroups(authenticator=authenticator),

airbyte-integrations/connectors/source-sendgrid/source_sendgrid/streams.py

+14
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,18 @@ def path(self, **kwargs) -> str:
191191
return "marketing/segments"
192192

193193

194+
class SingleSends(SendgridStreamMetadataPagination):
195+
"""
196+
https://docs.sendgrid.com/api-reference/marketing-campaign-stats/get-all-single-sends-stats
197+
"""
198+
199+
data_field = "results"
200+
201+
@staticmethod
202+
def initial_path() -> str:
203+
return "marketing/stats/singlesends"
204+
205+
194206
class Templates(SendgridStreamMetadataPagination):
195207
data_field = "result"
196208

@@ -217,6 +229,8 @@ def path(self, **kwargs) -> str:
217229

218230

219231
class SuppressionGroupMembers(SendgridStreamOffsetPagination):
232+
primary_key = "group_id"
233+
220234
def path(self, **kwargs) -> str:
221235
return "asm/suppressions"
222236

docs/integrations/sources/sendgrid.md

+1
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,5 @@ We recommend creating a key specifically for Airbyte access. This will allow you
4545

4646
| Version | Date | Pull Request | Subject |
4747
| :------ | :-------- | :----- | :------ |
48+
| 0.2.7 | 2021-09-08 | [5910](https://github.com/airbytehq/airbyte/pull/5910) | Add Single Sends Stats stream |
4849
| 0.2.6 | 2021-07-19 | [4839](https://github.com/airbytehq/airbyte/pull/4839) | Gracefully handle malformed responses from the API |

0 commit comments

Comments
 (0)