Add missing endpoints#126
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (20)
📝 WalkthroughWalkthroughThe PR extends MailtrapClient to support organization-scoped APIs by introducing webhooks and organizations management, adds API token functionality, and wires new resource classes with supporting type definitions and test coverage. Configuration updates supply Mailtrap environment variables. Changes
Sequence Diagram(s)sequenceDiagram
actor User
participant Client as MailtrapClient
participant WebhooksAPI as WebhooksBaseAPI
participant Resource as WebhooksApi
participant HTTP as Axios
User->>Client: get webhooks (accountId set)
Client->>Client: checkAccountIdPresence()
Client->>WebhooksAPI: new WebhooksBaseAPI(axios, accountId)
WebhooksAPI->>Resource: new WebhooksApi(axios, accountId)
WebhooksAPI->>User: return WebhooksBaseAPI instance
User->>WebhooksAPI: getList()
WebhooksAPI->>Resource: getList()
Resource->>Resource: construct endpoint URL
Resource->>HTTP: GET /webhooks
HTTP-->>Resource: return webhook list
Resource-->>WebhooksAPI: typed response
WebhooksAPI-->>User: webhook list
sequenceDiagram
actor User
participant Client as MailtrapClient
participant OrgAPI as OrganizationsBaseAPI
participant Resource as SubAccountsApi
participant HTTP as Axios
User->>Client: get organizations (organizationId set)
Client->>Client: checkOrganizationIdPresence()
Client->>OrgAPI: new OrganizationsBaseAPI(axios, organizationId)
OrgAPI->>Resource: new SubAccountsApi(axios, organizationId)
OrgAPI->>User: return OrganizationsBaseAPI instance
User->>OrgAPI: organizations.subAccounts.create(params)
OrgAPI->>Resource: create(params)
Resource->>Resource: construct endpoint URL
Resource->>HTTP: POST /organizations/{orgId}/sub-accounts
HTTP-->>Resource: return created SubAccount
Resource-->>OrgAPI: typed response
OrgAPI-->>User: SubAccount object
sequenceDiagram
actor User
participant Client as MailtrapClient
participant General as GeneralAPI
participant Resource as ApiTokensApi
participant HTTP as Axios
User->>Client: get general (accountId set)
Note over Client: GeneralAPI already initialized
User->>General: general.apiTokens.create(params)
General->>General: checkAccountIdPresence()
General->>Resource: new ApiTokensApi(axios, accountId)
Resource->>Resource: construct endpoint URL
Resource->>HTTP: POST /api-tokens
HTTP-->>Resource: return ApiTokenWithToken
Resource-->>General: typed response
General-->>User: ApiTokenWithToken (includes token value)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
|
|
||
| constructor(client: AxiosInstance, accountId: number) { | ||
| this.client = client; | ||
| this.apiTokensURL = `${GENERAL_ENDPOINT}/api/accounts/${accountId}/api_tokens`; |
There was a problem hiding this comment.
Shouldn't we start moving to accountId-less endpoints already?
There was a problem hiding this comment.
we should, but it should be done as a separate change. API is working in compatibility mode
Motivation
Changes
Webhooks
API Tokens
Sub-Accounts
Summary by CodeRabbit
New Features
Tests