Skip to content

Commit 4eeed6f

Browse files
committed
Merge pull request #32 from djiang/master
Add Multiple Emails to Recipient Lists
2 parents 130ca45 + 140c573 commit 4eeed6f

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,19 @@ Add email:
215215
```ruby
216216
response = list_emails_obj.add :list => 'some_list_name', :data => { :email => 'some_new_email@example.com', :name => 'some_new_person'}
217217
```
218+
219+
Add multiple emails:
220+
221+
This is limited to 1,000 entries by the API
222+
223+
```ruby
224+
response = list_emails_obj.add :list => 'some_list_name', :data => [
225+
{ :email => 'some_new_email1@example.com', :name => 'some_new_person1'},
226+
{ :email => 'some_new_email2@example.com', :name => 'some_new_person2'},
227+
{ :email => 'some_new_email3@example.com', :name => 'some_new_person3'}
228+
]
229+
```
230+
218231
`response` will be a hash containing a `inserted` key, which contains the number of emails inserted into the list.
219232

220233
- - -

lib/sendgrid_toolkit/newsletter/list_emails.rb

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class ListEmails < NewsletterSendgridClient
55
def add(options = {})
66
if options[:data].kind_of?(Hash)
77
options[:data] = options[:data].to_json
8+
elsif options[:data].kind_of?(Array)
9+
options[:data] = options[:data].map{|data| data.to_json}
810
end
911

1012
api_post('email', 'add', options).parsed_response

0 commit comments

Comments
 (0)