order reservation

This commit is contained in:
phyusin
2018-04-12 11:01:13 +06:30
parent c1a6ff7230
commit 49ebc6c0dc
6 changed files with 122 additions and 73 deletions

View File

@@ -36,5 +36,37 @@ class Origami::OrderReservationController < BaseOrigamiController
end
end
def send_status
base_url = "http://192.168.1.186:3002"
post_url = base_url + params[:url]
# status = params[:status]
if params[:status] == "cancel"
status = "rejected"
else
status = params[:status]
end
begin
response = HTTParty.post(post_url,
:body => { id: params[:ref_no], status: status}.to_json,
:headers => {
'Authorization' => 'Token token=3T-tnlYtFJ-5Z1vY6XQqxQ',
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
}, :timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
rescue OpenURI::HTTPError
response = { status: false}
rescue SocketError
response = { status: false}
end
Rails.logger.debug "Get Doemal Status "
Rails.logger.debug response.to_json
render :json => response
end
end