live_help Notes

assignment This action requires one of theses roles: Advanced staff, Events manager

settings Params

Param name Description
event optional , nil allowed . Must be a Hash
event[name] required . Must be String

The name.

event[begin_at] required . Must be Fixnum

The begin at. .

event[end_at] required . Must be Fixnum

The end at. . Beginning must be after ending.

event[description] required . Must be String

The description.

event[location] optional , nil allowed . Must be String

The location. Maximum length is 255.

event[kind] required . Must be one of: pedago, rush, piscine, partnership, meet, conference, meet_up, event, association, speed_working, hackathon, workshop, challenge, other, extern.

The kind.

event[max_people] optional , nil allowed . Must be Fixnum

The max people.

event[prohibition_of_cancellation] optional , nil allowed . Must be Fixnum

The prohibition of cancellation.

event[activate_waitlist] optional , nil allowed . Must be String

The activate waitlist.

event[events_themes_attributes] optional , nil allowed . Must be an Array of nested elements

The events themes attributes.

event[events_themes_attributes][id] optional , nil allowed . Must be Fixnum

The id.

event[events_themes_attributes][theme_id] required . Must be Fixnum

The theme id. Must be unique in the scope of a given event.

event[events_themes_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

event[events_themes_attributes][theme_attributes] optional , nil allowed . Must be an Array of nested elements

The theme attributes.

event[events_themes_attributes][theme_attributes][id] optional , nil allowed . Must be Fixnum

The id.

event[events_themes_attributes][theme_attributes][name] required . Must be String

The name. Must be unique.

event[cursus_ids] optional , nil allowed . Must be an array of Integer

The cursus ids.

event[campus_ids] optional , nil allowed . Must be an array of Integer

The campus ids.

POST /v2/events
{
  "event": {
    "begin_at": "2017-11-25 13:43:10 UTC",
    "campus_ids": [
      "1"
    ],
    "cursus_ids": [
      "1"
    ],
    "events_themes_attributes": [
      {
        "theme_id": 11
      },
      {
        "theme_attributes": {
          "name": "My awesome new theme"
        }
      },
      {
        "theme_attributes": {
          "name": "My awesome new theme 2"
        }
      }
    ],
    "activate_waitlist": "true",
    "description": "A fucking great event",
    "end_at": "2017-11-29 13:43:10 UTC",
    "kind": "workshop",
    "location": "Holodeck",
    "max_people": "120",
    "prohibition_of_cancellation": 10,
    "name": "Rainbowcat festival 🌈"
  }
}
201
{
  "id": 5,
  "name": "Rainbowcat festival 🌈",
  "description": "A fucking great event",
  "location": "Holodeck",
  "kind": "workshop",
  "max_people": 120,
  "nbr_subscribers": 0,
  "begin_at": "2017-11-25T13:43:10.000Z",
  "end_at": "2017-11-29T13:43:10.000Z",
  "campus_ids": [
    1
  ],
  "cursus_ids": [
    1
  ],
  "themes": [
    {
      "created_at": "2018-10-21T16:35:38.782Z",
      "id": 11,
      "name": "Security",
      "updated_at": "2018-10-21T16:35:38.782Z"
    },
    {
      "created_at": "2019-01-14T15:06:56.968Z",
      "id": 42,
      "name": "My awesome new theme",
      "updated_at": "2019-01-14T15:06:56.968Z"
    },
    {
      "created_at": "2019-01-14T15:06:56.968Z",
      "id": 43,
      "name": "My awesome new theme 2",
      "updated_at": "2019-01-14T15:06:56.968Z"
    }
  ],
  "waitlist": {
    "created_at": "2019-01-14T16:20:43.412Z",
    "id": 389,
    "updated_at": "2019-01-14T16:20:43.412Z",
    "waitlistable_id": 5,
    "waitlistable_type": "Event"
  },
  "prohibition_of_cancellation": 10,
  "created_at": "2017-11-22T13:43:37.609Z",
  "updated_at": "2017-11-22T13:43:37.633Z"
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"event":{"begin_at":"2017-11-25 13:43:10 UTC","campus_ids":["1"],"cursus_ids":["1"],"events_themes_attributes":[{"theme_id":11},{"theme_attributes":{"name":"My awesome new theme"}},{"theme_attributes":{"name":"My awesome new theme 2"}}],"activate_waitlist":"true","description":"A fucking great event","end_at":"2017-11-29 13:43:10 UTC","kind":"workshop","location":"Holodeck","max_people":"120","prohibition_of_cancellation":10,"name":"Rainbowcat festival 🌈"}}' "https://api.intra.42.fr/v2/events"

{
  "id": 5,
  "name": "Rainbowcat festival 🌈",
  "description": "A fucking great event",
  "location": "Holodeck",
  "kind": "workshop",
  "max_people": 120,
  "nbr_subscribers": 0,
  "begin_at": "2017-11-25T13:43:10.000Z",
  "end_at": "2017-11-29T13:43:10.000Z",
  "campus_ids": [
    1
  ],
  "cursus_ids": [
    1
  ],
  "themes": [
    {
      "created_at": "2018-10-21T16:35:38.782Z",
      "id": 11,
      "name": "Security",
      "updated_at": "2018-10-21T16:35:38.782Z"
    },
    {
      "created_at": "2019-01-14T15:06:56.968Z",
      "id": 42,
      "name": "My awesome new theme",
      "updated_at": "2019-01-14T15:06:56.968Z"
    },
    {
      "created_at": "2019-01-14T15:06:56.968Z",
      "id": 43,
      "name": "My awesome new theme 2",
      "updated_at": "2019-01-14T15:06:56.968Z"
    }
  ],
  "waitlist": {
    "created_at": "2019-01-14T16:20:43.412Z",
    "id": 389,
    "updated_at": "2019-01-14T16:20:43.412Z",
    "waitlistable_id": 5,
    "waitlistable_type": "Event"
  },
  "prohibition_of_cancellation": 10,
  "created_at": "2017-11-22T13:43:37.609Z",
  "updated_at": "2017-11-22T13:43:37.633Z"
}
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 = {event: {begin_at: "2017-11-25 13:43:10 UTC", campus_ids: ["1"], cursus_ids: ["1"], events_themes_attributes: [{theme_id: 11}, {theme_attributes: {name: "My awesome new theme"}}, {theme_attributes: {name: "My awesome new theme 2"}}], activate_waitlist: "true", description: "A fucking great event", end_at: "2017-11-29 13:43:10 UTC", kind: "workshop", location: "Holodeck", max_people: "120", prohibition_of_cancellation: 10, name: "Rainbowcat festival 🌈"}}
response = token.post("/v2/events", params: params)
response.status
# => 201
response.parsed
# => {"id"=>5, "name"=>"Rainbowcat festival 🌈", "description"=>"A fucking great event", "location"=>"Holodeck", "kind"=>"workshop", "max_people"=>120, "nbr_subscribers"=>0, "begin_at"=>"2017-11-25T13:43:10.000Z", "end_at"=>"2017-11-29T13:43:10.000Z", "campus_ids"=>[1], "cursus_ids"=>[1], "themes"=>[{"created_at"=>"2018-10-21T16:35:38.782Z", "id"=>11, "name"=>"Security", "updated_at"=>"2018-10-21T16:35:38.782Z"}, {"created_at"=>"2019-01-14T15:06:56.968Z", "id"=>42, "name"=>"My awesome new theme", "updated_at"=>"2019-01-14T15:06:56.968Z"}, {"created_at"=>"2019-01-14T15:06:56.968Z", "id"=>43, "name"=>"My awesome new theme 2", "updated_at"=>"2019-01-14T15:06:56.968Z"}], "waitlist"=>{"created_at"=>"2019-01-14T16:20:43.412Z", "id"=>389, "updated_at"=>"2019-01-14T16:20:43.412Z", "waitlistable_id"=>5, "waitlistable_type"=>"Event"}, "prohibition_of_cancellation"=>10, "created_at"=>"2017-11-22T13:43:37.609Z", "updated_at"=>"2017-11-22T13:43:37.633Z"}