module SendGrid4r::REST::Users

SendGrid Web API v3 Users

Constants

Account
Credits
Email
Password
Profile
Username

Public Class Methods

create_account(resp) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 47
def self.create_account(resp)
  return resp if resp.nil?
  Account.new(resp['type'], resp['reputation'])
end
create_credits(resp) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 62
def self.create_credits(resp)
  return resp if resp.nil?
  Credits.new(
    resp['remain'],
    resp['total'],
    resp['overage'],
    resp['used'],
    resp['last_reset'],
    resp['next_reset'],
    resp['reset_frequency']
  )
end
create_email(resp) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 52
def self.create_email(resp)
  return resp if resp.nil?
  Email.new(resp['email'])
end
create_password(resp) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 75
def self.create_password(resp)
  return resp if resp.nil?
  Password.new(resp['new_password'], resp['old_password'])
end
create_profile(resp) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 31
def self.create_profile(resp)
  return resp if resp.nil?
  Profile.new(
    resp['address'],
    resp['city'],
    resp['company'],
    resp['country'],
    resp['first_name'],
    resp['last_name'],
    resp['phone'],
    resp['state'],
    resp['website'],
    resp['zip']
  )
end
create_username(resp) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 57
def self.create_username(resp)
  return resp if resp.nil?
  Username.new(resp['username'], resp['user_id'])
end
url(path) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 27
def self.url(path)
  "#{BASE_URL}/user/#{path}"
end

Public Instance Methods

get_user_account(&block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 90
def get_user_account(&block)
  resp = get(@auth, Users.url(:account), nil, &block)
  finish(resp, @raw_resp) { |r| Users.create_account(r) }
end
get_user_credits(&block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 117
def get_user_credits(&block)
  resp = get(@auth, Users.url(:credits), &block)
  finish(resp, @raw_resp) { |r| Users.create_credits(r) }
end
get_user_email(&block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 95
def get_user_email(&block)
  resp = get(@auth, Users.url(:email), nil, &block)
  finish(resp, @raw_resp) { |r| Users.create_email(r) }
end
get_user_profile(&block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 80
def get_user_profile(&block)
  resp = get(@auth, Users.url(:profile), nil, &block)
  finish(resp, @raw_resp) { |r| Users.create_profile(r) }
end
get_user_username(&block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 106
def get_user_username(&block)
  resp = get(@auth, Users.url(:username), nil, &block)
  finish(resp, @raw_resp) { |r| Users.create_username(r) }
end
patch_user_profile(params:, &block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 85
def patch_user_profile(params:, &block)
  resp = patch(@auth, Users.url(:profile), params, &block)
  finish(resp, @raw_resp) { |r| Users.create_profile(r) }
end
put_user_email(email:, &block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 100
def put_user_email(email:, &block)
  params = { email: email }
  resp = put(@auth, Users.url(:email), params, &block)
  finish(resp, @raw_resp) { |r| Users.create_email(r) }
end
put_user_password(new_password:, old_password:, &block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 122
def put_user_password(new_password:, old_password:, &block)
  params = {
    new_password: new_password,
    old_password: old_password
  }
  resp = put(@auth, Users.url(:password), params, &block)
  finish(resp, @raw_resp) { |r| Users.create_password(r) }
end
put_user_username(username:, &block) click to toggle source
# File lib/sendgrid4r/rest/users.rb, line 111
def put_user_username(username:, &block)
  params = { username: username }
  resp = put(@auth, Users.url(:username), params, &block)
  finish(resp, @raw_resp) { |r| Users.create_username(r) }
end