Module: MotionYak::Request

Defined in:
lib/motion_yak/request.rb

Class Method Summary collapse

Class Method Details

.delete(url, params, &block) ⇒ Object



23
24
25
26
27
28
# File 'lib/motion_yak/request.rb', line 23

def self.delete(url, params, &block)
  BW::HTTP.delete(url, {:format => :json}) do |response|
    json = BW::JSON.parse(response.body.to_str)
    block.call(json)
  end
end

.get(url, params, &block) ⇒ Object



3
4
5
6
7
8
# File 'lib/motion_yak/request.rb', line 3

def self.get(url, params, &block)
  BW::HTTP.get(url, {:format => :json}) do |response|
    json = BW::JSON.parse(response.body.to_str)
    block.call(json)
  end
end

.post(url, params, &block) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/motion_yak/request.rb', line 16

def self.post(url, params, &block)
  params = BW::JSON.generate(params)
  BW::HTTP.post(url, {payload: params, :format => :json}) do |response|
    json = BW::JSON.parse(response.body.to_str)
    block.call(json)
  end
end

.put(url, params, &block) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/motion_yak/request.rb', line 9

def self.put(url, params, &block)
  params = BW::JSON.generate(params)
  BW::HTTP.put(url, {payload: params, :format => :json}) do |response|
    json = BW::JSON.parse(response.body.to_str)
    block.call(json)
  end
end