glip-poster 0.0.3 → 0.1.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 +4 -4
- data/README.md +8 -12
- data/Rakefile +0 -1
- data/glip-poster.gemspec +3 -3
- data/lib/glip-poster/poster.rb +11 -9
- data/lib/glip_poster.rb +1 -0
- data/test/test_base.rb +1 -1
- data/test/test_setup.rb +1 -1
- metadata +4 -4
- data/lib/glip-poster.rb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e04b1814536e841a21c40ef76ebc22efb374901
|
4
|
+
data.tar.gz: 7225cb0a4e817bf2f6f810594ec35fb94a33d0c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b504dff9e41d75bf616b97cfbf5ff0bbf72381b04aba84b1a11745afa54e622a232bf0070afbc3ff46dd4a40349651e0c9e84b044f293a2c6bb0076b89c32610
|
7
|
+
data.tar.gz: 4fa261626d489515e6229fa1577e46a264f7027e2b8291880f0c4ed2df30fbdf8c53e1f2a3f736a33bafb32dc14ba04b5d6c3b10c54d4ce68c6b7ff6fcf8a695
|
data/README.md
CHANGED
@@ -32,41 +32,37 @@ $ gem install glip-poster
|
|
32
32
|
|
33
33
|
## Glip setup
|
34
34
|
|
35
|
-
This gem
|
35
|
+
This gem uses an incoming webhook integration on Glip. To create a new Glip webhook integration, in Glip.com, click on "Integrations" in the left column and then select the "Glip Webhooks" integration. After you select a conversation, a webhook URL will be presented which you will use with this gem to post messages to. The URL looks like the following:
|
36
36
|
|
37
37
|
```http
|
38
38
|
https://hooks.glip.com/webhook/11112222-3333-4444-5555-666677778888
|
39
39
|
```
|
40
40
|
|
41
|
-
You can instantiate the `Glip::Poster` class with the full URL or the webhook ID (GUID) only.
|
42
|
-
|
43
41
|
## Usage
|
44
42
|
|
45
|
-
|
43
|
+
Initialize your poster and then call the `send_message` method to send your message. You must supply the webhook URL or webhook ID configured in the desired "Glip Webhooks" integration.
|
46
44
|
|
47
45
|
```ruby
|
48
|
-
require '
|
46
|
+
require 'glip_poster' # note underscore
|
49
47
|
|
50
|
-
poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
|
48
|
+
poster = Glip::Poster.new(YOUR_WEBHOOK_URL) # or YOUR_WEBHOOK_ID (GUID)
|
51
49
|
poster.send_message('Hi there!') # Faraday::Response
|
52
50
|
```
|
53
51
|
|
54
52
|
You can send text in Markdown:
|
55
53
|
|
56
54
|
```ruby
|
57
|
-
poster
|
58
|
-
poster.send_message('* Location: [The Funky Buddha Lounge](http://www.thefunkybuddha.com)\n*Beer Advocate Rating: [99](http://tinyurl.com/psf4uzq)')
|
55
|
+
poster.send_message("* Location: [The Funky Buddha Lounge](http://www.thefunkybuddha.com)\n*Beer Advocate Rating: [99](http://tinyurl.com/psf4uzq)")
|
59
56
|
```
|
60
57
|
|
61
58
|
You can use an options array if you don't want to use the default settings.
|
62
59
|
|
63
60
|
```ruby
|
64
61
|
options = {
|
65
|
-
icon:
|
66
|
-
activity:
|
67
|
-
title:
|
62
|
+
icon: 'http://example.com/icon.png',
|
63
|
+
activity: 'Activity Alert',
|
64
|
+
title: 'A New Incoming Message Has Been Received'
|
68
65
|
}
|
69
|
-
poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
|
70
66
|
poster.send_message('Hi there!', options)
|
71
67
|
```
|
72
68
|
|
data/Rakefile
CHANGED
data/glip-poster.gemspec
CHANGED
@@ -7,14 +7,14 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = 'glip-poster'
|
8
8
|
s.version = version
|
9
9
|
s.date = '2016-01-31'
|
10
|
-
s.summary = 'Glip Poster - Ruby SDK
|
11
|
-
s.description = 'A Ruby SDK
|
10
|
+
s.summary = 'Glip Poster - Ruby SDK to post messages via Glip webhooks'
|
11
|
+
s.description = 'A Ruby SDK to post messages via Glip webhooks'
|
12
12
|
s.authors = ['John Wang']
|
13
13
|
s.email = 'johncwang@gmail.com'
|
14
14
|
s.homepage = 'https://github.com/grokify/'
|
15
15
|
s.licenses = ['MIT']
|
16
16
|
s.files = Dir['lib/**/**/*'] # + Dir['bin/*']
|
17
|
-
s.files += Dir['[A-Z]*']
|
17
|
+
s.files += Dir['[A-Z]*'] + Dir['test/**/*']
|
18
18
|
# s.files.reject! { |fn| fn.include? "CVS" }
|
19
19
|
# s.required_ruby_version = '>= 1.8.7' # 1.8.7+ is tested
|
20
20
|
s.add_dependency 'faraday', '~> 0.9', '>= 0.9'
|
data/lib/glip-poster/poster.rb
CHANGED
@@ -3,7 +3,7 @@ require 'faraday_middleware'
|
|
3
3
|
|
4
4
|
module Glip
|
5
5
|
class Poster
|
6
|
-
VERSION = '0.0
|
6
|
+
VERSION = '0.1.0'
|
7
7
|
GLIP_WEBHOOK_BASE_URL = 'https://hooks.glip.com/webhook/'
|
8
8
|
|
9
9
|
attr_reader :webhook_url
|
@@ -14,11 +14,11 @@ module Glip
|
|
14
14
|
set_webhook_url(webhook_url_or_id)
|
15
15
|
|
16
16
|
@options = {}
|
17
|
-
|
18
|
-
@http = Faraday.new(:
|
19
|
-
faraday.request
|
17
|
+
|
18
|
+
@http = Faraday.new(url: GLIP_WEBHOOK_BASE_URL) do |faraday|
|
19
|
+
faraday.request :json
|
20
20
|
faraday.response :logger
|
21
|
-
faraday.adapter
|
21
|
+
faraday.adapter Faraday.default_adapter # use Net::HTTP
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -28,15 +28,17 @@ module Glip
|
|
28
28
|
elsif webhook_url_or_id =~ %r{^https?://}
|
29
29
|
@webhook_url = webhook_url_or_id
|
30
30
|
else
|
31
|
-
|
31
|
+
fail ArgumentError, 'must include webhook URL or id argument'
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def send_message(message, opts={})
|
36
|
-
|
35
|
+
def send_message(message, opts = {})
|
36
|
+
response = @http.post do |req|
|
37
37
|
req.url @webhook_url
|
38
|
-
req.body = @options.merge(opts).merge(
|
38
|
+
req.body = @options.merge(opts).merge(body: message)
|
39
39
|
end
|
40
|
+
|
41
|
+
response
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end
|
data/lib/glip_poster.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'glip-poster/poster'
|
data/test/test_base.rb
CHANGED
data/test/test_setup.rb
CHANGED
@@ -9,7 +9,7 @@ class GlipPosterTest < Test::Unit::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def test_url
|
12
|
-
url = 'https://hooks.glip.com/webhook/
|
12
|
+
url = 'https://hooks.glip.com/webhook/11112222-3333-4444-5555-666677778888'
|
13
13
|
poster = Glip::Poster.new(url)
|
14
14
|
assert_equal url, poster.webhook_url
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glip-poster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
|
-
description: A Ruby SDK
|
53
|
+
description: A Ruby SDK to post messages via Glip webhooks
|
54
54
|
email: johncwang@gmail.com
|
55
55
|
executables: []
|
56
56
|
extensions: []
|
@@ -63,8 +63,8 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
65
|
- glip-poster.gemspec
|
66
|
-
- lib/glip-poster.rb
|
67
66
|
- lib/glip-poster/poster.rb
|
67
|
+
- lib/glip_poster.rb
|
68
68
|
- test/test_base.rb
|
69
69
|
- test/test_setup.rb
|
70
70
|
homepage: https://github.com/grokify/
|
@@ -90,5 +90,5 @@ rubyforge_project:
|
|
90
90
|
rubygems_version: 2.4.8
|
91
91
|
signing_key:
|
92
92
|
specification_version: 4
|
93
|
-
summary: Glip Poster - Ruby SDK
|
93
|
+
summary: Glip Poster - Ruby SDK to post messages via Glip webhooks
|
94
94
|
test_files: []
|
data/lib/glip-poster.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
require 'glip-poster/poster'
|