Appearance
07.03 Shipment Response Data Model
📌 At a Glance
| รายการ | รายละเอียด |
|---|---|
| Topic | Shipment Response Data Model |
| Endpoint | GET /shipments |
| Difficulty | ⭐⭐⭐ Intermediate |
| Reading Time | 12 นาที |
| Target | Developer |
🎯 Learning Objectives
หลังจากศึกษาหัวข้อนี้แล้ว ผู้อ่านจะสามารถ
- เข้าใจโครงสร้างข้อมูลที่ส่งกลับจาก Shipment Tracking API
- อ้างอิงข้อมูลแต่ละ Field ได้อย่างถูกต้อง
- เข้าใจความสัมพันธ์ระหว่าง Order, Items และ Status History
- นำข้อมูลไปแสดงผลใน Client System ได้อย่างถูกต้อง
Overview
Shipment Tracking API ส่งข้อมูลกลับในรูปแบบ JSON ซึ่งประกอบด้วยข้อมูลระดับเอกสาร รายการสินค้า และประวัติการเปลี่ยนสถานะ
ข้อมูลทั้งหมดถูกจัดกลุ่มให้อ่านง่ายและสามารถนำไปใช้งานกับ ERP, POS, WMS หรือ Customer Portal ได้ทันที
Figure 7-3 Shipment Response Data Model

Figure 7-3 แสดงโครงสร้างข้อมูลของ Shipment Response ตั้งแต่ข้อมูลหลักของ Order รายการสินค้า และประวัติการเปลี่ยนสถานะ
Response Structure
text
Shipment
│
├── id
├── client_reference_no
├── order_header_no
├── order_header_date
├── order_status
├── order_type
├── order_amount
├── branch
├── branch_rec
├── customer
├── customer_rec
├── remark
├── items[]
└── history[]Root Fields
| Field | Type | Description |
|---|---|---|
| id | Integer | Order ID ใช้เป็นเลขอ้างอิงหลัก |
| tracking_no | String | รองรับ API V1 โดยมีค่าเท่ากับ id |
| client_reference_no | String | เลขอ้างอิงจาก Client System |
| order_header_no | String | เลขที่ใบรับส่งสินค้า |
| order_header_date | Date | วันที่เอกสาร |
| order_status | String | สถานะล่าสุดของรายการ |
| order_type | String | ประเภทงานขนส่ง |
| order_amount | Decimal | ยอดค่าขนส่ง |
| branch | String | สาขาต้นทาง |
| branch_rec | String | สาขาปลายทาง |
| customer | String | ลูกค้าต้นทาง |
| customer_rec | String | ผู้รับสินค้า |
| remark | String | หมายเหตุของเอกสาร (แสดงใน API รายการเดี่ยว) |
Items Object
แต่ละ Shipment สามารถมีรายการสินค้าได้หลายรายการ
text
items[]
│
├── id
├── product_id
├── product_name
├── unit_id
├── unit
├── price
├── amount
├── line_amount
├── remark
├── client_line_id
├── client_item_no
└── client_product_codeItem Fields
| Field | Description |
|---|---|
| id | รหัสรายการสินค้า |
| product_id | รหัสสินค้า |
| product_name | ชื่อสินค้า |
| unit_id | รหัสหน่วยนับ |
| unit | ชื่อหน่วยนับ |
| price | ราคาต่อหน่วย |
| amount | จำนวนสินค้า |
| line_amount | มูลค่ารวมของรายการ |
| remark | หมายเหตุ |
| client_line_id | เลขอ้างอิงรายการจาก Client |
| client_item_no | รหัสรายการสินค้าในระบบลูกค้า |
| client_product_code | รหัสสินค้าของลูกค้า |
History Object
ประวัติการเปลี่ยนสถานะของรายการ
text
history[]
│
├── status
└── changed_atHistory Fields
| Field | Description |
|---|---|
| status | สถานะของรายการ |
| changed_at | วันที่และเวลาที่เปลี่ยนสถานะ (ISO 8601) |
Meta Object
การเรียก API แบบรายการ (List API) จะส่งข้อมูล Pagination กลับมาด้วย
| Field | Description |
|---|---|
| current_page | หน้าปัจจุบัน |
| per_page | จำนวนรายการต่อหน้า |
| total | จำนวนรายการทั้งหมด |
| last_page | จำนวนหน้าทั้งหมด |
Response Relationship
text
Shipment
│
├── Order Information
├── Items (1..N)
└── Status History (1..N)Business Notes
idเป็นเลขอ้างอิงหลักของรายการtracking_noมีไว้เพื่อรองรับ API V1 และมีค่าเท่ากับidhistoryแสดงลำดับการเปลี่ยนสถานะตามเวลาจริงitemsรองรับสินค้าหลายรายการในหนึ่ง Shipmentmetaจะแสดงเฉพาะเมื่อเรียก API แบบ List
Implementation Notes
- ใช้
idเป็น Primary Reference - ใช้
historyสำหรับสร้าง Timeline - ใช้
itemsสำหรับแสดงรายละเอียดสินค้า - ใช้
metaสำหรับรองรับ Pagination
Best Practices
- จัดเก็บ
idและclient_reference_no - ใช้
historyแสดงสถานะล่าสุดแก่ผู้ใช้งาน - รองรับกรณี Shipment มีสินค้าหลายรายการ
- ตรวจสอบ
order_statusทุกครั้งก่อนแสดงผล
Related APIs
- GET /shipments
- GET /shipments/
- POST /order-checkings
Summary
Shipment Tracking API ส่งข้อมูลกลับในรูปแบบที่ประกอบด้วยข้อมูลหลักของ Order รายการสินค้า และประวัติการเปลี่ยนสถานะ ช่วยให้ Client System สามารถแสดงข้อมูลการจัดส่งได้ครบถ้วน พร้อมรองรับการติดตามสถานะย้อนหลังและการเชื่อมโยงกับระบบต้นทาง
Next Step
➡️ 07.04 Shipment Status History
