-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Generate a Ruby client from a Servant API with Net::HTTP. -- -- Generate a Ruby client from a Servant API with Net::HTTP. @package servant-ruby @version 0.5.0.0 module Servant.Ruby -- | The namespace for the generated class. data NameSpace NameSpace :: [Text] -> Text -> NameSpace -- | The list of namespaces you'd like the class to appear in. [moduleNames] :: NameSpace -> [Text] -- | The name of the class you'd like the API methods to appear in. [className] :: NameSpace -> Text -- | Generate a Ruby class with methods for the Servant API. -- -- Currently assumes the API accepts and returns JSON. -- -- For example: -- --
-- >>> Data.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)
-- @http = Net::HTTP.new(@origin.host, @origin.port)
-- end
--
-- def get()
-- uri = URI("#{@origin}")
--
-- req = Net::HTTP::Get.new(uri)
--
-- @http.request(req)
-- end
-- end
--
--
-- 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)
-- @http = Net::HTTP.new(@origin.host, @origin.port)
-- end
--
-- def get()
-- uri = URI("#{@origin}")
--
-- req = Net::HTTP::Get.new(uri)
--
-- @http.request(req)
-- end
-- end
-- end
-- end
--
--
-- Captures and query parameters are translated into required arguments,
-- in that order.
--
-- The request body and headers are translated into keyword arguments, in
-- that order.
--
--
-- >>> let api = Proxy :: Proxy ("foo" :> Capture "fooId" Int :> ReqBody '[JSON] () :> QueryParam "barId" Bool :> Header "Max-Forwards" Int :> Post '[JSON] ())
--
-- >>> Data.Text.IO.putStr $ ruby (NameSpace [] "Foo") api
-- require "json"
-- require "net/http"
-- require "uri"
--
-- class Foo
-- def initialize(origin)
-- @origin = URI(origin)
-- @http = Net::HTTP.new(@origin.host, @origin.port)
-- end
--
-- def post_foo_by_foo_id(foo_id, bar_id, body:, max_forwards:)
-- uri = URI("#{@origin}/foo/#{foo_id}?barId=#{bar_id}")
--
-- req = Net::HTTP::Post.new(uri)
-- req["Content-Type"] = "application/json"
-- req["Max-Forwards"] = max_forwards
--
-- @http.request(req, body)
-- end
-- end
--
ruby :: (GenerateList NoContent (Foreign NoContent api), HasForeign NoTypes NoContent api) => NameSpace -> Proxy api -> Text