Class: Snapfish::Album

Inherits:
Base
  • Object
show all
Defined in:
lib/snapfish/album.rb

Instance Attribute Summary

Attributes inherited from Base

#json

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

connection, connection=, #created_at, #initialize, #updated_at

Constructor Details

This class inherits a constructor from Snapfish::Base

Class Method Details

.get(album_id) ⇒ Object



3
4
5
6
7
8
# File 'lib/snapfish/album.rb', line 3

def self.get(album_id)
  response = connection.get("collection/#{album_id}")
  if response.success?
    Snapfish::Album.new(response.body['entities'].first)
  end
end

Instance Method Details

#as_jsonObject



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

def as_json
  {
    id: id,
    name: name,
    created_at: created_at
  }
end

#asset_countObject



14
15
16
# File 'lib/snapfish/album.rb', line 14

def asset_count
  json['assetIdList'].size
end

#assetsObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/snapfish/album.rb', line 22

def assets
  album_json = connection.get(album_url,
    assetType: 'ALL',
    limit: asset_count,
    skip: 0,
    sortCriteria: 'dateTaken',
    sortOrder: 'ascending'
  ).body

  album_json['entities'].map do |entity_json|
    Asset.new(entity_json)
  end
end

#idObject



10
11
12
# File 'lib/snapfish/album.rb', line 10

def id
  json['id']
end

#nameObject



18
19
20
# File 'lib/snapfish/album.rb', line 18

def name
  extract_tag('userTags', 'caption')
end