Class: FiveMobilePush::Tag

Inherits:
Object
  • Object
show all
Defined in:
lib/five_mobile_push/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, device_uid, device_token) ⇒ Tag

Returns a new instance of Tag.



7
8
9
10
11
# File 'lib/five_mobile_push/tag.rb', line 7

def initialize(client, device_uid, device_token)
  @client           = client
  self.device_uid   = device_uid
  self.device_token = device_token
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



3
4
5
# File 'lib/five_mobile_push/tag.rb', line 3

def client
  @client
end

#device_tokenObject

Returns the value of attribute device_token.



5
6
7
# File 'lib/five_mobile_push/tag.rb', line 5

def device_token
  @device_token
end

#device_uidObject

Returns the value of attribute device_uid.



5
6
7
# File 'lib/five_mobile_push/tag.rb', line 5

def device_uid
  @device_uid
end

Instance Method Details

#create(*tags) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/five_mobile_push/tag.rb', line 13

def create(*tags)
  client.post end_point(:add),
    :id_type   => FiveMobilePush::DEFAULT_ID_TYPE,
    :id_value  => device_uid,
    :tags      => normalize_tags(tags),
    :api_token => device_token
end

#delete(*tags) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/five_mobile_push/tag.rb', line 21

def delete(*tags)
  client.post end_point(:delete),
    :id_type   => FiveMobilePush::DEFAULT_ID_TYPE,
    :id_value  => device_uid,
    :tags      => normalize_tags(tags),
    :api_token => device_token
end

#getObject



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/five_mobile_push/tag.rb', line 29

def get
  response = client.get end_point(:get),
    :id_type   => FiveMobilePush::DEFAULT_ID_TYPE,
    :id_value  => device_uid,
    :api_token => device_token
    
  if response.headers['content-type'] =~ /json/i
    MultiJson.decode(response.body)
  else
    response.body
  end
end