Skip to content

Instantly share code, notes, and snippets.

@ajahongir
Last active August 29, 2015 14:05
Show Gist options
  • Save ajahongir/dd76c187e1022e5e52e6 to your computer and use it in GitHub Desktop.
Save ajahongir/dd76c187e1022e5e52e6 to your computer and use it in GitHub Desktop.
api interface
###client side###
request_parser_url = 'http://parsing.clickavia.ru/parsing'
options = {
datafile: {
title: 'ntk_mow_boj_csv',
parser: {
rule: 'some_rule',
city_from: 'MOW',
city_to: 'BOJ',
flight_class: 'econom',
start_date: '22.09.2014'
end_date: '29.09.2014'
}
},
currency: {
usd: 37.6,
rur: 1,
eur: 47.2
}
}
response = RestClient.post request_parser_url, options
ParserRequest.create(options: options, parser_queue_id: response.parser_queue_id)
###parser side###
parser = HtmlFlightParser::Tourdom.new({
resource: {
options: {
directions: { to: {}, back: {} }
}
}
})
result = parser.run_and_save
result_url = "http://parsing.clickavia.ru/parsing#{ result.id }"
Pusher['parser-channel'].trigger 'parsing_success',
{ parser_queue_id: parser_queue_id, url: result_url, status: success}
### client side ###
pusher_response = Pusher.response
if pusher_response.status.success?
ParserRequest.find(parser_queue_id: pusher_response.parser_queue_id)
temp_flights = RestClient.post result_url
TempFlight.import(temp_flights)
else
#run again
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment