#get status list
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.project.get_project_status_list' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--header 'Content-Type: application/json' \
--data '{
    "limit_start": 0,
    "limit_page_length": 0
}'

#response
{
    "message": [
        {
            "status": "Pending approval",
            "label": "Chờ phê duyệt",
            "color": "Warning",
            "index": 1
        },
        {
            "status": "Approved",
            "label": "Đã được phê duyệt",
            "color": "Success",
            "index": 2
        },
        {
            "status": "Rejected",
            "label": "Từ chối",
            "color": "Danger",
            "index": 3
        },
        {
            "status": "Cancelled",
            "label": "HỦY BỎ",
            "color": "Danger",
            "index": 4
        }
    ]
}


#get project list
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.project.get_list' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--header 'Content-Type: application/json' \
--data '{
    "limit_start": 0,
    "limit_page_length": 0
}'
#response
{
    "message": [
        {
            "name": "p9ti8veq2g",
            "designed_area": "Sunrise Villa Phase 355",
            "design_area": 350.5,
            "request_date": "2025-11-26 09:30:00",
            "status": "Đã được phê duyệt",
            "reason_for_rejection": null,
            "status_color": "Success"
        }
    ]
}

#get project progress
curl --location 'https://land.dbiz.com//api/method/frappe.client.get_list' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'Content-Type: application/json' \
--data '{
  "doctype": "Progress of construction",
  "fields": ["name","status"],
  "order_by": "number_of_display asc",
  "limit_page_length": 0
}'

#response
{
    "message": [
        {
            "name": "h6n0hat3o2",
            "status": "Chưa khởi công"
        },
        {
            "name": "k1mr565o91",
            "status": "Khởi công móng"
        },
        {
            "name": "2obpqokr8q",
            "status": "Đang phần thô"
        },
        {
            "name": "i5qkovb09j",
            "status": "Đang hoàn thiện"
        },
        {
            "name": "kdj1jjlr28",
            "status": "Cất nóc"
        },
        {
            "name": "254e3ealdf",
            "status": "Hoàn thiện"
        }
    ]
}

#create new project
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.project.save' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--header 'Content-Type: application/json' \
--data '{
  "name": "p9ti8veq2g",
  "designed_area": "Sunrise Villa Phase 355",
  "address_of_project": "123 Đường Võ Văn Kiệt, Quận 2, TP.HCM",
  "project_owner": "Nguyễn Văn A",
  "design_firm": "Studio Green",
  "contruction_contractor": "CTCP Xây Dựng Minh Phú",
  "design_area": 350.5,
  "products_included_in_the_design": "Gạch ốp lát, sơn ngoại thất, \nkhóa thông minh",
  "project_progress": "h6n0hat3o2",
  "expected_commencement_date": "2026-01-15",
  "description": "Yêu cầu phối màu mới cho khu vực hồ bơi",
  "request_date": "2025-11-26 09:30:00"
}'

#upload image file for project
#docname is the project name returned from create new project
#file is the local path of the file to be uploaded
#other parameters can be kept as is
curl --location 'https://land.dbiz.com//api/method/upload_file' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--form 'file=@"/C:/Users/tiennld/Downloads/76369094c7604b3e1271.jpg"' \
--form 'is_private="1"' \
--form 'folder="Home/Attachments"' \
--form 'doctype="Architectural Project"' \
--form 'docname="p9ti8veq2g"' \
--form 'optimize="true"'

#delete image file of project
curl --location 'https://land.dbiz.com//api/method/frappe.desk.form.utils.remove_attach' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--form 'fid="67803d2e95"' \ #file id to be deleted
--form 'dt="Architectural Project"' \ #doctye
--form 'dn="p9ti8veq2g"' #docname

#get detail of a project
curl --location 'https://land.dbiz.com//api/method/building_material.building_material.api.project.get_detail' \
--header 'Cookie: sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; full_name=Ha%20Duy%20Lam; sid=a0cbe3ea6f9a7e9cf083bbe3139eada68d2357eac0167bcc66cda17d; system_user=yes; user_id=lamhd%40gmail.com; user_image=/files/avatar_0986788766_1763627962.jpg' \
--header 'X-Frappe-Csrf-Token: 6ff3be4d1f887dbebf86ba4502b05d94b30c0b0569de49b74a7171a9' \
--header 'Content-Type: application/json' \
--data '{
    "name": "#DA00011"
}'

#response
{
    "message": {
        "success": true,
        "data": {
            "name": "#DA00011",
            "designed_area": "f67gg7",
            "address_of_project": "7fucuv",
            "project_owner": "cycu",
            "design_firm": null,
            "contruction_contractor": null,
            "design_area": 2585.0,
            "products_included_in_the_design": "thy",
            "project_progress": "k1mr565o91",
            "expected_commencement_date": "2025-11-30",
            "description": null,
            "request_date": "2025-11-27 16:51:54",
            "workflow_state": "Pending approval",
            "reason_for_rejection": null,
            "status": "Chờ phê duyệt",
            "status_color": "Warning",
            "is_allow_modify": true,
            "is_allow_cancel": true,
            "files_list": [
                {
                    "name": "0068d2403c",
                    "file_url": "https://land.dbiz.com/private/files/image_picker_32BD79E6-7A71-448E-A5DF-6DA7D12A1303-66894-000015E4259DBB5B.png"
                }
            ]
        }
    }
}