BIGmama-technology / Hyko-toolkit

Collection of APIs/Models/Functions definitions in Hyko πŸ“¦
5 stars 1 forks source link

add http post as new util #63

Closed Mouhamedtec closed 3 months ago

Mouhamedtec commented 3 months ago

61

  1. Utils Name: http_utils

  2. Function Name: post

  3. Purpose: The post function is responsible for making an HTTP request to a specified URL using the httpx library. It sends form data (input values) to the server and handles the response.

  4. Function Signature:

    • Parameters:
      • inputs: An instance of the Inputs class, containing input field names and corresponding values.
      • params: An instance of the Params class, containing the URL and an optional bearer token.
    • Return Type: An instance of the Outputs class, indicating whether the task was successful.
  5. Steps Performed:

    • Creates an asynchronous HTTP client using httpx.AsyncClient().
    • Generates form data by zipping input field names and values together.
    • Sets appropriate headers (including optional bearer token) for the HTTP request.
    • Makes a POST request to the specified URL with the generated form data.
    • Checks if the response is successful.
    • If successful, returns an instance of Outputs with response_success set to True.
    • If not successful, raises an APICallError with the response status code and details.
1hachem commented 3 months ago

I like what you did with the inputs in order to construct a dict with it, however we are currently working on adding a json input node where you can pass a json directly, after that we will work on adding a custom_api_call utility function that can make all http requests (post, put, get ...) and return a json as well. You are the first person from the community to contribute to Hyko and we really appreciate that ! πŸ”₯

However I have to close this pr in favor of future feature inchalah ! Thank you πŸ™ŒπŸΌ

Mouhamedtec commented 3 months ago

It's greatly appreciated that you and your team are developing this feature. I enjoy using Hyko and am pleased to contribute proposals for its enhancement.