Class: Integromat::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/integromat/base.rb

Direct Known Subclasses

Webhook

Instance Method Summary collapse

Instance Method Details

#apiObject



13
14
15
16
17
18
19
# File 'lib/integromat/base.rb', line 13

def api
  @api ||= ::Faraday.new(url: api_url) do |faraday|
    faraday.request :json
    faraday.response :logger, ::Logger.new($stdout), bodies: true
    faraday.adapter ::Faraday.default_adapter
  end
end

#api_urlObject



21
22
23
# File 'lib/integromat/base.rb', line 21

def api_url
  config.base_uri.to_s
end

#configObject



29
30
31
# File 'lib/integromat/base.rb', line 29

def config
  Integromat.config
end

#hook_pathObject



25
26
27
# File 'lib/integromat/base.rb', line 25

def hook_path
  "/#{web_hook_id}"
end

#post_hook(data) ⇒ Object



5
6
7
# File 'lib/integromat/base.rb', line 5

def post_hook(data)
  api.post(hook_path, data)
end

#web_hook_idObject



9
10
11
# File 'lib/integromat/base.rb', line 9

def web_hook_id
  @web_hook_id ||= config.web_hooks[hook_ref]
end