Guest User

Untitled

a guest
Jun 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. class ShipmentsController < ApplicationController
  2. authorize_resource
  3.  
  4. def get_point
  5. points = SetShipmentService.new(
  6. service_name: params[:service_name],
  7. q: params[:city_code]).get_point
  8.  
  9. if points[0]['err']
  10. render_data(points)
  11. else
  12. points = points.map {|add| [add["Address"], add["Code"]]}
  13. render_data(points)
  14. end
  15. end
  16.  
  17. def calculation
  18. price = SetShipmentService.new(
  19. q: params[:point_id],
  20. service_name: params[:service_name]).calculation
  21.  
  22. render_data(price)
  23. end
  24.  
  25. def list_cities
  26. get_cities = SetShipmentService.new(
  27. service_name: params[:service_name],
  28. q: params[:name_startsWith]).list_cities
  29.  
  30. render_data(get_cities)
  31. end
  32.  
  33. def show_on_map
  34. get_points = SetShipmentService.new(
  35. service_name: params[:service_name],
  36. q: params[:point_id],
  37. city_code: params[:city_code]).show_on_map
  38.  
  39. render_data(get_points)
  40. end
  41. # Курьерская доставка
  42. def get_zip_code
  43. zip_code = SetShipmentService.new(
  44. q: params[:point_id],
  45. service_name: params[:service_name]).get_zip_code
  46.  
  47. render_data(zip_code)
  48. end
  49.  
  50. def express_delivery_cities
  51. courier_city = SetShipmentService.new(
  52. q: params[:point_id],
  53. service_name: params[:service_name]).express_delivery_cities
  54.  
  55. render_data(courier_city)
  56. end
  57.  
  58. def express
  59. courier_city = SetShipmentService.new(
  60. q: params[:q],
  61. service_name: params[:service_name]).express
  62.  
  63. render_data(courier_city)
  64. end
  65.  
  66. private def render_data(data_json)
  67. respond_to do |format|
  68. format.json { render json: data_json }
  69. end
  70. end
  71. end
Add Comment
Please, Sign In to add comment