Class: Services::ThirdPartiesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/services/third_parties_controller.rb

Constant Summary

Constants inherited from ApplicationController

ApplicationController::MAX_LIST_LENGTH

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#third_partyObject (readonly)

Returns the value of attribute third_party.



4
5
6
# File 'app/controllers/services/third_parties_controller.rb', line 4

def third_party
  @third_party
end

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
# File 'app/controllers/services/third_parties_controller.rb', line 16

def create
  tp = CreateThirdPartyContext.call(safe_params)
  if tp.errors.empty?
    render json: { id: tp.id }
  else
    render json: { validation_error: tp.errors.full_messages }, status: 403
  end
end

#indexObject



9
10
11
# File 'app/controllers/services/third_parties_controller.rb', line 9

def index
  @third_parties = ThirdParty.limit(MAX_LIST_LENGTH)
end

#showObject



13
14
# File 'app/controllers/services/third_parties_controller.rb', line 13

def show
end

#updateObject



25
26
27
28
29
30
31
32
# File 'app/controllers/services/third_parties_controller.rb', line 25

def update
  UpdateThirdPartyContext.call(third_party, safe_params)
  if third_party.errors.blank?
    render json: { id: third_party.id }
  else
    render json: { validation_error: third_party.errors.full_messages }, status: 403
  end
end