Module: GSGraph::Connections::Picture

Included in:
Album, Application, Event, Group, Page, Photo, User, Video
Defined in:
lib/gs_graph/connections/picture.rb

Defined Under Namespace

Modules: Updatable

Instance Method Summary collapse

Instance Method Details

#picture(options_or_size = {}) ⇒ Object

User can specify size in two ways:

  1. By type: square | small | normal | large

  2. By width and height, so facebook return the closest match to the size you specified, if only one parameter is set, then facebook will return square image

See: developers.gamestamper.com/docs/reference/api/user/



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gs_graph/connections/picture.rb', line 10

def picture(options_or_size = {})
  options = if options_or_size.is_a?(String) || options_or_size.is_a?(Symbol)
    {:type => options_or_size}
  else
    options_or_size
  end
  _endpoint_ = ["#{self.endpoint}/picture", options.to_query].delete_if(&:blank?).join('?')

  if options[:redirect] == false
    response = get options.merge(
      :connection => :picture,

      # NOTE: can be removed when addressable 2.3.3+ released with this fix
      # https://github.com/sporkmonger/addressable/commit/421a88fed1d2f14426f15158f3712ab563581327
      :redirect => 'false'
    )
    GSGraph::Picture.new response[:data]
  else
    _endpoint_
  end
end