earthowned / planetfarms

GNU Affero General Public License v3.0
5 stars 8 forks source link

Courses API #519

Closed neil-sweetcodepro closed 2 years ago

neil-sweetcodepro commented 2 years ago

Courses API changes:

Need to be logged in in order to access the APIs (need bearer token).

In order to add a course description with an image, you need to upload the image first and then use the image URL from the response.

lmmrssa commented 2 years ago

Its somehow difficult to know which fields are required and which are not when looking into Postman. It takes some try to understand it. Also when certain fields are not passed it gives error from code such as

Screen Shot 2022-05-10 at 22 51 15

We should avoid code error and return error message that can be sent to user. Also structure of text, photo seems like it can be multiple item but when sending it on api its not clear how to send multiple. So far was able to send one text and image

neil-sweetcodepro commented 2 years ago

@lmmrssa can be checked again. Kindly check the description since there were changes in the body structure of the APIs. Our postman collection is updated as well,

lmmrssa commented 2 years ago
Screen Shot 2022-05-16 at 13 51 51
neil-sweetcodepro commented 2 years ago

@lmmrssa is that from a clean migration? can you try db migration and db seed with a clean db?

lmmrssa commented 2 years ago

not sure if having pull path in media is right approach

{
    "title": "Sample title",
    "price": 12.12,
    "isPublished": true,
    "thumbnail": "http://localhost:5000/resources/1.jpg",
    "description": [
        { "image": "http://localhost:5000/resources/images/2.jpg", "description": "img description (order 1)" },
        { "text": "text description 1 (order 2)", "heading": "text heading" },
        { "image": "http://localhost:5000/resources/images/3.jpg", "description": "img description (order 3)" }
    ]
}

For example If we change domain name then this will not work. May be if we assume there to be cdn path which will be same irrespective of application url then it might be ok. Also how will we send image attachment. will there be different request to upload them before creating course?

dogi commented 2 years ago

@neil-sweetcodepro usually CDN have their own URL which might vary based on CDN system/service we use and/or instance we create -> in other words relative URLs make us more flexible

neil-sweetcodepro commented 2 years ago

@lmmrssa @dogi fixed this and updated the postman