glip-poster 0.0.2 → 0.0.3
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 +25 -11
- data/Rakefile +1 -1
- data/glip-poster.gemspec +1 -1
- data/lib/glip-poster/poster.rb +5 -9
- metadata +2 -3
- data/glip-poster-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf78cb00473593f849b8a6fdbddc778f677d4884
|
4
|
+
data.tar.gz: 36e1cb0d1738cfbebc0975ddefa2116ec809766b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea165044446914a0c5fe3a446303ff6e42740cc4e70a6c48a3895bc17536e5d1ecc8e91d2c25c6f772a6fa4d312046af46fc0b08189c6183c1e012dd28ebaa6e
|
7
|
+
data.tar.gz: 94a6adeac3f4d6244c883bc85ff44ebcf3ffcf20a83aaa36045f5f8f2cf6fa754a9fb5a5d1934500c98827d52fe4e462f7bd806da8b407975b81e50cf6bc6083
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
Glip Poster
|
2
|
-
|
2
|
+
===========
|
3
3
|
|
4
4
|
[![Gem Version][gem-version-svg]][gem-version-link]
|
5
5
|
[![Build Status][build-status-svg]][build-status-link]
|
@@ -11,11 +11,13 @@ Glip Poster
|
|
11
11
|
[![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
|
12
12
|
[![License][license-svg]][license-link]
|
13
13
|
|
14
|
+
`glip-poster` is a simple gem to make your integration with Glip (https://glip.com/) easier. It supports only incoming communications (from you to Glip).
|
15
|
+
|
14
16
|
## Installation
|
15
17
|
|
16
18
|
### Via Bundler
|
17
19
|
|
18
|
-
Add
|
20
|
+
Add `glip-poster` to your `Gemfile` and then run `bundle`:
|
19
21
|
|
20
22
|
```sh
|
21
23
|
$ echo "gem 'glip-poster'" >> Gemfile
|
@@ -28,13 +30,25 @@ $ bundle
|
|
28
30
|
$ gem install glip-poster
|
29
31
|
```
|
30
32
|
|
33
|
+
## Glip setup
|
34
|
+
|
35
|
+
This gem will use a incoming webHook integration on Glip. First, you need to create a new Glip webhook integration. In Glip.com, click on 'Integrations' if the left column and then select the "Glip Webhooks" integration. After you select a conversation, a webhook URL will be displayed for you which will be used by this gem to post messages to. The URL looks like the following:
|
36
|
+
|
37
|
+
```http
|
38
|
+
https://hooks.glip.com/webhook/11112222-3333-4444-5555-666677778888
|
39
|
+
```
|
40
|
+
|
41
|
+
You can instantiate the `Glip::Poster` class with the full URL or the webhook ID (GUID) only.
|
42
|
+
|
31
43
|
## Usage
|
32
44
|
|
33
|
-
First you have to initialize your poster and then you can use `send_message` to send your message.
|
45
|
+
First you have to initialize your poster and then you can use `send_message` to send your message. You must have a webhook URL configured in Glip using the "Glip Webhooks" integration.
|
34
46
|
|
35
47
|
```ruby
|
48
|
+
require 'glip-poster'
|
49
|
+
|
36
50
|
poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
|
37
|
-
poster.send_message('
|
51
|
+
poster.send_message('Hi there!') # Faraday::Response
|
38
52
|
```
|
39
53
|
|
40
54
|
You can send text in Markdown:
|
@@ -47,13 +61,13 @@ poster.send_message('* Location: [The Funky Buddha Lounge](http://www.thefunkybu
|
|
47
61
|
You can use an options array if you don't want to use the default settings.
|
48
62
|
|
49
63
|
```ruby
|
50
|
-
options
|
51
|
-
|
52
|
-
|
53
|
-
|
64
|
+
options = {
|
65
|
+
icon: "http://example.com/icon.png",
|
66
|
+
activity: "Activity Alert",
|
67
|
+
title: "A New Incoming Message Has Been Received"
|
54
68
|
}
|
55
69
|
poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
|
56
|
-
poster.send_message('
|
70
|
+
poster.send_message('Hi there!', options)
|
57
71
|
```
|
58
72
|
|
59
73
|
You can preset your options:
|
@@ -61,8 +75,8 @@ You can preset your options:
|
|
61
75
|
```ruby
|
62
76
|
poster = Glip::Poster.new(YOUR_WEBHOOK_URL)
|
63
77
|
poster.options[:icon] = 'http://example.com/icon.png'
|
64
|
-
poster.options = {:
|
65
|
-
poster.send_message('
|
78
|
+
poster.options = {icon: 'http://example.com/icon.png'}
|
79
|
+
poster.send_message('Hi there!')
|
66
80
|
```
|
67
81
|
|
68
82
|
## Supported Ruby Versions
|
data/Rakefile
CHANGED
data/glip-poster.gemspec
CHANGED
@@ -6,7 +6,7 @@ version = $1
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = 'glip-poster'
|
8
8
|
s.version = version
|
9
|
-
s.date = '2016-01-
|
9
|
+
s.date = '2016-01-31'
|
10
10
|
s.summary = 'Glip Poster - Ruby SDK for post messages via Glip webhooks'
|
11
11
|
s.description = 'A Ruby SDK for post messages via Glip webhooks'
|
12
12
|
s.authors = ['John Wang']
|
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.0.3'
|
7
7
|
GLIP_WEBHOOK_BASE_URL = 'https://hooks.glip.com/webhook/'
|
8
8
|
|
9
9
|
attr_reader :webhook_url
|
@@ -11,7 +11,7 @@ module Glip
|
|
11
11
|
attr_accessor :http
|
12
12
|
|
13
13
|
def initialize(webhook_url_or_id)
|
14
|
-
|
14
|
+
set_webhook_url(webhook_url_or_id)
|
15
15
|
|
16
16
|
@options = {}
|
17
17
|
|
@@ -22,7 +22,7 @@ module Glip
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
25
|
+
def set_webhook_url(webhook_url_or_id)
|
26
26
|
if webhook_url_or_id.to_s !~ %r{/}
|
27
27
|
@webhook_url = GLIP_WEBHOOK_BASE_URL + webhook_url_or_id
|
28
28
|
elsif webhook_url_or_id =~ %r{^https?://}
|
@@ -33,14 +33,10 @@ module Glip
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def send_message(message, opts={})
|
36
|
-
|
37
|
-
opts[:body] = message
|
38
|
-
|
39
|
-
res = @http.post do |req|
|
36
|
+
return @http.post do |req|
|
40
37
|
req.url @webhook_url
|
41
|
-
req.body = opts
|
38
|
+
req.body = @options.merge(opts).merge({body: message})
|
42
39
|
end
|
43
|
-
return res
|
44
40
|
end
|
45
41
|
end
|
46
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -62,7 +62,6 @@ files:
|
|
62
62
|
- LICENSE.txt
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
|
-
- glip-poster-0.0.1.gem
|
66
65
|
- glip-poster.gemspec
|
67
66
|
- lib/glip-poster.rb
|
68
67
|
- lib/glip-poster/poster.rb
|
data/glip-poster-0.0.1.gem
DELETED
Binary file
|