+
+
+
+<%= link_to "Log In or Sign Up with Spotify", "/auth/spotify" unless current_user %>
\ No newline at end of file
diff --git a/app/views/suggestions/_suggestion.html.erb b/app/views/suggestions/_suggestion.html.erb
new file mode 100644
index 0000000..300d6a1
--- /dev/null
+++ b/app/views/suggestions/_suggestion.html.erb
@@ -0,0 +1,45 @@
+
+
+<%end%>
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index 9b37a86..027776c 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -8,6 +8,9 @@
module TunesTakeout
class Application < Rails::Application
+
+ config.autoload_paths += %W(#{config.root}/lib)
+ config.autoload_paths += %W(#{config.root}/extras)
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
new file mode 100644
index 0000000..8f1aab5
--- /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_CLIENT_SECRET"]
+end
\ No newline at end of file
diff --git a/config/initializers/spotify.rb b/config/initializers/spotify.rb
new file mode 100644
index 0000000..1ebaa89
--- /dev/null
+++ b/config/initializers/spotify.rb
@@ -0,0 +1,3 @@
+require 'rspotify'
+
+RSpotify::authenticate(ENV["SPOTIFY_CLIENT_ID"], ENV["SPOTIFY_CLIENT_SECRET"])
\ No newline at end of file
diff --git a/config/initializers/yelp.rb b/config/initializers/yelp.rb
new file mode 100644
index 0000000..c9b2e18
--- /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
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 3f66539..f575314 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,56 +1,16 @@
Rails.application.routes.draw do
- # The priority is based upon order of creation: first created -> highest priority.
- # See how all your routes lay out with "rake routes".
+ root 'suggestions#index'
- # You can have the root of your site routed with "root"
- # root 'welcome#index'
+ resources :users, :only => [:new, :create]
- # Example of regular route:
- # get 'products/:id' => 'catalog#view'
+ delete "/logout" => "sessions#destroy", as: 'logout'
+ get "/auth/:provider/callback" => "sessions#create"
+ get "/signin", to: "sessions#new", as: :signin
+ post "/" => "suggestions#index"
+ get "/myfavorites" => "suggestions#myfavorites"
- # 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
-end
+ post "/favorite/:suggestion_id" => "suggestions#favorite"
+ delete "/unfavorite/:suggestion_id" => "suggestions#unfavorite"
+ # delete "/logout" => "sessions#destroy"
+ # get "/login" => "sessions#new"
+end
\ No newline at end of file
diff --git a/db/migrate/20160518213803_create_users.rb b/db/migrate/20160518213803_create_users.rb
new file mode 100644
index 0000000..aeff593
--- /dev/null
+++ b/db/migrate/20160518213803_create_users.rb
@@ -0,0 +1,12 @@
+class CreateUsers < ActiveRecord::Migration
+ def change
+ create_table :users do |t|
+ t.string :provider, null: false
+ t.string :uid, null: false
+ t.string :name
+ t.string :email
+
+ t.timestamps null: false
+ end
+ end
+end
diff --git a/db/migrate/20160518214846_create_foods.rb b/db/migrate/20160518214846_create_foods.rb
new file mode 100644
index 0000000..5d62fcd
--- /dev/null
+++ b/db/migrate/20160518214846_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/20160518214850_create_musics.rb b/db/migrate/20160518214850_create_musics.rb
new file mode 100644
index 0000000..2cc03f3
--- /dev/null
+++ b/db/migrate/20160518214850_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/20160519055803_deleting_null_restrictions.rb b/db/migrate/20160519055803_deleting_null_restrictions.rb
new file mode 100644
index 0000000..78d8420
--- /dev/null
+++ b/db/migrate/20160519055803_deleting_null_restrictions.rb
@@ -0,0 +1,6 @@
+class DeletingNullRestrictions < ActiveRecord::Migration
+ def change
+ change_column :users, :uid, :string, null: true
+ change_column :users, :provider, :string, null: true
+ end
+end
diff --git a/db/migrate/20160519060114_deleteemailcolumn.rb b/db/migrate/20160519060114_deleteemailcolumn.rb
new file mode 100644
index 0000000..324091c
--- /dev/null
+++ b/db/migrate/20160519060114_deleteemailcolumn.rb
@@ -0,0 +1,5 @@
+class Deleteemailcolumn < ActiveRecord::Migration
+ def change
+ remove_column :users, :email
+ end
+end
diff --git a/db/migrate/20160519194329_add_image_to_user.rb b/db/migrate/20160519194329_add_image_to_user.rb
new file mode 100644
index 0000000..1216e99
--- /dev/null
+++ b/db/migrate/20160519194329_add_image_to_user.rb
@@ -0,0 +1,6 @@
+class AddImageToUser < ActiveRecord::Migration
+ def change
+ add_column :users, :image, :string, default: "spotify.jpeg"
+ change_column :users, :provider, :string, default: "spotify"
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..0fb65d3
--- /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: 20160519194329) 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.string "provider", default: "spotify"
+ t.string "uid"
+ t.string "name"
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
+ t.string "image", default: "spotify.jpeg"
+ end
+
+end
diff --git a/lib/TunesTakeoutWrapper.rb b/lib/TunesTakeoutWrapper.rb
new file mode 100644
index 0000000..43a3835
--- /dev/null
+++ b/lib/TunesTakeoutWrapper.rb
@@ -0,0 +1,34 @@
+require 'HTTParty'
+
+class TunesTakeoutWrapper
+ BASE_URL = "https://tunes-takeout-api.herokuapp.com"
+
+ #find a defined list of suggestion based on query
+ def self.search(query, limit=10, seed=query)
+ data = HTTParty.get(BASE_URL + "/v1/suggestions/search?query=#{query}&limit=#{limit}&seed=#{query}").parsed_response
+ end
+
+ #find a defined size of top suggestions, brings back an array
+ def self.top_suggestions(limit=20)
+ data = HTTParty.get(BASE_URL + "/v1/suggestions/top?limit=#{limit}").parsed_response["suggestions"]
+ end
+
+ #find suggestion attributes based on suggestion ID
+ def self.retrieve(suggestion_id)
+ HTTParty.get(BASE_URL + "/v1/suggestions/#{suggestion_id}").parsed_response
+ end
+
+ def self.favorites(uid)
+ data = HTTParty.get(BASE_URL + "/v1/users/#{uid}/favorites").parsed_response
+ end
+
+ def self.favorite(uid, suggestion_id)
+ response = HTTParty.post(BASE_URL+"/v1/users/#{uid}/favorites", {:body => { "suggestion": "#{suggestion_id}"}.to_json})
+ return response
+ end
+
+ def self.unfavorite(uid,suggestion_id)
+ response = HTTParty.delete(BASE_URL+"/v1/users/#{uid}/favorites", {:body => { "suggestion": "#{suggestion_id}"}.to_json})
+ return response
+ end
+end
\ No newline at end of file
diff --git a/list b/list
new file mode 100644
index 0000000..e3624dd
--- /dev/null
+++ b/list
@@ -0,0 +1,12 @@
+#Favorite individual food+music pairing suggestions
+
+- be able to log in (spotify)
+ - need to identify the logged in user
+- get suggestions from Charles' API
+ - need suggestion ID
+- gotta be able to send favorite data back to Charles' API
+- gotta be able to display suggestions
+- indicate satus of post-favorite action
+- need interaction in UI to initiate favoriting
+- gotta able to unfavorite
+- what data's needed when user favorites
\ No newline at end of file
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..f4587a5
--- /dev/null
+++ b/test/controllers/suggestions_controller_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class SuggestionsControllerTest < ActionController::TestCase
+ # test "the truth" do
+ # assert true
+ # 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..82aca4e
--- /dev/null
+++ b/test/models/music_test.rb
@@ -0,0 +1,17 @@
+require 'test_helper'
+
+
+describe Music do
+
+class MusicTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+
+
+end
+
+
+#sample data
+#{"id"=>"Vz0KQY-RRwADboE-", "food_id"=>"a-la-mode-pies-seattle",
+ #{}"music_id"=>"1OYLLmDS0pJVFRbUo19vrG", "music_type"=>"album"}
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
new file mode 100644
index 0000000..d0e95f6
--- /dev/null
+++ b/test/models/user_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class UserTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+ #insert tests here!
+end
diff --git a/test/test_helper.rb b/test/test_helper.rb
index 92e39b2..3ce8471 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,7 +1,25 @@
+require 'simplecov'
+SimpleCov.start
+
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
+require 'minitest/spec'
+require "minispec-metadata"
+require 'vcr'
+require 'minitest-vcr'
+require 'webmock/minitest'
+require "minitest/reporters"
+
+VCR.configure do |c|
+ c.cassette_library_dir = 'test/cassettes'
+ c.hook_into :webmock
+end
+
+Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
+MinitestVcr::Spec.configure!
+
class ActiveSupport::TestCase
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
fixtures :all