Module: Trav3::REST
- Extended by:
- Net
- Defined in:
- lib/trav3/rest.rb
Class Method Summary collapse
- .create(travis, url, data) ⇒ Object
- .delete(travis, url) ⇒ Object
- .get(travis, url, raw_reply = false) ⇒ Object
- .patch(travis, url, data = {}) ⇒ Object
- .post(travis, url, body = nil) ⇒ Object
Class Method Details
.create(travis, url, data) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/trav3/rest.rb', line 12 def create(travis, url, data) uri = as_uri url req = request_post uri set_headers travis, req set_json_body req, data response = get_response uri, req output travis, response end |
.delete(travis, url) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/trav3/rest.rb', line 22 def delete(travis, url) uri = as_uri url req = request_delete uri set_headers travis, req response = get_response uri, req output travis, response end |
.get(travis, url, raw_reply = false) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trav3/rest.rb', line 31 def get(travis, url, raw_reply = false) uri = as_uri url req = request_get uri set_headers travis, req response = get_response uri, req return response.body if raw_reply output travis, response end |
.patch(travis, url, data = {}) ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/trav3/rest.rb', line 42 def patch(travis, url, data = {}) uri = as_uri url req = request_patch uri set_headers travis, req set_json_body req, data response = get_response uri, req output travis, response end |
.post(travis, url, body = nil) ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'lib/trav3/rest.rb', line 52 def post(travis, url, body = nil) uri = as_uri url req = request_post uri set_headers travis, req req.body = body if body response = get_response uri, req output travis, response end |