Class: LC::Installation

Inherits:
Object
  • Object
show all
Defined in:
lib/leancloud/installation.rb

Constant Summary collapse

UPDATABLE_FIELDS =
{
  badge: 'badge',
  channels: 'channels',
  time_zone: 'timeZone',
  device_token: 'deviceToken',
  channel_uris: 'channelUris',
  app_name: 'appName',
  app_version: 'appVersion',
  parse_version: 'parseVersion',
  app_identifier: 'appIdentifier'
}

Instance Attribute Summary

Attributes inherited from Object

#class_name, #created_at, #parse_object_id, #updated_at

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Object

#array_add, #array_add_relation, #array_add_unique, #array_remove, #array_remove_relation, #decrement, #eql?, #hash, #increment, #inspect, #new?, #parse_delete, #pointer, #refresh, #safe_hash, #should_call_to_h?, #to_h, #to_json, #to_s, #update_attributes

Constructor Details

#initialize(parse_object_id) ⇒ Installation

Returns a new instance of Installation.



20
21
22
# File 'lib/leancloud/installation.rb', line 20

def initialize(parse_object_id)
  @parse_object_id = parse_object_id
end

Class Method Details

.get(parse_object_id) ⇒ Object



24
25
26
# File 'lib/leancloud/installation.rb', line 24

def self.get(parse_object_id)
  new(parse_object_id).get
end

Instance Method Details

#getObject



28
29
30
31
32
# File 'lib/leancloud/installation.rb', line 28

def get
  if response = LC.client.request(uri, :get, nil, nil)
    parse LC.parse_json(nil, response)
  end
end

#methodObject



52
53
54
# File 'lib/leancloud/installation.rb', line 52

def method
  @parse_object_id ? :put : :post
end

#rest_api_hashObject



48
49
50
# File 'lib/leancloud/installation.rb', line 48

def rest_api_hash
  self
end

#saveObject



44
45
46
# File 'lib/leancloud/installation.rb', line 44

def save
  LC.client.request uri, method, self.to_json, nil
end

#uriObject



40
41
42
# File 'lib/leancloud/installation.rb', line 40

def uri
  Protocol.installation_uri @parse_object_id
end