Skip to content
This repository was archived by the owner on Dec 3, 2019. It is now read-only.

Issue #218 Added Requests API documentation - #229

Merged
hpjaj merged 9 commits into
OperationCode:masterfrom
apex-omontgomery:master
Jan 13, 2018
Merged

hpjaj merged 9 commits into
OperationCode:masterfrom
apex-omontgomery:master

Conversation

@apex-omontgomery

@apex-omontgomery apex-omontgomery commented Jan 4, 2018 •

Copy link
Copy Markdown
Contributor

Description of changes

Completes request for Issue #218 adds documentation for:
api/v1/requests_controller#index
api/v1/requests_controller#create
api/v1/requests_controller#show
api/v1/requests_controller#update

Issue Resolved

Fixes #218

@hpjaj
hpjaj self-requested a review January 4, 2018 02:49
Comment thread apiary.apib Outdated
errors: "Some error message"
}

## Mentor Request | Create [/api/v1/requests{?user_id,details,language,service_id,requested_mentor_id,status,assigned_mentor_id}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the model name is Request and the endpoint is also requests, can you please change this to "Request a Mentor", and then re-alphabetize all of the Request related endpoints accordingly.

Comment thread apiary.apib Outdated
}


## Mentor Request | Update [/api/v1/requests{?user_id,details,language,service_id,requested_mentor_id,status,assigned_mentor_id}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update endpoint takes the request_id as a part of the url itself, not a parameter.

Here is an example from TeamMember#update.

Comment thread apiary.apib
+ Body

{
"user_id": 4600,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will also include the id: of the newly created Request db record.

Comment thread apiary.apib Outdated
errors: "Some error message"
}

## Mentor Request | Show [/api/v1/requests{?user_id}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The show endpoint takes the request_id as a part of the url itself, not a parameter.

Here is an example from CodeSchool#show.

Comment thread apiary.apib Outdated

+ Response 400 (application/json)

## Mentor Requests Unclaimed | Show [/api/v1/requests]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually "Collection" instead of a "Show"

Comment thread apiary.apib Outdated

[
{
"service_id": 223,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id: will be included for each one of these records

Comment thread apiary.apib
+ Body

{
"user_id": 5200,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The id: will be included for the record

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I included the value, but I think because I did "id" and not "id:" github isn't registering correctly?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, force of (Ruby) habit. In this API documentation it is "id".

Comment thread apiary.apib

## Scholarship Applications | Create [/api/v1/code_schools/{?scholarship_application,reason,terms_accepted,scholarship_id}]
+ Parameters

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user_id is a required param

Comment thread apiary.apib Outdated
error: 'No such record'
}

## Scholarship Applications | Create [/api/v1/code_schools/{?scholarship_application,reason,terms_accepted,scholarship_id}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The URL is /api/v1/scholarship_applications

@hpjaj

hpjaj commented Jan 4, 2018

Copy link
Copy Markdown
Contributor

@wimo7083 - Can you please pull out the code changes for Issue #218 out of this PR, and create a dedicated PR for that issue. So that we have a 1:1 relationship, in that every issue has its own resolving PR.

@apex-omontgomery

Copy link
Copy Markdown
Contributor Author

Updated, split PR, and renamed since you reviewed mentorships in this one.

@apex-omontgomery apex-omontgomery changed the title Issue #219 more api documentation Issue #218 Requests API documentation Jan 5, 2018
@apex-omontgomery apex-omontgomery changed the title Issue #218 Requests API documentation Issue #218 Added Requests API documentation Jan 5, 2018
Comment thread apiary.apib Outdated
errors: "Some error message"
}

## Mentor Request | Create a New Mentor Request [/api/v1/requests{?user_id,details,language,service_id,requested_mentor_id,status,assigned_mentor_id}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the model name is Request and the endpoint is also ../requests, can you please all of these endpoints to begin with "Request ....". For example, "Request a Mentor".

And then re-alphabetize all of the Request related endpoints accordingly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix them to be like this:
## Mentor Request | Request .... r [/api/vi/....]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They'll need to go by their model, Request, so it would be:

## Request | Request a Mentor .... r [/api/vi/....]

Comment thread apiary.apib Outdated
## Mentor Request | Create a New Mentor Request [/api/v1/requests{?user_id,details,language,service_id,requested_mentor_id,status,assigned_mentor_id}]
+ Parameters

+ user_id (integer, required) - Identification of the User requesting a mentor in the form of an integer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the passed user must also be verified, perhaps also include that information in this description. i.e. "The passed in user must be a verified military veteran (i.e. user.verified == true)."

Comment thread apiary.apib Outdated
"assigned_mentor_id": 250
}

+ Response 422 (application/json)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The create action is current not accounting for an error response.

Here is an example of a different controller method that is accounting for error handling.

As such, you can adjust this whole section to return a 401, like you did in the index action.

Comment thread apiary.apib Outdated
+ Body

{
"request_id": 1234,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute will just be "id"

Comment thread apiary.apib Outdated
+ request_id (integer, required) - Indentification of mentor request in the form of an integer


### Show an Exiting Request From User ID [POST]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a get request

Comment thread apiary.apib Outdated

Authorization: Bearer Access-Token

+ Body

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, the id is supplied as part of the url itself, and there will be no body in the request.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, so there's no body in the update of the request?

Frontend, to me this looks like it's passing the id in the url like you say, but there's a body in the request that contains status and mentor. But then here shows that the update takes in request params.

I compared the syntax for both update with Request controller and User controller and they both have the same type of input with params. The only difference is one uses obj.update and the other uses obj.update_attributes.

So i thought maybe this has to do with the difference. But this states that the only difference in behavior of the two functions it the return value for a success vs failure. update_attributes returns false if it fails validation, update returns the new object if it fails validation.

At this point I'm thorougly confused why there isn't a body in the request.

I also used a PUT here but changed it to PATCH based on the information provided in the frontend axios call.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wimo7083 - Apologies, I miscommunicated that. My intent was to say that the id would not be in the body, rather in the url itself. And yes, you're correct, there is a body in the request with all the attributes you have below.

Comment thread apiary.apib Outdated
error: 'Unauthorized'
}

## Mentor Request | Update [/api/v1/requests{user_id}{?details,language,service_id,requested_mentor_id,status,assigned_mentor_id}]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a / after requests because the id is part of the url itself, i.e. /api/v1/requests/{user_id}{?details,language....

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add API Documentation for Requests endpoints

2 participants