Skip to content

Commit

Permalink
Source Intercom: fix acceptance tests, fix format
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-yermilov-gl committed Aug 21, 2023
1 parent d1c9702 commit b850380
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ acceptance_tests:
spec:
tests:
- spec_path: "source_intercom/spec.json"
# Small fix: advanced auth configuration contain `client_id` and `client_secret` fields but they were missing in spec.
backward_compatibility_tests_config:
disable_for_version: "0.2.1"
connection:
tests:
- config_path: "secrets/config.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
from airbyte_cdk.sources.declarative.requesters.error_handlers.response_status import ResponseStatus
from airbyte_cdk.sources.declarative.requesters.http_requester import HttpRequester
from airbyte_cdk.sources.declarative.requesters.request_option import RequestOptionType
from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_nested_request_input_provider import (
InterpolatedNestedRequestInputProvider,
)
from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_request_input_provider import InterpolatedRequestInputProvider
from airbyte_cdk.sources.declarative.requesters.request_options.interpolated_nested_request_input_provider import InterpolatedNestedRequestInputProvider
from airbyte_cdk.sources.declarative.types import Config, Record, StreamSlice, StreamState
from airbyte_cdk.sources.streams.core import Stream


RequestInput = Union[str, Mapping[str, str]]


Expand Down Expand Up @@ -141,9 +142,7 @@ def __post_init__(self, parameters: Mapping[str, Any]):
def set_initial_state(self, stream_state: StreamState):
super().set_initial_state(stream_state=stream_state)
if self.parent_stream_name in stream_state and stream_state.get(self.parent_stream_name, {}).get(self.parent_cursor_field):
parent_stream_state = {
self.parent_cursor_field: stream_state[self.parent_stream_name][self.parent_cursor_field]
}
parent_stream_state = {self.parent_cursor_field: stream_state[self.parent_stream_name][self.parent_cursor_field]}
self._state[self.parent_stream_name] = parent_stream_state
if "prior_state" in self._state:
self._state["prior_state"][self.parent_stream_name] = parent_stream_state
Expand All @@ -164,18 +163,13 @@ def read_parent_stream(
self.parent_stream.state = stream_state

parent_stream_slices_gen = self.parent_stream.stream_slices(
sync_mode=sync_mode,
cursor_field=cursor_field,
stream_state=stream_state
sync_mode=sync_mode, cursor_field=cursor_field, stream_state=stream_state
)

for parent_slice in parent_stream_slices_gen:

parent_records_gen = self.parent_stream.read_records(
sync_mode=sync_mode,
cursor_field=cursor_field,
stream_slice=parent_slice,
stream_state=stream_state
sync_mode=sync_mode, cursor_field=cursor_field, stream_slice=parent_slice, stream_state=stream_state
)

for parent_record in parent_records_gen:
Expand All @@ -189,7 +183,7 @@ def read_parent_stream(
cursor_field: self._state.get(cursor_field),
self.parent_stream_name: {
self.parent_cursor_field: self._state.get(self.parent_stream_name, {}).get(self.parent_cursor_field)
}
},
}


Expand Down Expand Up @@ -325,8 +319,8 @@ class HttpRequesterWithRateLimiter(HttpRequester):
the default requester's logic doesn't allow to handle the status of 200 with `should_retry()`.
"""

request_headers: Optional[RequestInput] = None
request_body_json: Optional[RequestInput] = None
request_body_json: Optional[RequestInput] = None
request_headers: Optional[RequestInput] = None
request_parameters: Optional[RequestInput] = None

def __post_init__(self, parameters: Mapping[str, Any]) -> None:
Expand Down Expand Up @@ -372,7 +366,7 @@ def get_request_headers(
next_page_token: Optional[Mapping[str, Any]] = None,
) -> Mapping[str, Any]:
return self._headers_interpolator.eval_request_inputs(stream_state, stream_slice, next_page_token)

def get_request_body_json(
self,
*,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ definitions:
request_headers:
Intercom-Version: '2.5' # ATTENTION: API version change is possible here
Accept: 'application/json'
error_handler:
type: "DefaultErrorHandler"
retriever:
description: "Base Retriever for Full Refresh streams"
record_selector:
Expand Down Expand Up @@ -67,7 +69,7 @@ definitions:
'page': {{ next_page_token.get('next_page_token').get('page') }},
'starting_after': '{{ next_page_token.get('next_page_token').get('starting_after') }}'
}"

## streams
# full-refresh
stream_full_refresh:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@
"type": "string",
"description": "Access token for making authenticated requests. See the <a href=\"https://developers.intercom.com/building-apps/docs/authentication-types#how-to-get-your-access-token\">Intercom docs</a> for more information.",
"airbyte_secret": true
},
"client_id": {
"title": "Client Id",
"type": "string",
"description": "Client Id for your Intercom application.",
"airbyte_secret": true
},
"client_secret": {
"title": "Client Secret",
"type": "string",
"description": "Client Secret for your Intercom application.",
"airbyte_secret": true
}
}
},
Expand Down

0 comments on commit b850380

Please sign in to comment.