Class: XRPC::Client::GetRequest

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

Instance Method Summary collapse

Constructor Details

#initialize(base_url, headers) ⇒ GetRequest

Returns a new instance of GetRequest.



45
46
47
48
# File 'lib/xrpc/client.rb', line 45

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



50
51
52
53
54
# File 'lib/xrpc/client.rb', line 50

def method_missing(method_name, **params)
  self.class.get("/xrpc/#{method_name.to_s.gsub("_", ".")}", query: params, headers: @headers).then do |response|
    response.body.empty? ? response.code : JSON.parse(response.body)
  end
end