lib/emaildirect.rb in emaildirect-1.0.1 vs lib/emaildirect.rb in emaildirect-1.1.0

- old
+ new

@@ -25,18 +25,18 @@ require 'emaildirect/subscriber' require 'emaildirect/suppression_list' require 'emaildirect/workflow' module EmailDirect - # Just allows callers to do EmailDirect.api_key "..." rather than EmailDirect::EmailDirect.api_key "..." etc + # Just allows callers to do EmailDirect.api_key = "..." rather than EmailDirect::EmailDirect.api_key "..." etc class << self - def api_key(api_key=nil) - r = EmailDirect.api_key api_key + def api_key=(api_key=nil) + EmailDirect.api_key api_key end - def base_uri(uri) - r = EmailDirect.base_uri uri + def base_uri=(uri) + EmailDirect.base_uri uri end end # Represents a EmailDirect API error and contains specific data about the error. class EmailDirectError < StandardError @@ -60,18 +60,19 @@ @@base_uri = "https://rest.emaildirect.com/v1/" @@api_key = "" headers({ 'User-Agent' => "emaildirect-rest-#{VERSION}", 'Content-Type' => 'application/json; charset=utf-8', - 'Accept-Encoding' => 'gzip, deflate' }) + 'Accept-Encoding' => 'gzip, deflate', + 'ApiKey' => @@api_key + }) base_uri @@base_uri - basic_auth 'x', @@api_key # Sets the API key which will be used to make calls to the EmailDirect API. - def self.api_key(api_key=nil) + def self.api_key(api_key = nil) return @@api_key unless api_key @@api_key = api_key - basic_auth 'x', @@api_key + headers 'ApiKey' => @@api_key end # This call returns an object reflecting the current permissions allowed for the provided API Key def ping response = EmailDirect.get('/Ping')