# Rakmao Purchase Order Open API ## Preparing Connection ### Rakmao Environment | Name | Endpoint | | ---------- | --------------------------------- | | Test | https://rakmao-api-test.builk.com | | Production | https://api.rakmao.com | ### RakmaoPO Environment | Name | Endpoint | | ---------- | --------------------------------- | | Test | https://rakmao-po-api-test.builk.com | | Production | https://api-po.rakmao.com | ### Rakmao Standard Object > ทุกๆ Response จาก Rakmao Buyer Center จะประกอบด้วย สาม Parameter หลักดังนี้ | Parameter | Description | Schema | | ----------- | ----------------- | ------ | | data | ผลลัพท์ของการทำงานใน API ผลลัพท์ความเป็นไปได้ประกอบด้วย null, object, array, string ,number และ boolean | object | | status | สถานะของการทำงานใน API ผลลัพท์ความเป็นไปได้ประกอบด้วย 2xx, 4xx และ 5xx | number | | message | ข้อความอธิบายผลลัพท์ของการทำงานใน API โดยเป็นคู่บงชี้กับ parameter `status` หากเป็นหมวด 2XX จะตอบกลับเป็น `success` และ หมวดอื่นๆจะตอบเป็นคำอธิบายอย่างสั้น | string | > หมายเหตุ ในกรณีที่ status บงชี้ในหมวดหมู่ 4XX ผู้ทำการร้องของสามารถจัดการปัญหาได้ด้วยตนเองตาม error case ที่ list ไว้ให้ (จะดำเนินการในภายหลัง) และ ในกรณีที่ status บงชี้ในหมวดหมู่ 5XX โปรดแจ้งให้ทางผู้พัฒนาให้ทราบโดยเร็วที่สุด **Example Response** ```json { "status": 200, "message": "Success", "data": some object .. } ``` ### Rakmao MasterData (Enum) #### POStatusEnum | Name | Value | | ------------------ | ----- | | Preview | 1 | | Complete | 2 | | Draft | 3 | | PendingPayment | 4 | | BuyerReject | -1 | | BuyerCancel | -2 | | SellerReject | -3 | | SellerRequestCancel| -4 | | SellerCancel | -5 | | AllCancel | -6 | | BuyerRequestCancel | -7 | #### PoCreateTypeEnum | Name | Value | | ------------------ | ----- | | Rakmao | 1 | | Attachment | 2 | | DirectPO | 3 | ### Rakmao Authentication > ทุกๆ Request ที่ทำการติดต่อกับ Rakmao Buyer Center ต้องแนบ Header ประกอบมาด้วยเสมอ ซึ่งประกอบไปด้วย > Header Key : `Authorization` และ Header Value : `Bearer *access_token*` > โดย *access_token* จะกล่าวถึงในหัวข้อ [Rakmao Request and Refersh Authorization](#Rakmao-Request-and-Refersh-Authorization) Example : ` Authorization : Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9 ` หรือผลลัพท์ Request ดังภาพ ![](https://i.imgur.com/pwUKaTf.png) ### Rakmao Request Authorization #### Rqeuest Path `/api/v1/Authentication/RequestAPIToken` > การ Request Authorization หรือการ Login ในที่นี้จะไม่สามารถใช้ User/Password และวิธีทั่วไปในการใช้งานเว็บไซต์ www.rakmao.com ให้ทำตามวิธีดังต่อไปนี้ > 1. นำ authen_string ที่ได้รับจากการลงทะเบียน (หมายเหตุ แจ้งให้ผู้พัฒนาลงทะเบียนให้) แนบลงในส่วนของ body ของ request > 2. ทำการร้องขอ Method POST ไปที่ `{baseUrl}/api/v1/Authentication/RequestAPIToken` (หมายเหตุ baseUrl ในที่นี้หมายถึง Endpoint ในส่วน [Rakmao Environment](#Rakmao-Environment)) > > หมายเหตุ authen_string ได้จากการนำ user/password ไปประกอบในรูปแบบ json และทำการ encoding ด้วย method base64, Example `{"UserName":"your-username","Password":"your-password"}` **Body Request** | Parameter | Description | Schema | | ------------------------- | -------------------------------------- | ------------------- | | authenString (*required*) | authen string ที่ได้รับจากการลงทะเบียน | string (plain/text) | **Data Response** | Parameter | Description | Schema | | ----------- | ----------------- | ------ | | token | token สำหรับแนบ ใน Header | string | | refreshToken | token สำหรับ ในการร้องขอสิทธิ์ใหม่อีกครั้งหลังจากหมดอายุ | string | | expiration | วันที่และเวลาหมดอายุของ token ที่ร้องขอ | DateTime | **Example Request** ``` "authString..." ``` **Example Response** ```json { "status": 200, "message": "Success", "data": { "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.****", "refreshToken": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.****", "expiration": 1613978508 } } ``` ### Rakmao Renew Authorization #### Rqeuest Path `/api/v1/Authentication/RenewAPIToken` > การ Renew Authorization คือการออก Token ใหม่โดยใช้สิทธ์ล่าสุดที่เคยได้รับ (หมายเหตุ ต้องเป็น refreshToken ล่าสุดเท่านั้น) > 1. นำ refreshToken ที่ได้รับจากการ Rquest Authorization แนบลงในส่วนของ body ของ request > 2. ทำการร้องขอ Method POST ไปที่ `{baseUrl}/api/v1/Authentication/RenewAPIToken` (หมายเหตุ baseUrl ในที่นี้หมายถึง Endpoint ในส่วน [Rakmao Environment](#Rakmao-Environment)) > **Body Request** | Parameter | Description | Schema | | ------------------------- | -------------------------------------- | ------------------- | | refreshToken (*required*) | refreshToken ที่ได้รับจากการ login ครั้งล่าสุด | string (plain/text) | **Data Response** | Parameter | Description | Schema | | ----------- | ----------------- | ------ | | token | token สำหรับแนบ ใน Header | string | | refreshToken | token สำหรับ ในการร้องขอสิทธิ์ใหม่อีกครั้งหลังจากหมดอายุ | string | | expiration | วันที่และเวลาหมดอายุของ token ที่ร้องขอ | DateTime | **Example Request** ``` "refreshToken..." ``` **Example Response** ```json { "status": 200, "message": "Success", "data": { "token": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.****", "refreshToken": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.****", "expiration": 1613978508 } } ``` ## Buyer API ### `POST /api/v1/Buyer` > สำหรับให้ Buyer สร้าง เอกสาร po โดยจะได้เป็น Po status Draft **Body Request** | Parameter | Required | Description | Schema | | --------------------- |:------------------:| -------------------------- | --------------- | | CreateByUserId | :heavy_check_mark: | User ref id | string | | CreateByUserName | :heavy_check_mark: | | string | | OrgId | :heavy_check_mark: | OrgId ที่ออกโดยระบบ Rakmao | guid | | OrgName | :heavy_check_mark: | | string | | RfqId | :heavy_check_mark: | | guid | | QuotationId | :heavy_check_mark: | | guid | | ProjectId | :heavy_check_mark: | | guid | | ProjectName | :heavy_check_mark: | | string | | VendorId | :heavy_check_mark: | | guid | | VendorName | :heavy_check_mark: | | string | | DocumentFileUrl | | | string | | ContactName | :heavy_check_mark: | | string | | ContactPhone | :heavy_check_mark: | | string | | Address | :heavy_check_mark: | | string | | Note | | | string | | CreateType | :heavy_check_mark: | | number | | DocumentReference | | | string | | TotalItem | :heavy_check_mark: | | number | | SubTotal | :heavy_check_mark: | | number | | Beforvat | :heavy_check_mark: | | number | | Discount | | | number | | VatType | :heavy_check_mark: | | number | | VatRate | :heavy_check_mark: | | number | | VatAmount | :heavy_check_mark: | | number | | DeliveryFee | | | number | | DeliveryVatType | | | number | | DeliveryVatRate | | | number | | DeliveryVatAmount | | | number | | GrandTotal | :heavy_check_mark: | | number | | GrandTotalDeliveryFee | :heavy_check_mark: | | number | | SellerTaxId | :heavy_check_mark: | | string | | BuyerTaxId | :heavy_check_mark: | | string | | PoItemDetail | :heavy_check_mark: | | array of object | **PoItemDetail Object** | Parameter | Required | Description | Schema | | --------------- |:------------------:| ----------- | ------ | | RfqItemId | :heavy_check_mark: | | guid | | QuotationItemId | :heavy_check_mark: | | guid | | Quantity | :heavy_check_mark: | | number | | Price | :heavy_check_mark: | | number | | Unit | :heavy_check_mark: | | string | | Description | :heavy_check_mark: | | string | | Note | | | string | **Body Response** | Parameter | Description | Schema | | --------- | ----------- | ------ | | PoId | | guid | | PoCode | | string | #### Example Request ```json { "CreateByUserId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "CreateByUserName":"TestMan", "OrgId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "OrgName":"ทดสอบ จำกัด", "RfqId":"cf7aba83-468d-41e1-9af8-3465189f3143", "QuotationId":"e3a551af-cae9-432c-adfb-77fb3f812a08", "ProjectId":"2b1be735-e90f-4700-b1d1-514ba8710a56", "ProjectName":"โครงการทดสอบ", "VendorId":"490f4f7a-761a-4595-990a-ba128d7dc6f0", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "ContactName":"นะจ๊ะ", "ContactPhone":"010001100", "Address":"No. 1624/2 New Phetburi Road Makkasan Ratchathewi Bangkok 10400", "Note":"-", "CreateType": 1 , "DocumentReference":"pr-001,pr-002", "TotalItem":13, "SubTotal": 500, "Beforvat": 500, "Discount": 50, "VatType": 3, "VatRate": 0, "VatAmount":0, "DeliveryFee": 50 , "DeliveryVatType": 3, "DeliveryVatRate": 0, "DeliveryVatAmount": 50, "GrandTotal": 450, "GrandTotalDeliveryFee":500, "SellerTaxId":"112232323", "BuyerTaxId":"323232211", "PoItemDetail":[ { "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":99, "Price":1250, "Unit":"gg", "Description":"Iron ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":12, "Price":250, "Unit":"gg", "Description":"Gold ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":1, "Price":50000, "Unit":"gg", "Description":"sircon ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":3200, "Price":1900000, "Unit":"gg", "Description":"paper glass ", "Note": null }, ] } ``` #### Example Response ```json { "status": 200, "message": "Success", "data": { "PoId":"30e410d8-4117-4669-9a28-d32b4717fadd", "PoCode":"PO-220422-0001", } } ``` ### `PUT /api/v1/Buyer/{PoId}/Status/{Status}` > สำหรับให้ Buyer เปลี่ยนแปลงสถานะของเอกสาร po โดยเป็นสถานะใดๆก็ได้ **Body Request** | Parameter | Required | Description | Schema | | ----------------------- |:------------------:| --------------- | ------ | | [Status](#POStatusEnum) | :heavy_check_mark: | | number | | PoId | :heavy_check_mark: | | guid | | CreateByUserId | :heavy_check_mark: | User ref id | string | | CreateByUserName | :heavy_check_mark: | | string | | Reason | | | string | | ActionByType | | Buyer and Admin | string | **Body Response** | Parameter | Description | Schema | | --------- | ----------- | ------ | | data | | boolean| #### Example Request ```xml > https://{environment}/api/v1/Buyer/30e410d8-4117-4669-9a28-d32b4717fadd/Status` ``` ```json { "CreateByUserId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "CreateByUserName":"TestMan", "Status":1, "Reason":"Cancel reason", "ActionBy":"Buyer" } ``` #### Example Response ```json { "status": 200, "message": "Success", "data": true } ``` ### `PUT /api/v1/Buyer/{PoId}` > สำหรับให้ Buyer แก้ไข เอกสาร po **Body Request** | Parameter | Required | Description | Schema | | --------------------- |:------------------:| ----------- | --------------- | | CreateByUserId | :heavy_check_mark: | User ref id | string | | CreateByUserName | :heavy_check_mark: | | string | | DocumentFileUrl | | | string | | ContactName | :heavy_check_mark: | | string | | ContactPhone | :heavy_check_mark: | | string | | Address | :heavy_check_mark: | | string | | Note | | | string | | DocumentReference | | | string | | TotalItem | :heavy_check_mark: | | number | | SubTotal | :heavy_check_mark: | | number | | Beforvat | :heavy_check_mark: | | number | | Discount | | | number | | VatType | :heavy_check_mark: | | number | | VatRate | :heavy_check_mark: | | number | | VatAmount | :heavy_check_mark: | | number | | DeliveryFee | | | number | | DeliveryVatType | | | number | | DeliveryVatRate | | | number | | DeliveryVatAmount | | | number | | GrandTotal | :heavy_check_mark: | | number | | GrandTotalDeliveryFee | :heavy_check_mark: | | number | | PoItemDetail | :heavy_check_mark: | | array of object | **PoItemDetail Object** | Parameter | Required | Description | Schema | | ----------- |:------------------:| ----------- | ------ | | PoItemId | | | guid | | Quantity | :heavy_check_mark: | | number | | Price | :heavy_check_mark: | | number | | Unit | :heavy_check_mark: | | string | | Description | :heavy_check_mark: | | string | | Note | | | string | **Body Response** | Parameter | Description | Schema | | --------- | ----------- | ------ | | data | | boolean| #### Example Request ```json { "PoId":"490f4f7a-761a-4595-990a-ba128d7dc6f0", "CreateByUserId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "CreateByUserName":"TestMan", "DocumentFileUrl":"path to file ", "ContactName":"นะจ๊ะ", "ContactPhone":"010001100", "Address":"No. 1624/2 New Phetburi Road Makkasan Ratchathewi Bangkok 10400", "Note":"-", "CreateType": 1 , "DocumentReference":"pr-001,pr-002", "TotalItem":13, "SubTotal": 500, "Beforvat": 500, "Discount": 50, "VatType": 3, "VatRate": 0, "VatAmount":0, "DeliveryFee": 50 , "DeliveryVatType": 3, "DeliveryVatRate": 0, "DeliveryVatAmount": 50, "GrandTotal": 450, "GrandTotalDeliveryFee":500, "PoItemDetail":[ { "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":99, "Price":1250, "Unit":"gg", "Description":"Iron ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":12, "Price":250, "Unit":"gg", "Description":"Gold ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":1, "Price":50000, "Unit":"gg", "Description":"sircon ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":3200, "Price":1900000, "Unit":"gg", "Description":"paper glass ", "Note": null }, ] } ``` #### Example Response ```json { "status": 200, "message": "Success", "data": true } ``` ### `GET /api/v1/Buyer/{OrgId}` > สำหรับให้ Buyer เรียกดูรายการเอกสาร po จำแนกโดย organize **Param Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------------------------------------------------------------------- | ------ | | Keyword | | ใช้สำหรับการค้นหาทึ่เจาะจง เช่น PO-Code , ProjectName , Vendorname | string | | status | | ค้นหาโดยเจาะจงสถานะของเอกสาร โดยค่าเริ่มต้นคือทั้งหมด | number | | page | | หมายเลขหน้าในกรณีที่มีมากกว่า 1 หน้า โดยค่าเริ่มต้นคือ 1 | number | | perpage | | จำนวนเอกสารที่เรียกได้ใน 1 หน้า สูงสุด 100 รายการ โดยค่าเริ่มต้นคือ 10 | number | | OrgId | :heavy_check_mark: | organize id ที่ออกโดย rakamo | string | **Body Response** | Parameter | Required | Description | Schema | | --------------------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | | guid | | PoCode | :heavy_check_mark: | | string | | ProjectName | :heavy_check_mark: | | string | | VendorName | :heavy_check_mark: | | string | | CreateDate | :heavy_check_mark: | | string | | GrandTotal | :heavy_check_mark: | | string | | Status | :heavy_check_mark: | | string | | DocumentFileUrl | | | string | #### Example Request ```xml > https://{environment}/api/v1/Buyer/b1b7711b-158f-48fe-adc0-9cfb52565911/?keyword=PO-220422-0001&page=1&perpage=10&status=0` ``` #### Example Response ```json { "status": 200, "message": "Success", "data": { "count": 15, "item" :[ { "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "ProjectName":"โครงการทดสอบ", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "CreateDate":"2022-04-22 18:00:01", "GrandTotal":500, "Status":1, },{ "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "ProjectName":"โครงการทดสอบ", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "CreateDate":"2022-04-22 18:00:01", "GrandTotal":500, "Status":1, } ] } } ``` ### `GET /api/v1/Buyer/{OrgId}/Document` > สำหรับให้ Buyer เรียกดูรายละเอียดเอกสาร po **Param Request** | Parameter | Required | Mandary | Description | Schema | | ----------- | ------------------ |:------------------:| ---------------------------- | ------ | | OrgId | :heavy_check_mark: | | | string | | QuotationId | | :heavy_check_mark: | QuotationId ที่ออกโดย rakmao | string | | RfqId | | :heavy_check_mark: | RfqId ที่ออกโดย rakmao | string | | PoId | | :heavy_check_mark: | PoId ที่ออกโดย rakmao | string | **Body Response** | Parameter | Required | Description | Schema | | --------------------- |:------------------:| ----------- | --------------- | | PoId | :heavy_check_mark: | | guid | | PoCode | :heavy_check_mark: | | string | | CreateDate | :heavy_check_mark: | | string | | CreateByUserId | :heavy_check_mark: | | string | | OrgId | :heavy_check_mark: | | guid | | OrgName | :heavy_check_mark: | | string | | RfqId | :heavy_check_mark: | | guid | | QuotationId | :heavy_check_mark: | | guid | | ProjectId | :heavy_check_mark: | | guid | | ProjectName | :heavy_check_mark: | | string | | VendorId | :heavy_check_mark: | | guid | | VendorName | :heavy_check_mark: | | string | | DocumentFileUrl | | | string | | ContactName | :heavy_check_mark: | | string | | ContactPhone | :heavy_check_mark: | | string | | Address | :heavy_check_mark: | | string | | Note | | | string | | CreateType | :heavy_check_mark: | | number | | Status | :heavy_check_mark: | | number | | DocumentReference | | | string | | TotalItem | :heavy_check_mark: | | number | | SubTotal | :heavy_check_mark: | | number | | Beforvat | :heavy_check_mark: | | number | | Discount | | | number | | VatType | :heavy_check_mark: | | number | | VatRate | :heavy_check_mark: | | number | | VatAmount | :heavy_check_mark: | | number | | DeliveryFee | | | number | | DeliveryVatType | | | number | | DeliveryVatRate | | | number | | DeliveryVatAmount | | | number | | GrandTotal | :heavy_check_mark: | | number | | GrandTotalDeliveryFee | :heavy_check_mark: | | number | | SellerTaxId | :heavy_check_mark: | | string | | BuyerTaxId | :heavy_check_mark: | | string | | PoItemDetail | :heavy_check_mark: | | array of object | **PoItemDetail Object** | Parameter | Required | Description | Schema | | --------------- |:------------------:| ----------- | ------ | | PoItemId | :heavy_check_mark: | | guid | | RfqItemId | :heavy_check_mark: | | guid | | QuotationItemId | :heavy_check_mark: | | guid | | Quantity | :heavy_check_mark: | | number | | Price | :heavy_check_mark: | | number | | Unit | :heavy_check_mark: | | string | | Description | :heavy_check_mark: | | string | | Note | | | string | **Body Response** | Parameter | Description | Schema | | --------- | ----------- | ------ | | PoId | | guid | | PoCode | | string | #### Example Request ```xml > https://{environment}/api/v1/Buyer/b1b7711b-158f-48fe-adc0-9cfb52565911/Document?PoId=b1b7711b-158f-48fe-adc0-9cfb52565911` ``` #### Example Response ```json { "status": 200, "message": "Success", "data": [ { "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "CreateByUserId":"", "OrgId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "OrgName":"ทดสอบ จำกัด", "RfqId":"cf7aba83-468d-41e1-9af8-3465189f3143", "QuotationId":"e3a551af-cae9-432c-adfb-77fb3f812a08", "ProjectId":"2b1be735-e90f-4700-b1d1-514ba8710a56", "ProjectName":"โครงการทดสอบ", "VendorId":"490f4f7a-761a-4595-990a-ba128d7dc6f0", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "ContactName":"นะจ๊ะ", "ContactPhone":"010001100", "Address":"No. 1624/2 New Phetburi Road Makkasan Ratchathewi Bangkok 10400", "Note":"-", "CreateType": 1 , "Status": 1 , "DocumentReference":"pr-001,pr-002", "TotalItem":13, "SubTotal": 500, "Beforvat": 500, "Discount": 50, "VatType": 3, "VatRate": 0, "VatAmount":0, "DeliveryFee": 50 , "DeliveryVatType": 3, "DeliveryVatRate": 0, "DeliveryVatAmount": 50, "GrandTotal": 450, "GrandTotalDeliveryFee":500, "SellerTaxId":"112232323", "BuyerTaxId":"323232211", "PoItemDetail":[ { "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":99, "Price":1250, "Unit":"gg", "Description":"Iron ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":12, "Price":250, "Unit":"gg", "Description":"Gold ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":1, "Price":50000, "Unit":"gg", "Description":"sircon ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":3200, "Price":1900000, "Unit":"gg", "Description":"paper glass ", "Note": null }, ] }, { "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "CreateByUser":"", "OrgId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "OrgName":"ทดสอบ จำกัด", "RfqId":"cf7aba83-468d-41e1-9af8-3465189f3143", "QuotationId":"e3a551af-cae9-432c-adfb-77fb3f812a08", "ProjectId":"2b1be735-e90f-4700-b1d1-514ba8710a56", "ProjectName":"โครงการทดสอบ", "VendorId":"490f4f7a-761a-4595-990a-ba128d7dc6f0", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "ContactName":"นะจ๊ะ", "ContactPhone":"010001100", "Address":"No. 1624/2 New Phetburi Road Makkasan Ratchathewi Bangkok 10400", "Note":"-", "CreateType": 1 , "Status": 1 , "DocumentReference":"pr-001,pr-002", "TotalItem":13, "SubTotal": 500, "Beforvat": 500, "Discount": 50, "VatType": 3, "VatRate": 0, "VatAmount":0, "DeliveryFee": 50 , "DeliveryVatType": 3, "DeliveryVatRate": 0, "DeliveryVatAmount": 50, "GrandTotal": 450, "GrandTotalDeliveryFee":500, "SellerTaxId":"112232323", "BuyerTaxId":"323232211", "PoItemDetail":[ { "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":99, "Price":1250, "Unit":"gg", "Description":"Iron ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":12, "Price":250, "Unit":"gg", "Description":"Gold ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":1, "Price":50000, "Unit":"gg", "Description":"sircon ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":3200, "Price":1900000, "Unit":"gg", "Description":"paper glass ", "Note": null }, ] } ] } ``` ## Seller API ### `GET /api/v1/Seller/{TaxId}` > สำหรับให้ Seller เรียกดูรายการเอกสาร po จำแนกโดย organize **Param Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------------------------------------------------------------------- | ------ | | Keyword | | ใช้สำหรับการค้นหาทึ่เจาะจง เช่น PO-Code , ProjectName , Vendorname | string | | status | | ค้นหาโดยเจาะจงสถานะของเอกสาร โดยค่าเริ่มต้นคือทั้งหมด | number | | page | | หมายเลขหน้าในกรณีที่มีมากกว่า 1 หน้า โดยค่าเริ่มต้นคือ 1 | number | | perpage | | จำนวนเอกสารที่เรียกได้ใน 1 หน้า สูงสุด 100 รายการ โดยค่าเริ่มต้นคือ 10 | number | | TaxId | :heavy_check_mark: | Vendor taxid | string | **Body Response** | Parameter | Required | Description | Schema | | --------------------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | | guid | | PoCode | :heavy_check_mark: | | string | | ProjectName | :heavy_check_mark: | | string | | BuyerOrgName | :heavy_check_mark: | | string | | CreateDate | :heavy_check_mark: | | string | | GrandTotal | :heavy_check_mark: | | string | | Status | :heavy_check_mark: | | string | | DocumentFileUrl | | | string | #### Example Request ```xml > https://{environment}/api/v1/Buyer/List/b1b7711b-158f-48fe-adc0-9cfb52565911/?keyword=PO-220422-0001&page=1&perpage=10&status=0` ``` #### Example Response ```json { "status": 200, "message": "Success", "data": { "count": 15, "item" :[ { "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "ProjectName":"โครงการทดสอบ", "BuyerOrgName":"ผู้ซื้อทดสอบ", "DocumentFileUrl":"path to file ", "CreateDate":"2022-04-22 18:00:01", "GrandTotal":500, "Status":1, },{ "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "ProjectName":"ผู้ซื้อทดสอบ", "BuyerOrgName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "CreateDate":"2022-04-22 18:00:01", "GrandTotal":500, "Status":1, } ] } } ``` ### `GET /api/v1/Seller/{TaxId}/Document` > สำหรับให้ Seller เรียกดูรายละเอียดเอกสาร po เลือกส่ง query parameter อย่างได้อย่างหนึ่งเผื่ออาจอิงข้อมูล **Param Request** | Parameter | Required | Mandary | Description | Schema | | ----------- | ------------------ |:------------------:| ---------------------------- | ------ | | TaxId | :heavy_check_mark: | | Vendor taxid | string | | QuotationId | | :heavy_check_mark: | QuotationId ที่ออกโดย rakmao | string | | RfqId | | :heavy_check_mark: | RfqId ที่ออกโดย rakmao | string | | PoId | | :heavy_check_mark: | PoId ที่ออกโดย rakmao | string | **Body Response** | Parameter | Required | Description | Schema | | --------------------- |:------------------:| ----------- | --------------- | | PoId | :heavy_check_mark: | | guid | | PoCode | :heavy_check_mark: | | string | | Status | :heavy_check_mark: | | number | | BuyerOrgName | :heavy_check_mark: | | string | | RfqId | :heavy_check_mark: | | guid | | QuotationId | :heavy_check_mark: | | guid | | CreateDate | :heavy_check_mark: | | date | | SenderDate | :heavy_check_mark: | | date | | ProjectName | :heavy_check_mark: | | string | | VendorName | :heavy_check_mark: | | string | | DocumentFileUrl | | | string | | ContactName | :heavy_check_mark: | | string | | ContactPhone | :heavy_check_mark: | | string | | Address | :heavy_check_mark: | | string | | Note | | | string | | TotalItem | :heavy_check_mark: | | number | | SubTotal | :heavy_check_mark: | | number | | Beforvat | :heavy_check_mark: | | number | | Discount | | | number | | VatType | :heavy_check_mark: | | number | | VatRate | :heavy_check_mark: | | number | | VatAmount | :heavy_check_mark: | | number | | DeliveryFee | | | number | | DeliveryVatType | | | number | | DeliveryVatRate | | | number | | DeliveryVatAmount | | | number | | GrandTotal | :heavy_check_mark: | | number | | GrandTotalDeliveryFee | :heavy_check_mark: | | number | | SellerTaxId | :heavy_check_mark: | | string | | BuyerTaxId | :heavy_check_mark: | | string | | PoItemDetail | :heavy_check_mark: | | array of object | | CancelReason | | | string | | CancelNote | | | string | **PoItemDetail Object** | Parameter | Required | Description | Schema | | --------------- |:------------------:| ----------- | ------ | | PoItemId | :heavy_check_mark: | | guid | | Quantity | :heavy_check_mark: | | number | | Price | :heavy_check_mark: | | number | | Unit | :heavy_check_mark: | | string | | Description | :heavy_check_mark: | | string | | Note | | | string | #### Example Request ```xml > https://{environment}/api/v1/Seller/112232323/Document?PoId=b1b7711b-158f-48fe-adc0-9cfb52565911` ``` #### Example Response ```json { "status": 200, "message": "Success", "data": [ { "PoId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "PoCode":"PO-220422-0001", "BuyerOrgName":"ทดสอบ จำกัด", "RfqId":"cf7aba83-468d-41e1-9af8-3465189f3143", "QuotationId":"e3a551af-cae9-432c-adfb-77fb3f812a08", "ProjectName":"โครงการทดสอบ", "CreateDate":"2022/06/01 01:20:30", "SenderDate":"2022/06/01 01:20:30", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "ContactName":"นะจ๊ะ", "ContactPhone":"010001100", "Address":"No. 1624/2 New Phetburi Road Makkasan Ratchathewi Bangkok 10400", "Note":"-", "CreateType": 1 , "Status": 1 , "TotalItem":13, "SubTotal": 500, "Beforvat": 500, "Discount": 50, "VatType": 3, "VatRate": 0, "VatAmount":0, "DeliveryFee": 50 , "DeliveryVatType": 3, "DeliveryVatRate": 0, "DeliveryVatAmount": 50, "GrandTotal": 450, "GrandTotalDeliveryFee":500, "SellerTaxId":"112232323", "BuyerTaxId":"323232211", "PoItemDetail":[ { "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":99, "Price":1250, "Unit":"gg", "Description":"Iron ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":12, "Price":250, "Unit":"gg", "Description":"Gold ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":1, "Price":50000, "Unit":"gg", "Description":"sircon ", "Note": null },{ "PoItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "Quantity":3200, "Price":1900000, "Unit":"gg", "Description":"paper glass ", "Note": null }, ] },{ "CreateByUser":"", "OrgId":"b1b7711b-158f-48fe-adc0-9cfb52565911", "OrgName":"ทดสอบ จำกัด", "RfqId":"cf7aba83-468d-41e1-9af8-3465189f3143", "QuotationId":"e3a551af-cae9-432c-adfb-77fb3f812a08", "ProjectId":"2b1be735-e90f-4700-b1d1-514ba8710a56", "ProjectName":"โครงการทดสอบ", "VendorId":"490f4f7a-761a-4595-990a-ba128d7dc6f0", "VendorName":"ร้านค้าทดสอบ", "DocumentFileUrl":"path to file ", "ContactName":"นะจ๊ะ", "ContactPhone":"010001100", "Address":"No. 1624/2 New Phetburi Road Makkasan Ratchathewi Bangkok 10400", "Note":"-", "CreateType": 1 , "Status": 1 , "DocumentReference":"pr-001,pr-002", "TotalItem":13, "SubTotal": 500, "Beforvat": 500, "Discount": 50, "VatType": 3, "VatRate": 0, "VatAmount":0, "DeliveryFee": 50 , "DeliveryVatType": 3, "DeliveryVatRate": 0, "DeliveryVatAmount": 50, "GrandTotal": 450, "GrandTotalDeliveryFee":500, "SellerTaxId":"112232323", "BuyerTaxId":"323232211", "PoItemDetail":[ { "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":99, "Price":1250, "Unit":"gg", "Description":"Iron ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":12, "Price":250, "Unit":"gg", "Description":"Gold ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":1, "Price":50000, "Unit":"gg", "Description":"sircon ", "Note": null },{ "RfqItemId":"391f3266-d828-48e4-a2aa-fc5da817968a", "QuotationItemId":"98a26680-160d-402c-872d-6e8750bf5f82", "Quantity":3200, "Price":1900000, "Unit":"gg", "Description":"paper glass ", "Note": null }, ] } ] } ``` ### `POST /api/v1/Seller/{PoId}/RequestCancel` > สำหรับให้ Seller ร้องขอการเปลี่ยนแปลงสถานะของเอกสาร po เป็นยกเลิก **Parameter Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | | guid | **Body Request** | Parameter | Required | Description | Schema | | ---------------- |:------------------:| ----------- | ------ | | CreateByUserId | :heavy_check_mark: | | string | | CreateByUserName | :heavy_check_mark: | | string | | SellerTaxId | :heavy_check_mark: | | string | | Reason | | | string | | Note | | | string | **Body Response** | Parameter | Description | Schema | | --------- | ----------- | ------ | | data | | boolean| #### Example Request ```xml > https://{environment}/api/v1/Seller/30e410d8-4117-4669-9a28-d32b4717fadd/Cancel` ``` ```json { "CreateByUserId": "104", "CreateByUserName": "Test man", "SellerTaxId":"0010010011121" "Reason": "Cancel reason" } ``` #### Example Response ```json { "status": 200, "message": "Success", "data": true } ``` ### `POST /api/v1/Seller/{PoId}/Reject` > สำหรับให้ Seller ร้องขอการเปลี่ยนแปลงของเอกสาร po **Parameter Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | | guid | **Body Request** | Parameter | Required | Description | Schema | | ---------------- |:------------------:| ----------- | ------ | | CreateByUserId | :heavy_check_mark: | | string | | CreateByUserName | :heavy_check_mark: | | string | | SellerTaxId | :heavy_check_mark: | | string | | Reason | | | string | | Note | | | string | **Body Response** | Parameter | Description | Schema | | --------- | ----------- | ------ | | data | | boolean| #### Example Request ```xml > https://{environment}/api/v1/Seller/30e410d8-4117-4669-9a28-d32b4717fadd/Cancel` ``` ```json { "CreateByUserId": "104", "CreateByUserName": "Test man", "SellerTaxId":"0010010011121" "Reason": "Cancel reason" } ``` #### Example Response ```json { "status": 200, "message": "Success", "data": true } ``` ## Webhook ### List Webhook `GET /api/v1/Webhook` > List รายการ webhook ที่ลงทะเบียน **Body Response** | Parameter | Description | Schema | | --------- | ------------------------------------------------------- | -------------- | | Id | | string | | TypeName | ชื่อของ Webhook | string | | Endpoint | Url Webhook ที่ลงทะเบียน | string | | IsLogin | Endpoint นี้ต้องการ login จาก profile ก่อนที่จะ reqeust | boolean | | Header | Header ที่แนบไปกับ Webhook ที่ลงทะเบียน | key/pair value | **Example Request** > GET https://{environment}/api/v1/Webhook **Example Response** ```json { "status": 200, "message": "Success", "data": [ { "Id" : "4560d9a6-9264-4f20-898a-b722aedd9b8f", "IsLogin" : false, "TypeName" : "DocumentReady", "Endpoint" : "https://api-name.domain/path-to-example-api/VendorInterested", "Header" : { "Authorization": "beare **********" } } ] } ``` ### Get Webhook `GET /api/v1/Webhook/{enumValue}` > เรียกข้อมูล webhook แบบเจาะจง **Body Response** | Parameter | Description | Schema | | --------- | ------------------------------------------------------- | -------------- | | Id | | string | | TypeName | ชื่อของ Webhook | string | | Endpoint | Url Webhook ที่ลงทะเบียน | string | | IsLogin | Endpoint นี้ต้องการ login จาก profile ก่อนที่จะ reqeust | boolean | | Header | Header ที่แนบไปกับ Webhook ที่ลงทะเบียน | key/pair value | **Example Request** > GET https://{environment}/api/v1/Webhook/301 **Example Response** ```json { "status": 200, "message": "Success", "data": { "Id" : "4560d9a6-9264-4f20-898a-b722aedd9b8f", "IsLogin" : false, "TypeName" : "DocumentReady", "Endpoint" : "https://sub-domain.domain-name.domain/path-to-example-api/DocumentReady", "Header" : { "Authorization": "beare **********" } } } ``` ### Register Webhook `POST /api/v1/Webhook` > ผู้พัฒนาต้องลงทะเบียน Webhook ก่อนใช้งานระบบมิเช่นนั้นจะไม่ดำเนินการ Reqeust ใดๆทีข้ามา > และในบางกรณีผู้พัฒนาอาจจะต้องทำการเพิ่ม Whitelist ตัว Rakmao endpoint ของ environment นั้นๆเพือให้ Webhook สามารถตอบกลับได้สำเร็จ (อาจเกิดขึ้นในกรณีมี security หรือ Firewall) **Body Request** | Parameter | Required | Description | Schema | | ---------------- | ------------------ | ----------------------------------------------------------------------------------------------- | -------------- | | [Type](#Webhook-Schema) | :heavy_check_mark: | ชนิดของ webhook ที่ต้องการสมัคร | enum | | Endpoint | :heavy_check_mark: | URL ปลายทางของ webhook ที่ต้องการสมัคร | string | | IsLogin | :heavy_check_mark: | Endpoint นี้ต้องการ login จาก profile ก่อนที่จะ reqeust | boolean | | Header | :heavy_check_mark: | เป็นตัวเลือกเพิ่มเติมในกรณีทีต้องการแนบ Header ใดๆในขณะที่ Webhook ตอบกลับ (เช่น Authorization) | key/pair value | **Body Response** | Parameter | Description | Schema | | --------- | ---------------------------- | ------ | | Id | Id ของข้อมูลที่ทำการบันทึก | string | **Example Request** ```json { "IsLogin" : false, "Type" : 301, "Endpoint" : "https://sub-domain.domain-name.domain/path-to-example-api/DocumentReady", "Header" : { "Authorization": "beare **********" } } ``` **Example Response** ```json { "status": 200, "message": "Success", "data": "588db7e2-ea75-4fbf-98fc-c48419eb9edf" } ``` ### Update Webhook `PUT /api/v1/Webhook` > อัพเดทข้อมูล webhook > **Body Request** | Parameter | Required | Description | Schema | | ---------------- | ------------------ | ----------------------------------------------------------------------------------------------- | -------------- | | Id | :heavy_check_mark: | Id ของ webhook | enum | | Endpoint | :heavy_check_mark: | URL ปลายทางของ webhook ที่ต้องการสมัคร | string | | IsLogin | :heavy_check_mark: | Endpoint นี้ต้องการ login จาก profile ก่อนที่จะ reqeust | boolean | | Header | :heavy_check_mark: | เป็นตัวเลือกเพิ่มเติมในกรณีทีต้องการแนบ Header ใดๆในขณะที่ Webhook ตอบกลับ (เช่น Authorization) | key/pair value | **Example Request** ```json { "Id": "588db7e2-ea75-4fbf-98fc-c48419eb9edf" "IsLogin" : false, "Type" : 301, "Endpoint" : "https://sub-domain.domain-name.domain/path-to-example-api/DocumentReady", "Header" : { "Authorization": "beare **********" } } ``` **Example Response** ```json { "status": 200, "message": "Success", "data": true } ``` ### De-Register Webhook `DELETE /api/v1/Webhook/{enumValue}` > ลบการลงทะเบียน Webhook ออกจากระบบ **Example Request** > DELETE https://{environment}/api/v1/Webhook/301 **Example Response** ```json { "status": 200, "message": "Success", "data": true } ``` ## Webhook Schema | WebhookName | Value | ServiceType | Description | Schema | | ------------- | ----- | ----------- | -------------------------------------------------------- | ----------------------------- | | DocumentReady | 301 | Seller | จะมีการตอบกลับเมื่อฝั่งผู้ซื้อยืนยันการส่งเอกสาร | [LINK](#DocumentReady) | | BuyerNegate | 302 | Seller | จะมีการตอบกลับเมื่อฝั่งผู้ซื้อ reject หรือ cancel เอกสาร | [LINK](#DocumentBuyerNegate) | | CancelAccept | 303 | Seller | จะมีการตอบกลับเมื่อฝั่งผู้ซื้อยอมรับการยกเลิกการซื้อขายจากผู้ขาย | [LINK](#DocumentCancelAccept) | | SellerNegate | 402 | Buyer | จะมีการตอบกลับเมื่อฝั่งผู้ขาย reject หรือ request cancel เอกสาร | [LINK](#DocumentSellerNegate) | ### DocumentReady **Body Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | PoId ที่ออกโดย po service | guid | | PoCode | :heavy_check_mark: | PoCode ที่ออกโดย po service | guid | | RfqId | :heavy_check_mark: | rfqId ที่ออกโดย rakmao | guid | | QuotationId | :heavy_check_mark: | QuotationId ที่ออกโดย rakmao | guid | | DocumentFileUrl | :heavy_check_mark: | เอกสารที่ผู้ซื้อแนบมาด้วย | string | | ContactName | :heavy_check_mark: | ชื่อผู้ติดต่อ | string | | ContactPhone | :heavy_check_mark: | เบอร์โทรติดต่อ | string | | PoCreateType | :heavy_check_mark: | ประเภทการสร้างเอกสารก | [number](#PoCreateTypeEnum) | | ProjectName | :heavy_check_mark: | ชื่อโครงการ | string | | Province | | จังหวัด (จะส่งเฉพาะ DirectPO) | string | | VendorId | | Id seller ของทาง seller (จะส่งเฉพาะ DirectPO) | string | | GrandTotal | :heavy_check_mark: | ยอดเงินรวม | number | | <mark>BuyerOrgRefId | :heavy_check_mark: | OrgId ที่ออกโดย rakmao | guid | ### DocumentBuyerNegate **Body Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | PoId ที่ออกโดย po service | guid | | RfqId | :heavy_check_mark: | rfqId ที่ออกโดย rakmao | guid | | QuotationId | :heavy_check_mark: | QuotationId ที่ออกโดย rakmao | guid | | [Status](#PoDocumentStatus) | :heavy_check_mark: | สถานะที่เปลี่ยนแปลงไป | number | | CancelReason | | เหตุผลในกรณียกเลิกหรือปฏิเสธ | string | | CancelNote | | หมายเหตุในกรณียกเลิกหรือปฏิเสธ| string | | ActionByType | :heavy_check_mark: | ชนิดของผู้ดำเนินการเปลี่ยนแปลงเอกสาร (Buyer / Admin) | string | ### DocumentCancelAccept **Body Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | PoId ที่ออกโดย po service | guid | | RfqId | :heavy_check_mark: | rfqId ที่ออกโดย rakmao | guid | | QuotationId | :heavy_check_mark: | QuotationId ที่ออกโดย rakmao | guid | ### DocumentSellerNegate **Body Request** | Parameter | Required | Description | Schema | | --------- |:------------------:| ----------- | ------ | | PoId | :heavy_check_mark: | PoId ที่ออกโดย po service | guid | | RfqId | :heavy_check_mark: | rfqId ที่ออกโดย rakmao | guid | | QuotationId | :heavy_check_mark: | QuotationId ที่ออกโดย rakmao | guid | | [Status](#PoDocumentStatus) | :heavy_check_mark: | สถานะที่เปลี่ยนแปลงไป | number | | CancelReason | | เหตุผลในกรณียกเลิกหรือปฏิเสธ | string | | CancelNote | | หมายเหตุในกรณียกเลิกหรือปฏิเสธ| string |