Skip to content

Commit

Permalink
Merge pull request #9 from yujoy/consolidation
Browse files Browse the repository at this point in the history
add stream; fix camel case
  • Loading branch information
hkuffel authored Jul 10, 2024
2 parents b9fa98f + 24ba76b commit e334dea
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
12 changes: 8 additions & 4 deletions tap_megaphone/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import re
import urllib.parse
from pathlib import Path
from typing import Any, Dict, Iterable, Callable, Optional, Union
from typing import Any, Callable, Dict, Iterable, Optional, Union

import backoff
import requests
from singer_sdk.exceptions import FatalAPIError, RetriableAPIError
from singer_sdk.helpers.jsonpath import extract_jsonpath
from singer_sdk.streams import RESTStream
from singer_sdk.exceptions import FatalAPIError, RetriableAPIError

from tap_megaphone.auth import megaphoneAuthenticator

Expand Down Expand Up @@ -157,8 +157,12 @@ def validate_response(self, response: requests.Response) -> None:
"^.*User does not have access to object requested.*$"
)

if response.status_code == 403 and inaccessible_pattern.match(error_message):
self.logger.warning(f"Skipping record because user does not have access to the object: {msg}")
if response.status_code == 403 and inaccessible_pattern.match(
error_message
):
self.logger.warning(
f"Skipping record because user does not have access to the object: {msg}"
)
return

raise FatalAPIError(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,7 @@
"null"
]
},
"orderID": {
"type": [
"string",
"null"
]
},
"promoID": {
"orderId": {
"type": [
"string",
"null"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"null"
]
},
"promoID": {
"promoId": {
"type": [
"string",
"null"
Expand Down
10 changes: 8 additions & 2 deletions tap_megaphone/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ class PodcastsStream(NetworksStream):
def get_child_context(self, record: dict, context: Optional[dict]) -> dict:
"""Return a context dictionary for child streams."""

return {"podcast_id": record.get("id", "not available"), "network_id": record.get("networkId")}
return {
"podcast_id": record.get("id", "not available"),
"network_id": record.get("networkId"),
}


class EpisodesStream(PodcastsStream):
Expand Down Expand Up @@ -94,7 +97,10 @@ class CampaignOrdersStream(CampaignsStream):
def get_child_context(self, record: dict, context: Optional[dict]) -> dict:
"""Return a context dictionary for child streams."""

return {"order_id": record.get("id", "not available"), "campaign_id": record.get("campaignId", "not available")}
return {
"order_id": record.get("id", "not available"),
"campaign_id": record.get("campaignId", "not available"),
}


class PromoOrdersStream(megaphoneStream):
Expand Down
2 changes: 1 addition & 1 deletion tap_megaphone/tap.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
CampaignsStream,
CampaignOrdersStream,
PromoOrdersStream,
# CampaignOrderAdvertisementsStream,
CampaignOrderAdvertisementsStream,
PromoOrderAdvertisementsStream,
AgenciesStream,
AdvertisersStream,
Expand Down

0 comments on commit e334dea

Please sign in to comment.