Class: MonkeyParty::Account
Instance Attribute Summary collapse
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
- #add_api_key ⇒ Object
- #api_key ⇒ Object
-
#initialize(attrs = {}) ⇒ Account
constructor
A new instance of Account.
Methods inherited from Base
Constructor Details
#initialize(attrs = {}) ⇒ Account
Returns a new instance of Account.
5 6 7 8 9 |
# File 'lib/monkey_party/account.rb', line 5 def initialize(attrs = {}) self.keys ||= [] self.keys << attrs.delete(:api_key) if attrs[:api_key] super end |
Instance Attribute Details
#keys ⇒ Object
Returns the value of attribute keys.
3 4 5 |
# File 'lib/monkey_party/account.rb', line 3 def keys @keys end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/monkey_party/account.rb', line 3 def password @password end |
#user_name ⇒ Object
Returns the value of attribute user_name.
3 4 5 |
# File 'lib/monkey_party/account.rb', line 3 def user_name @user_name end |
Class Method Details
.login(user_name, password) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/monkey_party/account.rb', line 16 def login(user_name, password) response = get("", :query => { :method => "login", :username => user_name, :password => password })["MCAPI"] account = new account.keys << response account.user_name = user_name account.password = password #set a global api key configatron.mailchimp.api_key = response account end |
Instance Method Details
#add_api_key ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/monkey_party/account.rb', line 36 def add_api_key response = self.class.get("", :query => { :method => "apikeyAdd", :username => self.user_name, :password => self.password, :apikey => self.api_key })["MCAPI"] self.keys << response response end |
#api_key ⇒ Object
11 12 13 |
# File 'lib/monkey_party/account.rb', line 11 def api_key self.keys[0] end |