Sha256: d441b72945dd5957fae807016f05d38da3f2e72604a9f595b07189f6a51e2794
Contents?: true
Size: 1.32 KB
Versions: 7
Compression:
Stored size: 1.32 KB
Contents
module SendGridWebApi::Helper extend self def run_sendgrid_query(username, password) @client = SendGridWebApi::Client.new(username, password) result = yield raise "it returns the following errors: #{result}" unless result.eql?({"message"=>"success"}) end ###this accepts subuser array def create_sub_user_account(username, password, users) users.each do |user, data| #load users run_sendgrid_query(username, password) do @client.sub_user.management.add(data[:account].merge!(:username => user)) end #active user for send email run_sendgrid_query(username, password){@client.sub_user.management.enable(:user => user)} #assign ip unless data[:assigned_ips].empty? run_sendgrid_query(username, password){@client.sub_user.ip_management.assign_ip :user => user, :ip => data[:assigned_ips]} end #load apps unless data[:applications].empty? data[:applications].each do |app_name, options| run_sendgrid_query(username, password){@client.sub_user.apps.activate(:user => user, :name => app_name)} unless options.empty? run_sendgrid_query(username, password){@client.sub_user.apps.customize(options.merge!(:user => user, :name => app_name))} end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems