Genres

Genre merupakan tipe dari book genre itu sendiri untuk mengklasifikasikan genre berdasarkan buku-buku.

Get All Genres

Get All

GET https://openapi.omdo.site/api/genres

{
  "success": true,
  "message": "Genres retrieved successfully",
  "data": [
    {
      "id": 1,
      "name": "Genre Name",
      "description": "Genre Description",
      "genre_id": 1,
      "category": {
        "id": 1,
        "name": "Category Name",
        "description": "Category Description"
      }
    }
  ]
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://openapi.omdo.site0/api/genres',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Get Genres by ID

GET https://openapi.omdo.site/api/genres/{id}

Path Parameters

Name
Type
Description

id*

integer

Genre ID for get specify data books

{
  "success": true,
  "message": "Genre retrieved successfully",
  "data": {
    "id": 1,
    "name": "Genre Name",
    "description": "Genre Description",
    "genre_id": 1,
    "category": {
      "id": 1,
      "name": "Category Name",
      "description": "Category Description"
    }
  }
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://openapi.omdo.site/api/genres/2',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'GET',
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Create Genre

POST https://openapi.omdo.site/api/genres

application/json

Headers

Name
Type
Description

Authorization*

String

Token JWT with Bearer type

Request Body

Name
Type
Description

name*

String

Genre name

description

String

Genre description

category_id*

String

Category ID

{
  "success": true,
  "message": "Genre created successfully",
  "data": {
    "id": 1,
    "name": "Genre Name",
    "description": "Genre Description",
    "genre_id": 1,
    "category": {
      "id": 1,
      "name": "Category Name",
      "description": "Category Description"
    }
  }
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://openapi.omdo.site/api/genres',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
  "name": "Genre Name",
  "description": "Genre Description",
  "category_id": 1
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Update Genre

PUT https://openapi.omdo.site/api/genres/{id}

application/json

Path Parameters

Name
Type
Description

id*

Integer

Genre id

Headers

Name
Type
Description

Authorization*

String

Token JWT with Bearer type

Request Body

Name
Type
Description

name*

String

Genre name

description

String

Genre description

category_id

String

Category ID

{
  "success": true,
  "message": "Genre updated successfully",
  "data": {
    "id": 1,
    "name": "Genre Name",
    "description": "Genre Description",
    "genre_id": 1,
    "category": {
      "id": 1,
      "name": "Category Name",
      "description": "Category Description"
    }
  }
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://openapi.omdo.site/api/genres',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'PUT',
  CURLOPT_POSTFIELDS =>'{
  "name": "Genre Name",
  "description": "Genre Description",
  "category_id": 1
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Delete Genre

DELETE https://openapi.omdo.site/api/genres/{id}

Path Parameters

Name
Type
Description

id*

integer

Genre ID for get specify data books

{
  "success": true,
  "message": "Genre has been deleted",
  "data": {}
}
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://openapi.omdo.site/api/genres/2',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'DELETE',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer 39|dqFhIMxujGfOfJlp1ddc6ktU2tqg1vENe6j7BfC6'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

Last updated