Class: Wechat::DataObject
- Inherits:
-
Object
- Object
- Wechat::DataObject
- Defined in:
- lib/wechat/data_object.rb
Class Method Summary collapse
-
.get(method_name, params) ⇒ Hash
Make a HTTP GET request.
-
.parameterize_params(params) ⇒ String
Custom Parameterizer for Wechat.
-
.post(method_name, params) ⇒ Hash
Make a HTTP POST request.
Instance Method Summary collapse
-
#request(http_verb, method_name, params) ⇒ Hash
Make a HTTP request.
Class Method Details
.get(method_name, params) ⇒ Hash
Make a HTTP GET request
11 12 13 14 15 16 17 18 |
# File 'lib/wechat/data_object.rb', line 11 def get(method_name, params) if params.empty? self.new.request 'get', method_name, params else self.new.request 'get', [method_name + '?', parameterize_params(params)].join("&"), {} end end |
.parameterize_params(params) ⇒ String
Custom Parameterizer for Wechat
35 36 37 |
# File 'lib/wechat/data_object.rb', line 35 def parameterize_params(params) params.inject(""){|string, (k, v)| string << "#{k}=#{v}"; string << "&"; string}[0..-2] end |
.post(method_name, params) ⇒ Hash
Make a HTTP POST request
25 26 27 |
# File 'lib/wechat/data_object.rb', line 25 def post(method_name, params) self.new.request 'post', method_name, params end |
Instance Method Details
#request(http_verb, method_name, params) ⇒ Hash
Make a HTTP request
46 47 48 49 |
# File 'lib/wechat/data_object.rb', line 46 def request(http_verb, method_name, params) response = Wechat::Request.new(http_verb, method_name, params).send_request #hashiefy(response) end |