úÎ+*.:Generate a Ruby client from a Servant API using Net::HTTP.(c) Hardy Jones, 2017BSD3jones3.hardy@gmail.com ExperimentalNone!":<=&The namespace for the generated class.9The list of namespaces you'd like the class to appear in.>The name of the class you'd like the API methods to appear in.7Generate a Ruby class with methods for the Servant API.3Currently assumes the API accepts and returns JSON. For example:QData.Text.IO.putStr $ ruby (NameSpace [] "Baz") (Proxy :: Proxy (Get '[JSON] ()))require "json"require "net/http" require "uri" class Baz def initialize(origin) @origin = URI(origin)5 @http = Net::HTTP.new(@origin.host, @origin.port) end def get() uri = URI("#{origin}")! req = Net::HTTP::Get.new(uri)& req["Accept"] = "application/json" request(req) end private def request(req, body = nil)! res = http.request(req, body): res.body = JSON.parse(res.body, symbolize_names: true) res endend?The class can be nested in a module namespace if you choose so.]Data.Text.IO.putStr $ ruby (NameSpace ["Foo", "Bar"] "Baz") (Proxy :: Proxy (Get '[JSON] ()))require "json"require "net/http" require "uri" module Foo module Bar class Baz def initialize(origin) @origin = URI(origin)9 @http = Net::HTTP.new(@origin.host, @origin.port) end def get() uri = URI("#{origin}")% req = Net::HTTP::Get.new(uri)* req["Accept"] = "application/json" request(req) end private" def request(req, body = nil)% res = http.request(req, body)> res.body = JSON.parse(res.body, symbolize_names: true) res end end endendTCaptures and query parameters are translated into required arguments, in that order.RThe request body and headers are translated into keyword arguments, in that order.–let api = Proxy :: Proxy ("foo" :> Capture "fooId" Int :> ReqBody '[JSON] () :> QueryParam "bar" Bool :> Header "Max-Forwards" Int :> Post '[JSON] ())3Data.Text.IO.putStr $ ruby (NameSpace [] "Foo") apirequire "json"require "net/http" require "uri" class Foo def initialize(origin) @origin = URI(origin)5 @http = Net::HTTP.new(@origin.host, @origin.port) end; def post_foo_by_foo_id(foo_id, bar, body:, max_forwards:)2 uri = URI("#{origin}/foo/#{fooId}?bar=#{bar}")" req = Net::HTTP::Post.new(uri)& req["Accept"] = "application/json", req["Content-Type"] = "application/json"& req["Max-Forwards"] = max_forwards request(req, body) end private def request(req, body = nil)! res = http.request(req, body): res.body = JSON.parse(res.body, symbolize_names: true) res endend       +servant-ruby-0.1.0.0-4IqFgjjNmQE4Kc97a5ZZdn Servant.Ruby NameSpace moduleNames classNamerubyimports properIndent initializeprivatepublic requestHeader rbSegments segmentToStrsegmentTypeToStrrbParams paramToStrsnake