Class: TokenAuth::Api::PayloadsController

Inherits:
ActionController::Base
  • 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.



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

def authentication_token
  @authentication_token
end

Instance Method Details

#createObject



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

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



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

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

#optionsObject



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

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