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, Profile
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, #get, #patch, #post, #process_array_params, #process_url_params, #put
Class Method Details
.create_account(resp) ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/sendgrid4r/rest/users.rb', line 39
def self.create_account(resp)
return resp if resp.nil?
Account.new(
resp['type'],
resp['reputation']
)
end
|
.create_profile(resp) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/sendgrid4r/rest/users.rb', line 23
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
|
.url(path) ⇒ Object
18
19
20
21
|
# File 'lib/sendgrid4r/rest/users.rb', line 18
def self.url(path)
url = "#{BASE_URL}/user/#{path}"
url
end
|
Instance Method Details
#get_user_account(&block) ⇒ Object
58
59
60
61
|
# File 'lib/sendgrid4r/rest/users.rb', line 58
def get_user_account(&block)
resp = get(@auth, SendGrid4r::REST::Users.url('account'), nil, &block)
SendGrid4r::REST::Users.create_account(resp)
end
|
#get_user_profile(&block) ⇒ Object
47
48
49
50
|
# File 'lib/sendgrid4r/rest/users.rb', line 47
def get_user_profile(&block)
resp = get(@auth, SendGrid4r::REST::Users.url('profile'), nil, &block)
SendGrid4r::REST::Users.create_profile(resp)
end
|
#patch_user_profile(params:, &block) ⇒ Object
52
53
54
55
56
|
# File 'lib/sendgrid4r/rest/users.rb', line 52
def patch_user_profile(params:, &block)
endpoint = SendGrid4r::REST::Users.url('profile')
resp = patch(@auth, endpoint, params, &block)
SendGrid4r::REST::Users.create_profile(resp)
end
|