Module: Picasa::Client::Gallery

Includes:
Base
Included in:
Picasa::Client
Defined in:
lib/picasa/client/gallery.rb

Constant Summary

Constants included from Base

Base::DEFAULT_LANGUAGE

Instance Method Summary collapse

Methods included from Base

#format_response

Instance Method Details



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/picasa/client/gallery.rb', line 21

def create_gallery(options = {})
  title       = options[:title].nil? ? "" : options[:title]
  summary     = options[:summary].nil? ? "" : options[:summary]
  location    = options[:location].nil? ? "" : options[:location]
  access      = options[:access].nil? ? "public" : options[:access]
  commentable = options[:commentable].nil? ? "true" : options[:commentable].to_s
  keywords    = options[:keywords].nil? ? "" : options[:keywords]
  time_i      = (Time.now).to_i

  body = "<entry xmlns='http://www.w3.org/2005/Atom'
  xmlns:media='http://search.yahoo.com/mrss/'
  xmlns:gphoto='http://schemas.google.com/photos/2007'>
    <title type='text'>#{title}</title>
    <summary type='text'>#{summary}</summary>
    <gphoto:location>#{location}</gphoto:location>
    <gphoto:access>#{access}</gphoto:access>
    <gphoto:commentingEnabled>#{commentable}</gphoto:commentingEnabled>
    <gphoto:timestamp>#{time_i}</gphoto:timestamp>
    <media:group>
      <media:keywords>#{keywords}</media:keywords>
    </media:group>
    <category scheme='http://schemas.google.com/g/2005#kind'
      term='http://schemas.google.com/photos/2007#album'></category>
  </entry>"

  response = post("https://picasaweb.google.com/data/feed/api/user/default", body)
  status, headers, body = response
  case status
    when 200
      return body
    else
      return body
  end
end

#get_galleriesObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/picasa/client/gallery.rb', line 9

def get_galleries
  response = get('https://picasaweb.google.com/data/feed/api/user/default?alt=json')
  status, headers, body = response
  case status
    when 200
      galleries = MultiJson.decode(body.first)
      return galleries["feed"]["entry"]
    else
      raise(StandardError, "#{status.to_s} - #{body.to_s}")
  end
end


56
57
58
59
60
61
62
63
64
65
# File 'lib/picasa/client/gallery.rb', line 56

def get_gallery_tags gallery_id
  response = get("https://picasaweb.google.com/data/feed/api/user/default/albumid/#{gallery_id}?kind=tag")
  status, headers, body = response
  case status
    when 200
      return body
    else
      return body
  end
end