Class: Mailchimp::Users

Inherits:
Object
  • Object
show all
Defined in:
lib/mailchimp/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(master) ⇒ Users

Returns a new instance of Users.



159
160
161
# File 'lib/mailchimp/api.rb', line 159

def initialize(master)
    @master = master
end

Instance Attribute Details

#masterObject

Returns the value of attribute master.



157
158
159
# File 'lib/mailchimp/api.rb', line 157

def master
  @master
end

Instance Method Details

#invite(email, role = 'viewer', msg = '') ⇒ Hash

Invite a user to your account

Parameters:

  • email (String)

    A valid email address to send the invitation to

  • role (String) (defaults to: 'viewer')

    the role to assign to the user - one of viewer, author, manager, admin. defaults to viewer. More details <a href=“kb.mailchimp.com/article/can-we-have-multiple-users-on-our-account-with-limited-access” target=“_blank”>here</a>

  • msg (String) (defaults to: '')

    an optional message to include. Plain text any HTML tags will be stripped.

Returns:

  • (Hash)

    the method completion status

    • String

      status The status (success) of the call if it completed. Otherwise an error is thrown.



169
170
171
172
# File 'lib/mailchimp/api.rb', line 169

def invite(email, role='viewer', msg='')
    _params = {:email => email, :role => role, :msg => msg}
    return @master.call 'users/invite', _params
end

#invite_resend(email) ⇒ Hash

Resend an invite a user to your account. Note, if the same address has been invited multiple times, this will simpy re-send the most recent invite

Parameters:

  • email (String)

    A valid email address to resend an invitation to

Returns:

  • (Hash)

    the method completion status

    • String

      status The status (success) of the call if it completed. Otherwise an error is thrown.



178
179
180
181
# File 'lib/mailchimp/api.rb', line 178

def invite_resend(email)
    _params = {:email => email}
    return @master.call 'users/invite-resend', _params
end

#invite_revoke(email) ⇒ Hash

Revoke an invitation sent to a user to your account. Note, if the same address has been invited multiple times, this will simpy revoke the most recent invite

Parameters:

  • email (String)

    A valid email address to send the invitation to

Returns:

  • (Hash)

    the method completion status

    • String

      status The status (success) of the call if it completed. Otherwise an error is thrown.



187
188
189
190
# File 'lib/mailchimp/api.rb', line 187

def invite_revoke(email)
    _params = {:email => email}
    return @master.call 'users/invite-revoke', _params
end

#invitesArray

Retrieve the list of pending users invitations have been sent for.

Returns:

  • (Array)

    structs for each invitation, including:

    • String

      email the email address the invitation was sent to

    • String

      role the role that will be assigned if they accept

    • String

      sent_at the time the invitation was sent. this will change if it’s resent.

    • String

      expiration the expiration time for the invitation. this will change if it’s resent.

    • String

      msg the welcome message included with the invitation



199
200
201
202
# File 'lib/mailchimp/api.rb', line 199

def invites()
    _params = {}
    return @master.call 'users/invites', _params
end

#login_revoke(username) ⇒ Hash

Revoke access for a specified login

Parameters:

  • username (String)

    The username of the login to revoke access of

Returns:

  • (Hash)

    the method completion status

    • String

      status The status (success) of the call if it completed. Otherwise an error is thrown.



208
209
210
211
# File 'lib/mailchimp/api.rb', line 208

def (username)
    _params = {:username => username}
    return @master.call 'users/login-revoke', _params
end

#loginsArray

Retrieve the list of active logins.

Returns:

  • (Array)

    structs for each user, including:

    • Int

      id the login id for this login

    • String

      username the username used to log in

    • String

      name a display name for the account - empty first/last names will return the username

    • String

      email the email tied to the account used for passwords resets and the ilk

    • String

      role the role assigned to the account

    • String

      avatar if available, the url for the login’s avatar

    • Int

      global_user_id the globally unique user id for the user account connected to

    • String

      dc_unique_id the datacenter unique id for the user account connected to, like helper/account-details



223
224
225
226
# File 'lib/mailchimp/api.rb', line 223

def logins()
    _params = {}
    return @master.call 'users/logins', _params
end

#profileHash

Retrieve the profile for the login owning the provided API Key

Returns:

  • (Hash)

    the current user’s details, including:

    • Int

      id the login id for this login

    • String

      username the username used to log in

    • String

      name a display name for the account - empty first/last names will return the username

    • String

      email the email tied to the account used for passwords resets and the ilk

    • String

      role the role assigned to the account

    • String

      avatar if available, the url for the login’s avatar

    • Int

      global_user_id the globally unique user id for the user account connected to

    • String

      dc_unique_id the datacenter unique id for the user account connected to, like helper/account-details

    • String

      account_name The name of the account to which the API key belongs



239
240
241
242
# File 'lib/mailchimp/api.rb', line 239

def profile()
    _params = {}
    return @master.call 'users/profile', _params
end