Skip to content

Commit e677766

Browse files
feat(api): manual updates (#503)
1 parent 621174c commit e677766

File tree

5 files changed

+12
-80
lines changed

5 files changed

+12
-80
lines changed

src/finch/_client.py

+10-46
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ class Finch(SyncAPIClient):
6969
access_token: str | None
7070
client_id: str | None
7171
client_secret: str | None
72-
sandbox_client_id: str | None
73-
sandbox_client_secret: str | None
7472
webhook_secret: str | None
7573

7674
def __init__(
@@ -79,8 +77,6 @@ def __init__(
7977
access_token: str | None = None,
8078
client_id: str | None = None,
8179
client_secret: str | None = None,
82-
sandbox_client_id: str | None = None,
83-
sandbox_client_secret: str | None = None,
8480
webhook_secret: str | None = None,
8581
base_url: str | httpx.URL | None = None,
8682
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
@@ -112,8 +108,6 @@ def __init__(
112108
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
113109
- `client_id` from `FINCH_CLIENT_ID`
114110
- `client_secret` from `FINCH_CLIENT_SECRET`
115-
- `sandbox_client_id` from `FINCH_SANDBOX_CLIENT_ID`
116-
- `sandbox_client_secret` from `FINCH_SANDBOX_CLIENT_SECRET`
117111
- `webhook_secret` from `FINCH_WEBHOOK_SECRET`
118112
"""
119113
self.access_token = access_token
@@ -126,14 +120,6 @@ def __init__(
126120
client_secret = os.environ.get("FINCH_CLIENT_SECRET")
127121
self.client_secret = client_secret
128122

129-
if sandbox_client_id is None:
130-
sandbox_client_id = os.environ.get("FINCH_SANDBOX_CLIENT_ID")
131-
self.sandbox_client_id = sandbox_client_id
132-
133-
if sandbox_client_secret is None:
134-
sandbox_client_secret = os.environ.get("FINCH_SANDBOX_CLIENT_SECRET")
135-
self.sandbox_client_secret = sandbox_client_secret
136-
137123
if webhook_secret is None:
138124
webhook_secret = os.environ.get("FINCH_WEBHOOK_SECRET")
139125
self.webhook_secret = webhook_secret
@@ -193,11 +179,11 @@ def _bearer_auth(self) -> dict[str, str]:
193179

194180
@property
195181
def _basic_auth(self) -> dict[str, str]:
196-
if self.sandbox_client_id is None:
182+
if self.client_id is None:
197183
return {}
198-
if self.sandbox_client_secret is None:
184+
if self.client_secret is None:
199185
return {}
200-
credentials = f"{self.sandbox_client_id}:{self.sandbox_client_secret}".encode("ascii")
186+
credentials = f"{self.client_id}:{self.client_secret}".encode("ascii")
201187
header = f"Basic {base64.b64encode(credentials).decode('ascii')}"
202188
return {"Authorization": header}
203189

@@ -218,13 +204,13 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
218204
if isinstance(custom_headers.get("Authorization"), Omit):
219205
return
220206

221-
if self.sandbox_client_id and self.sandbox_client_secret and headers.get("Authorization"):
207+
if self.client_id and self.client_secret and headers.get("Authorization"):
222208
return
223209
if isinstance(custom_headers.get("Authorization"), Omit):
224210
return
225211

226212
raise TypeError(
227-
'"Could not resolve authentication method. Expected either access_token, sandbox_client_id or sandbox_client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
213+
'"Could not resolve authentication method. Expected either access_token, client_id or client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
228214
)
229215

230216
def copy(
@@ -233,8 +219,6 @@ def copy(
233219
access_token: str | None = None,
234220
client_id: str | None = None,
235221
client_secret: str | None = None,
236-
sandbox_client_id: str | None = None,
237-
sandbox_client_secret: str | None = None,
238222
webhook_secret: str | None = None,
239223
base_url: str | httpx.URL | None = None,
240224
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
@@ -290,8 +274,6 @@ def copy(
290274
access_token=access_token or self.access_token,
291275
client_id=client_id or self.client_id,
292276
client_secret=client_secret or self.client_secret,
293-
sandbox_client_id=sandbox_client_id or self.sandbox_client_id,
294-
sandbox_client_secret=sandbox_client_secret or self.sandbox_client_secret,
295277
webhook_secret=webhook_secret or self.webhook_secret,
296278
base_url=base_url or self.base_url,
297279
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,
@@ -423,8 +405,6 @@ class AsyncFinch(AsyncAPIClient):
423405
access_token: str | None
424406
client_id: str | None
425407
client_secret: str | None
426-
sandbox_client_id: str | None
427-
sandbox_client_secret: str | None
428408
webhook_secret: str | None
429409

430410
def __init__(
@@ -433,8 +413,6 @@ def __init__(
433413
access_token: str | None = None,
434414
client_id: str | None = None,
435415
client_secret: str | None = None,
436-
sandbox_client_id: str | None = None,
437-
sandbox_client_secret: str | None = None,
438416
webhook_secret: str | None = None,
439417
base_url: str | httpx.URL | None = None,
440418
timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN,
@@ -466,8 +444,6 @@ def __init__(
466444
This automatically infers the following arguments from their corresponding environment variables if they are not provided:
467445
- `client_id` from `FINCH_CLIENT_ID`
468446
- `client_secret` from `FINCH_CLIENT_SECRET`
469-
- `sandbox_client_id` from `FINCH_SANDBOX_CLIENT_ID`
470-
- `sandbox_client_secret` from `FINCH_SANDBOX_CLIENT_SECRET`
471447
- `webhook_secret` from `FINCH_WEBHOOK_SECRET`
472448
"""
473449
self.access_token = access_token
@@ -480,14 +456,6 @@ def __init__(
480456
client_secret = os.environ.get("FINCH_CLIENT_SECRET")
481457
self.client_secret = client_secret
482458

483-
if sandbox_client_id is None:
484-
sandbox_client_id = os.environ.get("FINCH_SANDBOX_CLIENT_ID")
485-
self.sandbox_client_id = sandbox_client_id
486-
487-
if sandbox_client_secret is None:
488-
sandbox_client_secret = os.environ.get("FINCH_SANDBOX_CLIENT_SECRET")
489-
self.sandbox_client_secret = sandbox_client_secret
490-
491459
if webhook_secret is None:
492460
webhook_secret = os.environ.get("FINCH_WEBHOOK_SECRET")
493461
self.webhook_secret = webhook_secret
@@ -547,11 +515,11 @@ def _bearer_auth(self) -> dict[str, str]:
547515

548516
@property
549517
def _basic_auth(self) -> dict[str, str]:
550-
if self.sandbox_client_id is None:
518+
if self.client_id is None:
551519
return {}
552-
if self.sandbox_client_secret is None:
520+
if self.client_secret is None:
553521
return {}
554-
credentials = f"{self.sandbox_client_id}:{self.sandbox_client_secret}".encode("ascii")
522+
credentials = f"{self.client_id}:{self.client_secret}".encode("ascii")
555523
header = f"Basic {base64.b64encode(credentials).decode('ascii')}"
556524
return {"Authorization": header}
557525

@@ -572,13 +540,13 @@ def _validate_headers(self, headers: Headers, custom_headers: Headers) -> None:
572540
if isinstance(custom_headers.get("Authorization"), Omit):
573541
return
574542

575-
if self.sandbox_client_id and self.sandbox_client_secret and headers.get("Authorization"):
543+
if self.client_id and self.client_secret and headers.get("Authorization"):
576544
return
577545
if isinstance(custom_headers.get("Authorization"), Omit):
578546
return
579547

580548
raise TypeError(
581-
'"Could not resolve authentication method. Expected either access_token, sandbox_client_id or sandbox_client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
549+
'"Could not resolve authentication method. Expected either access_token, client_id or client_secret to be set. Or for one of the `Authorization` or `Authorization` headers to be explicitly omitted"'
582550
)
583551

584552
def copy(
@@ -587,8 +555,6 @@ def copy(
587555
access_token: str | None = None,
588556
client_id: str | None = None,
589557
client_secret: str | None = None,
590-
sandbox_client_id: str | None = None,
591-
sandbox_client_secret: str | None = None,
592558
webhook_secret: str | None = None,
593559
base_url: str | httpx.URL | None = None,
594560
timeout: float | Timeout | None | NotGiven = NOT_GIVEN,
@@ -644,8 +610,6 @@ def copy(
644610
access_token=access_token or self.access_token,
645611
client_id=client_id or self.client_id,
646612
client_secret=client_secret or self.client_secret,
647-
sandbox_client_id=sandbox_client_id or self.sandbox_client_id,
648-
sandbox_client_secret=sandbox_client_secret or self.sandbox_client_secret,
649613
webhook_secret=webhook_secret or self.webhook_secret,
650614
base_url=base_url or self.base_url,
651615
timeout=self.timeout if isinstance(timeout, NotGiven) else timeout,

tests/api_resources/connect/test_sessions.py

-16
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
class TestSessions:
2121
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
2222

23-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
2423
@parametrize
2524
def test_method_new(self, client: Finch) -> None:
2625
session = client.connect.sessions.new(
@@ -30,7 +29,6 @@ def test_method_new(self, client: Finch) -> None:
3029
)
3130
assert_matches_type(SessionNewResponse, session, path=["response"])
3231

33-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
3432
@parametrize
3533
def test_method_new_with_all_params(self, client: Finch) -> None:
3634
session = client.connect.sessions.new(
@@ -49,7 +47,6 @@ def test_method_new_with_all_params(self, client: Finch) -> None:
4947
)
5048
assert_matches_type(SessionNewResponse, session, path=["response"])
5149

52-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
5350
@parametrize
5451
def test_raw_response_new(self, client: Finch) -> None:
5552
response = client.connect.sessions.with_raw_response.new(
@@ -63,7 +60,6 @@ def test_raw_response_new(self, client: Finch) -> None:
6360
session = response.parse()
6461
assert_matches_type(SessionNewResponse, session, path=["response"])
6562

66-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
6763
@parametrize
6864
def test_streaming_response_new(self, client: Finch) -> None:
6965
with client.connect.sessions.with_streaming_response.new(
@@ -79,15 +75,13 @@ def test_streaming_response_new(self, client: Finch) -> None:
7975

8076
assert cast(Any, response.is_closed) is True
8177

82-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
8378
@parametrize
8479
def test_method_reauthenticate(self, client: Finch) -> None:
8580
session = client.connect.sessions.reauthenticate(
8681
connection_id="connection_id",
8782
)
8883
assert_matches_type(SessionReauthenticateResponse, session, path=["response"])
8984

90-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
9185
@parametrize
9286
def test_method_reauthenticate_with_all_params(self, client: Finch) -> None:
9387
session = client.connect.sessions.reauthenticate(
@@ -98,7 +92,6 @@ def test_method_reauthenticate_with_all_params(self, client: Finch) -> None:
9892
)
9993
assert_matches_type(SessionReauthenticateResponse, session, path=["response"])
10094

101-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
10295
@parametrize
10396
def test_raw_response_reauthenticate(self, client: Finch) -> None:
10497
response = client.connect.sessions.with_raw_response.reauthenticate(
@@ -110,7 +103,6 @@ def test_raw_response_reauthenticate(self, client: Finch) -> None:
110103
session = response.parse()
111104
assert_matches_type(SessionReauthenticateResponse, session, path=["response"])
112105

113-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
114106
@parametrize
115107
def test_streaming_response_reauthenticate(self, client: Finch) -> None:
116108
with client.connect.sessions.with_streaming_response.reauthenticate(
@@ -128,7 +120,6 @@ def test_streaming_response_reauthenticate(self, client: Finch) -> None:
128120
class TestAsyncSessions:
129121
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
130122

131-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
132123
@parametrize
133124
async def test_method_new(self, async_client: AsyncFinch) -> None:
134125
session = await async_client.connect.sessions.new(
@@ -138,7 +129,6 @@ async def test_method_new(self, async_client: AsyncFinch) -> None:
138129
)
139130
assert_matches_type(SessionNewResponse, session, path=["response"])
140131

141-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
142132
@parametrize
143133
async def test_method_new_with_all_params(self, async_client: AsyncFinch) -> None:
144134
session = await async_client.connect.sessions.new(
@@ -157,7 +147,6 @@ async def test_method_new_with_all_params(self, async_client: AsyncFinch) -> Non
157147
)
158148
assert_matches_type(SessionNewResponse, session, path=["response"])
159149

160-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
161150
@parametrize
162151
async def test_raw_response_new(self, async_client: AsyncFinch) -> None:
163152
response = await async_client.connect.sessions.with_raw_response.new(
@@ -171,7 +160,6 @@ async def test_raw_response_new(self, async_client: AsyncFinch) -> None:
171160
session = response.parse()
172161
assert_matches_type(SessionNewResponse, session, path=["response"])
173162

174-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
175163
@parametrize
176164
async def test_streaming_response_new(self, async_client: AsyncFinch) -> None:
177165
async with async_client.connect.sessions.with_streaming_response.new(
@@ -187,15 +175,13 @@ async def test_streaming_response_new(self, async_client: AsyncFinch) -> None:
187175

188176
assert cast(Any, response.is_closed) is True
189177

190-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
191178
@parametrize
192179
async def test_method_reauthenticate(self, async_client: AsyncFinch) -> None:
193180
session = await async_client.connect.sessions.reauthenticate(
194181
connection_id="connection_id",
195182
)
196183
assert_matches_type(SessionReauthenticateResponse, session, path=["response"])
197184

198-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
199185
@parametrize
200186
async def test_method_reauthenticate_with_all_params(self, async_client: AsyncFinch) -> None:
201187
session = await async_client.connect.sessions.reauthenticate(
@@ -206,7 +192,6 @@ async def test_method_reauthenticate_with_all_params(self, async_client: AsyncFi
206192
)
207193
assert_matches_type(SessionReauthenticateResponse, session, path=["response"])
208194

209-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
210195
@parametrize
211196
async def test_raw_response_reauthenticate(self, async_client: AsyncFinch) -> None:
212197
response = await async_client.connect.sessions.with_raw_response.reauthenticate(
@@ -218,7 +203,6 @@ async def test_raw_response_reauthenticate(self, async_client: AsyncFinch) -> No
218203
session = response.parse()
219204
assert_matches_type(SessionReauthenticateResponse, session, path=["response"])
220205

221-
@pytest.mark.skip(reason="authentication setup doesn't currently work with the mock server")
222206
@parametrize
223207
async def test_streaming_response_reauthenticate(self, async_client: AsyncFinch) -> None:
224208
async with async_client.connect.sessions.with_streaming_response.reauthenticate(

tests/api_resources/sandbox/connections/test_accounts.py

-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
class TestAccounts:
2121
parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
2222

23-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
2423
@parametrize
2524
def test_method_create(self, client: Finch) -> None:
2625
account = client.sandbox.connections.accounts.create(
@@ -29,7 +28,6 @@ def test_method_create(self, client: Finch) -> None:
2928
)
3029
assert_matches_type(AccountCreateResponse, account, path=["response"])
3130

32-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
3331
@parametrize
3432
def test_method_create_with_all_params(self, client: Finch) -> None:
3533
account = client.sandbox.connections.accounts.create(
@@ -40,7 +38,6 @@ def test_method_create_with_all_params(self, client: Finch) -> None:
4038
)
4139
assert_matches_type(AccountCreateResponse, account, path=["response"])
4240

43-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
4441
@parametrize
4542
def test_raw_response_create(self, client: Finch) -> None:
4643
response = client.sandbox.connections.accounts.with_raw_response.create(
@@ -53,7 +50,6 @@ def test_raw_response_create(self, client: Finch) -> None:
5350
account = response.parse()
5451
assert_matches_type(AccountCreateResponse, account, path=["response"])
5552

56-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
5753
@parametrize
5854
def test_streaming_response_create(self, client: Finch) -> None:
5955
with client.sandbox.connections.accounts.with_streaming_response.create(
@@ -104,7 +100,6 @@ def test_streaming_response_update(self, client: Finch) -> None:
104100
class TestAsyncAccounts:
105101
parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])
106102

107-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
108103
@parametrize
109104
async def test_method_create(self, async_client: AsyncFinch) -> None:
110105
account = await async_client.sandbox.connections.accounts.create(
@@ -113,7 +108,6 @@ async def test_method_create(self, async_client: AsyncFinch) -> None:
113108
)
114109
assert_matches_type(AccountCreateResponse, account, path=["response"])
115110

116-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
117111
@parametrize
118112
async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None:
119113
account = await async_client.sandbox.connections.accounts.create(
@@ -124,7 +118,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncFinch) ->
124118
)
125119
assert_matches_type(AccountCreateResponse, account, path=["response"])
126120

127-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
128121
@parametrize
129122
async def test_raw_response_create(self, async_client: AsyncFinch) -> None:
130123
response = await async_client.sandbox.connections.accounts.with_raw_response.create(
@@ -137,7 +130,6 @@ async def test_raw_response_create(self, async_client: AsyncFinch) -> None:
137130
account = response.parse()
138131
assert_matches_type(AccountCreateResponse, account, path=["response"])
139132

140-
@pytest.mark.skip(reason="Auth isn't setup correctly in this test")
141133
@parametrize
142134
async def test_streaming_response_create(self, async_client: AsyncFinch) -> None:
143135
async with async_client.sandbox.connections.accounts.with_streaming_response.create(

0 commit comments

Comments
 (0)