* initial first pass converting every component to dataclasses * replace the hackier options pass through * get rid of the hackier way * fix issues w/ type hints by making options required and lots of fixes to the language to fix compatability for dataclasses * add dataclasses-jsonschema to setup * fix oauth authenticator to avoid dataclass name collisions * fix spacing for CI tests * remove property from oauth and fix a interpolation bug * pr feedback and cleaning up the code a bit, attempt at avoiding renaming * fix templates and bugs surfaced during greenhouse spec testing * fix tests * fix missing options in some declarative components * fix tests related to pulling latest master * fix issue w/ passing state, slice, and token to subcomponents * switch name back to get_access_token() since no name collision anymore
22 lines
539 B
Python
22 lines
539 B
Python
#
|
|
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
|
#
|
|
|
|
from dataclasses import InitVar, dataclass
|
|
from typing import Any, List, Mapping, Union
|
|
|
|
import requests
|
|
from airbyte_cdk.sources.declarative.decoders.decoder import Decoder
|
|
|
|
|
|
@dataclass
|
|
class JsonDecoder(Decoder):
|
|
"""
|
|
Decoder strategy that returns the json-encoded content of a response, if any.
|
|
"""
|
|
|
|
options: InitVar[Mapping[str, Any]]
|
|
|
|
def decode(self, response: requests.Response) -> Union[Mapping[str, Any], List]:
|
|
return response.json() or {}
|