Class: Bronto::Delivery
Instance Attribute Summary collapse
-
#authentication ⇒ Object
Returns the value of attribute authentication.
-
#content ⇒ Object
Returns the value of attribute content.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#from_email ⇒ Object
Returns the value of attribute from_email.
-
#from_name ⇒ Object
Returns the value of attribute from_name.
-
#message_id ⇒ Object
Returns the value of attribute message_id.
-
#recipients ⇒ Object
Returns the value of attribute recipients.
-
#reply_email ⇒ Object
Returns the value of attribute reply_email.
-
#reply_tracking ⇒ Object
Returns the value of attribute reply_tracking.
-
#start ⇒ Object
Returns the value of attribute start.
-
#status ⇒ Object
Returns the value of attribute status.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Base
Class Method Summary collapse
-
.find(filter = Bronto::Filter.new, page_number = 1, include_recipients = false, include_content = false, api_key = nil) ⇒ Object
Finds contacts based on the ‘filter` (Bronto::Filter object).
Instance Method Summary collapse
- #add_recipient(*args) ⇒ Object
-
#initialize(options = {}) ⇒ Delivery
constructor
A new instance of Delivery.
- #to_hash ⇒ Object
Methods inherited from Base
api, api_key, api_key=, #create, create, destroy, #destroy, plural_class_name, #reload, #request, request, save, #save, session_expired, update, #update
Constructor Details
#initialize(options = {}) ⇒ Delivery
Returns a new instance of Delivery.
21 22 23 24 |
# File 'lib/bronto/delivery.rb', line 21 def initialize( = {}) super() self.recipients = [] end |
Instance Attribute Details
#authentication ⇒ Object
Returns the value of attribute authentication.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def authentication @authentication end |
#content ⇒ Object
Returns the value of attribute content.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def content @content end |
#fields ⇒ Object
Returns the value of attribute fields.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def fields @fields end |
#from_email ⇒ Object
Returns the value of attribute from_email.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def from_email @from_email end |
#from_name ⇒ Object
Returns the value of attribute from_name.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def from_name @from_name end |
#message_id ⇒ Object
Returns the value of attribute message_id.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def @message_id end |
#recipients ⇒ Object
Returns the value of attribute recipients.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def recipients @recipients end |
#reply_email ⇒ Object
Returns the value of attribute reply_email.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def reply_email @reply_email end |
#reply_tracking ⇒ Object
Returns the value of attribute reply_tracking.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def reply_tracking @reply_tracking end |
#start ⇒ Object
Returns the value of attribute start.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def start @start end |
#status ⇒ Object
Returns the value of attribute status.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def status @status end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'lib/bronto/delivery.rb', line 3 def type @type end |
Class Method Details
.find(filter = Bronto::Filter.new, page_number = 1, include_recipients = false, include_content = false, api_key = nil) ⇒ Object
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.
11 12 13 14 15 16 17 18 19 |
# 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 |
Instance Method Details
#add_recipient(*args) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bronto/delivery.rb', line 36 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 ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'lib/bronto/delivery.rb', line 26 def to_hash hash = { id: id, start: start, message_id: , 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 |