Class: WcoEmail::Api::MessagesController

Inherits:
WcoEmail::ApiController
  • Object
show all
Defined in:
app/controllers/wco_email/api/messages_controller.rb

Instance Method Summary collapse

Instance Method Details

#create_postalObject

2026-03-27 payload is parsed json.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/wco_email/api/messages_controller.rb', line 9

def create_postal
  # puts! params, 'api/messages#create_postal'

  ## save to bucket
  @client ||= Aws::S3::Client.new(::SES_S3_CREDENTIALS)
  @client.put_object({
    body:          params.to_unsafe_h.to_json,
    bucket:      ::SES_S3_BUCKET,
    content_type: 'application/json',
    key:           params['message_id'],
  })

  stub = WcoEmail::MessageStub.create({
    bucket:   ::SES_S3_BUCKET,
    format:    'json',
    object_key: params['message_id'],
  })

  WcoEmail::MessageIntakeJob.perform_async( stub.id.to_s )
  render status: :ok, json: { status: :ok }
end