Class: EASY_HTTP
Class Method Summary collapse
-
.get(url, options = {}) ⇒ Object
attr_accessor :url.
- .patch(url, options = {}) ⇒ Object
- .post(url, options = {}) ⇒ Object
- .put(url, options = {}) ⇒ Object
- .request_type(http_method, url, option) ⇒ Object
Instance Method Summary collapse
- #body_parse ⇒ Object
- #body_parser(body = {}) ⇒ Object
- #header_parse(header = {}) ⇒ Object
- #params_paser ⇒ Object
Class Method Details
.get(url, options = {}) ⇒ Object
attr_accessor :url
14 15 16 17 |
# File 'lib/easy_http.rb', line 14 def self.get(url, = {}) puts 'hello' self.request_type Net::HTTP::Get, url, end |
.patch(url, options = {}) ⇒ Object
27 28 29 |
# File 'lib/easy_http.rb', line 27 def self.patch(url, = {}) self.request_type Net::HTTP::Patch, url, end |
.post(url, options = {}) ⇒ Object
19 20 21 |
# File 'lib/easy_http.rb', line 19 def self.post(url, = {}) self.request_type Net::HTTP::Post, url, end |
.put(url, options = {}) ⇒ Object
23 24 25 |
# File 'lib/easy_http.rb', line 23 def self.put(url, = {}) self.request_type Net::HTTP::Put, url, end |
.request_type(http_method, url, option) ⇒ Object
49 50 51 |
# File 'lib/easy_http.rb', line 49 def self.request_type http_method, url, option response = Easy_http_Request::Request.new(http_method, url, option).connect() end |
Instance Method Details
#body_parse ⇒ Object
36 37 38 |
# File 'lib/easy_http.rb', line 36 def body_parse body_parser(self.params['body']) end |
#body_parser(body = {}) ⇒ Object
45 46 47 |
# File 'lib/easy_http.rb', line 45 def body_parser body ={} body.to_json end |
#header_parse(header = {}) ⇒ Object
40 41 42 43 |
# File 'lib/easy_http.rb', line 40 def header_parse header = {} raise ArgumentError, 'Headers must be an object which responds to #to_hash' unless header.respond_to?(:to_hash) [:headers].merge!(h.to_hash) end |
#params_paser ⇒ Object
32 33 34 |
# File 'lib/easy_http.rb', line 32 def params_paser header_parse(self.params['headers']) end |