Class: TokenAuth::Api::PayloadsController

Inherits:
BaseController
  • Object
show all
Includes:
Concerns::CorsSettings
Defined in:
app/controllers/token_auth/api/payloads_controller.rb

Overview

Processes inbound and outbound resources.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Concerns::CorsSettings

#cors_set_access_control_headers

Instance Attribute Details

#authentication_tokenObject (readonly)

Returns the value of attribute authentication_token.



11
12
13
# File 'app/controllers/token_auth/api/payloads_controller.rb', line 11

def authentication_token
  @authentication_token
end

Instance Method Details

#createObject



33
34
35
36
37
38
39
40
41
42
# File 'app/controllers/token_auth/api/payloads_controller.rb', line 33

def create
  authenticate!
  payload = Payload.new(entity_id: authentication_token.entity_id)
  payload.save request_data

  headers["Errors"] = payload.errors.join(", ")
  render json: payload.valid_resources, status: 201
rescue TokenAuth::Payload::MalformedPayloadError
  render json: {}, status: 400
end

#indexObject



23
24
25
26
27
# File 'app/controllers/token_auth/api/payloads_controller.rb', line 23

def index
  authenticate!
  render json: pullable_records,
         meta: { timestamp: Time.zone.now.iso8601 }
end

#optionsObject



29
30
31
# File 'app/controllers/token_auth/api/payloads_controller.rb', line 29

def options
  render json: {}, status: 200
end