class Bronto::Delivery
Attributes
authentication[RW]
content[RW]
fields[RW]
from_email[RW]
from_name[RW]
message_id[RW]
recipients[RW]
reply_email[RW]
reply_tracking[RW]
start[RW]
status[RW]
type[RW]
Public Class Methods
find(filter = Bronto::Filter.new, page_number = 1, include_recipients = false, include_content = false, api_key = nil)
click to toggle source
Finds contacts based on the `filter` (Bronto::Filter
object).
-
`page_number` is the page of contacts to request.
Bronto
doesn't specify how many contacts are returned per page,only that you should keep increasing the number until no more contacts are returned.
-
`fields` can be an array of field IDs or an array of
Field
objects. -
`include_lists` determines whether to include the list IDs each contact belongs to.
# File lib/bronto/delivery.rb, line 11 def self.find(filter = Bronto::Filter.new, page_number = 1, include_recipients = false, include_content = false, api_key = nil) body = { filter: filter.to_hash, page_number: page_number, include_recipients: include_recipients, include_content: include_content } api_key = api_key || self.api_key resp = request(:read, body) Array.wrap(resp[:return]).map { |hash| new(hash) } end
new(options = {})
click to toggle source
Calls superclass method
Bronto::Base::new
# File lib/bronto/delivery.rb, line 21 def initialize(options = {}) super(options) self.recipients = [] end
Public Instance Methods
add_recipient(*args)
click to toggle source
# File lib/bronto/delivery.rb, line 44 def add_recipient(*args) type = id = nil type, id = if args.is_a? Array and args.length == 2 args else [args.first.class.to_s.split("::").last.downcase, args.first.id] end self.recipients << { id: id, type: type } end
to_hash()
click to toggle source
# File lib/bronto/delivery.rb, line 26 def to_hash start_val = if start.is_a?(String) start elsif start.respond_to?(:strftime) start.strftime("%Y-%m-%dT%H:%M:%S.%6N%:z") else start end hash = { id: id, start: start_val, message_id: message_id, type: type, from_email: from_email, from_name: from_name, reply_email: reply_email, recipients: recipients, fields: fields, authentication: authentication, reply_tracking: reply_tracking } hash.each { |k,v| hash.delete(k) if v.blank? } hash end