live_help Notes

assignment This action requires one of theses roles: Basic staff

settings Params

Param name Description
location optional , nil allowed . Must be a Hash
location[user_id] required . Must be Fixnum

The user id.

location[begin_at] required . Must be DateTime

The begin at.

location[end_at] optional , nil allowed . Must be DateTime

The end at.

location[floor] optional , nil allowed . Must be Fixnum

The floor.

location[row] optional , nil allowed . Must be Fixnum

The row.

location[post] optional , nil allowed . Must be Fixnum

The post.

location[primary] optional , nil allowed . Must be one of: true, false.

Is it primary ?

location[host] required . Must be String

The host. Must be unique in the scope of a given campus id and end at.

location[campus_id] required . Must be Fixnum

The campus id.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/locations
{
  "location": {
    "begin_at": "2017-11-22 11:43:10 UTC",
    "campus_id": "2",
    "host": "burrito",
    "user_id": "56"
  }
}
201
{
  "id": 16,
  "begin_at": "2017-11-22T11:43:10.000Z",
  "end_at": null,
  "primary": true,
  "floor": null,
  "row": null,
  "post": null,
  "host": "burrito",
  "campus_id": 2,
  "user": {
    "id": 56,
    "login": "pdameron",
    "url": "https://api.intra.42.fr/v2/users/pdameron"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"location":{"begin_at":"2017-11-22 11:43:10 UTC","campus_id":"2","host":"burrito","user_id":"56"}}' "https://api.intra.42.fr/v2/locations"

{
  "id": 16,
  "begin_at": "2017-11-22T11:43:10.000Z",
  "end_at": null,
  "primary": true,
  "floor": null,
  "row": null,
  "post": null,
  "host": "burrito",
  "campus_id": 2,
  "user": {
    "id": 56,
    "login": "pdameron",
    "url": "https://api.intra.42.fr/v2/users/pdameron"
  }
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token

params = {location: {begin_at: "2017-11-22 11:43:10 UTC", campus_id: "2", host: "burrito", user_id: "56"}}
response = token.post("/v2/locations", params: params)
response.status
# => 201
response.parsed
# => {"id"=>16, "begin_at"=>"2017-11-22T11:43:10.000Z", "end_at"=>nil, "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"burrito", "campus_id"=>2, "user"=>{"id"=>56, "login"=>"pdameron", "url"=>"https://api.intra.42.fr/v2/users/pdameron"}}