Class: Issuu::Bookmark

Inherits:
Object
  • Object
show all
Defined in:
lib/issuu/bookmark.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Bookmark

Returns a new instance of Bookmark.



5
6
7
8
9
10
11
# File 'lib/issuu/bookmark.rb', line 5

def initialize(hash)
  @attributes = hash
  hash.each do |key, value|
    metaclass.send :attr_accessor, key
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



3
4
5
# File 'lib/issuu/bookmark.rb', line 3

def attributes
  @attributes
end

Class Method Details

.add(name, document_user_name, params = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/issuu/bookmark.rb', line 20

def add(name, document_user_name, params={})
  response = Cli.http_post(
    Issuu::API_URL,
    ParameterSet.new("issuu.bookmark.add", params.merge({:name => name, :documentUsername => document_user_name})).output
  )
  Bookmark.new(response["rsp"]["_content"]["bookmark"])
end

.delete(bookmark_ids, params = {}) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/issuu/bookmark.rb', line 44

def delete(bookmark_ids,  params={})        
  Cli.http_post(
    Issuu::API_URL,
    ParameterSet.new("issuu.bookmark.delete", params.merge({:bookmarkIds => bookmark_ids.join(',')})).output
  )
  return true
end

.list(params = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/issuu/bookmark.rb', line 28

def list(params={})        
  response = Cli.http_get(
    Issuu::API_URL,
    ParameterSet.new("issuu.bookmarks.list", params).output
  )
  response["rsp"]["_content"]["result"]["_content"].map{|bookmark_hash| Document.new(bookmark_hash["bookmark"]) }
end

.update(bookmark_id, params = {}) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/issuu/bookmark.rb', line 36

def update(bookmark_id, params={})        
  response = Cli.http_post(
    Issuu::API_URL,
    ParameterSet.new("issuu.bookmark.update", params.merge({:bookmarkId => bookmark_id})).output
  )
  Bookmark.new(response["rsp"]["_content"]["bookmark"])
end

Instance Method Details

#metaclassObject



13
14
15
16
17
# File 'lib/issuu/bookmark.rb', line 13

def metaclass
  class << self
    self
  end
end