diff --git a/.gitignore b/.gitignore
index 03f3ce7..ef9fa8e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,8 @@
# Ignore bundler config.
/.bundle
+/.env
+
# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
diff --git a/Gemfile b/Gemfile
index 288bb87..c01d275 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,6 +3,7 @@ ruby '2.3.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
+gem 'omniauth-oauth2', '1.3.1' #reverted back to an older version to resolve route issue
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
@@ -20,10 +21,13 @@ gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
-
-# Use ActiveModel has_secure_password
-# gem 'bcrypt', '~> 3.1.7'
-
+# Spotify API wrapper
+gem 'rspotify'
+# Yelp API wrapper
+gem 'yelp', require: 'yelp'
+gem 'omniauth'
+gem 'omniauth-spotify'
+gem 'httparty'
# Use Unicorn as the app server
# gem 'unicorn'
@@ -33,13 +37,21 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
+ gem 'minitest-vcr'
+ gem 'minitest-reporters'
+ gem 'pry-rails'
+ gem 'webmock'
+ gem 'dotenv-rails'
+ gem 'minitest-rails'
+
end
group :development do
+ gem "better_errors"
+
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
-
diff --git a/Gemfile.lock b/Gemfile.lock
index 6ff0f39..edcd450 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -36,11 +36,18 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
+ addressable (2.4.0)
+ ansi (1.5.0)
arel (6.0.3)
+ better_errors (2.1.1)
+ coderay (>= 1.0.0)
+ erubis (>= 2.6.6)
+ rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (8.2.5)
+ coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
@@ -49,11 +56,26 @@ GEM
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
+ crack (0.4.3)
+ safe_yaml (~> 1.0.0)
debug_inspector (0.0.2)
+ dotenv (2.1.1)
+ dotenv-rails (2.1.1)
+ dotenv (= 2.1.1)
+ railties (>= 4.0, < 5.1)
erubis (2.7.0)
execjs (2.6.0)
+ faraday (0.9.2)
+ multipart-post (>= 1.2, < 3)
+ faraday_middleware (0.10.0)
+ faraday (>= 0.7.4, < 0.10)
globalid (0.3.6)
activesupport (>= 4.1.0)
+ hashdiff (0.3.0)
+ hashie (3.4.4)
+ httparty (0.13.7)
+ json (~> 1.8)
+ multi_xml (>= 0.5.2)
i18n (0.7.0)
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
@@ -63,19 +85,58 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
+ jwt (1.5.1)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
+ method_source (0.8.2)
mime-types (3.0)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0221)
mini_portile2 (2.0.0)
+ minispec-metadata (2.0.0)
+ minitest
minitest (5.8.4)
- multi_json (1.12.0)
+ minitest-rails (2.2.1)
+ minitest (~> 5.7)
+ railties (~> 4.1)
+ minitest-reporters (1.1.9)
+ ansi
+ builder
+ minitest (>= 5.0)
+ ruby-progressbar
+ minitest-vcr (1.4.0)
+ minispec-metadata (~> 2.0)
+ minitest (>= 4.7.5)
+ vcr (>= 2.9)
+ multi_json (1.12.1)
+ multi_xml (0.5.5)
+ multipart-post (2.0.0)
+ netrc (0.7.9)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
+ oauth2 (1.1.0)
+ faraday (>= 0.8, < 0.10)
+ jwt (~> 1.0, < 1.5.2)
+ multi_json (~> 1.3)
+ multi_xml (~> 0.5)
+ rack (>= 1.2, < 3)
+ omniauth (1.3.1)
+ hashie (>= 1.2, < 4)
+ rack (>= 1.0, < 3)
+ omniauth-oauth2 (1.3.1)
+ oauth2 (~> 1.0)
+ omniauth (~> 1.2)
+ omniauth-spotify (0.0.9)
+ omniauth-oauth2 (~> 1.1)
pg (0.18.4)
+ pry (0.10.3)
+ coderay (~> 1.1.0)
+ method_source (~> 0.8.1)
+ slop (~> 3.4)
+ pry-rails (0.3.4)
+ pry (>= 0.9.10)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
@@ -106,6 +167,13 @@ GEM
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
+ rest_client (1.8.3)
+ netrc (~> 0.7.7)
+ rspotify (1.10.0)
+ omniauth-oauth2 (~> 1.1)
+ rest_client (~> 1.8)
+ ruby-progressbar (1.8.1)
+ safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
@@ -116,6 +184,8 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
+ simple_oauth (0.3.1)
+ slop (3.6.0)
spring (1.7.1)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
@@ -131,27 +201,52 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
+ vcr (3.0.1)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
+ webmock (2.0.2)
+ addressable (>= 2.3.6)
+ crack (>= 0.3.2)
+ hashdiff
+ yelp (2.1.2)
+ faraday (~> 0.8, >= 0.8.0)
+ faraday_middleware (~> 0.8, >= 0.8.0)
+ simple_oauth (~> 0.3.1)
PLATFORMS
ruby
DEPENDENCIES
+ better_errors
byebug
coffee-rails (~> 4.1.0)
+ dotenv-rails
+ httparty
jbuilder (~> 2.0)
jquery-rails
+ minitest-rails
+ minitest-reporters
+ minitest-vcr
+ omniauth
+ omniauth-oauth2 (= 1.3.1)
+ omniauth-spotify
pg (~> 0.15)
+ pry-rails
rails (= 4.2.6)
+ rspotify
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
uglifier (>= 1.3.0)
web-console (~> 2.0)
+ webmock
+ yelp
+
+RUBY VERSION
+ ruby 2.3.1p112
BUNDLED WITH
- 1.12.3
+ 1.12.4
diff --git a/app/assets/javascripts/sessions.coffee b/app/assets/javascripts/sessions.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/sessions.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/javascripts/suggestions.coffee b/app/assets/javascripts/suggestions.coffee
new file mode 100644
index 0000000..24f83d1
--- /dev/null
+++ b/app/assets/javascripts/suggestions.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/sessions.scss b/app/assets/stylesheets/sessions.scss
new file mode 100644
index 0000000..ccb1ed2
--- /dev/null
+++ b/app/assets/stylesheets/sessions.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Sessions controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/assets/stylesheets/suggestions.scss b/app/assets/stylesheets/suggestions.scss
new file mode 100644
index 0000000..2ac92ee
--- /dev/null
+++ b/app/assets/stylesheets/suggestions.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Suggestions controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d83690e..4aceccf 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,4 +2,15 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
+ helper_method :current_user
+
+ def current_user
+ @current_user ||= User.find_by(id: session[:user_id])
+ end
+
+ def current_user_name
+ @current_user ||= User.find_by(id: session[:user_id])
+ @current_user.name
+ end
+
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
new file mode 100644
index 0000000..02ec2a3
--- /dev/null
+++ b/app/controllers/sessions_controller.rb
@@ -0,0 +1,23 @@
+class SessionsController < ApplicationController
+
+ def create
+ auth_hash = request.env['omniauth.auth']
+ if auth_hash["uid"]
+ @user = User.find_or_create_from_omniauth(auth_hash)
+ if @user
+ session[:user_id] = @user.id
+ redirect_to root_path
+ else
+ redirect_to root_path, notice: "Failed to save the user"
+ end
+ else
+ redirect_to root_path, notice: "Failed to authenticate"
+ end
+ end
+
+ def destroy
+ session.delete :user_id
+ redirect_to root_path
+ end
+
+end
diff --git a/app/controllers/suggestions_controller.rb b/app/controllers/suggestions_controller.rb
new file mode 100644
index 0000000..f75389c
--- /dev/null
+++ b/app/controllers/suggestions_controller.rb
@@ -0,0 +1,28 @@
+class SuggestionsController < ApplicationController
+
+ def index
+ results = TunesTakeoutWrapper.top_twenty
+ @results = results["suggestions"]
+ end
+
+ def search
+ @search_results = TunesTakeoutWrapper.search(params[:q])["suggestions"]
+ end
+
+ def show
+
+ end
+
+ def favorites
+ @favorites = TunesTakeoutWrapper.favorites
+ # shows all suggestions favorited by the signed-in User
+ end
+
+ def unfavorite
+ end
+
+ def favorite
+ TunesTakeoutWrapper.favorite(params[:id])
+ end
+
+end
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb
new file mode 100644
index 0000000..309f8b2
--- /dev/null
+++ b/app/helpers/sessions_helper.rb
@@ -0,0 +1,2 @@
+module SessionsHelper
+end
diff --git a/app/helpers/suggestions_helper.rb b/app/helpers/suggestions_helper.rb
new file mode 100644
index 0000000..0e358dd
--- /dev/null
+++ b/app/helpers/suggestions_helper.rb
@@ -0,0 +1,2 @@
+module SuggestionsHelper
+end
diff --git a/app/models/food.rb b/app/models/food.rb
new file mode 100644
index 0000000..3f58467
--- /dev/null
+++ b/app/models/food.rb
@@ -0,0 +1,2 @@
+class Food < ActiveRecord::Base
+end
diff --git a/app/models/music.rb b/app/models/music.rb
new file mode 100644
index 0000000..427c9c2
--- /dev/null
+++ b/app/models/music.rb
@@ -0,0 +1,2 @@
+class Music < ActiveRecord::Base
+end
diff --git a/app/models/user.rb b/app/models/user.rb
new file mode 100644
index 0000000..376606f
--- /dev/null
+++ b/app/models/user.rb
@@ -0,0 +1,40 @@
+class User < ActiveRecord::Base
+ validates :email, :name, :uid, :provider, presence: true
+
+ def initialize
+ @favorites = []
+ end
+
+ def self.find_or_create_from_omniauth(auth_hash)
+ # Find or create a user
+ user = self.find_by(uid: auth_hash["uid"], provider: auth_hash["provider"])
+ if user
+ return user
+ else
+ user = User.new
+ user.uid = auth_hash["uid"]
+ user.provider = auth_hash["provider"]
+ user.name = auth_hash["info"]["name"]
+ user.email = auth_hash["info"]["email"]
+
+ if user.save
+ return user
+ else
+ return nil
+ end
+ end
+ end
+
+ def add_favorite(pair_id)
+ @favorites << pair_id
+ end
+
+ def unfavorite(id)
+ @favorites.each do |pair|
+ if pair["id"] == id
+ # remove the pair ID from the array here
+ end
+ end
+ end
+
+end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 509d1a2..3efd1dd 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -2,10 +2,33 @@
TunesTakeout
- <%= stylesheet_link_tag 'application', media: 'all' %>
- <%= javascript_include_tag 'application' %>
- <%= csrf_meta_tags %>
+
+
+ <%= stylesheet_link_tag 'application', media: 'all' %>
+ <%= javascript_include_tag 'application' %>
+ <%= csrf_meta_tags %>
+
+
+<%= link_to "tunes&takeout", root_path %>
+
+<% if current_user %>
+
+ <%= form_tag search_path do %>
+ <%= label_tag(:q, "Search for:") %>
+ <%= text_field_tag(:q) %>
+ <%= submit_tag("Search") %>
+ <% end %>
+<% else %>
+
+<% end %>
+
<%= yield %>
diff --git a/app/views/sessions/index.html.erb b/app/views/sessions/index.html.erb
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/app/views/sessions/index.html.erb
@@ -0,0 +1 @@
+
diff --git a/app/views/suggestions/favorite.html.erb b/app/views/suggestions/favorite.html.erb
new file mode 100644
index 0000000..5341dc1
--- /dev/null
+++ b/app/views/suggestions/favorite.html.erb
@@ -0,0 +1 @@
+Added to Favorites!
diff --git a/app/views/suggestions/favorites.html.erb b/app/views/suggestions/favorites.html.erb
new file mode 100644
index 0000000..8f69f27
--- /dev/null
+++ b/app/views/suggestions/favorites.html.erb
@@ -0,0 +1,9 @@
+<% if @favorites %>
+ <% @favorites.each do |fave| %>
+ <%= fave %>
+ <% end %>
+<% else %>
+ You have no favorites right now!
+<% end %>
+
+<%= @favorites %>
diff --git a/app/views/suggestions/index.html.erb b/app/views/suggestions/index.html.erb
new file mode 100644
index 0000000..e6d6fd1
--- /dev/null
+++ b/app/views/suggestions/index.html.erb
@@ -0,0 +1,49 @@
+Top Twenty Suggested Pairings
+
+ <% @results.each do |pair_id| %>
+
+ <% music = TunesTakeoutWrapper.suggestion_info(pair_id)["suggestion"] %>
+ <% info = Yelp.client.business(music["food_id"]).business %>
+ <%= info.name %>
+ <%= info.id %>
+ <%= info.image_url %>
+ <%= info.rating %>
+ <%= info.url %>
+
+ <% if music["music_type"] == "album" %>
+ <% album = RSpotify::Album.find(music["music_id"]) %>
+ <%= album.name %>
+ <%= album.uri %>
+ <%= album.images[0]["url"] %>
+ <%= album.album_type %>
+ <%= album.external_urls['spotify'] %>
+
+
+ <% elsif music["music_type"] == "artist" %>
+ <% artist = RSpotify::Artist.find(music["music_id"]) %>
+ <%= artist.name %>
+ <%= artist.uri %>
+ <%= artist.images[0] %>
+ <%= artist.type %>
+ <%= artist.external_urls['spotify'] %>
+
+ <% elsif music["music_type"] == "track" %>
+ <% track = RSpotify::Track.find(music["music_id"]) %>
+ <%= track.name %>
+ <%= track.uri %>
+ <%= track.type %>
+ <%= track.external_urls['spotify'] %>
+
+ <% else %>
+ <%= "Invalid music type." %>
+ <% end %>
+
+ <% if current_user %>
+ <%= hidden_field_tag :favorite, TunesTakeoutWrapper.favorite(pair_id) %>
+ <%= form_tag favorite_path do %>
+ <%= hidden_field_tag "pair_id", pair_id %>
+ <%= submit_tag "Favorite" %>
+ <% end %>
+ <% end %>
+
+ <% end %>
diff --git a/app/views/suggestions/search.html.erb b/app/views/suggestions/search.html.erb
new file mode 100644
index 0000000..257c72c
--- /dev/null
+++ b/app/views/suggestions/search.html.erb
@@ -0,0 +1,40 @@
+Results
+
+<% @search_results.each do |pair| %>
+
+ <% business = Yelp.client.business(pair["food_id"]).business %>
+ <%= business.name %>
+ <%= business.id %>
+ <%= business.image_url %>
+ <%= business.rating %>
+ <%= business.url %>
+
+ <% if pair["music_type"] == "album" %>
+ <% album = RSpotify::Album.find(pair["music_id"]) %>
+ <%= album.name %>
+ <%= album.uri %>
+ <%= album.images[0]["url"] %>
+ <%= album.album_type %>
+ <%= album.external_urls['spotify'] %>
+
+
+ <% elsif pair["music_type"] == "artist" %>
+ <% artist = RSpotify::Artist.find(pair["music_id"]) %>
+ <%= artist.name %>
+ <%= artist.uri %>
+ <%= artist.images[0] %>
+ <%= artist.type %>
+ <%= artist.external_urls['spotify'] %>
+
+ <% elsif pair["music_type"] == "track" %>
+ <% track = RSpotify::Track.find(pair["music_id"]) %>
+ <%= track.name %>
+ <%= track.uri %>
+ <%= track.type %>
+ <%= track.external_urls['spotify'] %>
+
+ <% else %>
+ <%= "Invalid music type." %>
+ <% end %>
+
+<% end %>
diff --git a/app/views/suggestions/show.html.erb b/app/views/suggestions/show.html.erb
new file mode 100644
index 0000000..e69de29
diff --git a/config/application.rb b/config/application.rb
index 9b37a86..19130f9 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,6 +1,8 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
+require_relative "../lib/TunesTakeoutWrapper"
+
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
new file mode 100644
index 0000000..11ac600
--- /dev/null
+++ b/config/initializers/omniauth.rb
@@ -0,0 +1,3 @@
+Rails.application.config.middleware.use OmniAuth::Builder do
+ provider :spotify, ENV["SPOTIFY_CLIENT_ID"], ENV["SPOTIFY_SECRET_ID"], scope: 'user-read-email'
+end
diff --git a/config/initializers/yelp.rb b/config/initializers/yelp.rb
new file mode 100644
index 0000000..e1bb5ad
--- /dev/null
+++ b/config/initializers/yelp.rb
@@ -0,0 +1,8 @@
+require 'yelp'
+
+Yelp.client.configure do |config|
+ config.consumer_key = ENV["YELP_CONSUMER_KEY"]
+ config.consumer_secret = ENV["YELP_CONSUMER_SECRET"]
+ config.token = ENV["YELP_TOKEN"]
+ config.token_secret = ENV["YELP_TOKEN_SECRET"]
+end
diff --git a/config/routes.rb b/config/routes.rb
index 3f66539..4b59270 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -2,55 +2,24 @@
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
- # You can have the root of your site routed with "root"
- # root 'welcome#index'
-
- # Example of regular route:
- # get 'products/:id' => 'catalog#view'
-
- # Example of named route that can be invoked with purchase_url(id: product.id)
- # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
-
- # Example resource route (maps HTTP verbs to controller actions automatically):
- # resources :products
-
- # Example resource route with options:
- # resources :products do
- # member do
- # get 'short'
- # post 'toggle'
- # end
- #
- # collection do
- # get 'sold'
- # end
- # end
-
- # Example resource route with sub-resources:
- # resources :products do
- # resources :comments, :sales
- # resource :seller
- # end
-
- # Example resource route with more complex sub-resources:
- # resources :products do
- # resources :comments
- # resources :sales do
- # get 'recent', on: :collection
- # end
- # end
-
- # Example resource route with concerns:
- # concern :toggleable do
- # post 'toggle'
- # end
- # resources :posts, concerns: :toggleable
- # resources :photos, concerns: :toggleable
-
- # Example resource route within a namespace:
- # namespace :admin do
- # # Directs /admin/products/* to Admin::ProductsController
- # # (app/controllers/admin/products_controller.rb)
- # resources :products
- # end
+ root 'suggestions#index'
+ # get '/top_twenty' => 'sessions#top_twenty'
+
+
+ get '/auth/spotify', :to => 'sessions#create'
+ get '/auth/spotify/callback', :to => 'sessions#create'
+ get '/logout', :to => 'sessions#destroy'
+ resources :food, :music
+ # Confirm these are the correct resources. What is this line even doing???????
+
+ get '/top_twenty', :to => 'suggestions#index'
+ post '/top_twenty/show', :to => 'suggestions#show', as: 'top_twenty_results'
+
+ post '/v1/suggestions/search', :to => 'suggestions#search', as: 'search'
+
+ get '/favorites', :to => 'suggestions#favorites', as: 'favorites'
+
+ get '/show/:id', :to => 'suggestions#show', as: 'show'
+
+ post '/favorited', :to => 'suggestions#favorite', as: 'favorite'
end
diff --git a/db/migrate/20160518172252_create_foods.rb b/db/migrate/20160518172252_create_foods.rb
new file mode 100644
index 0000000..5d62fcd
--- /dev/null
+++ b/db/migrate/20160518172252_create_foods.rb
@@ -0,0 +1,8 @@
+class CreateFoods < ActiveRecord::Migration
+ def change
+ create_table :foods do |t|
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20160518174405_create_musics.rb b/db/migrate/20160518174405_create_musics.rb
new file mode 100644
index 0000000..2cc03f3
--- /dev/null
+++ b/db/migrate/20160518174405_create_musics.rb
@@ -0,0 +1,8 @@
+class CreateMusics < ActiveRecord::Migration
+ def change
+ create_table :musics do |t|
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20160519180532_create_users.rb b/db/migrate/20160519180532_create_users.rb
new file mode 100644
index 0000000..e6f0ee5
--- /dev/null
+++ b/db/migrate/20160519180532_create_users.rb
@@ -0,0 +1,8 @@
+class CreateUsers < ActiveRecord::Migration
+ def change
+ create_table :users do |t|
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20160519201121_add_columns_to_users.rb b/db/migrate/20160519201121_add_columns_to_users.rb
new file mode 100644
index 0000000..da27de9
--- /dev/null
+++ b/db/migrate/20160519201121_add_columns_to_users.rb
@@ -0,0 +1,8 @@
+class AddColumnsToUsers < ActiveRecord::Migration
+ def change
+ add_column(:users, :uid, :text, presence: true)
+ add_column(:users, :name, :text, presence: true)
+ add_column(:users, :email, :text, presence: true)
+ add_column(:users, :provider, :text, presence: true)
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..0971bb8
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,38 @@
+# encoding: UTF-8
+# This file is auto-generated from the current state of the database. Instead
+# of editing this file, please use the migrations feature of Active Record to
+# incrementally modify your database, and then regenerate this schema definition.
+#
+# Note that this schema.rb definition is the authoritative source for your
+# database schema. If you need to create the application database on another
+# system, you should be using db:schema:load, not running all the migrations
+# from scratch. The latter is a flawed and unsustainable approach (the more migrations
+# you'll amass, the slower it'll run and the greater likelihood for issues).
+#
+# It's strongly recommended that you check this file into your version control system.
+
+ActiveRecord::Schema.define(version: 20160519201121) do
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ create_table "foods", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "musics", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ end
+
+ create_table "users", force: :cascade do |t|
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.text "uid"
+ t.text "name"
+ t.text "email"
+ t.text "provider"
+ end
+
+end
diff --git a/lib/TunesTakeoutWrapper.rb b/lib/TunesTakeoutWrapper.rb
new file mode 100644
index 0000000..8a30b82
--- /dev/null
+++ b/lib/TunesTakeoutWrapper.rb
@@ -0,0 +1,28 @@
+require 'httparty'
+
+class TunesTakeoutWrapper
+ BASE_URL = "https://tunes-takeout-api.herokuapp.com/"
+
+ def self.search(keyword)
+ HTTParty.get(BASE_URL + "v1/suggestions/search?query=" + keyword).parsed_response
+ end
+
+ def self.top_twenty
+ HTTParty.get(BASE_URL + "v1/suggestions/top").parsed_response
+ end
+
+ def self.suggestion_info(id)
+ HTTParty.get(BASE_URL + "/v1/suggestions/" + id).parsed_response
+ end
+
+ def self.favorites
+ HTTParty.get(BASE_URL + "/v1/users/:#{User.last.uid}/favorites").parsed_response
+ # Returns a list of pair IDs from Charles' API
+ end
+
+ def self.favorite(pair_id)
+ HTTParty.post(BASE_URL + "/v1/users/:#{User.last.uid}/favorites", body: {"suggestions": pair_id}.to_json)
+ # Currently not saving the favorite in Charles' API, returns an empty array
+ # work on this
+ end
+end
diff --git a/lib/tasks/SpotifyWrapper.rb b/lib/tasks/SpotifyWrapper.rb
new file mode 100644
index 0000000..fea55cb
--- /dev/null
+++ b/lib/tasks/SpotifyWrapper.rb
@@ -0,0 +1,56 @@
+require 'httparty'
+require 'rspotify'
+
+class SpotifyWrapper
+ BASE_URL = "https://tunes-takeout-api.herokuapp.com/"
+
+ def self.hello
+ artists = RSpotify::Artist.search('Arctic Monkeys')
+ arctic_monkeys = artists.first
+ arctic_monkeys.popularity
+ end
+
+ # def self.top_twenty
+ # @results.each do |pair_id|
+ # music = TunesTakeoutWrapper.suggestion_info(pair_id)["suggestion"]
+ #
+ # if music["music_type"] == "album"
+ # @album_name = RSpotify::Album.find(music["music_id"]).name
+ # @album_uri = RSpotify::Album.find(music["music_id"]).uri
+ # @album_image = RSpotify::Album.find(music["music_id"]).images[0]["url"]
+ # @album_type = RSpotify::Album.find(music["music_id"]).album_type
+ # @album_url = RSpotify::Album.find(music["music_id"]).external_urls['spotify']
+ #
+ # elsif music["music_type"] == "artist"
+ # @artist_name = RSpotify::Artist.find(music["music_id"]).name
+ # @artist_uri = RSpotify::Artist.find(music["music_id"]).uri
+ # @artist_image = RSpotify::Artist.find(music["music_id"]).images[0]
+ # @artist_type = RSpotify::Artist.find(music["music_id"]).type
+ # @artist_url = RSpotify::Artist.find(music["music_id"]).external_urls['spotify']
+ #
+ # elsif music["music_type"] == "track"
+ # @track_name = RSpotify::Track.find(music["music_id"]).name
+ # @track_uri = RSpotify::Track.find(music["music_id"]).uri
+ # @track_type = RSpotify::Track.find(music["music_id"]).type
+ # @track_url = RSpotify::Track.find(music["music_id"]).external_urls['spotify']
+ #
+ # else
+ # "Invalid music type."
+ # end
+ # end
+ # end
+
+ # def self.find_album(music_id)
+ # RSpotify::Album.find(music_id)
+ # end
+ #
+ # def self.find_artist(music_id)
+ # RSpotify::Artist.find(music_id)
+ # # HTTParty.get(BASE_URL + "v1/suggestions/search?query=" + keyword).parsed_response
+ # end
+ #
+ # def self.find_track(music_id)
+ # RSpotify::Track.find(music_id)
+ # # HTTParty.get(BASE_URL + "v1/suggestions/search?query=" + keyword).parsed_response
+ # end
+end
diff --git a/lib/tasks/YelpWrapper.rb b/lib/tasks/YelpWrapper.rb
new file mode 100644
index 0000000..24dbf63
--- /dev/null
+++ b/lib/tasks/YelpWrapper.rb
@@ -0,0 +1,51 @@
+require 'httparty'
+require 'yelp'
+
+class YelpWrapper
+ BASE_URL = "https://tunes-takeout-api.herokuapp.com/"
+
+
+ # def self.top_twenty
+ # @results.each do |pair_id|
+ # music = TunesTakeoutWrapper.suggestion_info(pair_id)["suggestion"]
+ #
+ # if music["music_type"] == "album"
+ # @album_name = RSpotify::Album.find(music["music_id"]).name
+ # @album_uri = RSpotify::Album.find(music["music_id"]).uri
+ # @album_image = RSpotify::Album.find(music["music_id"]).images[0]["url"]
+ # @album_type = RSpotify::Album.find(music["music_id"]).album_type
+ # @album_url = RSpotify::Album.find(music["music_id"]).external_urls['spotify']
+ #
+ # elsif music["music_type"] == "artist"
+ # @artist_name = RSpotify::Artist.find(music["music_id"]).name
+ # @artist_uri = RSpotify::Artist.find(music["music_id"]).uri
+ # @artist_image = RSpotify::Artist.find(music["music_id"]).images[0]
+ # @artist_type = RSpotify::Artist.find(music["music_id"]).type
+ # @artist_url = RSpotify::Artist.find(music["music_id"]).external_urls['spotify']
+ #
+ # elsif music["music_type"] == "track"
+ # @track_name = RSpotify::Track.find(music["music_id"]).name
+ # @track_uri = RSpotify::Track.find(music["music_id"]).uri
+ # @track_type = RSpotify::Track.find(music["music_id"]).type
+ # @track_url = RSpotify::Track.find(music["music_id"]).external_urls['spotify']
+ #
+ # else
+ # "Invalid music type."
+ # end
+ # end
+ # end
+
+ # def self.find_album(music_id)
+ # RSpotify::Album.find(music_id)
+ # end
+ #
+ # def self.find_artist(music_id)
+ # RSpotify::Artist.find(music_id)
+ # # HTTParty.get(BASE_URL + "v1/suggestions/search?query=" + keyword).parsed_response
+ # end
+ #
+ # def self.find_track(music_id)
+ # RSpotify::Track.find(music_id)
+ # # HTTParty.get(BASE_URL + "v1/suggestions/search?query=" + keyword).parsed_response
+ # end
+end
diff --git a/test/controllers/sessions_controller_test.rb b/test/controllers/sessions_controller_test.rb
new file mode 100644
index 0000000..d30ebc3
--- /dev/null
+++ b/test/controllers/sessions_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SessionsControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/controllers/suggestions_controller_test.rb b/test/controllers/suggestions_controller_test.rb
new file mode 100644
index 0000000..98d4091
--- /dev/null
+++ b/test/controllers/suggestions_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+describe SuggestionsController do
+ # it 'works' do
+ # get '/top_twenty'
+ # assert_response :success
+ # end
+end
diff --git a/test/fixtures/foods.yml b/test/fixtures/foods.yml
new file mode 100644
index 0000000..937a0c0
--- /dev/null
+++ b/test/fixtures/foods.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/musics.yml b/test/fixtures/musics.yml
new file mode 100644
index 0000000..937a0c0
--- /dev/null
+++ b/test/fixtures/musics.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
new file mode 100644
index 0000000..937a0c0
--- /dev/null
+++ b/test/fixtures/users.yml
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
+
+# This model initially had no columns defined. If you add columns to the
+# model remove the '{}' from the fixture names and add the columns immediately
+# below each fixture, per the syntax in the comments below
+#
+one: {}
+# column: value
+#
+two: {}
+# column: value
diff --git a/test/models/food_test.rb b/test/models/food_test.rb
new file mode 100644
index 0000000..8ad7dff
--- /dev/null
+++ b/test/models/food_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class FoodTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/music_test.rb b/test/models/music_test.rb
new file mode 100644
index 0000000..c5c6737
--- /dev/null
+++ b/test/models/music_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class MusicTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 0000000..82f61e0
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 92e39b2..e526f65 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,6 +1,12 @@
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
+require 'minitest/spec'
+
+VCR.configure do |c|
+ c.cassette_library_dir = 'test/cassettes'
+ c.hook_into :webmock
+end
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.