ZenfolioAPI 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,8 @@ module ZenfolioAPI
9
9
  # Create the Zenfolio Session
10
10
  #
11
11
  # @author David Slone
12
+ # @param [String] username
13
+ # @param [String] password
12
14
  def initialize username, password
13
15
  @username = username
14
16
  @password = password
@@ -27,6 +29,21 @@ module ZenfolioAPI
27
29
  @response = connection.POST(method, params, @auth.token)
28
30
  end
29
31
 
32
+ # The CollectionAddPhoto method adds a photo reference to the specified collection.
33
+ #
34
+ # @author David Slone
35
+ # @param [Integer] collection_id 64-bit identifier of the collection to modify
36
+ # @param [Integer] photo_id 64-bit identifier of the photo to add
37
+ def collection_add_photo collection_id, photo_id
38
+ raise ZenfolioAPI::ZenfolioAPISessionError, "Missing collection_id parameter" if collection_id.nil? || collection_id.to_i == 0
39
+ raise ZenfolioAPI::ZenfolioAPISessionError, "Missing photo_id parameter" if photo_id.nil? || photo_id.to_i == 0
40
+
41
+ @response = api_request 'CollectionAddPhoto', [collection_id, photo_id]
42
+ raise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0
43
+
44
+ # TODO: Finish implementing method
45
+ end
46
+
30
47
  # The LoadGroupHierarchy method obtains a snapshot of the entire photoset group hierarchy of the specified user.
31
48
  #
32
49
  # @author David Slone
@@ -171,5 +188,32 @@ module ZenfolioAPI
171
188
 
172
189
  photo_set
173
190
  end
191
+
192
+ # The LoadPhoto method obtains a snapshot of the specified photo.
193
+ #
194
+ # @author David Slone
195
+ # @param [Integer] photo_id 64-bit identifier of the photo to load.
196
+ # @param [String] info_level Specifies which Photo snapshot fields to return. This parameter is new in API version 1.4.
197
+ def load_photo photo_id, info_level = "Full"
198
+ @response = api_request 'LoadPhoto', [photo_id, info_level]
199
+ raise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0
200
+
201
+ value = @response['result']
202
+
203
+ access_descriptor = ZenfolioAPI::Model::AccessDescriptor.new(:realm_id => value['AccessDescriptor']['RealmId'],
204
+ :access_type => value['AccessDescriptor']['AccessType'], :is_derived => value['AccessDescriptor']['IsDerived'],
205
+ :access_mask => value['AccessDescriptor']['AccessMask'], :password_hint => value['AccessDescriptor']['PasswordHint'],
206
+ :src_password_hint => value['AccessDescriptor']['SrcPasswordHint'])
207
+
208
+ @photo = ZenfolioAPI::Model::Image.new(:id => value['Id'], :width => value['Width'], :height => value['Height'], :sequence => value['Sequence'],
209
+ :access_descriptor => access_descriptor, :owner => value['Owner'], :title => value['Title'], :mime_type => value['MimeType'],
210
+ :size => value['Size'], :gallery => value['Gallery'], :original_url => value['OriginalUrl'], :url_core => value['UrlCore'],
211
+ :url_host => value['UrlHost'], :url_token => value['UrlToken'], :page_url => value['PageUrl'], :mailbox_id => value['MailboxId'],
212
+ :text_cn => value['TextCn'], :flags => value['Flags'], :is_video => value['IsVideo'], :duration => value['Duration'], :caption => value['Caption'],
213
+ :file_name => value['FileName'], :uploaded_on => value['UploadedOn']['Value'], :taken_on => value['TakenOn']['Value'], :keywords => value['keywords'],
214
+ :categories => value['Categories'], :copyright => value['Copyright'], :rotation => value['Rotation'], :exif_tags => value['ExifTags'], :short_exif => value['ShortExif'])
215
+
216
+ @photo
217
+ end
174
218
  end
175
219
  end
@@ -1,3 +1,3 @@
1
1
  module ZenfolioAPI
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -9,6 +9,8 @@ describe ZenfolioAPI do
9
9
 
10
10
  it "should list galleries for user" do
11
11
  session.list_galleries
12
+ session.groups.each do |g|
13
+ end
12
14
  end
13
15
 
14
16
  it "should raise exception for incorrect gallery/collection id" do
@@ -20,6 +22,15 @@ describe ZenfolioAPI do
20
22
  photos = session.images_for_gallery 562597392871954814
21
23
  end
22
24
 
25
+ it "should raise error if photo is not found" do
26
+ expect { session.load_photo 0 }.to raise_error
27
+ end
28
+
29
+ it "should load specific photo" do
30
+ photo = session.load_photo 562597394281328477
31
+ photo.should_not be_nil
32
+ end
33
+
23
34
  it "should load a group" do
24
35
  group = session.load_group 562597392652020926
25
36
  group.should_not be_nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ZenfolioAPI
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-26 00:00:00.000000000 Z
12
+ date: 2013-06-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec