Class: Slanger::Api::RequestValidation

Inherits:
Struct
  • Object
show all
Defined in:
lib/slanger/api/request_validation.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RequestValidation

Returns a new instance of RequestValidation.



6
7
8
9
10
11
12
# File 'lib/slanger/api/request_validation.rb', line 6

def initialize(*args)
  super(*args)

  validate!
  authenticate!
  parse_body!
end

Instance Attribute Details

#path_infoObject

Returns the value of attribute path_info

Returns:

  • (Object)

    the current value of path_info



5
6
7
# File 'lib/slanger/api/request_validation.rb', line 5

def path_info
  @path_info
end

#raw_bodyObject

Returns the value of attribute raw_body

Returns:

  • (Object)

    the current value of raw_body



5
6
7
# File 'lib/slanger/api/request_validation.rb', line 5

def raw_body
  @raw_body
end

#raw_paramsObject

Returns the value of attribute raw_params

Returns:

  • (Object)

    the current value of raw_params



5
6
7
# File 'lib/slanger/api/request_validation.rb', line 5

def raw_params
  @raw_params
end

Instance Method Details

#auth_paramsObject



22
23
24
# File 'lib/slanger/api/request_validation.rb', line 22

def auth_params
  params.except("channel_id", "app_id")
end

#bodyObject



18
19
20
# File 'lib/slanger/api/request_validation.rb', line 18

def body
  @body ||= validate_body!
end

#channelsObject



34
35
36
# File 'lib/slanger/api/request_validation.rb', line 34

def channels
  @channels ||= Array(body["channels"] || params["channels"])
end

#dataObject



14
15
16
# File 'lib/slanger/api/request_validation.rb', line 14

def data
  @data ||= Oj.strict_load(body["data"] || params["data"])
end

#paramsObject



30
31
32
# File 'lib/slanger/api/request_validation.rb', line 30

def params
  @params ||= validate_raw_params!
end

#socket_idObject



26
27
28
# File 'lib/slanger/api/request_validation.rb', line 26

def socket_id
  @socket_id ||= determine_valid_socket_id
end