Class: Urbanairship::Devices::TagList
- Inherits:
-
Object
- Object
- Urbanairship::Devices::TagList
show all
- Includes:
- Common, Loggable
- Defined in:
- lib/urbanairship/devices/tag_lists.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')) ⇒ TagList
11
12
13
14
|
# File 'lib/urbanairship/devices/tag_lists.rb', line 11
def initialize(client: required('client'))
fail ArgumentError, 'Client cannot be set to nil' if client.nil?
@client = client
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
9
10
11
|
# File 'lib/urbanairship/devices/tag_lists.rb', line 9
def name
@name
end
|
Instance Method Details
#create(description: nil, extra: nil, add: nil, remove: nil, set: nil) ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/urbanairship/devices/tag_lists.rb', line 16
def create(description: nil, extra: nil, add:nil, remove: nil, set: nil)
fail ArgumentError, 'Name must be set' if name.nil?
payload = {'name': name}
payload['description'] = description unless description.nil?
payload['extra'] = unless .nil?
payload['add'] = add unless add.nil?
payload['remove'] = remove unless remove.nil?
payload['set'] = set unless set.nil?
response = @client.send_request(
method: 'POST',
body: JSON.dump(payload),
path: tag_lists_path,
content_type: 'application/json'
)
logger.info("Created Tag List for #{@name}")
response
end
|
#errors ⇒ Object
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/urbanairship/devices/tag_lists.rb', line 59
def errors
fail ArgumentError, 'Name must be set' if name.nil?
response = @client.send_request(
method: 'GET',
path: tag_lists_path(@name + '/errors/')
)
logger.info("Got error CSV for tag list #{@name}")
response
end
|
#list ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/urbanairship/devices/tag_lists.rb', line 70
def list
fail ArgumentError, 'Name must be set' if name.nil?
response = @client.send_request(
method: 'GET',
path: tag_lists_path
)
logger.info("Got tag lists listing")
response
end
|
#upload(csv_file: required('csv_file'), gzip: false) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/urbanairship/devices/tag_lists.rb', line 35
def upload(csv_file: required('csv_file'), gzip: false)
fail ArgumentError, 'Name must be set' if name.nil?
if gzip
response = @client.send_request(
method: 'PUT',
body: csv_file,
path: tag_lists_path(@name + '/csv/'),
content_type: 'text/csv',
encoding: gzip
)
else
response = @client.send_request(
method: 'PUT',
body: csv_file,
path: tag_lists_path(@name + '/csv/'),
content_type: 'text/csv'
)
end
logger.info("Uploaded a tag list for #{@name}")
response
end
|