Method: Mailchimp::API#initialize
- Defined in:
- lib/mailchimp.rb
#initialize(apikey = nil, debug = false) ⇒ API
Returns a new instance of API.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mailchimp.rb', line 13 def initialize(apikey=nil, debug=false) @host = 'https://api.mailchimp.com' @path = '/2.0/' @dc = 'us1' @apikey = apikey if @apikey.split('-').length == 2 @host = "https://#{@apikey.split('-')[1]}.api.mailchimp.com" end @session = Excon.new @host @debug = debug if not apikey if ENV['MAILCHIMP_APIKEY'] apikey = ENV['MAILCHIMP_APIKEY'] else apikey = read_configs end end raise Error, 'You must provide a MailChimp API key' if not apikey @apikey = apikey end |