live_help Notes

assignment This action requires one of theses roles: Translater

settings Params

Param name Description
translation optional , nil allowed . Must be a Hash
translation[id] optional , nil allowed . Must be Fixnum

The id.

translation[translatable_id] required . Must be Fixnum

The translatable id.

translation[translatable_type] optional , nil allowed . Must be String

The translatable type.

translation[language_id] required . Must be Fixnum

The language id. Must be unique in the scope of a given translatable type and translatable.

translation[fields] required . Must be String

The fields.

translation[created_at] optional , nil allowed . Must be DateTime

The created at.

translation[updated_at] optional , nil allowed . Must be DateTime

The updated at.

translation[user_id] optional , nil allowed . Must be Fixnum

The user id.

translation[default] optional , nil allowed . Must be one of: true, false.

Is it default ? Default to false.

translation[up_to_date] optional , nil allowed . Must be one of: true, false.

Is it up to date ? Default to true.

translation[translations_structure_id] optional , nil allowed . Must be Fixnum

The translations structure id.

translation[file] optional , nil allowed . Must be String

The file.

comments powered by <span class='logo-disqus'>Disqus</span>
POST /v2/translations
{
  "translation": {
    "fields": "{\"description\":\"You passed the Piscine test. Welcome to 42!\"}",
    "language_id": "3",
    "translatable_id": "1",
    "translatable_type": "Achievement"
  }
}
201
{
  "id": 99,
  "translatable_id": 1,
  "translatable_type": "Achievement",
  "language_id": 3,
  "fields": "{\"description\":\"You passed the Piscine test. Welcome to 42!\"}",
  "created_at": "2017-11-22T13:44:17.382Z",
  "updated_at": "2017-11-22T13:44:17.382Z",
  "user_id": null,
  "default": false,
  "up_to_date": true,
  "translations_structure_id": 6,
  "translations_structure": {
    "id": 6,
    "searchable_by": [
      "name"
    ],
    "identified_by": [
      "name"
    ],
    "structures_kind": "simple",
    "up_to_date": true,
    "fields_organisation": {
      "name": "string",
      "description": "string"
    },
    "type_name": "Achievement",
    "created_at": "2017-11-22T13:40:59.398Z",
    "updated_at": "2017-11-22T13:40:59.398Z"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"translation":{"fields":"{\"description\":\"You passed the Piscine test. Welcome to 42!\"}","language_id":"3","translatable_id":"1","translatable_type":"Achievement"}}' "https://api.intra.42.fr/v2/translations"

{
  "id": 99,
  "translatable_id": 1,
  "translatable_type": "Achievement",
  "language_id": 3,
  "fields": "{\"description\":\"You passed the Piscine test. Welcome to 42!\"}",
  "created_at": "2017-11-22T13:44:17.382Z",
  "updated_at": "2017-11-22T13:44:17.382Z",
  "user_id": null,
  "default": false,
  "up_to_date": true,
  "translations_structure_id": 6,
  "translations_structure": {
    "id": 6,
    "searchable_by": [
      "name"
    ],
    "identified_by": [
      "name"
    ],
    "structures_kind": "simple",
    "up_to_date": true,
    "fields_organisation": {
      "name": "string",
      "description": "string"
    },
    "type_name": "Achievement",
    "created_at": "2017-11-22T13:40:59.398Z",
    "updated_at": "2017-11-22T13:40:59.398Z"
  }
}
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 = {translation: {fields: "{"description":"You passed the Piscine test. Welcome to 42!"}", language_id: "3", translatable_id: "1", translatable_type: "Achievement"}}
response = token.post("/v2/translations", params: params)
response.status
# => 201
response.parsed
# => {"id"=>99, "translatable_id"=>1, "translatable_type"=>"Achievement", "language_id"=>3, "fields"=>"{\"description\":\"You passed the Piscine test. Welcome to 42!\"}", "created_at"=>"2017-11-22T13:44:17.382Z", "updated_at"=>"2017-11-22T13:44:17.382Z", "user_id"=>nil, "default"=>false, "up_to_date"=>true, "translations_structure_id"=>6, "translations_structure"=>{"id"=>6, "searchable_by"=>["name"], "identified_by"=>["name"], "structures_kind"=>"simple", "up_to_date"=>true, "fields_organisation"=>{"name"=>"string", "description"=>"string"}, "type_name"=>"Achievement", "created_at"=>"2017-11-22T13:40:59.398Z", "updated_at"=>"2017-11-22T13:40:59.398Z"}}