Class: Crm::MailingDelivery
- Inherits:
-
Object
- Object
- Crm::MailingDelivery
- Defined in:
- lib/crm/mailing_delivery.rb
Overview
MailingDelivery represents a mailing delivery.
Class Method Summary collapse
- .all(mailing_id, since: nil) ⇒ Object
-
.create(mailing_id, id, attributes = {}) ⇒ self
Creates or updates a mailing delivery.
-
.find(mailing_id, id) ⇒ MailingDelivery
Returns the requested mailing delivery.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes the mailing delivery.
- #reload ⇒ Object
-
#update(attributes = {}) ⇒ self
Updates the attributes of this mailing delivery.
Methods included from Core::Mixins::AttributeProvider
#[], #attributes, #initialize, #method_missing, #methods, #raw, #respond_to_missing?
Methods included from Core::Mixins::Inspectable
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Crm::Core::Mixins::AttributeProvider
Class Method Details
.all(mailing_id, since: nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/crm/mailing_delivery.rb', line 10 def self.all(mailing_id, since: nil) path = ['mailings', mailing_id, 'mailing_deliveries'].compact.join('/') params = {} case since when Time params[:since] = since.utc.xmlschema when String params[:since] = since when nil # ignore else raise "unknown class of since param: #{since.class}" end Core::RestApi.instance.get(path, params).map {|attrs| new({'mailing_id' => mailing_id}.merge(attrs))} end |
.create(mailing_id, id, attributes = {}) ⇒ self
Creates or updates a mailing delivery.
38 39 40 |
# File 'lib/crm/mailing_delivery.rb', line 38 def self.create(mailing_id, id, attributes = {}) new({'mailing_id' => mailing_id, 'id' => id}).update(attributes) end |
.find(mailing_id, id) ⇒ MailingDelivery
Returns the requested mailing delivery.
50 51 52 53 54 55 |
# File 'lib/crm/mailing_delivery.rb', line 50 def self.find(mailing_id, id) raise Crm::Errors::ResourceNotFound.new("Items could not be found.", [mailing_id]) if mailing_id.blank? raise Crm::Errors::ResourceNotFound.new("Items could not be found.", [id]) if id.blank? new({'mailing_id' => mailing_id, 'id' => id}).reload end |
Instance Method Details
#delete ⇒ Object
Deletes the mailing delivery.
62 63 64 65 |
# File 'lib/crm/mailing_delivery.rb', line 62 def delete Core::RestApi.instance.delete(path, nil, if_match_header) nil end |