webhook_manager 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f63d3140b89d251249964362c0ef8f41b79340093bf0e7b969316559bc704296
4
- data.tar.gz: 91da772e4b60d21cee5bf6aa57046e9d90b1e9ce00f6ea367e02bfdbee4045b2
3
+ metadata.gz: 9a409506ecbfcdf2f334beab456bbe6f604386d9307a808eed7df0665269c1de
4
+ data.tar.gz: 5d8332fea7454ae717751bdade1e71ceb7e5f57a7e10a3af583cb1e8c3742b1d
5
5
  SHA512:
6
- metadata.gz: 53f0c7a46473594d61cc6ebb97a2c06e57049fabd7ebe90e00eff342f523d1cafcbf431d35e1b86c2d07c668c1359a4e7ea3c86194b00e09ddedf8918f899ffd
7
- data.tar.gz: f69ff8766c98195011c8645e8736f3d92723783948074e509c6bfe9e03bb49b1301c5cb4b0f9542b76955e3e13525b134ed12101e441cab37dcef7eb23ea5a85
6
+ metadata.gz: daf3a1e0cedddde23f8072eb747309cdaab49b1175a58ffb30bdcade8f1e7e30b102f823e0dc82aa17bfbf4a8ffcb3e90117c7e89f1878b124018674a6139b61
7
+ data.tar.gz: 40c9202e731932e37876f222223033627fc92414aaae957a02d06c322ff080fd56e73d0e421c1e1b6d5f212b0521379d878c5b76eaa450f3d29781efdc16602a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webhook_manager (0.1.3)
4
+ webhook_manager (0.2.0)
5
5
  faraday (~> 0.17.3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # WebhookManager
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/webhook_manager`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ A gem that integrates the https://gethooky.com API for plain Ruby or Ruby on Rails applications.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,19 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ 1. Initialize the class with your Hooky API key:
24
+
25
+ ```ruby
26
+ client = WebhookManager::Webhook.new(HOOKY_API_KEY)
27
+ ```
28
+
29
+ 2. Send your webhook
30
+
31
+ Note: Payload expect a Ruby Hash. It will be automatically converted to JSON
32
+
33
+ ```ruby
34
+ client.trigger!(event_name: "any.event.name", payload: {foo: "bar"})
35
+ ```
26
36
 
27
37
  ## Development
28
38
 
@@ -4,6 +4,7 @@ require "faraday"
4
4
  require "json"
5
5
 
6
6
  require_relative "webhook_manager/version"
7
+ require_relative "webhook_manager/globals"
7
8
 
8
9
  module WebhookManager
9
10
  class Error < StandardError; end
@@ -11,9 +12,9 @@ module WebhookManager
11
12
  class Webhook
12
13
  attr_accessor :conn
13
14
 
14
- def initialize(url, api_key)
15
+ def initialize(api_key)
15
16
  @conn = Faraday::Connection.new(
16
- url: url,
17
+ url: HOOKY_API,
17
18
  headers: {
18
19
  "Authorization" => "ApiKey #{api_key}",
19
20
  "Content-Type" => "application/json"
@@ -60,7 +61,7 @@ module WebhookManager
60
61
  elsif res.status == 401
61
62
  raise Error.new("Unauthorized access to the API!")
62
63
  else
63
- raise Error.new("Something went wrong calling the hooky API!")
64
+ raise Error.new("Something went wrong calling the hooky API! #{res.body}")
64
65
  end
65
66
  end
66
67
  end
@@ -0,0 +1 @@
1
+ HOOKY_API = "https://app.hooky.me/api/v1".freeze
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WebhookManager
4
- VERSION = "0.1.3"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webhook_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luay Bseiso
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-30 00:00:00.000000000 Z
11
+ date: 2021-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -58,6 +58,7 @@ files:
58
58
  - bin/console
59
59
  - bin/setup
60
60
  - lib/webhook_manager.rb
61
+ - lib/webhook_manager/globals.rb
61
62
  - lib/webhook_manager/version.rb
62
63
  - webhook_manager.gemspec
63
64
  homepage: https://github.com/buttercloud/webhook_manager