Module: Xcal::Parktronic::Routes::CommandNotifications

Included in:
Xcal::Parktronic::Routes
Defined in:
lib/xcal/parktronic/routes/command_notifications.rb

Instance Method Summary collapse

Instance Method Details

#get_paged_command_notifications(args = {}) ⇒ Object Also known as: command_notifications

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


16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xcal/parktronic/routes/command_notifications.rb', line 16

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

#update_command_notification(id) ⇒ Object Also known as: set_inactive_command_notification

Set inactive remote command

Parameters

  • id remote command ID

Examples

api.update_command_notification(1)
api.set_inactive_command_notification(1)


38
39
40
41
42
43
44
45
46
47
48
# File 'lib/xcal/parktronic/routes/command_notifications.rb', line 38

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