lib/sendgrid4r/rest/users/users.rb in sendgrid4r-1.2.1 vs lib/sendgrid4r/rest/users/users.rb in sendgrid4r-1.3.0

- old
+ new

@@ -14,12 +14,14 @@ Profile = Struct.new( :address, :city, :company, :country, :first_name, :last_name, :phone, :state, :website, :zip ) - def self.url - url = "#{BASE_URL}/user/profile" + Account = Struct.new(:type, :reputation) + + def self.url(path) + url = "#{BASE_URL}/user/#{path}" url end def self.create_profile(resp) return resp if resp.nil? @@ -35,18 +37,31 @@ resp['website'], resp['zip'] ) end + def self.create_account(resp) + return resp if resp.nil? + Account.new( + resp['type'], + resp['reputation'] + ) + end + def get_user_profile(&block) - resp = get(@auth, SendGrid4r::REST::Users.url, nil, &block) + resp = get(@auth, SendGrid4r::REST::Users.url('profile'), nil, &block) SendGrid4r::REST::Users.create_profile(resp) end - def patch_user_profile(params: nil, &block) - endpoint = SendGrid4r::REST::Users.url + 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 + + def get_user_account(&block) + resp = get(@auth, SendGrid4r::REST::Users.url('account'), nil, &block) + SendGrid4r::REST::Users.create_account(resp) end end end end