Class: MonkeyWrench::Config
- Defined in:
- lib/monkeywrench/config.rb
Instance Method Summary collapse
-
#initialize(credentials) ⇒ Config
constructor
Establishes a connection to the Mailchimp API.
Methods inherited from Base
apikey, base_uri, datacenter, default_query_params, default_retry_limit, get, handle_errors, post
Constructor Details
#initialize(credentials) ⇒ Config
Establishes a connection to the Mailchimp API.
Can be called with either a path to a file containing credentials, or a hash of credentials. The formats of each are:
File:
mailchimp:
datacenter: us1 # Or whatever DC you use
apikey: your-api-key-goes-here
Hash:
{ :datacenter => "us1", :apikey => "your-api-key-goes-here"}
containing the credentials, or a hash of credentials.
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/monkeywrench/config.rb', line 22 def initialize(credentials) if credentials.is_a?(String) config = YAML.load_file(credentials)["mailchimp"] config.collect_kv!{|k,v| [k.to_sym, v]} else config = credentials end @@apikey = config[:apikey] @@datacenter = config[:datacenter] @@dryrun = config[:dryrun] || false super({}) end |