Skip to content

07.03 Shipment Response Data Model


📌 At a Glance

รายการรายละเอียด
TopicShipment Response Data Model
EndpointGET /shipments
Difficulty⭐⭐⭐ Intermediate
Reading Time12 นาที
TargetDeveloper

🎯 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

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

FieldTypeDescription
idIntegerOrder ID ใช้เป็นเลขอ้างอิงหลัก
tracking_noStringรองรับ API V1 โดยมีค่าเท่ากับ id
client_reference_noStringเลขอ้างอิงจาก Client System
order_header_noStringเลขที่ใบรับส่งสินค้า
order_header_dateDateวันที่เอกสาร
order_statusStringสถานะล่าสุดของรายการ
order_typeStringประเภทงานขนส่ง
order_amountDecimalยอดค่าขนส่ง
branchStringสาขาต้นทาง
branch_recStringสาขาปลายทาง
customerStringลูกค้าต้นทาง
customer_recStringผู้รับสินค้า
remarkStringหมายเหตุของเอกสาร (แสดงใน 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_code

Item Fields

FieldDescription
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_at

History Fields

FieldDescription
statusสถานะของรายการ
changed_atวันที่และเวลาที่เปลี่ยนสถานะ (ISO 8601)

Meta Object

การเรียก API แบบรายการ (List API) จะส่งข้อมูล Pagination กลับมาด้วย

FieldDescription
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 และมีค่าเท่ากับ id
  • history แสดงลำดับการเปลี่ยนสถานะตามเวลาจริง
  • items รองรับสินค้าหลายรายการในหนึ่ง Shipment
  • meta จะแสดงเฉพาะเมื่อเรียก 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

SISAHYGO API Integration Guide