sync token lookup
This commit is contained in:
@@ -76,8 +76,10 @@ authorize_resource :class => false
|
|||||||
# Here comes to call the sync api
|
# Here comes to call the sync api
|
||||||
# url = "http://192.168.1.176:3000/en/api/sync_data"
|
# url = "http://192.168.1.176:3000/en/api/sync_data"
|
||||||
url = Lookup.sync_url
|
url = Lookup.sync_url
|
||||||
|
token = Lookup.get_sync_token
|
||||||
# token = Lookup.token
|
# token = Lookup.token
|
||||||
|
|
||||||
|
unless url.nil? and token.nil?
|
||||||
begin
|
begin
|
||||||
@result = HTTParty.post(url.to_str,
|
@result = HTTParty.post(url.to_str,
|
||||||
:body => { :orders => @orders,
|
:body => { :orders => @orders,
|
||||||
@@ -94,7 +96,7 @@ authorize_resource :class => false
|
|||||||
}.to_json,
|
}.to_json,
|
||||||
:headers => {
|
:headers => {
|
||||||
'Content-Type' => 'application/json',
|
'Content-Type' => 'application/json',
|
||||||
'Authorization' => 'Bearer 698bd32190e86d076325'
|
'Authorization' => "Bearer #{token}"
|
||||||
}, :timeout => 10,
|
}, :timeout => 10,
|
||||||
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
|
:verify_ssl => OpenSSL::SSL::VERIFY_NONE,
|
||||||
:verify => false )
|
:verify => false )
|
||||||
@@ -116,6 +118,7 @@ authorize_resource :class => false
|
|||||||
|
|
||||||
puts url
|
puts url
|
||||||
puts response
|
puts response
|
||||||
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to '/en/reports/receipt_no/', notice: 'Sync Record Completed.'}
|
format.html { redirect_to '/en/reports/receipt_no/', notice: 'Sync Record Completed.'}
|
||||||
|
|||||||
@@ -14,10 +14,11 @@ class Booking < ApplicationRecord
|
|||||||
def self.sync_booking_records(bookings)
|
def self.sync_booking_records(bookings)
|
||||||
if !bookings.nil?
|
if !bookings.nil?
|
||||||
bookings.each do |b|
|
bookings.each do |b|
|
||||||
unless Booking.exists?(b['booking_id'])
|
unless TableBooking.exists?(b['booking_id'])
|
||||||
booking = Booking.new
|
booking = TableBooking.new
|
||||||
booking.booking_id = b['booking_id']
|
booking.booking_id = b['booking_id']
|
||||||
booking.dining_facility_id = b['dining_facility_id']
|
booking.dining_facility_id = b['dining_facility_id']
|
||||||
|
booking.type = b['type']
|
||||||
booking.checkin_at = b['checkin_at']
|
booking.checkin_at = b['checkin_at']
|
||||||
booking.checkin_by = b['checkin_by']
|
booking.checkin_by = b['checkin_by']
|
||||||
booking.checkout_at = b['checkout_at']
|
booking.checkout_at = b['checkout_at']
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ class Lookup < ApplicationRecord
|
|||||||
return lookup.value
|
return lookup.value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_sync_token
|
||||||
|
lookup = Lookup.find_by_lookup_type('sync_token')
|
||||||
|
return lookup.value
|
||||||
|
end
|
||||||
|
|
||||||
def self.collection_of(type)
|
def self.collection_of(type)
|
||||||
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
|
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user