Module: SendGrid4r::REST::Users
- Includes:
- Request
- Included in:
- API
- Defined in:
- lib/sendgrid4r/rest/users.rb
Overview
SendGrid Web API v3 Users
Defined Under Namespace
Classes: Account, Credits, Email, Password, Profile, Username
Constant Summary
Constants included
from Request
Request::BASE_URL
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Request
#create_args, #delete, #execute, #finish, #get, #patch, #post, #process_array_params, #process_url_params, #put
Class Method Details
.create_account(resp) ⇒ Object
48
49
50
51
|
# File 'lib/sendgrid4r/rest/users.rb', line 48
def self.create_account(resp)
return resp if resp.nil?
Account.new(resp['type'], resp['reputation'])
end
|
.create_credits(resp) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/sendgrid4r/rest/users.rb', line 63
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) ⇒ Object
53
54
55
56
|
# File 'lib/sendgrid4r/rest/users.rb', line 53
def self.create_email(resp)
return resp if resp.nil?
Email.new(resp['email'])
end
|
.create_password(resp) ⇒ Object
76
77
78
79
|
# File 'lib/sendgrid4r/rest/users.rb', line 76
def self.create_password(resp)
return resp if resp.nil?
Password.new(resp['new_password'], resp['old_password'])
end
|
.create_profile(resp) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/sendgrid4r/rest/users.rb', line 32
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) ⇒ Object
58
59
60
61
|
# File 'lib/sendgrid4r/rest/users.rb', line 58
def self.create_username(resp)
return resp if resp.nil?
Username.new(resp['username'], resp['user_id'])
end
|
.url(path) ⇒ Object
28
29
30
|
# File 'lib/sendgrid4r/rest/users.rb', line 28
def self.url(path)
"#{BASE_URL}/user/#{path}"
end
|
Instance Method Details
#get_user_account(&block) ⇒ Object
91
92
93
94
|
# File 'lib/sendgrid4r/rest/users.rb', line 91
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) ⇒ Object
118
119
120
121
|
# File 'lib/sendgrid4r/rest/users.rb', line 118
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) ⇒ Object
96
97
98
99
|
# File 'lib/sendgrid4r/rest/users.rb', line 96
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) ⇒ Object
81
82
83
84
|
# File 'lib/sendgrid4r/rest/users.rb', line 81
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) ⇒ Object
107
108
109
110
|
# File 'lib/sendgrid4r/rest/users.rb', line 107
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) ⇒ Object
86
87
88
89
|
# File 'lib/sendgrid4r/rest/users.rb', line 86
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) ⇒ Object
101
102
103
104
105
|
# File 'lib/sendgrid4r/rest/users.rb', line 101
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) ⇒ Object
123
124
125
126
127
128
129
130
|
# File 'lib/sendgrid4r/rest/users.rb', line 123
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) ⇒ Object
112
113
114
115
116
|
# File 'lib/sendgrid4r/rest/users.rb', line 112
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
|