Permalink
Browse files

Added the Cameraplus::API::Page class.

  • Loading branch information...
1 parent a7aabe8 commit 2ade6611f3c5f330d3a41ce7c2301821c44b26ac @kevintuhumury kevintuhumury committed Mar 19, 2012
Showing with 93 additions and 0 deletions.
  1. +1 −0 lib/cameraplus.rb
  2. +17 −0 lib/cameraplus/api/page.rb
  3. +17 −0 spec/cameraplus/api/page_spec.rb
  4. +58 −0 spec/vcr_cassettes/page.yml
View
@@ -3,6 +3,7 @@
require "cameraplus/api/request"
require "cameraplus/api/user"
+require "cameraplus/api/page"
require "cameraplus/user"
require "cameraplus/page"
@@ -0,0 +1,17 @@
+module Cameraplus
+ module API
+ class Page
+
+ def self.find(identifier, options = {})
+ Request.call(uri(identifier), options)
+ end
+
+ private
+
+ def self.uri(identifier)
+ "/#{identifier}:info"
+ end
+
+ end
+ end
+end
@@ -0,0 +1,17 @@
+require "spec_helper"
+
+describe Cameraplus::API::Page do
+
+ use_vcr_cassette :page
+
+ it "should be a Hash" do
+ response = Cameraplus::API::Page.find "b72Z"
+ response.should be_a Hash
+ end
+
+ it "should make a request to the Camera+ API" do
+ Cameraplus::API::Request.should_receive(:call).with "/b72Z:info", {}
+ Cameraplus::API::Page.find "b72Z"
+ end
+
+end
@@ -0,0 +1,58 @@
+---
+http_interactions:
+- request:
+ method: get
+ uri: http://camerapl.us/b72Z:info?
+ body:
+ encoding: US-ASCII
+ string: ''
+ headers: {}
+ response:
+ status:
+ code: 200
+ message: OK
+ headers:
+ Cache-Control:
+ - no-store, no-cache, must-revalidate, post-check=0, pre-check=0
+ Content-Type:
+ - application/json
+ Date:
+ - Mon, 19 Mar 2012 20:42:07 GMT
+ Expires:
+ - Thu, 19 Nov 1981 08:52:00 GMT
+ Pragma:
+ - no-cache
+ Server:
+ - Apache/2.2.21 (Amazon)
+ Set-Cookie:
+ - PHPSESSID=7jt1olsahvml2cu9q449oj1td7; expires=Sat, 15-Sep-2012 20:42:07 GMT;
+ path=/; domain=.campl.us
+ - PHPSESSID=7jt1olsahvml2cu9q449oj1td7; expires=Sat, 15-Sep-2012 20:42:07 GMT;
+ path=/; domain=.campl.us
+ X-Powered-By:
+ - PHP/5.3.10
+ Content-Length:
+ - '2553'
+ Connection:
+ - keep-alive
+ body:
+ encoding: US-ASCII
+ string: ! '{"page":{"timestamp":"2011-07-01 21:50:40","views":925,"comments":6,"tweet":{"id":"86914646237384704","text":"Tiny
+ Town of Kotor, Montenegro #mybestphoto","userid":14199276,"username":"lucyk","realname":"Oleg
+ Lutsenko","avatar":"http:\/\/a0.twimg.com\/profile_images\/1318866321\/avatar1_sqr_normal.jpg"},"location":{"coords":"42.574017 18.641312","name":"Kotor, Montenegro"}},"pictures":[{"800px":"http:\/\/pics.campl.us\/f\/f\/f2cc65ab786741e7ab9fb994d06626a6.jpg","120px":"http:\/\/pics.campl.us\/t\/f\/f2cc65ab786741e7ab9fb994d06626a6.jpg","480px":"http:\/\/pics.campl.us\/iphone\/f\/f2cc65ab786741e7ab9fb994d06626a6.jpg","fullwidth":800,"fullheight":597,"recipe":[{"type":"scenemode","value":"<a
+ href=\"\/clarity\" class=\"claritylink\">Clarity<\/a>"},{"type":"fx","value":"Miniaturize
+ (80%)"}],"exifdata":[{"title":"Camera","value":"Apple iPhone","style":"main"},{"title":"Software","value":"Camera+
+ 2.2.1","style":"main"},{"title":"Exposure","value":"1\/580 sec","style":"main"},{"title":"Aperture","value":"f\/2.4","style":"main"},{"title":"Focal
+ Length","value":"3.9 mm","style":""},{"title":"ISO Speed","value":"80","style":""},{"title":"Flash","value":"Auto,
+ Did not fire","style":""},{"title":"Metering Mode","value":"Average","style":""},{"title":"Light
+ Value","value":"12.0","style":""}]}],"comments":[{"author":"Lisa Bettany","avatar":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-snc4\/261022_674215636_4030749_q.jpg","url":"http:\/\/www.facebook.com\/profile.php?id=674215636","text":"great
+ shot!"},{"author":"Oleg Lutsenko","avatar":"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-snc4\/174392_1318365438_6251454_q.jpg","url":"http:\/\/www.facebook.com\/profile.php?id=1318365438","text":"thanks)"},{"author":"Oliver
+ Penack","avatar":"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-snc4\/187424_100001101654937_4862655_q.jpg","url":"http:\/\/www.facebook.com\/profile.php?id=100001101654937","text":"what
+ a stunning picture"},{"author":"John Goundry \u2714","avatar":"http:\/\/a3.twimg.com\/profile_images\/1380353650\/River_normal.jpg","url":"http:\/\/twitter.com\/Johntheone","text":"Congrats........
+ and Wow! Amazing."},{"author":"Jason Hansen","avatar":"http:\/\/profile.ak.fbcdn.net\/hprofile-ak-snc4\/203279_589653873_6670910_q.jpg","url":"http:\/\/www.facebook.com\/profile.php?id=589653873","text":"I
+ love tilt-shift photos & this is one of the best that I have seen. Great
+ shot!"},{"author":"Jonathan Feuer","avatar":"http:\/\/a1.twimg.com\/profile_images\/1375174511\/2D45AE39-9DB5-45C1-9F6E-D214DAEE514E_normal","url":"http:\/\/twitter.com\/SporTech","text":"This
+ looks fantastic! Congrats."}]}'
+ http_version:
+ recorded_at: Mon, 19 Mar 2012 20:42:07 GMT
+recorded_with: VCR 2.0.0

0 comments on commit 2ade661

Please sign in to comment.