Class: XRPC::Client::PostRequest

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/xrpc/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_url, headers) ⇒ PostRequest

Returns a new instance of PostRequest.



60
61
62
63
# File 'lib/xrpc/client.rb', line 60

def initialize(base_url, headers)
  self.class.base_uri base_url
  @headers = headers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, **params) ⇒ Object



65
66
67
68
# File 'lib/xrpc/client.rb', line 65

def method_missing(method_name, **params)
  response = self.class.post("/xrpc/#{method_name.to_s.gsub("_", ".")}", body: params.to_json, headers: @headers)
  response.body.empty? ? response.code : JSON.parse(response.body)
end