Class: WeThePeople::Config::MotionHTTPWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/we_the_people/config.rb

Defined Under Namespace

Classes: Response

Class Method Summary collapse

Class Method Details

.get(url, args = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/we_the_people/config.rb', line 11

def self.get(url, args = {})
  url_string = ("#{url}?#{make_query_string(args[:params] || {})}").stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
  url = NSURL.URLWithString(url_string)
  request = NSURLRequest.requestWithURL(url)
  response = nil
  error = nil
  data = NSURLConnection.sendSynchronousRequest(request, returningResponse: response, error: error)
  
  NSString.alloc.initWithData(data, encoding: NSUTF8StringEncoding)
end

.make_query_string(hash) ⇒ Object



22
23
24
25
26
# File 'lib/we_the_people/config.rb', line 22

def self.make_query_string(hash)
  hash.collect do |key, value|
    "#{key}=#{value}"
  end.sort * '&'
end