POST /v2/community_services
Create a community service
Warning: When you use this call, we suggest that you know what you do. If you want to link a community service with this community_service, pass it trough the closes#index API call, with his community_services_attributes
array attribute. An email is automatically sent to the user when he is assigned to a community service.
live_help Notes
assignment
This action requires one of theses roles:
Basic staff
group_work
Requires following application scopes:
tig
settings Params
Param name | Description |
---|---|
community_service | optional , nil allowed . Must be a Hash |
community_service[duration] |
required
. Must be Fixnum
The duration. |
community_service[occupation] |
optional
, nil allowed
. Must be String
The occupation. Maximum length is 255. Allow blank length is true. |
community_service[schedule_at] |
optional
, nil allowed
. Must be Fixnum
The schedule at. Must be after today. Must be before 2 weeks from now. |
community_service[close_id] |
optional
, nil allowed
. Must be Fixnum
The close id. |
community_service[tiger_id] |
optional
, nil allowed
. Must be Fixnum
The tiger id. |
Examples
POST /v2/community_services.json
{
"community_service": {
"close_id": "2",
"duration": "14400",
"occupation": "Regarder Shrek, en entier, avec Mathieu Trentin",
"schedule_at": "2017-11-27 09:00:00 UTC",
"tiger_id": "2"
}
}
201
{
"id": 3,
"duration": 14400,
"schedule_at": "2017-11-27T06:00:00.000Z",
"occupation": "Regarder Shrek, en entier, avec Mathieu Trentin",
"state": "schedule",
"created_at": "2017-11-22T13:43:32.216Z",
"updated_at": "2017-11-22T13:43:32.216Z",
"close": {
"id": 2,
"reason": "Connecticut giants",
"state": "unclose",
"created_at": "2017-11-22T13:42:20.888Z",
"updated_at": "2017-11-22T13:42:20.987Z"
}
}
curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"community_service":{"close_id":"2","duration":"14400","occupation":"Regarder Shrek, en entier, avec Mathieu Trentin","schedule_at":"2017-11-27 09:00:00 UTC","tiger_id":"2"}}' "https://api.intra.42.fr/v2/community_services.json"
{
"id": 3,
"duration": 14400,
"schedule_at": "2017-11-27T06:00:00.000Z",
"occupation": "Regarder Shrek, en entier, avec Mathieu Trentin",
"state": "schedule",
"created_at": "2017-11-22T13:43:32.216Z",
"updated_at": "2017-11-22T13:43:32.216Z",
"close": {
"id": 2,
"reason": "Connecticut giants",
"state": "unclose",
"created_at": "2017-11-22T13:42:20.888Z",
"updated_at": "2017-11-22T13:42:20.987Z"
}
}
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 = {community_service: {close_id: "2", duration: "14400", occupation: "Regarder Shrek, en entier, avec Mathieu Trentin", schedule_at: "2017-11-27 09:00:00 UTC", tiger_id: "2"}}
response = token.post("/v2/community_services.json", params: params)
response.status
# => 201
response.parsed
# => {"id"=>3, "duration"=>14400, "schedule_at"=>"2017-11-27T06:00:00.000Z", "occupation"=>"Regarder Shrek, en entier, avec Mathieu Trentin", "state"=>"schedule", "created_at"=>"2017-11-22T13:43:32.216Z", "updated_at"=>"2017-11-22T13:43:32.216Z", "close"=>{"id"=>2, "reason"=>"Connecticut giants", "state"=>"unclose", "created_at"=>"2017-11-22T13:42:20.888Z", "updated_at"=>"2017-11-22T13:42:20.987Z"}}