ilinkmaker 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ilinkmaker.gemspec
4
+ gemspec
data/README.md CHANGED
@@ -14,18 +14,25 @@ In your Gemfile
14
14
 
15
15
  ## Usage
16
16
 
17
- ### Instantiate a client
17
+ #### Instantiate a client
18
18
 
19
19
  >> ilinkmaker = Ilinkmaker::Client.new
20
20
 
21
- #### Example
21
+ ### Example
22
+
23
+ #### Search
22
24
 
23
25
  >> results = ilinkmaker.search(:term => "tribes", :media => "ebook", :limit => 1)
24
26
  => #<HTTParty::Response:0x101876430 @parsed_response={"results"=>[{"trackViewUrl"=>"http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4", "price"=>16.99, "kind"=>"ebook", "genreIds"=>["10014"], "artworkUrl100"=>"http://a4.mzstatic.com/us/r30/Features/d9/12/ad/dj.cbleznyd.100x100-75.jpg", "trackName"=>"Tribes", "artistId"=>2072165, "artworkUrl60"=>"http://a4.mzstatic.com/us/r30/Features/d9/12/ad/dj.cbleznyd.60x60-50.jpg", "releaseDate"=>Thu Oct 16 07:00:00 UTC 2008, "artistViewUrl"=>"http://itunes.apple.com/us/artist/seth-godin/id2072165?mt=11&uo=4", "artistName"=>"Seth Godin", "artistIds"=>[2072165], "currency"=>"USD", "description"=>"A tribe is any group of people, large or small, who are connected to one another, a leader, and an idea. For millions of years, humans have been seeking out tribes, be they religious, ethnic, economic, political, or even musical (think of the Deadheads). It\342\200\231s our nature.Now the Internet has eliminated the barriers of geography, cost, and time. All those blogs and social networking sites are helping existing tribes get bigger. But more important, they\342\200\231re enabling countless new tribes to be born\342\200\224groups of ten or ten thousand or ten million who care about their iPhones, or a political campaign, or a new way to fight global warming.And so the key question: Who is going to lead us?The Web can do amazing things, but it can\342\200\231t provide leadership. That still has to come from individuals\342\200\224 people just like you who have passion about something. The explosion in tribes means that anyone who wants to make a difference now has the tools at her fingertips.If you think leadership is for other people, think again\342\200\224leaders come in surprising packages. Consider Joel Spolsky and his international tribe of scary-smart software engineers. Or Gary Vaynerhuck, a wine expert with a devoted following of enthusiasts. Chris Sharma leads a tribe of rock climbers up impossible cliff faces, while Mich Mathews, a VP at Microsoft, runs her internal tribe of marketers from her cube in Seattle. All they have in common is the desire to change things, the ability to connect a tribe, and the willingness to lead.If you ignore this opportunity, you risk turning into a \\u201Csheepwalker\\u201D\342\200\224someone who fights to protect the status quo at all costs, never asking if obedience is doing you (or your organization) any good. Sheepwalkers don\342\200\231t do very well these days.Tribes will make you think (really think) about the opportunities in leading your fellow employees, customers, investors, believers, hobbyists, or readers. . . . It\342\200\231s not easy, but it\342\200\231s easier than you think.", "userRatingCount"=>35, "averageUserRating"=>4.5, "trackCensoredName"=>"Tribes", "genres"=>["Management & Leadership"], "trackId"=>361926215}], "resultCount"=>1}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"x-apple-orig-url-path"=>["/WebObjects/MZStoreServices.woa/wa/wsSearch/?limit=1&term=tribes&output=json&media=ebook"], "x-webobjects-loadaverage"=>["0"], "x-apple-application-site"=>["ST11"], "expires"=>["Thu, 26 May 2011 18:21:09 GMT"], "x-apple-partner"=>["origin.0"], "content-type"=>["text/javascript; charset=utf-8"], "connection"=>["close"], "x-apple-max-age"=>["3600"], "date"=>["Thu, 26 May 2011 18:21:09 GMT"], "x-apple-woa-inbound-url"=>["/WebObjects/MZStoreServices.woa/wa/wsSearch/?limit=1&term=tribes&output=json&media=ebook"], "x-apple-application-instance"=>["2036002"], "content-length"=>["2758"], "cache-control"=>["max-age=0, no-cache"], "vary"=>["X-Apple-Store-Front"], "pragma"=>["no-cache"]}>
25
27
 
28
+ #### Lookup
29
+
30
+ >> ilinkmaker.lookup(:id => 361926215)
31
+ => #<HTTParty::Response:0x105d87a38 @parsed_response={"results"=>[{"trackViewUrl"=>"http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4", "price"=>16.99, "kind"=>"ebook", "genreIds"=>["10014"], "artworkUrl100"=>"http://a4.mzstatic.com/us/r30/Features/d9/12/ad/dj.cbleznyd.100x100-75.jpg", "trackName"=>"Tribes", "artistId"=>2072165, "artworkUrl60"=>"http://a4.mzstatic.com/us/r30/Features/d9/12/ad/dj.cbleznyd.60x60-50.jpg", "releaseDate"=>Thu Oct 16 07:00:00 UTC 2008, "artistViewUrl"=>"http://itunes.apple.com/us/artist/seth-godin/id2072165?mt=11&uo=4", "artistName"=>"Seth Godin", "artistIds"=>[2072165], "currency"=>"USD", "description"=>nil, "userRatingCount"=>35, "averageUserRating"=>4.5, "trackCensoredName"=>"Tribes", "genres"=>["Management & Leadership"], "trackId"=>361926215}], "resultCount"=>1}, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"x-apple-orig-url-path"=>["/WebObjects/MZStoreServices.woa/wa/wsLookup?output=json&id=361926215"], "x-webobjects-loadaverage"=>["0"], "x-apple-application-site"=>["ST11"], "expires"=>["Thu, 26 May 2011 20:17:33 GMT"], "x-apple-partner"=>["origin.0"], "content-type"=>["text/javascript; charset=utf-8"], "connection"=>["close"], "x-apple-max-age"=>["3600"], "date"=>["Thu, 26 May 2011 20:17:33 GMT"], "x-apple-woa-inbound-url"=>["/WebObjects/MZStoreServices.woa/wa/wsLookup?output=json&id=361926215"], "x-apple-application-instance"=>["2012012"], "content-length"=>["750"], "vary"=>["X-Apple-Store-Front", "X-Apple-Store-Front"], "cache-control"=>["max-age=0, no-cache"], "pragma"=>["no-cache"]}>
32
+
26
33
  #### Get an affiliate link
27
34
  >> ilinkmaker.get_affiliate_link(results["results"], {:partner_id => "XXXXXX", :linkshare_url => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1"})
28
- => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1=http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4?partner_id=XXXXXX"
35
+ => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1=http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4?partner_id=XXXXXX"
29
36
 
30
37
  ## Copyright
31
38
 
data/Rakefile CHANGED
@@ -1,31 +1,2 @@
1
- require 'rake'
2
- require 'rake/testtask'
3
- require 'rake/rdoctask'
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gem|
8
- gem.name = "ilinkmaker"
9
- gem.summary = %Q{Ruby wrapper for the iTunes Store Search API}
10
- gem.description = %Q{Ruby wrapper for the iTunes Store Search API}
11
- gem.email = "johnnyn@gmail.com"
12
- gem.homepage = "http://github.com/phuphighter/ilinkmaker"
13
- gem.authors = ["Johnny Khai Nguyen"]
14
-
15
- gem.add_dependency('httparty', '>= 0.5.0')
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
- end
21
-
22
- desc 'Default: run unit tests.'
23
- task :default => :test
24
-
25
- desc 'Test ilinkmaker'
26
- Rake::TestTask.new(:test) do |t|
27
- t.libs << 'lib'
28
- t.libs << 'test'
29
- t.pattern = 'test/**/*_test.rb'
30
- t.verbose = true
31
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/ilinkmaker.gemspec CHANGED
@@ -1,47 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "ilinkmaker/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{ilinkmaker}
8
- s.version = "0.0.0"
6
+ s.name = "ilinkmaker"
7
+ s.version = Ilinkmaker::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Johnny Khai Nguyen"]
10
+ s.email = ["johnnyn@gmail.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Ruby wrapper for the iTunes Store API}
13
+ s.description = %q{Ruby wrapper for the iTunes Store API - Search and Lookup}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Johnny Khai Nguyen"]
12
- s.date = %q{2011-05-26}
13
- s.description = %q{Ruby wrapper for the iTunes Store Search API}
14
- s.email = %q{johnnyn@gmail.com}
15
- s.extra_rdoc_files = [
16
- "README.md"
17
- ]
18
- s.files = [
19
- "README.md",
20
- "Rakefile",
21
- "VERSION",
22
- "ilinkmaker.gemspec",
23
- "lib/ilinkmaker.rb",
24
- "lib/ilinkmaker/client.rb",
25
- "pkg/ilinkmaker-0.0.0.gem",
26
- "test/fixtures/search.json",
27
- "test/ilinkmaker_test.rb",
28
- "test/test_helper.rb"
29
- ]
30
- s.homepage = %q{http://github.com/phuphighter/ilinkmaker}
31
- s.require_paths = ["lib"]
32
- s.rubygems_version = %q{1.6.2}
33
- s.summary = %q{Ruby wrapper for the iTunes Store Search API}
34
-
35
- if s.respond_to? :specification_version then
36
- s.specification_version = 3
15
+ s.rubyforge_project = "ilinkmaker"
37
16
 
38
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
39
- s.add_runtime_dependency(%q<httparty>, [">= 0.5.0"])
40
- else
41
- s.add_dependency(%q<httparty>, [">= 0.5.0"])
42
- end
43
- else
44
- s.add_dependency(%q<httparty>, [">= 0.5.0"])
45
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
46
21
  end
47
-
@@ -2,7 +2,7 @@ module Ilinkmaker
2
2
 
3
3
  class Client
4
4
  include HTTParty
5
- base_uri "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch"
5
+ base_uri "http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa"
6
6
  format :json
7
7
 
8
8
  attr_reader :partner_id, :linkshare_url
@@ -13,16 +13,20 @@ module Ilinkmaker
13
13
  end
14
14
 
15
15
  def search(options={})
16
- response = self.class.get("/", :query => options.merge(self.default_options))
16
+ response = self.class.get("/wsSearch", :query => options.merge(self.default_options))
17
+ end
18
+
19
+ def lookup(options={})
20
+ response = self.class.get("/wsLookup", :query => options.merge(self.default_options))
17
21
  end
18
22
 
19
23
  def get_affiliate_link(result, options={})
20
24
  url = result["trackViewUrl"]
21
25
 
22
26
  if @partner_id && @linkshare_url
23
- url = "#{@linkshare_url}=#{url}?partner_id=#{@partner_id}"
27
+ url = "#{@linkshare_url}#{url}?partner_id=#{@partner_id}"
24
28
  elsif options[:partner_id] && options[:linkshare_url]
25
- url = "#{options[:linkshare_url]}=#{url}?partner_id=#{options[:partner_id]}"
29
+ url = "#{options[:linkshare_url]}#{url}?partner_id=#{options[:partner_id]}"
26
30
  end
27
31
  end
28
32
 
@@ -0,0 +1,3 @@
1
+ module Ilinkmaker
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ {
2
+ "resultCount":2,
3
+ "results": [
4
+ {"wrapperType":"artist", "artistType":"Artist", "artistName":"Jack Johnson", "artistLinkUrl":"http://itunes.apple.com/us/artist/jack-johnson/id909253?uo=4", "artistId":909253, "amgArtistId":468749, "amgVideoArtistId":null, "primaryGenreName":"Rock", "primaryGenreId":21},
5
+ {"wrapperType":"artist", "artistType":"Artist", "artistName":"U2", "artistLinkUrl":"http://itunes.apple.com/us/artist/u2/id78500?uo=4", "artistId":78500, "amgArtistId":5723, "amgVideoArtistId":null, "primaryGenreName":"Rock", "primaryGenreId":21}]
6
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "resultCount":1,
3
+ "results": [
4
+ {"kind":"ebook", "artistId":2072165, "artistName":"Seth Godin", "price":16.99, "description":null, "genreIds":["10014"], "releaseDate":"2008-10-16T07:00:00Z", "currency":"USD", "trackId":361926215, "trackName":"Tribes", "genres":["Management & Leadership"], "artistIds":[2072165], "artworkUrl60":"http://a4.mzstatic.com/us/r30/Features/d9/12/ad/dj.cbleznyd.60x60-50.jpg", "artworkUrl100":"http://a4.mzstatic.com/us/r30/Features/d9/12/ad/dj.cbleznyd.100x100-75.jpg", "artistViewUrl":"http://itunes.apple.com/us/artist/seth-godin/id2072165?mt=11&uo=4", "trackCensoredName":"Tribes", "trackViewUrl":"http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4", "averageUserRating":4.5, "userRatingCount":35}]
5
+ }
@@ -17,7 +17,7 @@ class IlinkmakerTest < Test::Unit::TestCase
17
17
 
18
18
  context "and searching for a product with affiliate" do
19
19
  setup do
20
- @client = Ilinkmaker::Client.new(:partner_id => "wtf", :linkshare_url => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1")
20
+ @client = Ilinkmaker::Client.new(:partner_id => "wtf", :linkshare_url => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1=")
21
21
  end
22
22
 
23
23
  should "find a specific product and get proper affiliate link" do
@@ -30,7 +30,26 @@ class IlinkmakerTest < Test::Unit::TestCase
30
30
 
31
31
  stub_get("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsSearch?term=tribes&media=ebook", "search.json")
32
32
  search_result = @client.search(:term => "tribes", :media => "ebook", :limit => 25)
33
- @client.get_affiliate_link(search_result["results"].first, {:partner_id => "wtf", :linkshare_url => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1"}).should == "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1=http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4?partner_id=wtf"
33
+ @client.get_affiliate_link(search_result["results"].first, {:partner_id => "wtf", :linkshare_url => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1="}).should == "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1=http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4?partner_id=wtf"
34
+ end
35
+ end
36
+
37
+ context "lookup by identifier" do
38
+ setup do
39
+ @client = Ilinkmaker::Client.new
40
+ end
41
+
42
+ should "find a specific identifier" do
43
+ stub_get("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsLookup?id=361926215", "lookup.json")
44
+ result = @client.lookup(:id => '361926215')
45
+ result["results"].first["trackViewUrl"].should == "http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4"
46
+ @client.get_affiliate_link(result["results"].first, {:partner_id => "wtf", :linkshare_url => "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1="}).should == "http://click.linksynergy.com/fs-bin/stat?id=XXXXXXXX&offerid=XXXXX&type=X&subid=X&tmpid=XXXX&RD_PARM1=http://itunes.apple.com/us/book/tribes/id361926215?mt=11&uo=4?partner_id=wtf"
47
+ end
48
+
49
+ should "find by id and get entity" do
50
+ stub_get("http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/wa/wsLookup?id=909253&entity=album", "entity_lookup.json")
51
+ result = @client.lookup(:id => '909253', :entity => "album")
52
+ result["results"].first["artistName"].should == "Jack Johnson"
34
53
  end
35
54
  end
36
55
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ilinkmaker
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Johnny Khai Nguyen
@@ -17,44 +17,33 @@ cert_chain: []
17
17
 
18
18
  date: 2011-05-26 00:00:00 -05:00
19
19
  default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- name: httparty
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 11
30
- segments:
31
- - 0
32
- - 5
33
- - 0
34
- version: 0.5.0
35
- type: :runtime
36
- version_requirements: *id001
37
- description: Ruby wrapper for the iTunes Store Search API
38
- email: johnnyn@gmail.com
20
+ dependencies: []
21
+
22
+ description: Ruby wrapper for the iTunes Store API - Search and Lookup
23
+ email:
24
+ - johnnyn@gmail.com
39
25
  executables: []
40
26
 
41
27
  extensions: []
42
28
 
43
- extra_rdoc_files:
44
- - README.md
29
+ extra_rdoc_files: []
30
+
45
31
  files:
32
+ - .gitignore
33
+ - Gemfile
46
34
  - README.md
47
35
  - Rakefile
48
- - VERSION
49
36
  - ilinkmaker.gemspec
50
37
  - lib/ilinkmaker.rb
51
38
  - lib/ilinkmaker/client.rb
52
- - pkg/ilinkmaker-0.0.0.gem
39
+ - lib/ilinkmaker/version.rb
40
+ - test/fixtures/entity_lookup.json
41
+ - test/fixtures/lookup.json
53
42
  - test/fixtures/search.json
54
43
  - test/ilinkmaker_test.rb
55
44
  - test/test_helper.rb
56
45
  has_rdoc: true
57
- homepage: http://github.com/phuphighter/ilinkmaker
46
+ homepage: ""
58
47
  licenses: []
59
48
 
60
49
  post_install_message:
@@ -82,10 +71,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
71
  version: "0"
83
72
  requirements: []
84
73
 
85
- rubyforge_project:
74
+ rubyforge_project: ilinkmaker
86
75
  rubygems_version: 1.6.2
87
76
  signing_key:
88
77
  specification_version: 3
89
- summary: Ruby wrapper for the iTunes Store Search API
90
- test_files: []
91
-
78
+ summary: Ruby wrapper for the iTunes Store API
79
+ test_files:
80
+ - test/fixtures/entity_lookup.json
81
+ - test/fixtures/lookup.json
82
+ - test/fixtures/search.json
83
+ - test/ilinkmaker_test.rb
84
+ - test/test_helper.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.0
Binary file