Class: LessonlyApi::Webhook
- Inherits:
-
Object
- Object
- LessonlyApi::Webhook
- Defined in:
- lib/lessonly_api/webhook.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(env) ⇒ Webhook
constructor
A new instance of Webhook.
Constructor Details
#initialize(env) ⇒ Webhook
Returns a new instance of Webhook.
11 12 13 |
# File 'lib/lessonly_api/webhook.rb', line 11 def initialize(env) @env = env end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
9 10 11 |
# File 'lib/lessonly_api/webhook.rb', line 9 def env @env end |
Class Method Details
.call(env) ⇒ Object
4 5 6 |
# File 'lib/lessonly_api/webhook.rb', line 4 def call(env) new(env).call end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/lessonly_api/webhook.rb', line 15 def call return [405, {"Content-Type" => "text/plain"}, ['Method Not Allowed']] unless webhook_handler return [401, {"Content-Type" => "text/plain"}, ['Unauthorized']] unless parse_webhook_data return [406, {"Content-Type" => "text/plain"}, ['Not Acceptable']] if raw_webhook_data.nil? webhook_handler.call(webhook_data) [200, {"Content-Type" => "text/plain"}, ['OK']] end |