Class: Urbanairship::Devices::ChannelUninstall

Inherits:
Object
  • Object
show all
Includes:
Common, Loggable
Defined in:
lib/urbanairship/devices/channel_uninstall.rb

Constant Summary

Constants included from Common

Common::CONTENT_TYPE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

create_logger, logger, #logger

Methods included from Common

#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper

Constructor Details

#initialize(client: required('client')) ⇒ ChannelUninstall

Initialize a ChannelUninstall Object

Parameters:

  • client (Object) (defaults to: required('client'))


14
15
16
# File 'lib/urbanairship/devices/channel_uninstall.rb', line 14

def initialize(client: required('client'))
  @client = client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



9
10
11
# File 'lib/urbanairship/devices/channel_uninstall.rb', line 9

def client
  @client
end

Instance Method Details

#uninstall(channels: required('channels')) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/urbanairship/devices/channel_uninstall.rb', line 18

def uninstall(channels: required('channels'))
  chan_num = channels.length
  fail ArgumentError,
       'Maximum of 200 channel uninstalls exceeded.' if chan_num > 200

  response = @client.send_request(
    method: 'POST',
    body: JSON.dump(channels),
    path: channel_path('uninstall/'),
    content_type: 'application/json'
  )

  logger.info { "Successfully uninstalled #{chan_num} channels." }
  response
end