lib/adp/api_connection.rb in adp-connection-0.1.4 vs lib/adp/api_connection.rb in adp-connection-0.1.5

- old
+ new

@@ -26,18 +26,18 @@ end def connect if self.connection_configuration.nil? - raise ADPConnectionException, "Configuration is empty or not found" + raise ConnectionException, "Configuration is empty or not found" end self.access_token = get_access_token() end def disconnect - self.access_token = null; + self.access_token = nil end # @return [Boolean] def is_connected_indicator? @@ -56,23 +56,23 @@ result = nil; if is_connected_indicator? if self.connection_configuration.nil? - raise ADPConnectionException, "Config error: Configuration is empty or not found" + raise ConnectionException, "Config error: Configuration is empty or not found" end if (self.connection_configuration.grantType.nil?) - raise ADPConnectionException, "Config error: Grant Type is empty or not known" + raise ConnectionException, "Config error: Grant Type is empty or not known" end if (self.connection_configuration.tokenServerURL.nil?) - raise ADPConnectionException, "Config error: tokenServerURL is empty or not known" + raise ConnectionException, "Config error: tokenServerURL is empty or not known" end if (self.connection_configuration.clientID.nil?) - raise ADPConnectionException, "Config error: clientID is empty or not known" + raise ConnectionException, "Config error: clientID is empty or not known" end if (self.connection_configuration.clientSecret.nil?) - raise ADPConnectionException, "Config error: clientSecret is empty or not known" + raise ConnectionException, "Config error: clientSecret is empty or not known" end end data = { "client_id" => self.connection_configuration.clientID, @@ -83,20 +83,20 @@ result = send_web_request(self.connection_configuration.tokenServerURL, data ); if result["error"].nil? then token = AccessToken.new(result) else - raise ADPConnectionException, "Connection error: #{result['error_description']}" + raise ConnectionException, "Connection error: #{result['error_description']}" end token end # @return [Object] def get_adp_data(product_url) - raise ADPConnectionException, "Connection error: can't get data, not connected" if (self.access_token.nil? || !is_connected_indicator?) + raise ConnectionException, "Connection error: can't get data, not connected" if (self.access_token.nil? || !is_connected_indicator?) authorization = "#{self.access_token.token_type} #{self.access_token.token}" data = { "client_id" => self.connection_configuration.clientID, @@ -106,11 +106,11 @@ "redirect_uri" => self.connection_configuration.redirectURL }; data = send_web_request(product_url, data, authorization, 'application/json', 'GET') - raise ADPConnectionException, "Connection error: #{data['error']}, #{data['error_description']}" unless data["error"].nil? + raise ConnectionException, "Connection error: #{data['error']}, #{data['error_description']}" unless data["error"].nil? return data end def send_web_request(url, data={}, authorization=nil, content_type=nil, method=nil) @@ -137,9 +137,11 @@ if (!self.connection_configuration.sslCertPath.nil?) http.use_ssl = true http.cert = OpenSSL::X509::Certificate.new( pem ); http.key = OpenSSL::PKey::RSA.new(key, self.connection_configuration.sslKeyPass); http.verify_mode = OpenSSL::SSL::VERIFY_PEER + http.cert_store = OpenSSL::X509::Store.new + http.cert_store.add_file(self.connection_configuration.sslCaPath) end if method.eql?('POST') request = Net::HTTP::Post.new(uri.request_uri) request.set_form_data( data );