GET /v2/products/:id
Get a product
GET /v2/campus/:campus_id/products/:id
Get a product of the given Id, associated with the given Campus
settings Params
Param name | Description |
---|---|
id |
required
. Must be String
The requested id |
campus_id |
optional
. Must be String
The campus id or slug |
Examples
GET /v2/products/1
200
{
"id": 1,
"name": "Jakku",
"description": "Utapau",
"price": 100,
"quantity": 20,
"begin_at": null,
"end_at": null,
"category_id": 1,
"created_at": "2017-11-22T13:41:20.457Z",
"updated_at": "2017-11-22T13:41:20.498Z",
"kind": "auto",
"slug": "jakku",
"image": {
"url": "/uploads/product/image/1/logo.png",
"thumb": {
"url": "/uploads/product/image/1/thumb_logo.png"
}
},
"is_uniq": true,
"one_time_purchase": false
}
curl -H "Authorization: Bearer YOUR_ACCESS_TOKEN" "https://api.intra.42.fr/v2/products/1"
{
"id": 1,
"name": "Jakku",
"description": "Utapau",
"price": 100,
"quantity": 20,
"begin_at": null,
"end_at": null,
"category_id": 1,
"created_at": "2017-11-22T13:41:20.457Z",
"updated_at": "2017-11-22T13:41:20.498Z",
"kind": "auto",
"slug": "jakku",
"image": {
"url": "/uploads/product/image/1/logo.png",
"thumb": {
"url": "/uploads/product/image/1/thumb_logo.png"
}
},
"is_uniq": true,
"one_time_purchase": false
}
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
response = token.get("/v2/products/1")
response.status
# => 200
response.parsed
# => {"id"=>1, "name"=>"Jakku", "description"=>"Utapau", "price"=>100, "quantity"=>20, "begin_at"=>nil, "end_at"=>nil, "category_id"=>1, "created_at"=>"2017-11-22T13:41:20.457Z", "updated_at"=>"2017-11-22T13:41:20.498Z", "kind"=>"auto", "slug"=>"jakku", "image"=>{"url"=>"/uploads/product/image/1/logo.png", "thumb"=>{"url"=>"/uploads/product/image/1/thumb_logo.png"}}, "is_uniq"=>true, "one_time_purchase"=>false}