# Sale APIs

# Get Sale Details

Method: GET
Path: /bifrost/api/sale/projects/{projectId}/sales/{saleId} Description: Get details of the sale.

Client Scope:
- sale.r

Authority: -

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}
Content-Type The MIME type of this content Y application/json

Example Request:

curl --location --request GET 'https://platform.weomni-test.com/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales/5ee83b05d5e2360001d404f2' \
--header 'Authorization: Bearer {token}'

Example Response:

{
    "id": "5ee83b05d5e2360001d404f2",
    "firstName": "John",
    "lastName": "Doe",
    "userName": "johndoe",
    "status": "ACTIVE",
    "createdBy": "66932520006",
    "createdDate": "2020-06-16T07:12:58.944Z",
    "lastModifiedBy": "66932520006",
    "lastModifiedDate": "2020-06-16T07:12:58.944Z",
    "data": {
        "true": {
            "empId": "true000001",
            "saleCode": "SALE0000001-2"
        }
    }
}

# Get Sale List

Method: GET
Path: /bifrost/api/sale/projects/{projectId}/sales Description: Get list of the sales

Client Scope:
- sale.r

Authority: -

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}
Content-Type The MIME type of this content Y application/json

Example Request:

curl --location --request GET 'https://platform.weomni-test.com/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales?attr.userName=johndoe' \
--header 'Authorization: Bearer {token}'

Parameter:

Key Description Required Example
attr search by attribute name and value N attr.userName=hello&attr.firstName=world
saleData sale data to show N saleData=gz,true,weshop
returnSaleData flag to return sale data or not N returnSaleData=true
page The requested page number to display N page=0
size The page size of the result in response body N size=10
sort Sorting criteria. Default sort order is ascending. Multiple sort criteria are supported. N sort=attr.firstName,desc
createdBy.<operator_name> search by createdBy that support operator only 'equals' N createdBy.equals=admin
createdDate.<operator_name>. search by createdDate that support operator 'greaterThan', 'greaterOrEqualThan', 'lessThan' and 'lessOrEqualThan' N createdDate.greaterThan='2020-04-16T02:15:11.455Z'
lastModifiedBy.<operator_name> search by lastModifiedBy that support operator only 'equals' N lastModifiedBy.equals=admin
lastModifiedDate.<operator_name> search by lastModifiedDate that support operator 'greaterThan', 'greaterOrEqualThan', 'lessThan' and 'lessOrEqualThan' N lastModifiedDate.greaterOrEqualThan='2020-04-16T02:15:11.455Z'

Example Response:

[
    {
        "id": "5ee86c7d4fd59c0001690c14",
        "firstName": "john",
        "lastName": "doe",
        "userName": "johndoe",
        "status": "ACTIVE",
        "createdBy": "sale-client",
        "createdDate": "2020-06-16T06:53:49.422Z",
        "lastModifiedBy": "sale-client",
        "lastModifiedDate": "2020-06-16T06:53:49.422Z",
        "data": {
            "true": {
                "empId": "true000001",
                "saleCode": "SALE0000001"
            }
        }
    }
]

# Create Sale

Method: POST
Path: /bifrost/api/sale/projects/{projectId}/sales Description: Create new sale

Client Scope:
- sale.w

Authority: -

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}
Content-Type The MIME type of this content Y application/json

Request Body:

Param Description Type Required
firstName first name of sale person String N
lastName last name of sale person String N
userName user name in source app of sale person String Y
data sale data per company of sale person, data will saved as key value pair String Y

Example:

{
    "firstName":"VcomFirst01",
    "lastName": "Lastname01",
	"userName": "wemall001",
	"data":{
		"true" : {
			"salecode": "SALE001",
			"employeeId": "010VC005",
			"email": "test@truecorp.co.th"
		  }
	}
}

Example Request:

curl --location --request POST 'https://platform.weomni-test.com/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales' \
--header 'Authorization: Bearer {token}'

Example Response:

{
    "firstName": "VcomFirst05",
    "lastName": "Lastname05",
    "userName": "wemall001",
    "data": {
        "true": {
            "salecode": "SALE001",
            "employeeId": "010VC005",
            "email": "test@truecorp.co.th"
        }
    },
    "id": "5ee9e00fa96ab30001a49d9e"
}

# Update Sale

Method: PUT
Path: /bifrost/api/sale/projects/{projectId}/sales/{saleId}
Description: Update sale content with specific saleId

Client Scope: -
- sale.w

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}
Content-Type The MIME type of this content Y application/json

Request Body:

Param Description Type Required
firstName first name of sale person String N
lastName last name of sale person String N
userName user name in source app of sale person String Y
data sale data per company of sale person, data will saved as key value pair String Y

Existing Data:

[
	{
        "firstName": "VcomFirst01",
        "lastName": "Lastname01",
        "userName": "wemall000",
        "data": {
            "true": {
                "salecode": "SALE000",
                "employeeId": "010VC001",
                "email": "test00@truecorp.co.th"
            }
        },
        "id": "5ee9e00fa96ab30001a49d9e"
    }
]

Request Body Example:

curl -X PUT \
  'http://dev-platform.weomni-test.com/cms/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales/5ee9e00fa96ab30001a49d9e' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {O2O Access Token}'
  -d '[
      	{
            "firstName": "VcomFirst05",
            "lastName": "Lastname05",
            "userName": "wemall001",
            "data": {
                "true": {
                    "salecode": "SALE001",
                    "employeeId": "010VC005",
                    "email": "test@truecorp.co.th"
                }
            }
        }
      ]'

Response Example:

{
    "firstName": "VcomFirst05",
    "lastName": "Lastname05",
    "userName": "wemall001",
    "data": {
        "true": {
            "salecode": "SALE001",
            "employeeId": "010VC005",
            "email": "test@truecorp.co.th"
        }
    }
}

**remove field from data

Example: remove email from data field

Request Body Example:

curl -X PUT \
  'http://dev-platform.weomni-test.com/cms/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales/5ee9e00fa96ab30001a49d9e' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {O2O Access Token}'
  -d '[
      	{
            "firstName": "VcomFirst05",
            "lastName": "Lastname05",
            "userName": "wemall001",
            "data": {
                "true": {
                    "salecode": "SALE001",
                    "employeeId": "010VC005",
                    "email": null
                }
            }
        }
      ]'

Response Example:

{
    "firstName": "VcomFirst05",
    "lastName": "Lastname05",
    "userName": "wemall001",
    "data": {
        "true": {
            "salecode": "SALE001",
            "employeeId": "010VC005",
            "email": null
        }
    }
}

**Add new field to data

Example: add channel field to data

Request Body Example:

curl -X PUT \
  'http://dev-platform.weomni-test.com/cms/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales/5ee9e00fa96ab30001a49d9e' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {O2O Access Token}'
  -d '[
      	{
            "firstName": "VcomFirst05",
            "lastName": "Lastname05",
            "userName": "wemall001",
            "data": {
                "true": {
                    "channel": "wemall app"                    
                }
            }
        }
      ]'

Response Example:

{
    "firstName": "VcomFirst05",
    "lastName": "Lastname05",
    "userName": "wemall001",
    "data": {
        "true": {
            "channel": "wemall app"           
        }
    }
}

**Add new company data

Example: add new company "gz"

Request Body Example:

curl -X PUT \
  'http://dev-platform.weomni-test.com/cms/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales/5ee9e00fa96ab30001a49d9e' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer {O2O Access Token}'
  -d '[
      	{
            "firstName": "VcomFirst05",
            "lastName": "Lastname05",
            "userName": "wemall001",
            "data": {
                "gz": {
                    "salecode": "sale001"   
                    "position": "shop sale"    
                    "phone": "0000000"                     
                }
            }
        }
      ]'

Response Example:

{
    "firstName": "VcomFirst05",
    "lastName": "Lastname05",
    "userName": "wemall001",
    "data": {
        "gz": {
            "salecode": "sale001"   
            "position": "shop sale"    
            "phone": "0000000"                     
        }
    }
}

# Delete Sale

Method: DELETE
Path: /bifrost/api/sale/projects/{projectId}/sales/{saleId}
Description: Set sale as INACTIVE status with specific saleId

Client Scope: -
- sale.w

Request Header:

Param Description Required Example
Authorization The OAuth2 authentication with the O2O System Y Bearer {O2O Access Token}
Content-Type The MIME type of this content Y application/json

Example Request:

curl --location --request DELETE 'https://platform.weomni-test.com/bifrost/api/sale/projects/5ea00cb0eeac5d00012dcba5/sales/5ee9ebd3a96ab30001a49da7' \
--header 'Authorization: Bearer {token}'

Response Example:

HTTP/1.1 204 NO CONTENT
Last Updated: 8/25/2020, 7:35:21 AM