NAV
http cURL ruby JS/jQuery

Introduction

Welcome to the Mutant School API! Use our API endpoints to get (or add to) the details of the students, enrollment periods, and advisors in our fine school.

There is no authentication of any sort in this release of the API, so knock yourself out.

You’ll find code examples in the dark area to the right, and you can toggle between programming languages for each example using the tabs in the top right. We have raw HTTP requests, cURL commands, Ruby, or JavaScript (jQuery, to be precise), because why the heck not?

Mutants

Get All Mutants

GET /api/v1/mutants HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


require 'net/http'
require 'net/https'

def send_request
  # Mutants#index (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Mutants#index (GET https://mutant-school.herokuapp.com/api/v1/mutants)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});
curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/mutants"

Expected response: 200 OK, with JSON structured like this:

[
  {
    "id": 2,
    "mutant_name": "Superdave",
    "power": "Flight",
    "real_name": "Dave",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2016-01-01T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/2"
  },
  {
    "id": 1,
    "mutant_name": "Fusionraptor",
    "power": "Creating small, controlled fusion reactions",
    "real_name": "Clarice Sloan",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2015-06-01T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1"
  }
]

This endpoint retrieves all mutants.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/mutants

Get a Specific Mutant

GET /api/v1/mutants/1 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/mutants/1"
require 'net/http'
require 'net/https'

def send_request
  # Mutants#show (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/1')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Mutants#show (GET https://mutant-school.herokuapp.com/api/v1/mutants/1)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/1",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 200 OK, with JSON structured like this:

{
  "id": 1,
  "mutant_name": "Fusionraptor",
  "power": "Creating small, controlled fusion reactions",
  "real_name": "Clarice Sloan",
  "created_at": "2016-02-02T21:24:07.249Z",
  "updated_at": "2016-02-02T22:23:47.482Z",
  "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
  "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
  "may_advise_beginning_at": "2015-06-01T00:00:00.000Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1",
  "advisor": {
    "id": 2,
    "mutant_name": "Superdave",
    "power": "Flight",
    "real_name": "Dave",
    "created_at": "2016-02-02T21:24:45.964Z",
    "updated_at": "2016-02-02T21:24:45.964Z",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2016-01-01T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/2"
  }
}

This endpoint retrieves a specific mutant. The advisor, if any, is nested in the results.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/mutants/<ID>

URL Parameters

Parameter Description
ID The ID of the mutant to retrieve

Errors

Error Code Meaning
404 Not Found – There’s no mutant with that ID.
500 Internal Server Error – It’s probably our fault.

Create a Mutant

POST /api/v1/mutants HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 185

{"mutant":{"real_name":"Dave","mutant_name":"Superdave","power":"Flight","eligibility_begins_at":"2010-01-01","eligibility_ends_at":"2020-01-01","may_advise_beginning_at":"2016-01-01"}}
curl -X "POST" "https://mutant-school.herokuapp.com/api/v1/mutants" \
    -H "Content-Type: application/json" \
    -d "{\"mutant\":{\"real_name\":\"Dave\",\"mutant_name\":\"Superdave\",\"power\":\"Flight\",\"eligibility_begins_at\":\"2010-01-01\",\"eligibility_ends_at\":\"2020-01-01\",\"may_advise_beginning_at\":\"2016-01-01\"}}"

require 'net/http'
require 'net/https'
require 'json'

def send_request
  # Mutants#create (POST )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "mutant" => {
                "eligibility_begins_at" => "2010-01-01",
                "power" => "Flight",
                "may_advise_beginning_at" => "2016-01-01",
                "eligibility_ends_at" => "2020-01-01",
                "real_name" => "Dave",
                "mutant_name" => "Superdave"
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Post.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Mutants#create (POST https://mutant-school.herokuapp.com/api/v1/mutants)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants",
    type: "POST",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "mutant": {
            "eligibility_begins_at": "2010-01-01",
            "power": "Flight",
            "may_advise_beginning_at": "2016-01-01",
            "eligibility_ends_at": "2020-01-01",
            "real_name": "Dave",
            "mutant_name": "Superdave"
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 201 Created, with JSON structured like this:

{
  "id": 2,
  "mutant_name": "Superdave",
  "power": "Flight",
  "real_name": "Dave",
  "created_at": "2016-02-02T21:24:45.964Z",
  "updated_at": "2016-02-02T21:24:45.964Z",
  "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
  "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
  "may_advise_beginning_at": "2016-01-01T00:00:00.000Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/2"
}

This endpoint creates a new mutant.

HTTP Request

POST https://mutant-school.herokuapp.com/api/v1/mutants

Payload

May be sent as any of the following:

Parameter Required Description
mutant[real_name] yes Legal name
mutant[mutant_name] yes Preferred name
mutant[power] yes Superpower
mutant[eligibility_begins_at] no Date when eligibility to enroll begins
mutant[eligibility_ends_at] no Date when mutant is no longer eligible to enroll; must be a date that occurs after mutant[eligibility_begins_at]
mutant[may_advise_beginning_at] no Mutant may be an advisor to students on or after this date.

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing parameters, or the parameters are malformed.
422 Unprocessable Entity – Probably a data validation error. Check response for details. Sample response:
{"power":["can't be blank"],"eligibility_ends_at":["is before the eligibility start date"]}
500 Internal Server Error – It’s probably our fault.

Update a Specific Mutant

PUT /api/v1/mutants/3 HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 105

{"mutant":{"power":"Invulnerability","may_advise_beginning_at":"2015-08-01"}}
curl -X "PUT" "https://mutant-school.herokuapp.com/api/v1/mutants/3" \
    -H "Content-Type: application/json" \
    -d "{\"mutant\":{\"power\":\"Invulnerability\",\"may_advise_beginning_at\":\"2015-08-01\"}}"
require 'net/http'
require 'net/https'
require 'json'

def send_request
  # Mutants#update (PUT )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/3')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "mutant" => {
                "power" => "Invulnerability",
                "may_advise_beginning_at" => "2015-08-01"
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Put.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Mutants#update (PUT https://mutant-school.herokuapp.com/api/v1/mutants/3)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/3",
    type: "PUT",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "mutant": {
            "power": "Invulnerability",
            "may_advise_beginning_at": "2015-08-01"
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 200 OK, with JSON structured like this:

{
  "id": 3,
  "mutant_name": "Superdave",
  "power": "Invulnerability",
  "real_name": "Dave",
  "created_at": "2016-02-03T03:37:24.709Z",
  "updated_at": "2016-02-03T03:44:00.123Z",
  "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
  "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
  "may_advise_beginning_at": "2015-08-01T00:00:00.000Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/3"
}

This updates a specific mutant.

HTTP Request

PUT https://mutant-school.herokuapp.com/api/v1/mutants/<ID>

PATCH https://mutant-school.herokuapp.com/api/v1/mutants/<ID>

URL Parameters

Parameter Description
ID The ID of the mutant to update

Payload

May be sent as any of the following:

Parameter Required Description
mutant[real_name] no Legal name
mutant[mutant_name] no Preferred name
mutant[power] no Superpower
mutant[eligibility_begins_at] no Date when eligibility to enroll begins
mutant[eligibility_ends_at] no Date when mutant is no longer eligible to enroll; must be a date that occurs after eligibility_begins_at
mutant[may_advise_beginning_at] no Mutant may be an advisor to students on or after this date.

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing parameters, or the parameters are malformed.
404 Not Found – There’s no mutant with that ID.
422 Unprocessable Entity – Probably a data validation error. Check response for details. Sample response:
{"power":["can't be blank"],"eligibility_ends_at":["is before the eligibility start date"]}
500 Internal Server Error – It’s probably our fault.

Delete a Specific Mutant

DELETE /api/v1/mutants/3 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "DELETE" "https://mutant-school.herokuapp.com/api/v1/mutants/3"
require 'net/http'
require 'net/https'

def send_request
  # Mutants#destroy (DELETE )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/3')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Delete.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Mutants#destroy (DELETE https://mutant-school.herokuapp.com/api/v1/mutants/3)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/3",
    type: "DELETE",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 204 No Content.

This deletes a specific mutant and any associated enrollments. If the mutant was an advisor, the advisees’ records are updated to nullify the advisor relationship.

HTTP Request

DELETE https://mutant-school.herokuapp.com/api/v1/mutants/<ID>

URL Parameters

Parameter Description
ID The ID of the mutant to delete

Errors

Error Code Meaning
404 Not Found – There’s no mutant with that ID. It may have already been deleted.
500 Internal Server Error – It’s probably our fault.

Terms

Get All Terms

GET /api/v1/terms HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest

require 'net/http'
require 'net/https'

def send_request
  # Terms#index (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Terms#index (GET https://mutant-school.herokuapp.com/api/v1/terms)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});
curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/terms"

Expected response: 200 OK, with JSON structured like this:

[
  {
    "id": 1,
    "begins_at": "2017-01-10T00:00:00.000Z",
    "ends_at": "2017-05-25T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/terms/1"
  },
  {
    "id": 2,
    "begins_at": "2016-01-10T00:00:00.000Z",
    "ends_at": "2016-05-25T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/terms/2"
  },
  {
    "id": 3,
    "begins_at": "2016-08-10T00:00:00.000Z",
    "ends_at": "2016-12-25T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/terms/3"
  }
]

This endpoint retrieves all terms.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/terms

Get a Specific Term

GET /api/v1/terms/3 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest

curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/terms/3"
require 'net/http'
require 'net/https'

def send_request
  # Terms#show (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/3')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Terms#show (GET https://mutant-school.herokuapp.com/api/v1/terms/3)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/3",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

The above command returns JSON structured like this:

{
  "id": 3,
  "begins_at": "2016-08-10T00:00:00.000Z",
  "ends_at": "2016-12-25T00:00:00.000Z",
  "created_at": "2016-02-02T21:26:26.496Z",
  "updated_at": "2016-02-02T21:26:26.496Z"
}

This endpoint retrieves a specific term.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/terms/<ID>

URL Parameters

Parameter Description
ID The ID of the term to retrieve

Errors

Error Code Meaning
404 Not Found – The specified term could not be found.
500 Internal Server Error – It’s probably our fault.

Create a Term

POST /api/v1/terms HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 58

{"term":{"begins_at":"2014-08-10","ends_at":"2014-12-25"}}
curl -X "POST" "https://mutant-school.herokuapp.com/api/v1/terms" \
    -H "Content-Type: application/json" \
    -d "{\"term\":{\"begins_at\":\"2014-08-10\",\"ends_at\":\"2014-12-25\"}}"
require 'net/http'
require 'net/https'
require 'json'

def send_request
  # Terms#create (POST )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "term" => {
                "begins_at" => "2014-08-10",
                "ends_at" => "2014-12-25"
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Post.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Terms#create (POST https://mutant-school.herokuapp.com/api/v1/terms)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms",
    type: "POST",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "term": {
            "begins_at": "2014-08-10",
            "ends_at": "2014-12-25"
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 201 Created, with JSON structured like this:

{
  "id": 4,
  "begins_at": "2014-08-10T00:00:00.000Z",
  "ends_at": "2014-12-25T00:00:00.000Z",
  "created_at": "2016-02-03T04:26:10.979Z",
  "updated_at": "2016-02-03T04:26:10.979Z"
}

This endpoint creates a new term.

HTTP Request

POST https://mutant-school.herokuapp.com/api/v1/terms

URL Parameters

Parameter Description
ID The ID of the term to retrieve

Payload

May be sent as any of the following:

Parameter Required Description
term[begins_at] yes Date when the term begins
term[ends_at] yes Date when the term ends

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing parameters, or the parameters are malformed.
422 Unprocessable Entity – Probably a data validation error. Check response for details. Sample response:
{"ends_at":["can't be blank"]}
500 Internal Server Error – It’s probably our fault.

Update a Specific Term

PUT /api/v1/terms/5 HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 33

{"term":{"ends_at":"2014-12-17"}}
curl -X "PUT" "https://mutant-school.herokuapp.com/api/v1/terms/5" \
    -H "Content-Type: application/json" \
    -d "{\"term\":{\"ends_at\":\"2014-12-17\"}}"
require 'net/http'
require 'net/https'
require 'json'

def send_request
  # Terms#update (PUT )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/5')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "term" => {
                "ends_at" => "2014-12-17"
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Put.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Terms#update (PUT https://mutant-school.herokuapp.com/api/v1/terms/5)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/5",
    type: "PUT",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "term": {
            "ends_at": "2014-12-17"
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 200 OK, with JSON structured like this:

{
  "id": 5,
  "begins_at": "2014-08-10T00:00:00.000Z",
  "ends_at": "2014-12-17T00:00:00.000Z",
  "created_at": "2016-02-03T04:30:10.976Z",
  "updated_at": "2016-02-03T04:31:47.016Z"
}

This endpoint updates a specific term.

HTTP Request

PUT https://mutant-school.herokuapp.com/api/v1/terms/<ID>

PATCH https://mutant-school.herokuapp.com/api/v1/terms/<ID>

URL Parameters

Parameter Description
ID The ID of the term to update

Payload

May be sent as any of the following:

Parameter Required Description
term[begins_at] no Date when the term begins
term[ends_at] no Date when the term ends

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing parameters, or the parameters are malformed.
422 Unprocessable Entity – Probably a data validation error. Check response for details. Sample response:
{"ends_at":["can't be blank"]}
500 Internal Server Error – It’s probably our fault.

Delete a Specific Term

DELETE /api/v1/terms/5 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "DELETE" "https://mutant-school.herokuapp.com/api/v1/terms/5"
require 'net/http'
require 'net/https'

def send_request
  # Terms#destroy (DELETE )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/5')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Delete.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Terms#destroy (DELETE https://mutant-school.herokuapp.com/api/v1/terms/5)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/5",
    type: "DELETE",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 204 No Content.

This deletes a specific mutant and any associated enrollments.

HTTP Request

DELETE https://mutant-school.herokuapp.com/api/v1/terms/<ID>

URL Parameters

Parameter Description
ID The ID of the term to delete

Errors

Error Code Meaning
404 Not Found – The specified term could not be found. It may have already been deleted.
500 Internal Server Error – It’s probably our fault.

Enrollments by Mutant

Get All Enrollments for a Specific Mutant

GET /api/v1/mutants/1/enrollments HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments"
require 'net/http'
require 'net/https'

def send_request
  # Enrollments#index (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#index (GET https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 200 OK, with JSON structured like this:

[
  {
    "id": 1,
    "student": {
      "id": 1,
      "mutant_name": "Fusionraptor",
      "power": "Creating small, controlled fusion reactions",
      "real_name": "Clarice Sloan",
      "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
      "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
      "may_advise_beginning_at": "2015-06-01T00:00:00.000Z",
      "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1"
    },
    "term": {
      "id": 2,
      "begins_at": "2016-01-10T00:00:00.000Z",
      "ends_at": "2016-05-25T00:00:00.000Z"
    },
    "created_at": "2016-02-02T21:27:31.461Z",
    "updated_at": "2016-02-02T21:27:31.461Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1"
  }
]

This endpoint retrieves all enrollments for the specified mutant.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/mutants/<MUTANT_ID>/enrollments

URL Parameters

Parameter Description
MUTANT_ID The ID of the enrolled mutant

Get a Specific Enrollment for a Specific Mutant

GET /api/v1/mutants/1/enrollments/1 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1"
require 'net/http'
require 'net/https'

def send_request
  # Enrollments#show (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#show (GET https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

The above command returns JSON structured like this:

{
  "id": 1,
  "student": {
    "id": 1,
    "mutant_name": "Fusionraptor",
    "power": "Creating small, controlled fusion reactions",
    "real_name": "Clarice Sloan",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2015-06-01T00:00:00.000Z"
  },
  "term": {
    "id": 2,
    "begins_at": "2016-01-10T00:00:00.000Z",
    "ends_at": "2016-05-25T00:00:00.000Z"
  },
  "created_at": "2016-02-02T21:27:31.461Z",
  "updated_at": "2016-02-02T21:27:31.461Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1"
}

This endpoint retrieves a specific enrollment for a specific mutant.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/mutants/<MUTANT_ID>/enrollments/<ID>

URL Parameters

Parameter Description
MUTANT_ID The ID of the enrolled mutant
ID The ID of the enrollment to retrieve

Errors

Error Code Meaning
404 Not Found – Either the mutant cannot be found, the enrollment cannot be found, or the enrollment is not associated with the mutant.
500 Internal Server Error – It’s probably our fault.

Create an Enrollment

POST /api/v1/mutants/1/enrollments HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 28

{"enrollment":{"term_id":4}}
curl -X "POST" "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments" \
    -H "Content-Type: application/json" \
    -d "{\"enrollment\":{\"term_id\":4}}"
require 'net/http'
require 'net/https'
require 'json'

def send_request
  # Enrollments#create (POST )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "enrollment" => {
                "term_id" => 4
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Post.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#create (POST https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments",
    type: "POST",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "enrollment": {
            "term_id": 4
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 201 Created, with JSON structured like this:

{
  "id": 6,
  "student": {
    "id": 1,
    "mutant_name": "Fusionraptor",
    "power": "Creating small, controlled fusion reactions",
    "real_name": "Clarice Sloan",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2015-06-01T00:00:00.000Z"
  },
  "term": {
    "id": 4,
    "begins_at": "2014-08-10T00:00:00.000Z",
    "ends_at": "2014-12-25T00:00:00.000Z"
  },
  "created_at": "2016-02-03T05:01:02.758Z",
  "updated_at": "2016-02-03T05:01:02.758Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/6"
}

This endpoint enrolls a mutant in a term.

HTTP Request

POST https://mutant-school.herokuapp.com/api/v1/mutants/<MUTANT_ID>/enrollments

URL Parameters

Parameter Description
MUTANT_ID The ID of the mutant to be enrolled.

Payload

May be sent as any of the following:

Parameter Required Description
enrollment[term_id] yes The ID of the term in which to enroll the mutant.

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing the term ID parameter, or the term ID could be invalid.
500 Internal Server Error. You might have provided an invalid or blank term ID.

Delete a Specific Enrollment

DELETE /api/v1/mutants/1/enrollments/10 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "DELETE" "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/10"
require 'net/http'
require 'net/https'

def send_request
  # Enrollments#destroy (DELETE )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/10')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Delete.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#destroy (DELETE https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/10)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/10",
    type: "DELETE",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 204 No Content.

This endpoint deletes a specific enrollment for a specific mutant.

HTTP Request

DELETE https://mutant-school.herokuapp.com/api/v1/mutants/<MUTANT_ID>/enrollments/<ID>

URL Parameters

Parameter Description
MUTANT_ID The ID of the enrolled mutant
ID The ID of the enrollment to delete

Errors

Error Code Meaning
404 Not Found – Either the mutant cannot be found, the enrollment cannot be found (possibly because it was already deleted), or the enrollment is not associated with the mutant.
500 Internal Server Error – It’s probably our fault.

Enrollments by Term

Get All Enrollments for a Specific Term

GET /api/v1/terms/2/enrollments HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments"
require 'net/http'
require 'net/https'

def send_request
  # Enrollments#index by Term (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#index by Term (GET https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 200 OK, with JSON structured like this:

[
  {
    "id": 1,
    "student": {
      "id": 1,
      "mutant_name": "Fusionraptor",
      "power": "Creating small, controlled fusion reactions",
      "real_name": "Clarice Sloan",
      "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
      "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
      "may_advise_beginning_at": "2015-06-01T00:00:00.000Z",
      "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1"
    },
    "term": {
      "id": 2,
      "begins_at": "2016-01-10T00:00:00.000Z",
      "ends_at": "2016-05-25T00:00:00.000Z"
    },
    "created_at": "2016-02-02T21:27:31.461Z",
    "updated_at": "2016-02-02T21:27:31.461Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/1"
  }
]

This endpoint retrieves all enrollments for the specified term.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/terms/<TERM_ID>/enrollments

URL Parameters

Parameter Description
TERM_ID The ID of the term for enrollment

Get a Specific Enrollment for a Specific Term

GET /api/v1/terms/2/enrollments/5 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/5"
require 'net/http'
require 'net/https'

def send_request
  # Enrollments#show by Term (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/5')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#show by Term (GET https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/5)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/5",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

The above command returns JSON structured like this:

{
  "id": 5,
  "student": {
    "id": 1,
    "mutant_name": "Fusionraptor",
    "power": "Creating small, controlled fusion reactions",
    "real_name": "Clarice Sloan",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2015-06-01T00:00:00.000Z"
  },
  "term": {
    "id": 2,
    "begins_at": "2016-01-10T00:00:00.000Z",
    "ends_at": "2016-05-25T00:00:00.000Z"
  },
  "created_at": "2016-02-03T05:00:43.628Z",
  "updated_at": "2016-02-03T05:00:43.628Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/5"
}

This endpoint retrieves a specific enrollment for a specific term.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/mutants/<TERM_ID>/enrollments/<ID>

URL Parameters

Parameter Description
TERM_ID The ID of the term of enrollment
ID The ID of the enrollment to retrieve

Errors

Error Code Meaning
404 Not Found – Either the term cannot be found, the enrollment cannot be found, or the enrollment is not associated with the term.
500 Internal Server Error – It’s probably our fault.

Create an Enrollment

POST /api/v1/terms/2/enrollments HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 30

{"enrollment":{"mutant_id":1}}
curl -X "POST" "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments" \
    -H "Content-Type: application/json" \
    -d "{\"enrollment\":{\"mutant_id\":1}}"
require 'net/http'
require 'net/https'
require 'json'

def send_request
  # Enrollments#create by Term (POST )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "enrollment" => {
                "mutant_id" => 1
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Post.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#create by Term (POST https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments",
    type: "POST",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "enrollment": {
            "mutant_id": 1
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 201 Created, with JSON structured like this:

{
  "id": 12,
  "student": {
    "id": 1,
    "mutant_name": "Fusionraptor",
    "power": "Creating small, controlled fusion reactions",
    "real_name": "Clarice Sloan",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2015-06-01T00:00:00.000Z"
  },
  "term": {
    "id": 2,
    "begins_at": "2016-01-10T00:00:00.000Z",
    "ends_at": "2016-05-25T00:00:00.000Z"
  },
  "created_at": "2016-02-03T06:39:48.319Z",
  "updated_at": "2016-02-03T06:39:48.319Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1/enrollments/12"
}

This endpoint enrolls a mutant in a term.

HTTP Request

POST https://mutant-school.herokuapp.com/api/v1/terms/<TERM_ID>/enrollments

URL Parameters

Parameter Description
TERM_ID The ID of the term in which to enroll the mutant.

Payload

May be sent as any of the following:

Parameter Required Description
enrollment[mutant_id] yes The ID of the mutant to be enrolled.

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing the mutant ID parameter.
500 Internal Server Error. You might have provided an invalid or blank mutant ID.

Delete a Specific Enrollment

DELETE /api/v1/terms/2/enrollments/17 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "DELETE" "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/17"
require 'net/http'
require 'net/https'

def send_request
  # Enrollments#destroy (DELETE )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/17')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Delete.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// Enrollments#destroy (DELETE https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/17)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/terms/2/enrollments/17",
    type: "DELETE",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 204 No Content.

This endpoint deletes a specific enrollment for a specific term.

HTTP Request

DELETE https://mutant-school.herokuapp.com/api/v1/terms/<TERM_ID>/enrollments/<ID>

URL Parameters

Parameter Description
TERM_ID The ID of the term of enrollment.
ID The ID of the enrollment to delete.

Errors

Error Code Meaning
404 Not Found – Either the term cannot be found, the enrollment cannot be found (possibly because it was already deleted), or the enrollment is not associated with the term.
500 Internal Server Error – It’s probably our fault.

Advisees

Get All Advisee Mutants for a Specific Advisor Mutant

GET /api/v1/mutants/2/advisees HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "GET" "https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees"
require 'net/http'
require 'net/https'

def send_request
  # My API (GET )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Get.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// My API (GET https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees",
    type: "GET",
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 200 OK, with JSON structured like this:

[
  {
    "id": 1,
    "mutant_name": "Fusionraptor",
    "power": "Creating small, controlled fusion reactions",
    "real_name": "Clarice Sloan",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2015-06-01T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/1"
  }
]

This endpoint retrieves all advisee mutants for the specified advisor mutant.

HTTP Request

GET https://mutant-school.herokuapp.com/api/v1/mutants/<ADVISOR_ID>/advisees

URL Parameters

Parameter Description
ADVISOR_ID The ID of the advisor mutant

Create an Advisor-Advisee Relationship

POST /api/v1/mutants/2/advisees HTTP/1.1
Content-Type: application/json
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest
Content-Length: 22

{"advisee":{"id":"4"}}
curl -X "POST" "https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees" \
    -H "Content-Type: application/json" \
    -d "{\"advisee\":{\"id\":\"4\"}}"
require 'net/http'
require 'net/https'
require 'json'

def send_request
  # My API (2) (POST )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER

    dict = {
            "advisee" => {
                "id" => "4"
            }
        }
    body = JSON.dump(dict)

    # Create Request
    req =  Net::HTTP::Post.new(uri)
    # Add headers
    req.add_field "Content-Type", "application/json"
    # Set header and body
    req.add_field "Content-Type", "application/json"
    req.body = body

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end
// My API (2) (POST https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees)

jQuery.ajax({
    url: "https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees",
    type: "POST",
    headers: {
        "Content-Type": "application/json",
    },
    contentType: "application/json",
    data: JSON.stringify({
        "advisee": {
            "id": "4"
        }
    })
})
.done(function(data, textStatus, jqXHR) {
    console.log("HTTP Request Succeeded: " + jqXHR.status);
    console.log(data);
})
.fail(function(jqXHR, textStatus, errorThrown) {
    console.log("HTTP Request Failed");
})
.always(function() {
    /* ... */
});

Expected response: 201 Created, with JSON structured like this:

{
  "id": 4,
  "mutant_name": "Megamarie",
  "power": "Super-human strength",
  "real_name": "Marie",
  "created_at": "2016-02-03T05:27:10.292Z",
  "updated_at": "2016-02-03T05:28:13.837Z",
  "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
  "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
  "may_advise_beginning_at": "2016-01-01T00:00:00.000Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/4",
  "advisor": {
    "id": 2,
    "mutant_name": "Superdave",
    "power": "Flight",
    "real_name": "Dave",
    "created_at": "2016-02-02T21:24:45.964Z",
    "updated_at": "2016-02-02T21:24:45.964Z",
    "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
    "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
    "may_advise_beginning_at": "2016-01-01T00:00:00.000Z",
    "url": "https://mutant-school.herokuapp.com/api/v1/mutants/2"
  }
}

This endpoint establishes an advisor-advisee relationship between two mutants.

HTTP Request

POST https://mutant-school.herokuapp.com/api/v1/mutants/<ADVISOR_ID>/advisees

URL Parameters

Parameter Description
ADVISOR_ID The ID of the advisor mutant

Payload

May be sent as any of the following:

Parameter Required Description
advisee[id] yes The ID of the mutant whose advisor is specified by ADVISOR_ID

Errors

Error Code Meaning
400 Bad Request – Your request is bad, and you should feel bad. You could be missing parameters, or the parameters are malformed.
404 Not Found – Either the advisor mutant or the advisee mutant cannot be found.
500 Internal Server Error. You might have provided an invalid or blank advisee ID.

Delete an Advisor-Advisee relationship

DELETE /api/v1/mutants/2/advisees/4 HTTP/1.1
Host: mutant-school.herokuapp.com
Connection: close
User-Agent: Paw/2.2.9 (Macintosh; OS X/10.11.2) GCDHTTPRequest


curl -X "DELETE" "https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees/4"
require 'net/http'
require 'net/https'

def send_request
  # My API (3) (DELETE )

  begin
    uri = URI('https://mutant-school.herokuapp.com/api/v1/mutants/2/advisees/4')

    # Create client
    http = Net::HTTP.new(uri.host, uri.port)
    http.use_ssl = true
    http.verify_mode = OpenSSL::SSL::VERIFY_PEER


    # Create Request
    req =  Net::HTTP::Delete.new(uri)

    # Fetch Request
    res = http.request(req)
    puts "Response HTTP Status Code: #{res.code}"
    puts "Response HTTP Response Body: #{res.body}"
  rescue StandardError => e
    puts "HTTP Request failed (#{e.message})"
  end
end

Expected response: 200 OK, with JSON structured like this:

{
  "id": 4,
  "mutant_name": "Megamarie",
  "power": "Super-human strength",
  "real_name": "Marie",
  "created_at": "2016-02-03T05:27:10.292Z",
  "updated_at": "2016-02-03T05:35:21.632Z",
  "eligibility_begins_at": "2010-01-01T00:00:00.000Z",
  "eligibility_ends_at": "2020-01-01T00:00:00.000Z",
  "may_advise_beginning_at": "2016-01-01T00:00:00.000Z",
  "url": "https://mutant-school.herokuapp.com/api/v1/mutants/4"
}

This endpoint removes an advisor-advisee relationship between two mutants. No records are destroyed. Rather, the advisee’s record is updated with a NULL advisor.

HTTP Request

DELETE https://mutant-school.herokuapp.com/api/v1/mutants/<ADVISOR_ID>/advisee/<ID>

URL Parameters

Parameter Description
ADVISOR_ID The ID of the advisor mutant
ID The ID of the advisee mutant

Errors

Error Code Meaning
404 Not Found – Either the advisor mutant or the advisee mutant cannot be found, or there is no such relationship between the two.
500 Internal Server Error – It’s probably our fault.