-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract configuration/connection/errors into their own files
- Loading branch information
Showing
4 changed files
with
70 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,29 @@ | |||
module Akamai | |||
|
|||
class Configuration | |||
|
|||
attr_accessor :cachecontrol_username, | |||
:cachecontrol_password, | |||
:cachecontrol_domain, | |||
:cachecontrol_purge_action, | |||
:netstorage_username, | |||
:netstorage_password, | |||
:netstorage_ftp_host, | |||
:netstorage_public_host, | |||
:netstorage_basedir, | |||
:wsdl_url | |||
|
|||
def initialize(args = {}) | |||
self.wsdl_url = 'http://ccuapi.akamai.com/ccuapi-axis.wsdl' | |||
self.cachecontrol_domain = "production" | |||
self.cachecontrol_purge_action = "remove" | |||
|
|||
for key, val in args | |||
send("#{key}=".to_sym, val) | |||
end | |||
|
|||
end | |||
|
|||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
module Akamai | |||
|
|||
class Connection | |||
|
|||
attr_accessor :config | |||
|
|||
def initialize(args = {}) | |||
@config = args.kind_of?(Configuration) ? args : Configuration.new(args) | |||
end | |||
|
|||
def driver | |||
return @driver if @driver | |||
|
|||
@driver = SOAP::WSDLDriverFactory.new(config.wsdl_url).create_rpc_driver | |||
@driver.options['protocol.http.ssl_config.verify_mode'] = OpenSSL::SSL::VERIFY_NONE | |||
@driver.options["protocol.http.basic_auth"] << [config.wsdl_url, config.cachecontrol_username, config.cachecontrol_password] | |||
@driver | |||
end | |||
|
|||
def purge(*urls) | |||
result = driver.purgeRequest(config.cachecontrol_username, config.cachecontrol_password, '', ["domain=#{config.cachecontrol_domain}", "action=#{config.cachecontrol_purge_action}"], urls) | |||
raise PurgeError, result.inspect unless result.resultCode == '100' | |||
true | |||
end | |||
|
|||
end | |||
|
|||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
module Akamai | |||
|
|||
class Error < StandardError | |||
end | |||
|
|||
class PurgeError < StandardError | |||
end | |||
|
|||
end |