Module: Jung::Drivers::Infobip::Campaign
- Defined in:
- lib/jung/drivers/infobip/campaign.rb
Instance Attribute Summary collapse
-
#api_url ⇒ Object
Returns the value of attribute api_url.
-
#app_id ⇒ Object
Warning: Infobip limitation: app_id should not be more than 30 chars.
-
#deliver_at ⇒ Object
Returns the value of attribute deliver_at.
-
#messages_ids ⇒ Object
Returns the value of attribute messages_ids.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
-
#webhook ⇒ Object
Returns the value of attribute webhook.
Instance Method Summary collapse
- #deliver(recipients = self.recipients) ⇒ Object
- #deliver_in ⇒ Object
- #deliver_test(recipients) ⇒ Object
- #schedule(time) ⇒ Object
Instance Attribute Details
#api_url ⇒ Object
Returns the value of attribute api_url.
3 4 5 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 3 def api_url @api_url end |
#app_id ⇒ Object
Warning: Infobip limitation: app_id should not be more than 30 chars
4 5 6 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 4 def app_id @app_id end |
#deliver_at ⇒ Object
Returns the value of attribute deliver_at.
7 8 9 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 7 def deliver_at @deliver_at end |
#messages_ids ⇒ Object
Returns the value of attribute messages_ids.
3 4 5 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 3 def @messages_ids end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 3 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 3 def username @username end |
#webhook ⇒ Object
Returns the value of attribute webhook.
5 6 7 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 5 def webhook @webhook end |
Instance Method Details
#deliver(recipients = self.recipients) ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 42 def deliver(recipients = self.recipients) = recipients.map do | recipient | address = recipient.is_a?(Jung::Recipient) ? recipient.address : recipient deliver_recipient address, end delivery_success? end |
#deliver_in ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 13 def deliver_in return @deliver_in = nil unless deliver_at.respond_to?(:to_time) @deliver_in ||= begin time = deliver_at.to_time seconds_from_now = (Time.now - time) * -1 unless seconds_from_now < 0 minutes_from_now, seconds_from_now = seconds_from_now.divmod(60) hours_from_now, minutes_from_now = minutes_from_now.divmod(60) days_from_now, hours_from_now = hours_from_now.divmod(24) seconds_from_now = seconds_from_now.to_i time_from_now = { :d => days_from_now, :h => hours_from_now, :m => minutes_from_now, :s => seconds_from_now }.reject { |k,v| v == 0 }.map { |(k,v)| "#{v}#{k}" }.join else time_from_now = nil end time_from_now end end |
#deliver_test(recipients) ⇒ Object
50 51 52 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 50 def deliver_test(recipients) deliver(recipients) end |
#schedule(time) ⇒ Object
54 55 56 57 |
# File 'lib/jung/drivers/infobip/campaign.rb', line 54 def schedule time self.deliver_at = time deliver end |