Module: Flapjack::Diner::Resources::NotificationRules

Included in:
Flapjack::Diner
Defined in:
lib/flapjack-diner/resources/notification_rules.rb

Instance Method Summary collapse

Instance Method Details

#create_contact_notification_rules(*args) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/flapjack-diner/resources/notification_rules.rb', line 12

def create_contact_notification_rules(*args)
  ids, data = unwrap_ids(*args), unwrap_create_data(*args)
  raise "'create_contact_notification_rules' requires at least one " \
        'contact id parameter' if ids.nil? || ids.empty?
  validate_params(data) do
    validate :query => STRING_PARAMS,  :as => :array_of_strings
    validate :query => BOOLEAN_PARAMS, :as => :boolean
  end
  perform_post("/contacts/#{escaped_ids(ids)}/notification_rules",
               nil, :notification_rules => data)
end

#delete_notification_rules(*ids) ⇒ Object



40
41
42
43
44
# File 'lib/flapjack-diner/resources/notification_rules.rb', line 40

def delete_notification_rules(*ids)
  raise "'delete_notification_rules' requires at least one " \
        'notification rule id parameter' if ids.nil? || ids.empty?
  perform_delete('/notification_rules', ids)
end

#notification_rules(*ids) ⇒ Object



24
25
26
# File 'lib/flapjack-diner/resources/notification_rules.rb', line 24

def notification_rules(*ids)
  perform_get('notification_rules', '/notification_rules', ids)
end

#update_notification_rules(*args) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/flapjack-diner/resources/notification_rules.rb', line 28

def update_notification_rules(*args)
  ids, params = unwrap_ids(*args), unwrap_params(*args)
  raise "'update_notification_rules' requires at least one " \
        'notification rule id parameter' if ids.nil? || ids.empty?
  validate_params(params) do
    validate :query => STRING_PARAMS,  :as => :array_of_strings
    validate :query => BOOLEAN_PARAMS, :as => :boolean
  end
  perform_patch("/notification_rules/#{escaped_ids(ids)}", nil,
                update_notification_rules_ops(params))
end