Class: MandateClaw::Api::V1::ContractsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- MandateClaw::Api::V1::ContractsController
- Defined in:
- app/controllers/mandate_claw/api/v1/contracts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /mandate_claw/api/v1/contracts Body: { contract_digest, template_name, scope_type, scope_id, parties_json, signatures_json, rendered_markdown, expires_at }.
-
#revoke ⇒ Object
POST /mandate_claw/api/v1/contracts/:id/revoke.
-
#show ⇒ Object
GET /mandate_claw/api/v1/contracts/:id.
-
#verify ⇒ Object
POST /mandate_claw/api/v1/contracts/:id/verify Returns whether the contract is active and not expired.
Instance Method Details
#create ⇒ Object
POST /mandate_claw/api/v1/contracts Body: { contract_digest, template_name, scope_type, scope_id,
parties_json, signatures_json, rendered_markdown, expires_at }
12 13 14 15 16 17 |
# File 'app/controllers/mandate_claw/api/v1/contracts_controller.rb', line 12 def create contract = SignedContract.create!(contract_params) render json: serialize(contract), status: :created rescue ActiveRecord::RecordInvalid => e render json: { error: e. }, status: :unprocessable_entity end |
#revoke ⇒ Object
POST /mandate_claw/api/v1/contracts/:id/revoke
37 38 39 40 |
# File 'app/controllers/mandate_claw/api/v1/contracts_controller.rb', line 37 def revoke @contract.revoke!(reason: params[:reason]) render json: { revoked: true, contract_id: @contract.id } end |
#show ⇒ Object
GET /mandate_claw/api/v1/contracts/:id
20 21 22 |
# File 'app/controllers/mandate_claw/api/v1/contracts_controller.rb', line 20 def show render json: serialize(@contract) end |
#verify ⇒ Object
POST /mandate_claw/api/v1/contracts/:id/verify Returns whether the contract is active and not expired.
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/mandate_claw/api/v1/contracts_controller.rb', line 26 def verify render json: { contract_id: @contract.id, digest: @contract.contract_digest, valid: @contract.active? && !@contract.expired?, status: @contract.status, expires_at: @contract.expires_at } end |