No release in over a year
Create API clients through configuration with complete transparency
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

client-api-builder

Utility for creating API clients through configuration

Example:

class LoremIpsumClient
  include ClientApiBuilder::Router

  # by default it converts the body data to JSON
  # to convert the body to query params (x=1&y=2) use the following
  # if using active support change this to :to_query
  body_builder :query_params

  base_url 'https://www.lipsum.com'

  header 'Content-Type', 'application/x-www-form-urlencoded'
  header 'Accept', 'application/json'

  # this creates a method called create_lorem_ipsum with 2 named arguments amont and what
  route :create_lorem_ipsum, '/feed/json', body: {amount: :amount, what: :what, start: 'yes', generate: 'Generate Lorem Ipsum'}
end

How to use:

client = LoremIpsumClient.new
payload = client.create_lorem_ipsum(amount: 10, what: 'words')
puts payload.dig('feed', 'lipsum')
# outputs: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at.