Module: ApiModel::RestMethods

Included in:
Base
Defined in:
lib/api_model/rest_methods.rb

Instance Method Summary collapse

Instance Method Details

#call_api(method, path, options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/api_model/rest_methods.rb', line 13

def call_api(method, path, options={})
  request = HttpRequest.new path: path, method: method, config: api_model_configuration
  request.builder = options.delete(:builder) || self
  request.options.merge! options
  request.run.build_objects
end

#get_json(path, params = {}, options = {}) ⇒ Object



4
5
6
# File 'lib/api_model/rest_methods.rb', line 4

def get_json(path, params={}, options={})
  call_api :get, path, options.merge(params: params)
end

#post_json(path, body = nil, options = {}) ⇒ Object



8
9
10
11
# File 'lib/api_model/rest_methods.rb', line 8

def post_json(path, body=nil, options={})
  body = body.to_json if body.is_a?(Hash)
  call_api :post, path, options.merge(body: body)
end