Class: SupportOps::GitLab::UserEmails

Inherits:
Base
  • Object
show all
Defined in:
lib/support_ops_gitlab/gitlab/user_emails.rb

Overview

Defines the class UserEmails within the module SupportOps::GitLab.

Author:

  • Jason Colyer

Since:

  • 1.0.0

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#activate!, #approve!, attributes, #badges, #ban!, #block!, client, #client=, #commits, configure, #contributors, #create_support_pin!, #deactivate!, define_attributes, #diffs, #disable_2fa!, #discussions, #emails, #encoded_path, #events, #find, #find!, #gpg_keys, #hard_delete!, #impersonations, #initialize, #issues, #jobs, #latest_pipeline, #members, #memberships, #merge_requests, #move!, #notes, #paid?, #pats, #pipeline_variables, #pipelines, #preferences, #projects, readonly_attributes, #reject!, #revoke!, #rotate!, #save!, #ssh_keys, #status, #store_original_attributes, #subscribe!, #support_pin, to_hash, #tokens, #unban!, #unblock!, #unsubscribe!, #webhooks

Constructor Details

This class inherits a constructor from SupportOps::GitLab::Base

Instance Attribute Details

#confirmed_atString

Timestamp of when the email address was confirmed

Returns:

  • (String)

    the current value of confirmed_at



18
19
20
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 18

def confirmed_at
  @confirmed_at
end

#emailString

The email address

Returns:

  • (String)

    the current value of email



18
19
20
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 18

def email
  @email
end

#idInteger

ID of the email address

Returns:

  • (Integer)

    the current value of id



18
19
20
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 18

def id
  @id
end

#skip_confirmationBoolean

Used in creations only, skips sending the confirmation email

Returns:

  • (Boolean)

    the current value of skip_confirmation



18
19
20
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 18

def skip_confirmation
  @skip_confirmation
end

#user_idInteger

Used in creations only, specifies the user ID

Returns:

  • (Integer)

    the current value of user_id



18
19
20
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 18

def user_id
  @user_id
end

Class Method Details

.list(key: value) ⇒ Array

Lists all email addresses for a user

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.url = 'https://gitlab.example.com/api/v4'
  config.token = 'abc123'
end

emails = SupportOps::GitLab::UserEmails.list(user_id: 123456)
pp emails.count
# => 2
pp emails.last.email
# => "email2@example.com"

Parameters:

  • user_id (Integer optional)

    The user ID to get emails of (not including this does it for the current user)

Returns:

  • (Array)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 97

def self.list(**args)
  args[:user_id] = nil unless args[:user_id]
  url = if args[:user_id].nil?
          'user/emails'
        else
          "users/#{args[:user_id]}/emails"
        end
  response = client.connection.get(url)
  body = Oj.load(response.body)
  raise "Unable to get emails of user => #{body}" if response.status != 200
  body.map { |e| UserEmails.new(e) }
end

Instance Method Details

#delete!Boolean

Note:

This is inherited from Base#delete!

Deletes a user

Examples:

require 'support_ops_gitlab'

SupportOps::GitLab::Configuration.configure do |config|
  config.token = ENV.fetch('GL_TOKEN')
  config.url = 'https://gitlab.com/api/v4'
end

emails = SupportOps::GitLab::UserEmails.list
email = emails.last
email.delete!

Returns:

  • (Boolean)

See Also:

Author:

  • Jason Colyer

Since:

  • 1.0.0



21
# File 'lib/support_ops_gitlab/gitlab/user_emails.rb', line 21

def delete!; end