Skip to content

bimanyunugroho/customer-api

Repository files navigation

Laravel API Customer Invoices

Tentang Proyek

Proyek ini dibuat untuk membantu kalian dalam belajar penggunaan RestAPI (Creating RestAPI or Consume API). Terlepas itu pula proyek ini juga bisa kalian kembangkan untuk pengembangan yang lebih lanjut lagi.

Endpoints

Params

  • eq : Sama Dengan
  • lt : Kurang Dari
  • gt : Lebih Dari
  • lte : Kurang Dari Sama Dengan
  • gte : Lebih Dari Sama Dengan
  • ne : Kurang Dari

Get Data

Mengambil data tertentu dari server.

  • URL: /api/v1/{id}
  • Metode: GET
  • Paramter:
    • id (int) - ID data yang diinginkan.

Contoh Permintaan

http
GET /api/v1/customers

Contoh Respons

json
{
    "data": {
        "id": 1,
        "name": "Crona-Roberts",
        "type": "B",
        "email": "pmurazik@ruecker.com",
        "address": "8880 Arielle Prairie",
        "city": "North Austen",
        "state": "Minnesota",
        "postalCode": "09676-3256"
    }
}

Menambahkan Data Baru

Menambahkan data baru ke server.

  • URL: /api/v1/customers
  • Metode: POST
  • Body:
json
{
    "name": "Crona-Roberts",
    "type": "B",
    "email": "pmurazik@gmail.com",
    "address": "8880 Arielle Prairie",
    "city": "North Austen",
    "state": "Minnesota",
    "postalCode": "09676-3256"
}

Contoh Permintaan

http
POST /api/v1/customers
Content-Type: application/json
Accept: application/json

json
{
    "name": "Crona-Roberts",
    "type": "B",
    etc...
}

Contoh Respons

json
{
    "data": {
        "id": 233,
        "name": "Crona-Roberts",
        "type": "B",
        "email": "pmurazik@gmail.com",
        "address": "8880 Arielle Prairie",
        "city": "North Austen",
        "state": "Minnesota",
        "postalCode": "09676-3256"
    }
}

Mengubah Data Baru

Mengubah data baru ke server.

  • URL: /api/v1/customers/{id}
  • Metode: PUT
  • Body:
json
{
    "name": "Crona-Roberts update",
    "type": "B",
    "email": "pmurazik@gmail.com",
    etc...
}

Contoh Permintaan

http
POST /api/v1/customers/{id}
Content-Type: application/json
Accept: application/json

json
{
    "name": "Crona-Roberts update",
    "type": "B",
    etc...
}

Contoh Respons

json
{
    "data": {
        "id": 1,
        "name": "Crona-Roberts update",
        "type": "B",
        "email": "pmurazik@gmail.com",
        etc...
    }
}

Bulk Insert Data Invoive by CustomerID

Contoh Permintaan

  • URL: api/v1/invoices/bulk
  • Metode: POST
  • Body:
json
{
    "name": "Crona-Roberts update",
    "type": "B",
    "email": "pmurazik@gmail.com",
    etc...
}

Contoh Response

json 
[
    {
    "customerId": 1,
    "amount": 90000,
    "status": "P",
    "billedDate": "2022-01-12 06:51:16",
    "paidDate": "2022-01-14 06:51:16"
    },
    {
    "customerId": 1,
    "amount": 100000,
    "status": "B",
    "billedDate": "2019-07-24 07:53:25",
    "paidDate": null
    }
]

Kontribusi

LinkedIn

Lisensi

DEVABI - 2023