@@ -15,40 +15,37 @@ def initialize(company_alias, key, secret, server="rws.maxcdn.com", secure_conne
1515 @company_alias = company_alias
1616 @server = server
1717 @request_signer = Signet ::OAuth1 ::Client . new (
18- : client_credential_key => key ,
19- : client_credential_secret => secret ,
20- : two_legged => true
18+ client_credential_key : key ,
19+ client_credential_secret : secret ,
20+ two_legged : true
2121 )
2222 end
2323
2424 def _connection_type
25- return "http" unless @secure_connection
26- "https"
25+ @secure_connection ? "https" : "http"
2726 end
2827
2928 def _get_url uri , params = { }
3029 url = "#{ _connection_type } ://#{ @server } /#{ @company_alias } /#{ uri . gsub ( /^\/ / , "" ) } "
31- if params and not params . empty?
32- url += "?#{ params . to_params } "
33- end
34-
30+ url += "?#{ params . to_params } " if params && !params . empty?
3531 url
3632 end
3733
3834 def _response_as_json method , uri , options = { } , data = { }
3935 puts "Making #{ method . upcase } request to #{ _get_url uri } " if debug
4036
41- req_opts = {
42- :method => method
43- }
37+ req_opts = { method : method }
4438
4539 req_opts [ :uri ] = _get_url ( uri , ( options [ :body ] ? { } : data ) )
4640 req_opts [ :body ] = data . to_params if options [ :body ]
4741
4842 request = @request_signer . generate_authenticated_request ( req_opts )
4943
5044 # crazyness for headers
51- headers = { "Content-Type" => options [ :body ] ? "application/json" : "application/x-www-form-urlencoded" }
45+ headers = {
46+ "Content-Type" => options [ :body ] ? "application/json" : "application/x-www-form-urlencoded"
47+ }
48+
5249 headers . case_indifferent_merge ( options . delete ( :headers ) || { } )
5350 headers [ "User-Agent" ] = "Ruby MaxCDN API Client"
5451
@@ -63,7 +60,7 @@ def _response_as_json method, uri, options={}, data={}
6360
6461 response = conn . send ( method , path ) do |req |
6562 req . headers = request . headers
66- req . body = request . body
63+ req . body = request . body
6764 end
6865
6966 return response if options [ :debug_request ]
0 commit comments