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-03-06 13:19:52 UTC",
    "campus_id": "1",
    "host": "burrito",
    "user_id": "60"
  }
}
201
{
  "id": 15,
  "begin_at": "2017-03-06T13:19:52.000Z",
  "end_at": null,
  "primary": true,
  "floor": null,
  "row": null,
  "post": null,
  "host": "burrito",
  "campus_id": 1,
  "user": {
    "id": 60,
    "login": "leiorgan",
    "url": "https://api.intra.42.fr/v2/users/leiorgan"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"location":{"begin_at":"2017-03-06 13:19:52 UTC","campus_id":"1","host":"burrito","user_id":"60"}}' "https://api.intra.42.fr/v2/locations"

{
  "id": 15,
  "begin_at": "2017-03-06T13:19:52.000Z",
  "end_at": null,
  "primary": true,
  "floor": null,
  "row": null,
  "post": null,
  "host": "burrito",
  "campus_id": 1,
  "user": {
    "id": 60,
    "login": "leiorgan",
    "url": "https://api.intra.42.fr/v2/users/leiorgan"
  }
}
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-03-06 13:19:52 UTC", campus_id: "1", host: "burrito", user_id: "60"}}
response = token.post("/v2/locations", params: params)
response.status
# => 201
response.parsed
# => {"id"=>15, "begin_at"=>"2017-03-06T13:19:52.000Z", "end_at"=>nil, "primary"=>true, "floor"=>nil, "row"=>nil, "post"=>nil, "host"=>"burrito", "campus_id"=>1, "user"=>{"id"=>60, "login"=>"leiorgan", "url"=>"https://api.intra.42.fr/v2/users/leiorgan"}}