Method: NotificationHub::SubscriptionManager.create_subscription_device

Defined in:
lib/notification_hub/subscription_manager.rb

.create_subscription_device(association_model_id, device_id, event_code, channel_code) ⇒ Object



35
36
37
38
39
40
41
42
43
44
# File 'lib/notification_hub/subscription_manager.rb', line 35

def create_subscription_device(association_model_id, device_id, event_code, channel_code)
  subscription = NotificationHub::Subscription.
    where("#{NotificationHub.association_model}_id" => association_model_id, event_code: event_code, 
    channel_code: channel_code).first_or_create!

  subscription_device = NotificationHub::SubscriptionDevice.where(notification_hub_subscription_id: 
    subscription.id, notification_hub_device_id: device_id).first_or_create!

  subscription_device
end