Class: Cangaroo::Webhook::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/cangaroo/webhook/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#connectionObject

Returns the value of attribute connection.



8
9
10
# File 'lib/cangaroo/webhook/client.rb', line 8

def connection
  @connection
end

#pathObject

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
# File 'lib/cangaroo/webhook/client.rb', line 15

def post(payload, request_id, parameters)
  request_body = body(payload, request_id, parameters).to_json
  req = self.class.post(url, headers: headers, body: request_body)
  if req.response.code == '200'
    req.parsed_response
  else
    fail Cangaroo::Webhook::Error, req.parsed_response['summary']
  end
end