Class: TxghServer::Webhooks::Transifex::RequestHandler

Inherits:
Object
  • Object
show all
Includes:
ResponseHelpers
Defined in:
lib/txgh-server/webhooks/transifex/request_handler.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request, logger) ⇒ RequestHandler

Returns a new instance of RequestHandler.



18
19
20
21
# File 'lib/txgh-server/webhooks/transifex/request_handler.rb', line 18

def initialize(request, logger)
  @request = request
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



16
17
18
# File 'lib/txgh-server/webhooks/transifex/request_handler.rb', line 16

def logger
  @logger
end

#requestObject (readonly)

Returns the value of attribute request.



16
17
18
# File 'lib/txgh-server/webhooks/transifex/request_handler.rb', line 16

def request
  @request
end

Class Method Details

.handle_request(request, logger) ⇒ Object



9
10
11
# File 'lib/txgh-server/webhooks/transifex/request_handler.rb', line 9

def handle_request(request, logger)
  new(request, logger).handle_request
end

Instance Method Details

#handle_requestObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/txgh-server/webhooks/transifex/request_handler.rb', line 23

def handle_request
  if publish_event
    # the event handled the request
    return respond_with(204, '')  # no content
  end

  handle_safely do
    handler = TxghServer::Webhooks::Transifex::HookHandler.new(
      project: config.transifex_project,
      repo: config.git_repo,
      resource_slug: payload[:resource],
      language: payload[:language],
      logger: logger
    )

    handler.execute
  end
end