live_help Notes

assignment This action requires one of theses roles: Basic staff

settings Params

Param name Description
user_id optional . Must be String

The user id or slug

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

The user id.

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

The begin at. If not set default value is the current date.

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

The end at.

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.

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"}}