Sha256: c880abf93d96546afde7360c31deefdfdebf6f16c16cc0f339b7e3ad33e7d3e8

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# typed: false
# frozen_string_literal: true

class YettoController < ApplicationController
  include BodyParameter::YettoParameters
  include PathParameter
  include PathParameter::YettoParameters
  include Authable

  include Headers::Yetto

  before_action :from_yetto?

  AFTER_CREATE_MESSAGE_SWITCH = JSON.parse(Rails.root.join("app/lib/plug_app/switches/message_created.jsonc").read)

  def event
    case pparam_yetto_event
    when Headers::Yetto::EVENT_AFTER_CREATE
      case pparam_yetto_record_type
      when Headers::Yetto::RECORD_TYPE_PLUG_INSTALLATION
        create_inbox_switch_data = {
          type: "create_inbox_switch",
          inbox: { id: bparam_inbox_id },
          plug_installation: { id: bparam_plug_installation_id },
          payload: AFTER_CREATE_MESSAGE_SWITCH,
        }

        UpdateYettoJob.perform_later(create_inbox_switch_data)

        no_content
      when Headers::Yetto::RECORD_TYPE_MESSAGE

        no_content
      else
        not_found
      end
    else
      not_found
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hephaestus-0.5.2 templates/app/controllers/yetto_controller.rb
hephaestus-0.5.1 templates/app/controllers/yetto_controller.rb
hephaestus-0.5.0 templates/app/controllers/yetto_controller.rb
hephaestus-0.4.0 templates/app/controllers/yetto_controller.rb