Class: Bamboo::Client::Http::Json

Inherits:
Abstract
  • Object
show all
Defined in:
lib/bamboo-client/http/json.rb

Defined Under Namespace

Classes: Doc

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from Bamboo::Client::Abstract

Instance Attribute Details

#cookiesObject (readonly)

Doc



42
43
44
# File 'lib/bamboo-client/http/json.rb', line 42

def cookies
  @cookies
end

Instance Method Details

#get(uri_or_path, params = nil) ⇒ Object



54
55
56
57
58
# File 'lib/bamboo-client/http/json.rb', line 54

def get(uri_or_path, params = nil)
  uri = uri_for(uri_or_path, params)
  puts "Json.get: url: #{uri} cookies: #{cookies}" if $DEBUG
  Doc.from RestClient.get(uri, default_headers)
end

#get_cookies(uri_or_path, params = nil) ⇒ Object



60
61
62
63
64
# File 'lib/bamboo-client/http/json.rb', line 60

def get_cookies(uri_or_path, params = nil)
  uri = uri_for(uri_or_path, nil)
  resp = RestClient.get(uri, :params => params)
  @cookies = resp.cookies
end

#post(uri_or_path, data = {}) ⇒ Object



44
45
46
47
# File 'lib/bamboo-client/http/json.rb', line 44

def post(uri_or_path, data = {})
  resp = RestClient.post(uri_for(uri_or_path), data.to_json, default_headers.merge(:content_type => :json))
  Doc.from(resp) unless resp.empty?
end

#post_with_query(uri_or_path, query = {}) ⇒ Object



49
50
51
52
# File 'lib/bamboo-client/http/json.rb', line 49

def post_with_query(uri_or_path, query = {})
  resp = RestClient.post(uri_for(uri_or_path, query), '{}', default_headers.merge(:content_type => :json))
  Doc.from(resp) unless resp.empty?
end