module Xcal module Parktronic module Routes module CommandNotifications # Fetches remote commands # # ==== Parameters # * +page+ page number, defaults to 1 # * +per_page+ per page value, defaults to 100 # # ==== Examples # api.get_paged_command_notifications # api.command_notifications def get_paged_command_notifications(args = {}) args.merge!(access_token: access_token) response = get_response("/#{api_version}/command_notifications?#{URI.encode_www_form(args)}") generic_response = Xcal::Parktronic::GenericResponse.new(response.body) if response.code == '200' && generic_response.has_key?(:remote_commands) generic_response.remote_commands.map { |command| Xcal::Parktronic::GenericResponse.new(command.remote_command, self) } else generic_response end end alias :command_notifications :get_paged_command_notifications # Set inactive remote command # # ==== Parameters # * +id+ remote command ID # # ==== Examples # api.update_command_notification(1) # api.set_inactive_command_notification(1) def update_command_notification(id) begin request = Net::HTTP::Patch.new("/#{api_version}/command_notifications/#{id}", 'Content-Type' => 'application/json') rescue # ruby 1.9.2 request = Net::HTTP::Put.new("/#{api_version}/command_notifications/#{id}", 'Content-Type' => 'application/json') end request.body = { access_token: access_token }.to_json response = http.start { |net| net.request(request) } Xcal::Parktronic::GenericResponse.new(response.body) end alias :set_inactive_command_notification :update_command_notification end end end end