mirror of
https://github.com/internetee/registry.git
synced 2025-08-02 16:02:03 +02:00
Complete auction integration
This commit is contained in:
parent
f1148bd4f4
commit
446b9fbf77
6 changed files with 62 additions and 6 deletions
|
@ -8,12 +8,12 @@ module Api
|
|||
end
|
||||
|
||||
def show
|
||||
auction = Auction.find_by(uuid: params[:uuid])
|
||||
auction = Auction.find_by!(uuid: params[:uuid])
|
||||
render json: serializable_hash(auction)
|
||||
end
|
||||
|
||||
def update
|
||||
auction = Auction.find_by(uuid: params[:uuid])
|
||||
auction = Auction.find_by!(uuid: params[:uuid])
|
||||
|
||||
case params[:status]
|
||||
when Auction.statuses[:awaiting_payment]
|
||||
|
@ -24,6 +24,8 @@ module Api
|
|||
auction.mark_as_payment_received
|
||||
when Auction.statuses[:payment_not_received]
|
||||
auction.mark_as_payment_not_received
|
||||
when Auction.statuses[:domain_not_registered]
|
||||
auction.mark_as_domain_not_registered
|
||||
else
|
||||
raise "Invalid status #{params[:status]}"
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@ class Auction < ActiveRecord::Base
|
|||
payment_received: 'payment_received',
|
||||
payment_not_received: 'payment_not_received',
|
||||
domain_registered: 'domain_registered',
|
||||
domain_not_registered: 'domain_not_registered',
|
||||
}
|
||||
|
||||
PENDING_STATUSES = [statuses[:started],
|
||||
|
@ -43,6 +44,15 @@ class Auction < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def mark_as_domain_not_registered
|
||||
self.status = self.class.statuses[:domain_not_registered]
|
||||
|
||||
transaction do
|
||||
save!
|
||||
restart
|
||||
end
|
||||
end
|
||||
|
||||
def domain_registrable?(registration_code = nil)
|
||||
payment_received? && registration_code_matches?(registration_code)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue