flickr_vision 0.0.2 → 0.0.3

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.
@@ -1,6 +1,6 @@
1
1
  class FlickrPhoto
2
2
 
3
- attr_accessor :id, :farm_id, :server_id, :secret, :title
3
+ attr_accessor :id, :farm_id, :server_id, :secret, :title, :description, :primary
4
4
 
5
5
  def small_square()
6
6
  return build_photo_url(@farm_id,@server_id,@id,@secret).gsub(".jpg","") + "_s" + ".jpg"
data/lib/flickr_vision.rb CHANGED
@@ -55,6 +55,9 @@ class FlickrVision
55
55
  flickrPhoto.server_id = photo.attributes["server"]
56
56
  flickrPhoto.secret = photo.attributes["secret"]
57
57
  flickrPhoto.title = photo.attributes["title"]
58
+ flickrPhoto.primary = photo.attributes["isprimary"]
59
+ # omschrijving ophalen via andere rest call
60
+ flickrPhoto.description = get_description(flickrPhoto.id)
58
61
  photos.push(flickrPhoto)
59
62
  end
60
63
 
@@ -63,4 +66,22 @@ class FlickrVision
63
66
  return photos
64
67
  end
65
68
 
69
+ private
70
+ def get_description(photo_id)
71
+ uri = URI(API_URL + "method=flickr.photos.getInfo" + "&api_key=" + self.app_id + "&photo_id=" + photo_id + "&user_id=" + self.user_id)
72
+
73
+ response = Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
74
+ request = Net::HTTP::Get.new uri.request_uri
75
+ https.request(request)
76
+ end
77
+
78
+ doc = REXML::Document.new(response.body)
79
+ result = Array.new
80
+ doc.elements.each('rsp/photo') do |photo|
81
+ return photo.elements["description"].text
82
+ end
83
+
84
+ return ""
85
+ end
86
+
66
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flickr_vision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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: 2015-01-02 00:00:00.000000000 Z
12
+ date: 2015-01-06 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A gem to access flickr
15
15
  email: koen@infovision.be