Module: PanlexClient

Defined in:
lib/panlex_client/panlex_client.rb

Overview

panlex_client namespace

Constant Summary collapse

API_URL =

PanLex public API URL

'http://api.panlex.org/'

Class Method Summary collapse

Class Method Details

.query(param, body) ⇒ Hash

Send a request to PanLex API and return JSON.

Parameters:

Returns:

Raises:

  • (RestClient::ExceptionWithResponse)

    if there is an error in the response. You can use e.response to access the PanLex API error response



12
13
14
15
16
17
18
19
# File 'lib/panlex_client/panlex_client.rb', line 12

def self.query(param, body)
  begin
    response = RestClient.post API_URL+param, body.to_json, { 'content-type' => :json, :accept => :json, 'accept-encoding' => 'gzip' }
    JSON.parse(response)
  rescue RestClient::ExceptionWithResponse => e
    raise e
  end
end