ZenfolioAPI 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/ZenfolioAPI.gemspec +19 -0
- data/lib/ZenfolioAPI.rb +28 -0
- data/lib/ZenfolioAPI/authentication.rb +25 -0
- data/lib/ZenfolioAPI/http.rb +30 -0
- data/lib/ZenfolioAPI/model/access_descriptor.rb +13 -0
- data/lib/ZenfolioAPI/model/exif_tag.rb +10 -0
- data/lib/ZenfolioAPI/model/gallery.rb +34 -0
- data/lib/ZenfolioAPI/model/group.rb +27 -0
- data/lib/ZenfolioAPI/model/group_element.rb +11 -0
- data/lib/ZenfolioAPI/model/image.rb +45 -0
- data/lib/ZenfolioAPI/model/message.rb +14 -0
- data/lib/ZenfolioAPI/model/user.rb +34 -0
- data/lib/ZenfolioAPI/record.rb +23 -0
- data/lib/ZenfolioAPI/session.rb +106 -0
- data/lib/ZenfolioAPI/version.rb +3 -0
- data/spec/ZenfolioAPI_spec.rb +38 -0
- data/spec/spec_helper.rb +10 -0
- metadata +87 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 David Slone
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# ZenfolioAPI
|
2
|
+
|
3
|
+
This is a basic implementation of the Zenfolio API. More features like uploading photos will come later.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ZenfolioAPI'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ZenfolioAPI
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/ZenfolioAPI.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/ZenfolioAPI/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["David Slone"]
|
6
|
+
gem.email = ["dbslone@gmail.com"]
|
7
|
+
gem.description = %q{Basic implementation of the Zenfolio API.}
|
8
|
+
gem.summary = %q{Currently just a basic implementation of the Zenfolio API with features to list all galleries and photos, and get all the information about a gallery or photo.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "ZenfolioAPI"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = ZenfolioAPI::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec", "~> 2.6"
|
19
|
+
end
|
data/lib/ZenfolioAPI.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "ZenfolioAPI/version"
|
2
|
+
require "ZenfolioAPI/authentication"
|
3
|
+
require "ZenfolioAPI/session"
|
4
|
+
require "ZenfolioAPI/http"
|
5
|
+
require "ZenfolioAPI/record"
|
6
|
+
require "ZenfolioAPI/model/gallery"
|
7
|
+
require "ZenfolioAPI/model/image"
|
8
|
+
require "ZenfolioAPI/model/exif_tag"
|
9
|
+
require "ZenfolioAPI/model/access_descriptor"
|
10
|
+
require "ZenfolioAPI/model/group"
|
11
|
+
require "ZenfolioAPI/model/group_element"
|
12
|
+
require "ZenfolioAPI/model/message"
|
13
|
+
require "ZenfolioAPI/model/user"
|
14
|
+
|
15
|
+
module ZenfolioAPI
|
16
|
+
|
17
|
+
# General Zenfolio error
|
18
|
+
class ZenfolioAPIError < StandardError
|
19
|
+
end
|
20
|
+
|
21
|
+
# Zenfolio Session Error
|
22
|
+
class ZenfolioAPISessionError < StandardError
|
23
|
+
end
|
24
|
+
|
25
|
+
# User Authentication Error
|
26
|
+
class ZenfolioAPIAuthenticationError < StandardError
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Authentication
|
3
|
+
|
4
|
+
attr_accessor :token
|
5
|
+
|
6
|
+
# Connect to the Zenfolio API
|
7
|
+
#
|
8
|
+
# @author David Slone
|
9
|
+
def initialize username,password
|
10
|
+
@api_url = "http://api.zenfolio.com/api/1.7/zfapi.asmx"
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
|
14
|
+
|
15
|
+
connection = ZenfolioAPI::HTTP.new()
|
16
|
+
@response = connection.POST('AuthenticatePlain', [username, password])
|
17
|
+
|
18
|
+
# Unable to authenticate the user. Return error code from server
|
19
|
+
raise ZenfolioAPI::ZenfolioAPIAuthenticationError, @response['error'] if !@response['error'].nil?
|
20
|
+
|
21
|
+
@token = @response['result']
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class HTTP
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@api_url = "https://api.zenfolio.com/api/1.7/zfapi.asmx"
|
6
|
+
end
|
7
|
+
|
8
|
+
#
|
9
|
+
#
|
10
|
+
# @author David Slone
|
11
|
+
def POST method, params = {}, token = nil
|
12
|
+
@api_body = {:method => method, :params => params, :id => 1}
|
13
|
+
|
14
|
+
url = URI.parse(@api_url)
|
15
|
+
post = Net::HTTP::Post.new(url.path)
|
16
|
+
http = Net::HTTP.new(url.host, url.port)
|
17
|
+
http.use_ssl = true
|
18
|
+
#http.set_debug_output $stderr
|
19
|
+
|
20
|
+
post['X-Zenfolio-User-Agent'] = 'Acme PhotoEdit plugin for Zenfolio v1.0'
|
21
|
+
post['User-Agent'] = 'Acme PhotoEdit plugin for Zenfolio v1.0'
|
22
|
+
post['X-Zenfolio-Token'] = token unless token.nil?
|
23
|
+
post.content_type = 'application/json'
|
24
|
+
post.body = @api_body.to_json
|
25
|
+
|
26
|
+
response = http.start {|http| http.request(post) }
|
27
|
+
@body = JSON.parse(response.body)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Model
|
3
|
+
class AccessDescriptor < ZenfolioAPI::Record
|
4
|
+
attr_reader :realm_id
|
5
|
+
attr_reader :access_type
|
6
|
+
attr_reader :access_mask
|
7
|
+
attr_reader :viewers
|
8
|
+
attr_reader :is_derived
|
9
|
+
attr_reader :password_hint
|
10
|
+
attr_reader :src_password_hint
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Model
|
3
|
+
class Gallery < ZenfolioAPI::Record
|
4
|
+
attr_reader :id
|
5
|
+
attr_reader :type
|
6
|
+
attr_reader :caption
|
7
|
+
attr_reader :created_on
|
8
|
+
attr_reader :modified_on
|
9
|
+
attr_reader :photo_count
|
10
|
+
attr_reader :image_count
|
11
|
+
attr_reader :video_count
|
12
|
+
attr_reader :photo_bytes
|
13
|
+
attr_reader :views
|
14
|
+
attr_reader :type
|
15
|
+
attr_reader :featured_index
|
16
|
+
attr_reader :title_photo
|
17
|
+
attr_reader :is_random_title_photo
|
18
|
+
attr_reader :parent_groups
|
19
|
+
attr_reader :title
|
20
|
+
attr_reader :keywords
|
21
|
+
attr_reader :upload_url
|
22
|
+
attr_reader :video_upload_url
|
23
|
+
attr_reader :owner
|
24
|
+
attr_reader :page_url
|
25
|
+
attr_reader :mailbox_id
|
26
|
+
attr_reader :text_cn
|
27
|
+
attr_reader :photo_list_cn
|
28
|
+
attr_reader :group_index
|
29
|
+
attr_reader :hide_branding
|
30
|
+
|
31
|
+
attr_accessor :photos
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Model
|
3
|
+
class Group < ZenfolioAPI::Record
|
4
|
+
attr_reader :id
|
5
|
+
attr_reader :created_on
|
6
|
+
attr_reader :modified_on
|
7
|
+
attr_reader :page_url
|
8
|
+
attr_reader :tile_photo
|
9
|
+
attr_reader :mailbox_id
|
10
|
+
attr_reader :immediate_children_count
|
11
|
+
attr_reader :text_cn
|
12
|
+
|
13
|
+
# Level 2 fields
|
14
|
+
attr_reader :caption
|
15
|
+
|
16
|
+
# Full Level fields
|
17
|
+
attr_reader :collection_count
|
18
|
+
attr_reader :sub_group_count
|
19
|
+
attr_reader :gallery_count
|
20
|
+
attr_reader :photo_count
|
21
|
+
attr_reader :parent_groups
|
22
|
+
|
23
|
+
# Other fields
|
24
|
+
attr_reader :elements
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Model
|
3
|
+
class Image < ZenfolioAPI::Record
|
4
|
+
|
5
|
+
#
|
6
|
+
# Level 1 Fields
|
7
|
+
#
|
8
|
+
attr_reader :id
|
9
|
+
attr_reader :width
|
10
|
+
attr_reader :height
|
11
|
+
attr_reader :sequence
|
12
|
+
attr_reader :access_descriptor
|
13
|
+
attr_reader :owner
|
14
|
+
attr_reader :title
|
15
|
+
attr_reader :mime_type
|
16
|
+
attr_reader :views
|
17
|
+
attr_reader :size
|
18
|
+
attr_reader :gallery
|
19
|
+
attr_reader :original_url
|
20
|
+
attr_reader :url_core
|
21
|
+
attr_reader :url_host
|
22
|
+
attr_reader :url_token
|
23
|
+
attr_reader :page_url
|
24
|
+
attr_reader :mailbox_id
|
25
|
+
attr_reader :text_cn
|
26
|
+
attr_reader :flags
|
27
|
+
attr_reader :is_video
|
28
|
+
attr_reader :duration
|
29
|
+
|
30
|
+
#
|
31
|
+
# Level 2 Fields
|
32
|
+
#
|
33
|
+
attr_reader :caption
|
34
|
+
attr_reader :file_name
|
35
|
+
attr_reader :uploaded_on
|
36
|
+
attr_reader :taken_on
|
37
|
+
attr_reader :keywords
|
38
|
+
attr_reader :categories
|
39
|
+
attr_reader :copyright
|
40
|
+
attr_reader :rotation
|
41
|
+
attr_reader :exif_tags
|
42
|
+
attr_reader :short_exif
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Model
|
3
|
+
class Gallery < ZenfolioAPI::Record
|
4
|
+
attr_reader :index
|
5
|
+
attr_reader :mailbox_id
|
6
|
+
attr_reader :posted_on
|
7
|
+
attr_reader :poster_login_name
|
8
|
+
attr_reader :poster_url
|
9
|
+
attr_reader :poster_email
|
10
|
+
attr_reader :body
|
11
|
+
attr_reader :is_private
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Model
|
3
|
+
class User < ZenfolioAPI::Record
|
4
|
+
attr_reader :login_name
|
5
|
+
attr_reader :display_name
|
6
|
+
attr_reader :first_name
|
7
|
+
attr_reader :last_name
|
8
|
+
attr_reader :primary_email
|
9
|
+
attr_reader :bio_photo
|
10
|
+
attr_reader :bio
|
11
|
+
attr_reader :views
|
12
|
+
attr_reader :gallery_count
|
13
|
+
attr_reader :collection_count
|
14
|
+
attr_reader :photo_count
|
15
|
+
attr_reader :photo_bytes
|
16
|
+
attr_reader :user_since
|
17
|
+
attr_reader :last_updated
|
18
|
+
attr_reader :public_address
|
19
|
+
attr_reader :personal_address
|
20
|
+
attr_reader :recent_photo_sets
|
21
|
+
attr_reader :featured_photo_sets
|
22
|
+
attr_reader :root_group
|
23
|
+
attr_reader :referral_code
|
24
|
+
attr_reader :expires_on
|
25
|
+
attr_reader :balance
|
26
|
+
attr_reader :domain_name
|
27
|
+
attr_reader :storage_quota
|
28
|
+
attr_reader :photo_bytes_quota
|
29
|
+
attr_reader :video_bytes_quota
|
30
|
+
attr_reader :video_duration_quota
|
31
|
+
attr_reader :hierarchy_cn
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ZenfolioAPI
|
2
|
+
class Record
|
3
|
+
def initialize params
|
4
|
+
return if params.nil?
|
5
|
+
|
6
|
+
params.each do |key, value|
|
7
|
+
name = key.to_s
|
8
|
+
instance_variable_set("@#{name}", value) if respond_to?(name)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# Display Gallery is JSON format
|
13
|
+
#
|
14
|
+
# @author David Slone
|
15
|
+
def to_json
|
16
|
+
self.instance_variable_hash
|
17
|
+
end
|
18
|
+
|
19
|
+
def instance_variable_hash
|
20
|
+
Hash[instance_variables.map { |name| [name[1..-1], instance_variable_get(name)] } ]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
module ZenfolioAPI
|
4
|
+
class Session
|
5
|
+
attr_accessor :galleries
|
6
|
+
attr_accessor :photos
|
7
|
+
attr_accessor :groups
|
8
|
+
|
9
|
+
# Create the Zenfolio Session
|
10
|
+
#
|
11
|
+
# @author David Slone
|
12
|
+
def initialize username, password
|
13
|
+
@username = username
|
14
|
+
@password = password
|
15
|
+
@auth = ZenfolioAPI::Authentication.new(username, password)
|
16
|
+
|
17
|
+
@galleries = []
|
18
|
+
@photos = []
|
19
|
+
@groups = []
|
20
|
+
end
|
21
|
+
|
22
|
+
# Performs the API request to the Zenfolio server
|
23
|
+
#
|
24
|
+
# @author David Slone
|
25
|
+
def api_request method, params
|
26
|
+
connection = ZenfolioAPI::HTTP.new()
|
27
|
+
@response = connection.POST(method, params, @auth.token)
|
28
|
+
end
|
29
|
+
|
30
|
+
# The LoadGroupHierarchy method obtains a snapshot of the entire photoset group hierarchy of the specified user.
|
31
|
+
#
|
32
|
+
# @author David Slone
|
33
|
+
# @return [Hash] Returns a hash that contains the Galleries and Groups at the top level for a users account.
|
34
|
+
def list_galleries
|
35
|
+
@response = api_request 'LoadGroupHierarchy', [@username]
|
36
|
+
|
37
|
+
@response['result']['Elements'].each do |value|
|
38
|
+
if value['$type'] == "PhotoSet"
|
39
|
+
@galleries << ZenfolioAPI::Model::Gallery.new(:id => value['Id'], :type => value['$type'], :caption => value['Caption'],
|
40
|
+
:created_on => value['CreatedOn']['Value'], :modified_on => value['ModifiedOn']['Value'], :photo_count => value['PhotoCount'],
|
41
|
+
:image_count => value['ImageCount'], :video_count => value['VideoCount'], :photo_bytes => value['PhotoBytes'], :views => value['Views'],
|
42
|
+
:featured_index => value['FeaturedIndex'], :is_random_title_photo => value['IsRandomTitlePhoto'], :upload_url => value['UploadUrl'],
|
43
|
+
:video_upload_url => value['VideoUploadUrl'], :page_url => value['PageUrl'], :mailbox_id => value['MailboxId'], :text_cn => value['TextCn'],
|
44
|
+
:photo_list_cn => value['PhotoListCn'], :group_index => value['GroupIndex'], :title => value['Title'], :owner => value['Owner'])
|
45
|
+
elsif value['$type'] == "Group"
|
46
|
+
elements = []
|
47
|
+
value['Elements'].each do |element|
|
48
|
+
elements << ZenfolioAPI::Model::Gallery.new(:id => element['Id'], :type => element['$type'], :caption => element['Caption'],
|
49
|
+
:created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], :photo_count => element['PhotoCount'],
|
50
|
+
:image_count => element['ImageCount'], :video_count => element['VideoCount'], :photo_bytes => element['PhotoBytes'], :views => element['Views'],
|
51
|
+
:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],
|
52
|
+
:video_upload_url => element['VideoUploadUrl'], :page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :text_cn => element['TextCn'],
|
53
|
+
:photo_list_cn => element['PhotoListCn'], :group_index => element['GroupIndex'], :title => element['Title'], :owner => element['Owner'])
|
54
|
+
end
|
55
|
+
|
56
|
+
@groups << ZenfolioAPI::Model::Group.new(:id => value['Id'], :created_on => value['CreatedOn']['Value'], :modified_on => value['ModifiedOn']['Value'],
|
57
|
+
:page_url => value['PageUrl'], :mailbox_id => value['MailboxId'], :immediate_children_count => value['ImmediateChildrenCount'], :text_cn => value['TextCn'],
|
58
|
+
:caption => value['Caption'], :collection_count => value['CollectionCount'], :sub_group_count => value['SubGroupCount'], :gallery_count => value['GalleryCount'],
|
59
|
+
:photo_count => value['PhotoCount'], :parent_groups => value['ParentGroups'], :elements => elements)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
{:galleries => @galleries, :groups => @groups}
|
64
|
+
end
|
65
|
+
|
66
|
+
# List images for a specific gallery
|
67
|
+
#
|
68
|
+
# @author David Slone
|
69
|
+
# @param [Integer] gallery_id 64-bit identifier of the photoset/gallery to load
|
70
|
+
# @param [String] info_level Specifies which PhotoSet snapshot fields to return. This parameter is new in API version 1.4.
|
71
|
+
# @param [String] include_photos Specifies whether to return photoset photos. This parameter is new in API version 1.4.
|
72
|
+
def images_for_gallery gallery_id, info_level = "Full", include_photos = "true"
|
73
|
+
@response = api_request 'LoadPhotoSet', [gallery_id, info_level, include_photos]
|
74
|
+
raise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0
|
75
|
+
|
76
|
+
@response['result']['Photos'].each do |value|
|
77
|
+
access_descriptor = ZenfolioAPI::Model::AccessDescriptor.new(:realm_id => value['AccessDescriptor']['RealmId'],
|
78
|
+
:access_type => value['AccessDescriptor']['AccessType'], :is_derived => value['AccessDescriptor']['IsDerived'],
|
79
|
+
:access_mask => value['AccessDescriptor']['AccessMask'], :password_hint => value['AccessDescriptor']['PasswordHint'],
|
80
|
+
:src_password_hint => value['AccessDescriptor']['SrcPasswordHint'])
|
81
|
+
|
82
|
+
@photos << ZenfolioAPI::Model::Image.new(:id => value['Id'], :width => value['Width'], :height => value['Height'], :sequence => value['Sequence'],
|
83
|
+
:access_descriptor => access_descriptor, :owner => value['Owner'], :title => value['Title'], :mime_type => value['MimeType'],
|
84
|
+
:size => value['Size'], :gallery => value['Gallery'], :original_url => value['OriginalUrl'], :url_core => value['UrlCore'],
|
85
|
+
:url_host => value['UrlHost'], :url_token => value['UrlToken'], :page_url => value['PageUrl'], :mailbox_id => value['MailboxId'],
|
86
|
+
:text_cn => value['TextCn'], :flags => value['Flags'], :is_video => value['IsVideo'], :duration => value['Duration'], :caption => value['Caption'],
|
87
|
+
:file_name => value['FileName'], :uploaded_on => value['UploadedOn']['Value'], :taken_on => value['TakenOn']['Value'], :keywords => value['keywords'],
|
88
|
+
:categories => value['Categories'], :copyright => value['Copyright'], :rotation => value['Rotation'], :exif_tags => value['ExifTags'], :short_exif => value['ShortExif'])
|
89
|
+
end
|
90
|
+
|
91
|
+
@photos
|
92
|
+
end
|
93
|
+
|
94
|
+
# The LoadMessages method loads comments or guestbook entries posted to a mailbox.
|
95
|
+
#
|
96
|
+
# @author David Slone
|
97
|
+
def get_mailbox_messages mailbox_id, posted_since = "", include_deleted = "false"
|
98
|
+
posted_since = Date.today if posted_since.length == 0
|
99
|
+
|
100
|
+
@response = api_request 'LoadMessages', [mailbox_id, posted_since, include_deleted]
|
101
|
+
raise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ZenfolioAPI do
|
4
|
+
session = ZenfolioAPI::Session.new('punndit','punndit1024')
|
5
|
+
|
6
|
+
it "Should connect to API server" do
|
7
|
+
session.should_not be_nil
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should list galleries for user" do
|
11
|
+
session.list_galleries
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should raise exception for incorrect gallery/collection id" do
|
15
|
+
expect { session.images_for_gallery 5 }.to raise_error
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should list photos for a gallery" do
|
20
|
+
session.images_for_gallery 562597393410974837
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should list photos for a group" do
|
24
|
+
session.list_galleries
|
25
|
+
session.groups.each do |group|
|
26
|
+
group.elements.each do |element|
|
27
|
+
session.images_for_gallery element.id
|
28
|
+
session.photos.should_not be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should list messages in inbox" do
|
34
|
+
session.list_galleries
|
35
|
+
inbox = session.get_mailbox_messages session.galleries.first.mailbox_id
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ZenfolioAPI
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Slone
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.6'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.6'
|
30
|
+
description: Basic implementation of the Zenfolio API.
|
31
|
+
email:
|
32
|
+
- dbslone@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- ZenfolioAPI.gemspec
|
43
|
+
- lib/ZenfolioAPI.rb
|
44
|
+
- lib/ZenfolioAPI/authentication.rb
|
45
|
+
- lib/ZenfolioAPI/http.rb
|
46
|
+
- lib/ZenfolioAPI/model/access_descriptor.rb
|
47
|
+
- lib/ZenfolioAPI/model/exif_tag.rb
|
48
|
+
- lib/ZenfolioAPI/model/gallery.rb
|
49
|
+
- lib/ZenfolioAPI/model/group.rb
|
50
|
+
- lib/ZenfolioAPI/model/group_element.rb
|
51
|
+
- lib/ZenfolioAPI/model/image.rb
|
52
|
+
- lib/ZenfolioAPI/model/message.rb
|
53
|
+
- lib/ZenfolioAPI/model/user.rb
|
54
|
+
- lib/ZenfolioAPI/record.rb
|
55
|
+
- lib/ZenfolioAPI/session.rb
|
56
|
+
- lib/ZenfolioAPI/version.rb
|
57
|
+
- spec/ZenfolioAPI_spec.rb
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
homepage: ''
|
60
|
+
licenses: []
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.24
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Currently just a basic implementation of the Zenfolio API with features to
|
83
|
+
list all galleries and photos, and get all the information about a gallery or photo.
|
84
|
+
test_files:
|
85
|
+
- spec/ZenfolioAPI_spec.rb
|
86
|
+
- spec/spec_helper.rb
|
87
|
+
has_rdoc:
|