live_help Notes

assignment This action requires one of theses roles: Advanced tutor

settings Params

Param name Description
user_id optional . Must be String

The user id or slug

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

The user id.

patronage[godfather_id] required . Must be Fixnum

The godfather id.

patronage[ongoing] optional , nil allowed . Must be one of: true, false.

Is it ongoing ? Default to true.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/patronages
{
  "patronage": {
    "godfather_id": "4",
    "user_id": "3"
  }
}
201
{
  "id": 123,
  "user_id": 3,
  "godfather_id": 4,
  "ongoing": true,
  "created_at": "2017-11-22T13:43:50.782Z",
  "updated_at": "2017-11-22T13:43:50.794Z",
  "user": {
    "id": 3,
    "login": "gargamel",
    "url": "https://api.intra.42.fr/v2/users/gargamel"
  },
  "godfather": {
    "id": 4,
    "login": "kpedro",
    "url": "https://api.intra.42.fr/v2/users/kpedro"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"patronage":{"godfather_id":"4","user_id":"3"}}' "https://api.intra.42.fr/v2/patronages"

{
  "id": 123,
  "user_id": 3,
  "godfather_id": 4,
  "ongoing": true,
  "created_at": "2017-11-22T13:43:50.782Z",
  "updated_at": "2017-11-22T13:43:50.794Z",
  "user": {
    "id": 3,
    "login": "gargamel",
    "url": "https://api.intra.42.fr/v2/users/gargamel"
  },
  "godfather": {
    "id": 4,
    "login": "kpedro",
    "url": "https://api.intra.42.fr/v2/users/kpedro"
  }
}
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 = {patronage: {godfather_id: "4", user_id: "3"}}
response = token.post("/v2/patronages", params: params)
response.status
# => 201
response.parsed
# => {"id"=>123, "user_id"=>3, "godfather_id"=>4, "ongoing"=>true, "created_at"=>"2017-11-22T13:43:50.782Z", "updated_at"=>"2017-11-22T13:43:50.794Z", "user"=>{"id"=>3, "login"=>"gargamel", "url"=>"https://api.intra.42.fr/v2/users/gargamel"}, "godfather"=>{"id"=>4, "login"=>"kpedro", "url"=>"https://api.intra.42.fr/v2/users/kpedro"}}