live_help Notes

assignment This action requires one of theses roles: Student tutor

settings Params

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

The id.

transaction[value] required . Must be Fixnum

The value.

transaction[user_id] required . Must be Fixnum

The user id. Must be unique in the scope of a given transactable type and transactable.

transaction[transactable_id] optional , nil allowed . Must be Fixnum

The transactable id.

transaction[transactable_type] required . Must be String

The transactable type.

transaction[reason] required . Must be String

The reason.

POST /v2/transactions
{
  "transaction": {
    "value": 5,
    "user_id": 123,
    "transactable_type": "Tuteur api",
    "reason": "cadeau"
  }
}
201
{
  "id": 6,
  "value": 5,
  "user_id": 123,
  "transactable_id": null,
  "transactable_type": "Tuteur api",
  "reason": "cadeau",
  "user": {
    "id": 123,
    "login": "jeanne",
    "url": "https://api.intra.42.fr/v2/users/jeanne"
  }
}
curl  -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"transaction":{"value":5,"user_id":123,"transactable_type":"Tuteur api","reason":"cadeau"}}' "https://api.intra.42.fr/v2/transactions"

{
  "id": 6,
  "value": 5,
  "user_id": 123,
  "transactable_id": null,
  "transactable_type": "Tuteur api",
  "reason": "cadeau",
  "user": {
    "id": 123,
    "login": "jeanne",
    "url": "https://api.intra.42.fr/v2/users/jeanne"
  }
}
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 = {transaction: {value: 5, user_id: 123, transactable_type: "Tuteur api", reason: "cadeau"}}
response = token.post("/v2/transactions", params: params)
response.status
# => 201
response.parsed
# => {"id"=>6, "value"=>5, "user_id"=>123, "transactable_id"=>nil, "transactable_type"=>"Tuteur api", "reason"=>"cadeau", "user"=>{"id"=>123, "login"=>"jeanne", "url"=>"https://api.intra.42.fr/v2/users/jeanne"}}