diff --git a/examples/helpers/mail/example.rb b/examples/helpers/mail/example.rb index 5d2e059e..5b3585bb 100644 --- a/examples/helpers/mail/example.rb +++ b/examples/helpers/mail/example.rb @@ -3,10 +3,10 @@ require 'json' def hello_world - from = Email.new(email: 'test@example.com') + from = SendGrid::Email.new(email: 'test@example.com') subject = 'Hello World from the Twilio SendGrid Ruby Library' - to = Email.new(email: 'test@example.com') - content = Content.new(type: 'text/plain', value: 'some text here') + to = SendGrid::Email.new(email: 'test@example.com') + content = SendGrid::Content.new(type: 'text/plain', value: 'some text here') mail = SendGrid::Mail.new(from, subject, to, content) # puts JSON.pretty_generate(mail.to_json) puts mail.to_json @@ -21,7 +21,7 @@ def hello_world # rubocop:disable Metrics/AbcSize def kitchen_sink mail = SendGrid::Mail.new - mail.from = Email.new(email: 'test@example.com') + mail.from = SendGrid::Email.new(email: 'test@example.com') mail.subject = 'Hello World from the Twilio SendGrid Ruby Library' personalization = Personalization.new personalization.add_to(Email.new(email: 'test1@example.com', name: 'Example User')) @@ -117,7 +117,7 @@ def kitchen_sink tracking_settings.ganalytics = Ganalytics.new(enable: true, utm_source: 'some source', utm_medium: 'some medium', utm_term: 'some term', utm_content: 'some content', utm_campaign: 'some campaign') mail.tracking_settings = tracking_settings - mail.reply_to = Email.new(email: 'test@example.com') + mail.reply_to = SendGrid::Email.new(email: 'test@example.com') # puts JSON.pretty_generate(mail.to_json) puts mail.to_json @@ -131,9 +131,9 @@ def kitchen_sink # rubocop:enable Metrics/AbcSize def dynamic_template_data_hello_world - mail = Mail.new + mail = SendGrid::Mail.new mail.template_id = '' # a non-legacy template id - mail.from = Email.new(email: 'test@example.com') + mail.from = SendGrid::Email.new(email: 'test@example.com') personalization = Personalization.new personalization.add_to(Email.new(email: 'test1@example.com', name: 'Example User')) personalization.add_dynamic_template_data( diff --git a/test/sendgrid/helpers/mail/test_mail.rb b/test/sendgrid/helpers/mail/test_mail.rb index 052960d0..40ef0937 100644 --- a/test/sendgrid/helpers/mail/test_mail.rb +++ b/test/sendgrid/helpers/mail/test_mail.rb @@ -8,10 +8,10 @@ class TestMail < Minitest::Test def setup; end def test_hello_world - from = Email.new(email: 'test@example.com') - to = Email.new(email: 'test@example.com') + from = SendGrid::Email.new(email: 'test@example.com') + to = SendGrid::Email.new(email: 'test@example.com') subject = 'Sending with Twilio SendGrid is Fun' - content = Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') + content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') mail = SendGrid::Mail.new(from, subject, to, content) assert_equal(mail.to_json, JSON.parse('{"from":{"email":"test@example.com"}, "subject":"Sending with Twilio SendGrid is Fun", "personalizations":[{"to":[{"email":"test@example.com"}]}], "content":[{"type":"text/plain", "value":"and easy to do anywhere, even with Ruby"}]}')) @@ -19,7 +19,7 @@ def test_hello_world def test_kitchen_sink mail = SendGrid::Mail.new - mail.from = Email.new(email: 'test@example.com') + mail.from = SendGrid::Email.new(email: 'test@example.com') mail.subject = 'Hello World from the Twilio SendGrid Ruby Library' personalization = Personalization.new personalization.add_to(Email.new(email: 'test1@example.com', name: 'Example User 1')) @@ -112,7 +112,7 @@ def test_kitchen_sink tracking_settings.ganalytics = Ganalytics.new(enable: true, utm_source: 'some source', utm_medium: 'some medium', utm_term: 'some term', utm_content: 'some content', utm_campaign: 'some campaign') mail.tracking_settings = tracking_settings - mail.reply_to = Email.new(email: 'test@example.com') + mail.reply_to = SendGrid::Email.new(email: 'test@example.com') # rubocop:disable Layout/LineLength assert_equal(mail.to_json, JSON.parse('{"asm":{"group_id":99,"groups_to_display":[4,5,6,7,8]},"attachments":[{"content":"TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12","content_id":"Balance Sheet","disposition":"attachment","filename":"balance_001.pdf","type":"application/pdf"},{"content":"BwdW","content_id":"Banner","disposition":"inline","filename":"banner.png","type":"image/png"}],"batch_id":"sendgrid_batch_id","categories":["May","2016"],"content":[{"type":"text/plain","value":"some text here"},{"type":"text/html","value":"some text here"}],"custom_args":{"campaign":"welcome","weekday":"morning"},"from":{"email":"test@example.com"},"headers":{"X-Test3":"test3","X-Test4":"test4"},"ip_pool_name":"23","mail_settings":{"bcc":{"email":"test@example.com","enable":true},"bypass_list_management":{"enable":true},"footer":{"enable":true,"html":"Footer Text","text":"Footer Text"},"sandbox_mode":{"enable":true},"spam_check":{"enable":true,"post_to_url":"https://spamcatcher.sendgrid.com","threshold":1}},"personalizations":[{"bcc":[{"email":"test5@example.com","name":"Example User 5"},{"email":"test6@example.com","name":"Example User 6"}],"cc":[{"email":"test3@example.com","name":"Example User 3"},{"email":"test4@example.com","name":"Example User 4"}],"custom_args":{"type":"marketing","user_id":"343"},"headers":{"X-Mock":"False","X-Test":"True"},"send_at":1443636843,"subject":"Hello World from the Personalized Twilio SendGrid Ruby Library","substitutions":{"%city%":"Denver","%name%":"Example User"},"to":[{"email":"test1@example.com","name":"Example User 1"},{"email":"test2@example.com","name":"Example User 2"}]},{"bcc":[{"email":"test5@example.com","name":"Example User 5"},{"email":"test6@example.com","name":"Example User 6"}],"cc":[{"email":"test3@example.com","name":"Example User 3"},{"email":"test4@example.com","name":"Example User 4"}],"custom_args":{"type":"marketing","user_id":"343"},"headers":{"X-Mock":"False","X-Test":"True"},"send_at":1443636843,"subject":"Hello World from the Personalized Twilio SendGrid Ruby Library","substitutions":{"%city%":"Denver","%name%":"Example User"},"to":[{"email":"test1@example.com","name":"Example User 1"},{"email":"test2@example.com","name":"Example User 2"}]}],"reply_to":{"email":"test@example.com"},"sections":{"%section1%":"Substitution Text for Section 1","%section2%":"Substitution Text for Section 2"},"send_at":1443636842,"subject":"Hello World from the Twilio SendGrid Ruby Library","template_id":"13b8f94f-bcae-4ec6-b752-70d6cb59f932","tracking_settings":{"click_tracking":{"enable":false,"enable_text":false},"ganalytics":{"enable":true,"utm_campaign":"some campaign","utm_content":"some content","utm_medium":"some medium","utm_source":"some source","utm_term":"some term"},"open_tracking":{"enable":true,"substitution_tag":"Optional tag to replace with the open image in the body of the message"},"subscription_tracking":{"enable":true,"html":"html to insert into the text/html portion of the message","substitution_tag":"Optional tag to replace with the open image in the body of the message","text":"text to insert into the text/plain portion of the message"}}}')) @@ -209,7 +209,7 @@ def test_add_custom_arg end def test_add_non_string_custom_arg - mail = Mail.new + mail = SendGrid::Mail.new mail.add_custom_arg(CustomArg.new(key: 'Integer', value: 1)) mail.add_custom_arg(CustomArg.new(key: 'Array', value: [1, 'a', true])) mail.add_custom_arg(CustomArg.new(key: 'Hash', value: { 'a' => 1, 'b' => 2 })) @@ -251,7 +251,7 @@ def test_add_invalid_category end def test_check_for_secrets - mail = Mail.new + mail = SendGrid::Mail.new mail.add_content(Content.new(type: 'text/plain', value: 'Sensitive information: SG.a123b456')) assert_raises(SecurityError) do mail.check_for_secrets([/SG.[a-zA-Z0-9_-]*/]) diff --git a/use-cases/legacy-templates.md b/use-cases/legacy-templates.md index e57b2b4e..313674a2 100644 --- a/use-cases/legacy-templates.md +++ b/use-cases/legacy-templates.md @@ -38,7 +38,7 @@ require 'sendgrid-ruby' include SendGrid mail = SendGrid::Mail.new -mail.from = Email.new(email: 'test@example.com') +mail.from = SendGrid::Email.new(email: 'test@example.com') mail.subject = 'I\'m replacing the subject tag' personalization = Personalization.new personalization.add_to(Email.new(email: 'test@example.com')) diff --git a/use-cases/personalizations.md b/use-cases/personalizations.md index 5e8058d4..16c8f051 100644 --- a/use-cases/personalizations.md +++ b/use-cases/personalizations.md @@ -7,8 +7,8 @@ require 'sendgrid-ruby' include SendGrid # Note that the domain for all From addresses must match -mail = Mail.new -mail.from = Email.new(email: 'test@example.com') +mail = SendGrid::Mail.new +mail.from = SendGrid::Email.new(email: 'test@example.com') mail.add_content(Content.new(type: 'text/plain', value: 'Some test text')) mail.subject = 'Personalized Test Email' @@ -31,4 +31,4 @@ end puts response.status_code puts response.body puts response.headers -``` \ No newline at end of file +``` diff --git a/use-cases/transactional-templates.md b/use-cases/transactional-templates.md index 95479d97..8b81587a 100644 --- a/use-cases/transactional-templates.md +++ b/use-cases/transactional-templates.md @@ -34,8 +34,8 @@ Template Body: require 'sendgrid-ruby' include SendGrid -mail = Mail.new -mail.from = Email.new(email: 'test@example.com') +mail = SendGrid::Mail.new +mail.from = SendGrid::Email.new(email: 'test@example.com') personalization = Personalization.new personalization.add_to(Email.new(email: 'test@example.com')) personalization.add_dynamic_template_data({