settings Params

Param name Description
id required . Must be String

The requested id

campus_id optional . Must be String

The campus id or slug

product optional , nil allowed . Must be a Hash
product[name] optional . Must be String

The name. Must be unique.

product[description] optional . Must be String

The description.

product[price] optional . Must be Fixnum

The price.

product[quantity] optional , nil allowed . Must be Fixnum

The quantity.

product[begin_at] optional , nil allowed . Must be DateTime

The begin at.

product[end_at] optional , nil allowed . Must be DateTime

The end at.

product[category_id] optional . Must be Fixnum

The category id.

product[kind] optional . Must be one of: user, manager, auto.

The kind.

product[slug] optional , nil allowed . Must be String

The slug.

product[image] optional . Must be File

The image.

product[is_uniq] optional , nil allowed . Must be one of: true, false.

Is it is uniq ?

product[one_time_purchase] optional , nil allowed . Must be one of: true, false.

Is it one time purchase ?

product[campus_products_attributes] optional , nil allowed . Must be an Array of nested elements

The campus products attributes.

product[campus_products_attributes][campus_id] optional . Must be Fixnum

The campus id.

product[campus_products_attributes][_destroy] optional , nil allowed . Must be String

The destroy.

comments powered by <span class='logo-disqus'>Disqus</span>
PUT /v2/products/1
{
  "product": {
    "campus_products_attributes": [
      {
        "campus_id": "3"
      }
    ],
    "name": "Chuck Norris programs do not accept input.",
    "description": "Kamino",
    "price": "10",
    "quantity": "10",
    "begin_at": "2017-05-22 13:43:52 UTC",
    "end_at": "2023-11-22 13:43:52 UTC",
    "category_id": "1",
    "kind": "auto",
    "slug": "DQar",
    "image": {
      "tempfile": [],
      "original_filename": "logo.png",
      "content_type": "image/png+xml",
      "headers": "Content-Disposition: form-data; name=\"product[image]\"; filename=\"logo.png\"\r\nContent-Type: image/png+xml\r\nContent-Length: 3058\r\n"
    },
    "is_uniq": "true",
    "one_time_purchase": "true"
  }
}
204
curl  -X PUT -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"product":{"campus_products_attributes":[{"campus_id":"3"}],"name":"Chuck Norris programs do not accept input.","description":"Kamino","price":"10","quantity":"10","begin_at":"2017-05-22 13:43:52 UTC","end_at":"2023-11-22 13:43:52 UTC","category_id":"1","kind":"auto","slug":"DQar","image":{"tempfile":[],"original_filename":"logo.png","content_type":"image/png+xml","headers":"Content-Disposition: form-data; name=\"product[image]\"; filename=\"logo.png\"\r\nContent-Type: image/png+xml\r\nContent-Length: 3058\r\n"},"is_uniq":"true","one_time_purchase":"true"}}' "https://api.intra.42.fr/v2/products/1"
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 = {product: {campus_products_attributes: [{campus_id: "3"}], name: "Chuck Norris programs do not accept input.", description: "Kamino", price: "10", quantity: "10", begin_at: "2017-05-22 13:43:52 UTC", end_at: "2023-11-22 13:43:52 UTC", category_id: "1", kind: "auto", slug: "DQar", image: {tempfile: [], original_filename: "logo.png", content_type: "image/png+xml", headers: "Content-Disposition: form-data; name="product[image]"; filename="logo.png"
Content-Type: image/png+xml
Content-Length: 3058
"}, is_uniq: "true", one_time_purchase: "true"}}
response = token.put("/v2/products/1", params: params)
response.status
# => 204
response.parsed
# =>