LegendarySpork9 / Hunter-Industries-API

File Store for the Assistant API
Other
0 stars 0 forks source link

Build the Assistant API #3

Closed LegendarySpork9 closed 1 week ago

LegendarySpork9 commented 11 months ago

Build the Assistant API and Test it.

LegendarySpork9 commented 11 months ago

https://medium.com/@AdanRobles00/how-to-build-a-fully-functional-restful-api-using-c-and-asp-net-core-38fc647b3a16

LegendarySpork9 commented 11 months ago

Added authorisation endpoint. Need to complete validation.

LegendarySpork9 commented 6 months ago

All endpoints added and tested on the UAT environment.

LegendarySpork9 commented 6 months ago

Code rearranged and retested. Submitting to HF for review and suggestions

LegendarySpork9 commented 5 months ago

Full details attached. API Feedback.docx

LegendarySpork9 commented 3 months ago

Make a validation service to check the models instead of checking in the controller.

LegendarySpork9 commented 3 months ago

https://code-maze.com/csharp-get-list-of-properties/#:~:text=Then%2C%20we%20use%20the%20GetType,using%20the%20PrintProperties()%20method. https://stackoverflow.com/questions/3723934/using-propertyinfo-to-find-out-the-property-type

LegendarySpork9 commented 3 months ago

https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

LegendarySpork9 commented 3 months ago

Need something like the following for validation.

internal class ModelValidationService
{
    public bool IsValid(object model, bool? allRequired = false)
    {
        PropertyInfo[] properties = GetProperties(model);

        foreach (PropertyInfo property in properties)
        {
            Console.WriteLine("{0} is of type {1}", property.Name, property.PropertyType);
            var value = property.GetValue(model, null);

            if (value != null)
            {
                Console.WriteLine("{0} is valid with value {1}", property.Name, value);
            }
        }

        return true;
    }

    private PropertyInfo[] GetProperties(object model)
    {
        return model.GetType().GetProperties();
    }
}

Have the validation service return the response if the model is invalid.

LegendarySpork9 commented 3 months ago

Left to do before this can be closed.

LegendarySpork9 commented 2 months ago

Having trouble deploying to the server. Awaiting some help from Kyle to get the application to recognise the URL and use it.

LegendarySpork9 commented 1 week ago

Add Endpoint for adding new users.

LegendarySpork9 commented 1 week ago

All work complete and tested.