Class: Cangaroo::Webhook::Client
- Inherits:
-
Object
- Object
- Cangaroo::Webhook::Client
- Includes:
- HTTParty
- Defined in:
- lib/cangaroo/webhook/client.rb
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(connection, path) ⇒ Client
constructor
A new instance of Client.
- #post(payload, request_id, parameters) ⇒ Object
Constructor Details
#initialize(connection, path) ⇒ Client
Returns a new instance of Client.
10 11 12 13 |
# File 'lib/cangaroo/webhook/client.rb', line 10 def initialize(connection, path) @connection = connection @path = path end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
8 9 10 |
# File 'lib/cangaroo/webhook/client.rb', line 8 def connection @connection end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/cangaroo/webhook/client.rb', line 8 def path @path end |
Instance Method Details
#post(payload, request_id, parameters) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cangaroo/webhook/client.rb', line 15 def post(payload, request_id, parameters) request_body = body(payload, request_id, parameters).to_json = { headers: headers, body: request_body } if Rails.configuration.cangaroo.basic_auth [:basic_auth] = { username: connection.key, password: connection.token } end if timeout = Rails.configuration.cangaroo.client_timeout [:timeout] = timeout end req = self.class.post(url, ) sanitized_response = sanitize_response(req) fail Cangaroo::Webhook::Error, sanitized_response unless %w(200 201 202 204).include?(req.response.code) sanitized_response end |