Aga-request

Aga request is a Ruby gem that provides a convenient way to make HTTP requests, including passing parameters, headers, and more. It simplifies the process of interacting with APIs and web services and handles the complexities of handling HTTP requests and responses.

Features

  • Make GET, POST, PUT, DELETE, and other HTTP requests easily.
  • Pass parameters and headers with the requests.
  • Handle response parsing automatically, returning OpenStruct responses.
  • Get access to the response status, headers, and body.

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add aga-request

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install aga-request

Usage

To use Aga-request in your application, require the gem and start making requests. Here's a basic example:

require 'request'
require 'ostruct'

options = OpenStruct.new(
    http_method: 'get', // get, post, put, patch, delete
    url: 'https://api.example.com/resource',
    headers: {}, // All headers you want, without authentication headers
    data: {}, // Body params
    params: nil, // Hash if you want to pass any query params 
    auth: (*),
    proxy: nil,
    options: {}
)

response = Request::Client.request(options)

puts response  # Output: #<Request::Response:0x00007fdac286dd38 @status=200, @body=#`<OpenStruct>`>
puts response.status # Output: 200

puts response.body # Output: #<OpenStruct userId=1, id=1, title="sunt aut facere repellat provident occaecati excepturi optio reprehenderit", body="quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto">

OpenStruct of auth possible (*):

Basic: OpenStruct.new(type::basic, user:'username', pass:'password')
Bearer: OpenStruct.new(type::bearer, token:'token_value')
Token: OpenStruct.new(type::token, token:'token_value')

Contributing

Contributions to Aga-request are welcome! If you encounter any issues or have suggestions for improvements, please submit an issue on the repository. Pull requests are also encouraged.

Private License

Version 0.0.2, 01/06/2023

By obtaining a copy of this software and associated documentation files (the "Software"), you agree that the Software is proprietary to AIGreenAnt and is protected under intellectual property laws. This license grants you limited rights to use the Software solely for internal purposes within your organization.

  1. License Grant

1.1 You are granted a non-exclusive, non-transferable license to use the Software for internal purposes only.

1.2 You may not distribute, sublicense, sell, or transfer the Software to any third party without prior written permission from AIGreenAnt.

  1. Intellectual Property

2.1 The Software and any associated intellectual property rights, including but not limited to copyrights, patents, trademarks, trade secrets, and any other proprietary rights, are and shall remain the exclusive property of AIGreenAnt.

2.2 You may not remove, alter, or obscure any proprietary notices or labels on the Software.

  1. Limitation of Liability

3.1 In no event shall AIGreenAnt be liable for any direct, indirect, incidental, special, or consequential damages arising out of the use or inability to use the Software, even if AIGreenAnt has been advised of the possibility of such damages.

  1. Termination

4.1 This license is effective until terminated. AIGreenAnt may terminate this license at any time if you fail to comply with the terms and conditions of this agreement.

4.2 Upon termination, you must immediately cease all use of the Software and destroy all copies in your possession or control.

  1. Governing Law

5.1 This license shall be governed by and construed in accordance with the laws of Italy, without regard to its conflict of laws principles.

By using the Software, you acknowledge that you have read and understood this license agreement and agree to be bound by its terms and conditions.