@@ -24,28 +24,35 @@ def authenticate!
2424 self
2525 end
2626
27- def execute_request ( request :, uri :, body : nil ,
28- authorization : default_authorization )
29- Net ::HTTP . start ( uri . host , uri . port , use_ssl : true ) do |http |
30- request [ "Authorization" ] = authorization . header
31- assign_body request : request , body : body
32- response = http . request ( request )
33- handle_response ( response : response )
34- end
27+ def build_patch_request ( uri :, body : nil )
28+ build_request_with_body ( uri : uri , body : body ,
29+ http_method : Net ::HTTP ::Patch )
3530 end
3631
37- def build_patch_request ( uri :, body :)
32+ def build_post_request ( uri :, body : nil )
3833 build_request_with_body ( uri : uri , body : body ,
39- http_method : Net ::HTTP ::Patch )
34+ http_method : Net ::HTTP ::Post )
4035 end
4136
42- def build_request_with_body ( uri :, body :, http_method : Net :: HTTP :: Post )
37+ def build_request_with_body ( uri :, body :, http_method :)
4338 request = http_method . new ( uri )
44- request . body = body . to_json
4539 request [ "content-type" ] = "application/json"
40+ unless body . nil?
41+ request . body = body . to_json
42+ end
4643 request
4744 end
4845
46+ def execute_request ( request :, uri :, body : nil ,
47+ authorization : default_authorization )
48+ Net ::HTTP . start ( uri . host , uri . port , use_ssl : true ) do |http |
49+ request [ "Authorization" ] = authorization . header
50+ assign_body request : request , body : body
51+ response = http . request ( request )
52+ handle_response ( response : response )
53+ end
54+ end
55+
4956 def authenticated?
5057 access_token . present?
5158 end
0 commit comments