Class: Urbanairship::Devices::ChannelInfo

Inherits:
Object
  • Object
show all
Includes:
Common, Loggable
Defined in:
lib/urbanairship/devices/devicelist.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')) ⇒ ChannelInfo

Returns a new instance of ChannelInfo.



13
14
15
# File 'lib/urbanairship/devices/devicelist.rb', line 13

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

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



10
11
12
# File 'lib/urbanairship/devices/devicelist.rb', line 10

def attributes
  @attributes
end

#audienceObject

Returns the value of attribute audience.



10
11
12
# File 'lib/urbanairship/devices/devicelist.rb', line 10

def audience
  @audience
end

#client=(value) ⇒ Object (writeonly)

Sets the attribute client

Parameters:

  • value

    the value to set the attribute client to.



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

def client=(value)
  @client = value
end

Instance Method Details

#lookup(uuid: required('uuid')) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/urbanairship/devices/devicelist.rb', line 17

def lookup(uuid: required('uuid'))
  response = @client.send_request(
    method: 'GET',
    path: channel_path(uuid)
  )
  logger.info("Retrieved channel information for #{uuid}")
  response['body']['channel']
end

#payloadObject



26
27
28
29
30
31
32
33
# File 'lib/urbanairship/devices/devicelist.rb', line 26

def payload
  {
    'audience': audience,
    'attributes': [
      attributes
    ]
  }
end

#set_attributesObject



35
36
37
38
39
40
41
42
43
# File 'lib/urbanairship/devices/devicelist.rb', line 35

def set_attributes
  response = @client.send_request(
    method: 'POST',
    body: JSON.dump(payload),
    path: channel_path('attributes'),
    content_type: 'application/json'
  )
  response
end