diff --git a/app/controllers/api/v1/offers_controller.rb b/app/controllers/api/v1/offers_controller.rb index 29246248d..09092892a 100644 --- a/app/controllers/api/v1/offers_controller.rb +++ b/app/controllers/api/v1/offers_controller.rb @@ -6,16 +6,23 @@ class OffersController < ApplicationController skip_before_action :verify_authenticity_token + def index + offers = Offer.includes(:auction) + .includes(:result) + .where(user_id: current_user) + .order('auctions.ends_at DESC') + + Rails.logger.info '---- offers ----' + Rails.logger.info(offers.inspect) + Rails.logger.info '----' + + # price with tax + render json: offers.as_json(include: [:auction, :billing_profile]) + end + # rubocop:disable Metrics/AbcSize # rubocop:disable Metrics/MethodLength def create - Rails.logger.info('----') - Rails.logger.info(params) - Rails.logger.info('----') - - #{"bid"=>{"price"=>320.0, "auction_id"=>"2a893210-f1f1-4be8-9d78-b793f1fa0ec6", "billing_profile_id"=>"23"}, - #"controller"=>"api/v1/offers", "action"=>"create", "offer"=>{}} - auction = Auction.find_by(uuid: params[:bid][:auction_id]) return if auction.nil? @@ -23,12 +30,6 @@ def create offer = auction.offer_from_user(current_user.id) - Rails.logger.info('----') - Rails.logger.info(current_user.inspect) - Rails.logger.info(billing_profile.inspect) - Rails.logger.info(offer.inspect) - Rails.logger.info('----') - if offer.nil? offer = Offer.new( auction:, diff --git a/config/routes.rb b/config/routes.rb index 89d2a4c30..56a6ac334 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -9,7 +9,7 @@ namespace :api do namespace :v1 do resource :stream_name, only: :show - resource :offers, only: :create + resources :offers, only: [:create, :index] resource :autobiders, only: :create resource :tara_auth_session, only: :create resource :auctions, only: :show