-
Notifications
You must be signed in to change notification settings - Fork 8
Add Account Accesses API #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| require 'mailtrap' | ||
|
|
||
| account_id = 3229 | ||
| client = Mailtrap::Client.new(api_key: 'your-api-key') | ||
| account_accesses = Mailtrap::AccountAccessesAPI.new(account_id, client) | ||
|
|
||
| # List all account accesses | ||
| account_accesses.list | ||
| # => [#<struct Mailtrap::AccountAccess id=1, specifier_type="User", specifier={...}, ...>] | ||
|
|
||
| # List with optional filters: domain_ids, inbox_ids, project_ids | ||
| account_accesses.list(domain_ids: [1, 2]) | ||
| account_accesses.list(inbox_ids: [12, 34]) | ||
| account_accesses.list(project_ids: [100, 200]) | ||
|
|
||
| # Combine multiple filters | ||
| account_accesses.list(domain_ids: [1], inbox_ids: [12], project_ids: [100]) | ||
|
|
||
| # Delete an account access | ||
| account_access_id = 123 | ||
| account_accesses.delete(account_access_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Mailtrap | ||
| # Data Transfer Object for AccountAccess | ||
| # @see https://docs.mailtrap.io/developers/account-management/access-control | ||
| # @attr_reader id [Integer] The access ID | ||
| # @attr_reader specifier_type [String] The type of the specifier | ||
| # @attr_reader specifier [Hash] The specifier for the access | ||
| # @attr_reader resources [Array<Hash>] The resources this access applies to | ||
| # @attr_reader permissions [Hash] The permissions granted | ||
| # | ||
| AccountAccess = Struct.new( | ||
| :id, | ||
| :specifier_type, | ||
| :specifier, | ||
| :resources, | ||
| :permissions, | ||
| keyword_init: true | ||
| ) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require_relative 'base_api' | ||
| require_relative 'account_access' | ||
|
|
||
| module Mailtrap | ||
| class AccountAccessesAPI | ||
| include BaseAPI | ||
|
|
||
| attr_reader :account_id | ||
|
|
||
| self.response_class = AccountAccess | ||
|
|
||
| # Retrieves a list of account accesses with optional filtering by domain, inbox, or project IDs | ||
| # @param domain_ids [Array<Integer>] Optional array of domain IDs to filter by | ||
| # @param inbox_ids [Array<Integer>] Optional array of inbox IDs to filter by | ||
| # @param project_ids [Array<Integer>] Optional array of project IDs to filter by | ||
| # @return [Array<AccountAccess>] List of account access objects | ||
| # @!macro api_errors | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def list(domain_ids: [], inbox_ids: [], project_ids: []) | ||
| query_params = {} | ||
| query_params[:domain_ids] = domain_ids unless domain_ids.empty? | ||
| query_params[:inbox_ids] = inbox_ids unless inbox_ids.empty? | ||
| query_params[:project_ids] = project_ids unless project_ids.empty? | ||
|
|
||
| base_list(query_params) | ||
| end | ||
|
|
||
| # Deletes an account access | ||
| # @param account_access_id [Integer] The account access ID | ||
| # @return [Hash] | ||
| # @!macro api_errors | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| def delete(account_access_id) | ||
| base_delete(account_access_id) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def base_path | ||
| "/api/accounts/#{account_id}/account_accesses" | ||
| end | ||
| end | ||
| end | ||
73 changes: 73 additions & 0 deletions
73
...s/vcr_cassettes/Mailtrap_AccountAccessesAPI/_delete/returns_deleted_account_access_id.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
..._AccountAccessesAPI/_delete/when_account_access_does_not_exist/raises_not_found_error.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...ettes/Mailtrap_AccountAccessesAPI/_list/maps_response_data_to_AccountAccesses_objects.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.