-
Notifications
You must be signed in to change notification settings - Fork 7
add projects API #67
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
Open
jurgens
wants to merge
10
commits into
railsware:main
Choose a base branch
from
kodolabs:projects-api
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add projects API #67
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0c1090c
add projects API
jurgens 85def53
fix documentation
jurgens 51fc8bb
fix spec
jurgens bf7278a
upd docs
jurgens cb42fc5
fix code review comments
jurgens 617b590
remove unused method and spec, do not use default env values as they …
jurgens a2b6be6
add cassettes
jurgens 15a5b5a
remove constructor, fix attribute type
jurgens 82833a9
improve sensitive data scrubbing, re-record cassettes
jurgens 225484a
rename variable in a spec
jurgens 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Mailtrap | ||
# Data Transfer Object for Project | ||
# @see https://api-docs.mailtrap.io/docs/mailtrap-api-docs/ee252e413d78a-create-project | ||
# @attr_reader id [String] The project ID | ||
# @attr_reader name [String] The project name | ||
# @attr_reader share_links [Array] Array of links | ||
# @attr_reader inboxes [Array] Array of inboxes | ||
# @attr_reader permissions [Hash] List of permissions | ||
Project = Struct.new( | ||
:id, | ||
:name, | ||
:share_links, | ||
:inboxes, | ||
:permissions, | ||
keyword_init: true | ||
) do | ||
def initialize(options) | ||
super | ||
end | ||
|
||
# @return [Hash] The project attributes as a hash | ||
def to_h | ||
super.compact | ||
end | ||
end | ||
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,67 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'base_api' | ||
require_relative 'project' | ||
|
||
module Mailtrap | ||
class ProjectsAPI | ||
include BaseAPI | ||
|
||
self.supported_options = %i[name] | ||
|
||
self.response_class = Project | ||
|
||
# Lists all projects for the account | ||
# @return [Array<Project>] Array of projects | ||
# @!macro api_errors | ||
def list | ||
base_list | ||
end | ||
|
||
# Retrieves a specific project | ||
# @param project_id [Integer] The project ID | ||
# @return [Project] Project object | ||
# @!macro api_errors | ||
def get(project_id) | ||
base_get(project_id) | ||
end | ||
|
||
# Creates a new project | ||
# @param [Hash] options The parameters to create | ||
# @option options [String] :name The project name | ||
# @return [Project] Created project object | ||
# @!macro api_errors | ||
# @raise [ArgumentError] If invalid options are provided | ||
def create(options) | ||
base_create(options) | ||
end | ||
|
||
# Updates an existing project | ||
# @param project_id [Integer] The project ID | ||
# @param [Hash] options The parameters to update | ||
# @return [Project] Updated project object | ||
# @!macro api_errors | ||
# @raise [ArgumentError] If invalid options are provided | ||
def update(project_id, options) | ||
base_update(project_id, options) | ||
end | ||
|
||
# Deletes a project | ||
# @param project_id [Integer] The project ID | ||
# @return nil | ||
# @!macro api_errors | ||
def delete(project_id) | ||
base_delete(project_id) | ||
end | ||
|
||
private | ||
|
||
def base_path | ||
"/api/accounts/#{account_id}/projects" | ||
end | ||
|
||
def wrap_request(options) | ||
{ project: options } | ||
end | ||
end | ||
end |
166 changes: 166 additions & 0 deletions
166
...tures/vcr_cassettes/Mailtrap_ProjectsAPI/_create/maps_response_data_to_Project_object.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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix YARD types and accessor annotations (docs are incorrect).
Apply this doc fix:
📝 Committable suggestion
🤖 Prompt for AI Agents