$ bundle gem foo-api-wrapper
$ cd foo-api-wrappers.add_dependency 'http'$ bundle installFor example, for the Jupiter Swap API (https://station.jup.ag/docs/apis/swap-api)
I created a jupiter.rb with the base URL
module Jupiter
class Error < StandardError; end
BASE_URL = "https://quote-api.jup.ag/v6"
endI created a quote.rb
module Jupiter
class Quote
def self.get(**params)
HTTP.get(BASE_URL + "/quote", params: params).parse(:json)
end
end
endI created a swap.rb
module Jupiter
class Swap
def self.post(**params)
HTTP.post(BASE_URL + "/swap", json: params).parse(:json)
end
end
endquote = Jupiter::Quote.get(inputMint: "123", outputMint: "321", amount: "1")
swap = Jupiter::Swap.post(quoteResponse: quote, userPublicKey: "f8a7df871...")Use the get and post class methods to instantiate the Quote and Swap classes with both your request and response params.
You can decide if you want to use a strict schema or something like Hashie.
thank you! @mculp