Class: SendGrid::Mail
- Inherits:
-
Object
- Object
- SendGrid::Mail
- Defined in:
- lib/sendgrid/helpers/mail/mail.rb
Instance Method Summary collapse
- #asm ⇒ Object
- #asm=(asm) ⇒ Object
- #attachments ⇒ Object
- #attachments=(attachments) ⇒ Object
- #batch_id ⇒ Object
- #batch_id=(batch_id) ⇒ Object
- #categories ⇒ Object
- #categories=(category) ⇒ Object
- #contents ⇒ Object
- #contents=(content) ⇒ Object
- #custom_args ⇒ Object
- #custom_args=(custom_args) ⇒ Object
- #from ⇒ Object
- #from=(from) ⇒ Object
- #headers ⇒ Object
- #headers=(headers) ⇒ Object
-
#initialize(from_email = nil, subj = nil, to_email = nil, cont = nil) ⇒ Mail
constructor
A new instance of Mail.
- #ip_pool_name ⇒ Object
- #ip_pool_name=(ip_pool_name) ⇒ Object
- #mail_settings ⇒ Object
- #mail_settings=(mail_settings) ⇒ Object
- #personalizations ⇒ Object
- #personalizations=(personalizations) ⇒ Object
- #reply_to ⇒ Object
- #reply_to=(reply_to) ⇒ Object
- #sections ⇒ Object
- #sections=(sections) ⇒ Object
- #send_at ⇒ Object
- #send_at=(send_at) ⇒ Object
- #subject ⇒ Object
- #subject=(subject) ⇒ Object
- #template_id ⇒ Object
- #template_id=(template_id) ⇒ Object
- #to_json ⇒ Object
- #tracking_settings ⇒ Object
- #tracking_settings=(tracking_settings) ⇒ Object
Constructor Details
#initialize(from_email = nil, subj = nil, to_email = nil, cont = nil) ⇒ Mail
Returns a new instance of Mail.
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 801 def initialize(from_email=nil, subj=nil, to_email=nil, cont=nil) @from = nil @subject = nil @personalizations = nil @contents = nil @attachments = nil @template_id = nil @sections = nil @headers = nil @categories = nil @custom_args = nil @send_at = nil @batch_id = nil @asm = nil @ip_pool_name = nil @mail_settings = nil @tracking_settings = nil @reply_to = nil if !(from_email.nil? && subj.nil? && to_email.nil? && cont.nil?) self.from = from_email self.subject = subj personalization = Personalization.new personalization.to = to_email self.personalizations = personalization self.contents = cont end end |
Instance Method Details
#asm ⇒ Object
941 942 943 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 941 def asm @asm.nil? ? nil : @asm.to_json end |
#asm=(asm) ⇒ Object
937 938 939 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 937 def asm=(asm) @asm = asm end |
#attachments ⇒ Object
869 870 871 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 869 def @attachments end |
#attachments=(attachments) ⇒ Object
864 865 866 867 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 864 def () @attachments = @attachments.nil? ? [] : @attachments @attachments = @attachments.push(.to_json) end |
#batch_id ⇒ Object
933 934 935 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 933 def batch_id @batch_id end |
#batch_id=(batch_id) ⇒ Object
929 930 931 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 929 def batch_id=(batch_id) @batch_id = batch_id end |
#categories ⇒ Object
907 908 909 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 907 def categories @categories end |
#categories=(category) ⇒ Object
901 902 903 904 905 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 901 def categories=(category) @categories = @categories.nil? ? [] : @categories category = category.to_json @categories = @categories.push(category['category']) end |
#contents ⇒ Object
860 861 862 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 860 def contents @contents end |
#contents=(content) ⇒ Object
855 856 857 858 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 855 def contents=(content) @contents = @contents ? @contents : [] @contents = @contents.push(content.to_json) end |
#custom_args ⇒ Object
917 918 919 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 917 def custom_args @custom_args end |
#custom_args=(custom_args) ⇒ Object
911 912 913 914 915 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 911 def custom_args=(custom_args) @custom_args = @custom_args.nil? ? {} : @custom_args custom_args = custom_args.to_json @custom_args = @custom_args.merge(custom_args['custom_arg']) end |
#from ⇒ Object
834 835 836 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 834 def from @from.nil? ? nil : @from.to_json end |
#from=(from) ⇒ Object
830 831 832 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 830 def from=(from) @from = from end |
#headers ⇒ Object
897 898 899 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 897 def headers @headers end |
#headers=(headers) ⇒ Object
891 892 893 894 895 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 891 def headers=(headers) @headers = @headers.nil? ? {} : @headers headers = headers.to_json @headers = @headers.merge(headers['header']) end |
#ip_pool_name ⇒ Object
949 950 951 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 949 def ip_pool_name @ip_pool_name end |
#ip_pool_name=(ip_pool_name) ⇒ Object
945 946 947 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 945 def ip_pool_name=(ip_pool_name) @ip_pool_name = ip_pool_name end |
#mail_settings ⇒ Object
957 958 959 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 957 def mail_settings @mail_settings.nil? ? nil : @mail_settings.to_json end |
#mail_settings=(mail_settings) ⇒ Object
953 954 955 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 953 def mail_settings=(mail_settings) @mail_settings = mail_settings end |
#personalizations ⇒ Object
851 852 853 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 851 def personalizations @personalizations.nil? ? nil : @personalizations end |
#personalizations=(personalizations) ⇒ Object
846 847 848 849 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 846 def personalizations=(personalizations) @personalizations = @personalizations.nil? ? [] : @personalizations @personalizations = @personalizations.push(personalizations.to_json) end |
#reply_to ⇒ Object
973 974 975 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 973 def reply_to @reply_to.nil? ? nil : @reply_to.to_json end |
#reply_to=(reply_to) ⇒ Object
969 970 971 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 969 def reply_to=(reply_to) @reply_to = reply_to end |
#sections ⇒ Object
887 888 889 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 887 def sections @sections end |
#sections=(sections) ⇒ Object
881 882 883 884 885 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 881 def sections=(sections) @sections = @sections.nil? ? {} : @sections sections = sections.to_json @sections = @sections.merge(sections['section']) end |
#send_at ⇒ Object
925 926 927 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 925 def send_at @send_at end |
#send_at=(send_at) ⇒ Object
921 922 923 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 921 def send_at=(send_at) @send_at = send_at end |
#subject ⇒ Object
842 843 844 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 842 def subject @subject end |
#subject=(subject) ⇒ Object
838 839 840 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 838 def subject=(subject) @subject = subject end |
#template_id ⇒ Object
877 878 879 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 877 def template_id @template_id end |
#template_id=(template_id) ⇒ Object
873 874 875 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 873 def template_id=(template_id) @template_id = template_id end |
#to_json ⇒ Object
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 977 def to_json(*) { 'from' => self.from, 'subject' => self.subject, 'personalizations' => self.personalizations, 'content' => self.contents, 'attachments' => self., 'template_id' => self.template_id, 'sections' => self.sections, 'headers' => self.headers, 'categories' => self.categories, 'custom_args' => self.custom_args, 'send_at' => self.send_at, 'batch_id' => self.batch_id, 'asm' => self.asm, 'ip_pool_name' => self.ip_pool_name, 'mail_settings' => self.mail_settings, 'tracking_settings' => self.tracking_settings, 'reply_to' => self.reply_to }.delete_if { |_, value| value.to_s.strip == '' } end |
#tracking_settings ⇒ Object
965 966 967 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 965 def tracking_settings @tracking_settings.nil? ? nil : @tracking_settings.to_json end |
#tracking_settings=(tracking_settings) ⇒ Object
961 962 963 |
# File 'lib/sendgrid/helpers/mail/mail.rb', line 961 def tracking_settings=(tracking_settings) @tracking_settings = tracking_settings end |