Class: Webhooks::Vendors::Bistrochat::CallbackController
Instance Method Summary
collapse
#identity_cache_memoization
#append_info_to_payload
Instance Method Details
#access_token_response(access_token) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/webhooks/vendors/bistrochat/callback_controller.rb', line 26
def access_token_response(access_token)
{
token_type: access_token.token_type,
scope: access_token.scopes.to_s,
created_at: access_token.created_at.to_i,
access_token: access_token.token,
expires_at: access_token.expires_at.to_i,
refresh_token: access_token.refresh_token,
}
end
|
#callback ⇒ JSON
Handles Bistrochat webhook callbacks. Extracts syncable_type and syncable_id, finds reservation, and enqueues worker if found. Reports errors to APM and returns JSON response.
42
43
44
45
46
47
48
49
50
|
# File 'app/controllers/webhooks/vendors/bistrochat/callback_controller.rb', line 42
def callback
HH_LOGGER.debug 'Bistrochat#callback', params: params
process_bistrochat_callback(params)
render json: { success: true, message: nil }
rescue StandardError => e
message = "Bistrochat Webhook processing error: #{e.message}"
APMErrorHandler.report('An error occurred on V5 API', exception: e)
render json: { success: false, message: message }
end
|
#oauth2_bistrochat ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/webhooks/vendors/bistrochat/callback_controller.rb', line 8
def oauth2_bistrochat
client_id = params[:client_id]
client_secret = params[:client_secret]
if client_id.blank? || client_secret.blank?
return render json: { success: false, message: 'client_id or client_secret is missing' }, status: :unauthorized
end
application = Doorkeeper::Application.find_by(uid: client_id, secret: client_secret)
if application.blank?
return render json: { success: false, message: 'Invalid client_id or client_secret' }, status: :unauthorized
end
access_token = Bistrochat::AccessTokenService.create_access_token(application)
render json: access_token_response(access_token)
end
|