Skip to content

SoundWaveX81/dynamic-ep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dynamic Api approach

This is the approach to make a dynamic endpoint to get prices of different product types.

I've mock a couple of products price logic located in dynamicapi/services/ dir, each one has its own serializer to simulate diferent params (pass as querystrings due to this endpoints is uses GET method) and validate those params with its proper serializer file.

example of success request/response (status: 200)

curl --location --request GET 'http://localhost:8000/dynamic-api/product_two/?char_2=sometext&int_2=1' \
--data-raw ''
{
    "detail": "ok"
}

example of missing/wrong params request/response (status: 400)

curl --location --request GET 'http://localhost:8000/dynamic-api/product_two/?char_1=sometext&int_2=1' \
--data-raw ''
{
    "char_2": [
        "This field is required."
    ]
}

example of unknown product type (status: 404)

curl --location --request GET 'http://localhost:8000/dynamic-api/product_three/?char_1=sometext&int_2=1' \
--data-raw ''
{
    "msg": "product_three no pricing calculation for this product type"
}

About

example of dynamic end point creation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages