mattermost-ruby 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -1
- data/lib/mattermost/channel.rb +3 -0
- data/lib/mattermost/mattermost_object.rb +1 -2
- data/lib/mattermost/models/channel.rb +14 -4
- data/lib/mattermost/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e693b82aee767301a05202ab5dbe02ef370e2493
|
4
|
+
data.tar.gz: 51b17471e2cde352de3a467a54be8530ca2db3a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 068aec5035d347c89b39ad67c770489642c1ced0a163bd69300bcee6822f2fe75d879c693558ea0db9607a36ea44cafeae21c2d040318dba9b278e6110fca5f2
|
7
|
+
data.tar.gz: 08b1872b4dc2b9a147a013936aea85210930ab3700dd37b7953885c2f0e128ba799dc754fc876ee4024efb36d2266a13466169249afa274cccf75cdf855ff220
|
data/README.md
CHANGED
@@ -18,11 +18,19 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install mattermost-ruby
|
20
20
|
|
21
|
+
## Supported versions of Mattermost
|
22
|
+
|
23
|
+
Tested against v3. In the future I'll publish separate versions for those who don't upgrade. But I'm going to assume most of us do since this is an infant.
|
24
|
+
|
25
|
+
## Setup
|
26
|
+
|
27
|
+
Because Mattermost doesn't provide an API user, Mattermost-Ruby uses a system admin account for its API calls.
|
28
|
+
|
21
29
|
## Configuration
|
22
30
|
|
23
31
|
```
|
24
32
|
options = {:httparty => {:debug_output => $stdout} } # pass defaults to httparty
|
25
|
-
Mattermost.connect("apiuser", "apipassword", "https://mattermost.example.com/api/
|
33
|
+
Mattermost.connect("apiuser", "apipassword", "https://mattermost.example.com/api/v3", "default_team_name", options)
|
26
34
|
|
27
35
|
users = Mattermost::User.all
|
28
36
|
users.last.class #User
|
data/lib/mattermost/channel.rb
CHANGED
@@ -7,8 +7,7 @@ module Mattermost
|
|
7
7
|
# Return an object that matches a given attribute.
|
8
8
|
# Return nil if no matches
|
9
9
|
def self.find_by(opts = {})
|
10
|
-
|
11
|
-
return obj
|
10
|
+
all.select { |obj| obj.send(opts.keys.first) == opts.values.first }.first
|
12
11
|
end
|
13
12
|
|
14
13
|
# Return the user that has an id of @param id
|
@@ -4,10 +4,15 @@ class Channel < Base
|
|
4
4
|
defined?(self.id) ? update : create_channel
|
5
5
|
end
|
6
6
|
|
7
|
+
def name
|
8
|
+
@name ||= self.display_name.gsub(" ", '-')
|
9
|
+
end
|
10
|
+
|
7
11
|
# Delete a channel
|
8
12
|
def delete
|
9
13
|
Mattermost.post("/channels/#{self.id}/delete")
|
10
14
|
end
|
15
|
+
alias_method :destroy, :delete
|
11
16
|
|
12
17
|
# Get channel info
|
13
18
|
def info
|
@@ -98,10 +103,15 @@ class Channel < Base
|
|
98
103
|
{:display_name => String, :team_id => String, :type => Integer, :purpose => String}
|
99
104
|
end
|
100
105
|
|
101
|
-
|
102
106
|
protected
|
103
107
|
def create_channel
|
104
|
-
|
105
|
-
|
106
|
-
|
108
|
+
Mattermost.post("/channels/create",
|
109
|
+
:body => {
|
110
|
+
:display_name => self.display_name,
|
111
|
+
:name => self.name,
|
112
|
+
:team_id => Mattermost::Team.id,
|
113
|
+
:purpose => self.purpose,
|
114
|
+
:type => self.type
|
115
|
+
}.to_json)
|
116
|
+
end
|
107
117
|
end
|
data/lib/mattermost/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mattermost-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Brody
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|