
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
A basic adaptor to send HTTP requests and parse the responses. Intended to bootstrap the quick writing of Adaptors for specific APIs, without having to write the same old JSON request and processing time and time again.
Install the gem and add to the application's Gemfile by executing:
bundle add api_adaptor
If bundler is not being used to manage dependencies, install the gem by executing:
gem install api_adaptor
Use the ApiAdaptor as a base class for your API wrapper, for example:
class MyApi < ApiAdaptor::Base
def base_url
endpoint
end
end
Use your new class to create a client that can make HTTP requests to JSON APIs for:
client = MyApi.new
response = client.get_json("http://some.endpoint/json")
client = MyApi.new
response = client.post_json("http://some.endpoint/json", { "foo": "bar" })
client = MyApi.new
response = client.put_json("http://some.endpoint/json", { "foo": "bar" })
client = MyApi.new
response = client.patch_json("http://some.endpoint/json", { "foo": "bar" })
client = MyApi.new
response = client.delete_json("http://some.endpoint/json", { "foo": "bar" })
you can also get a raw response from the API
client = MyApi.new
response = client.get_raw("http://some.endpoint/json")
User Agent is populated with a default string. See .env.example.
For instance if you provide:
APP_NAME=test_app
APP_VERSION=1.0.0
APP_CONTACT=contact@example.com
User agent would read
test_app/1.0.0 (contact@example.com)
Bug reports and pull requests are welcome on GitHub at https://github.com/huwd/api_adaptor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the ApiAdaptor project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.
FAQs
Unknown package
We found that api_adaptor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.