mattermost-api4-ruby 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +39 -0
  8. data/Rakefile +6 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/lib/mattermost.rb +8 -0
  12. data/lib/mattermost/client.rb +44 -0
  13. data/lib/mattermost/endpoint.rb +51 -0
  14. data/lib/mattermost/endpoint/brand.rb +27 -0
  15. data/lib/mattermost/endpoint/channels.rb +118 -0
  16. data/lib/mattermost/endpoint/cluster.rb +12 -0
  17. data/lib/mattermost/endpoint/commands.rb +39 -0
  18. data/lib/mattermost/endpoint/compliance.rb +33 -0
  19. data/lib/mattermost/endpoint/data_retention.rb +12 -0
  20. data/lib/mattermost/endpoint/elasticsearch.rb +16 -0
  21. data/lib/mattermost/endpoint/emoji.rb +38 -0
  22. data/lib/mattermost/endpoint/files.rb +60 -0
  23. data/lib/mattermost/endpoint/jobs.rb +28 -0
  24. data/lib/mattermost/endpoint/ldap.rb +17 -0
  25. data/lib/mattermost/endpoint/oauth.rb +40 -0
  26. data/lib/mattermost/endpoint/open_graph.rb +9 -0
  27. data/lib/mattermost/endpoint/plugins.rb +33 -0
  28. data/lib/mattermost/endpoint/posts.rb +62 -0
  29. data/lib/mattermost/endpoint/preferences.rb +28 -0
  30. data/lib/mattermost/endpoint/reactions.rb +9 -0
  31. data/lib/mattermost/endpoint/saml.rb +43 -0
  32. data/lib/mattermost/endpoint/status.rb +20 -0
  33. data/lib/mattermost/endpoint/system.rb +80 -0
  34. data/lib/mattermost/endpoint/teams.rb +113 -0
  35. data/lib/mattermost/endpoint/users.rb +9 -0
  36. data/lib/mattermost/endpoint/webhooks.rb +60 -0
  37. data/lib/mattermost/request.rb +7 -0
  38. data/mattermost-api4-ruby.gemspec +26 -0
  39. metadata +137 -0
@@ -0,0 +1,113 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Teams
6
+ def create_team(name, display_name, type)
7
+ post("/teams", :body => {
8
+ :name => name,
9
+ :display_name => display_name,
10
+ :type => type
11
+ }.to_json)
12
+ end
13
+
14
+ def get_teams(max = 60)
15
+ get("/teams?per_page=#{max}")
16
+ end
17
+
18
+ def get_team(team_id)
19
+ get("/teams/#{team_id}")
20
+ end
21
+
22
+ def update_team(team_id, team = {})
23
+ put("/teams/#{team_id}", :body => team.to_json)
24
+ end
25
+
26
+ def delete_team(team_id)
27
+ delete("/teams/#{team_id}")
28
+ end
29
+
30
+ def patch_team(team_id, patch = {})
31
+ put("/teams/#{team_id}/patch", :body => patch.to_json)
32
+ end
33
+
34
+ def get_team_by_name(team_name)
35
+ get("/teams/name/#{team_name}")
36
+ end
37
+
38
+ def search_teams(term)
39
+ post("/teams/search", :body => {:term => term}.to_json)
40
+ end
41
+
42
+ def team_exists?(team_name)
43
+ get("/teams/name/#{team_name}/exists")
44
+ end
45
+
46
+ def get_teams_for_user(user_id)
47
+ get("/users/#{user_id}/teams")
48
+ end
49
+
50
+ def get_team_members(team_id)
51
+ get("/teams/#{team_id}/members")
52
+ end
53
+
54
+ def add_user_to_team(team_id, user_id, roles)
55
+ post("/teams/#{team_id}/members", :body => {
56
+ :team_id => team_id,
57
+ :user_id => user_id,
58
+ :roles => roles
59
+ }.to_json)
60
+ end
61
+
62
+ def add_user_to_team_from_invite(hash, data, invite_id)
63
+ post("/teams/members/invoite?hash=#{hash}&data=#{data}&invite_id=#{invite_id}")
64
+ end
65
+
66
+ def add_users_to_team(team_id, users)
67
+ post("/teams/#{team_id}/members/batch", :body => users.to_json)
68
+ end
69
+
70
+ def get_team_members_for_user(user_id)
71
+ get("/users/#{user_id}/teams/members")
72
+ end
73
+
74
+ def get_team_member(team_id, user_id)
75
+ get("/teams/#{team_id}/members/#{user_id}")
76
+ end
77
+
78
+ def remove_user_from_team(team_id, user_id)
79
+ delete("/teams/#{team_id}/members/#{user_id}")
80
+ end
81
+
82
+ def get_team_members_by_ids(team_id, user_ids = [])
83
+ get("/teams/#{team_id}/members/ids", :body => JSON.generate(user_ids))
84
+ end
85
+
86
+ def get_team_stats(team_id)
87
+ get("/teams/#{team_id}/stats")
88
+ end
89
+
90
+ def update_team_member_role(team_id, user_id, roles)
91
+ put("/teams/#{team_id}/members/#{user_id}/roles", :body => { :roles => roles}.to_json)
92
+ end
93
+
94
+ def get_team_unreads(user_id)
95
+ get("/users/#{user_id}/teams/unread")
96
+ end
97
+
98
+ def get_unreads_for_team(user_id, team_id)
99
+ get("/users/#{user_id}/teams/#{team_id}/unread")
100
+ end
101
+
102
+ def invite_users_by_email(team_id, emails = [])
103
+ post("/teams/#{team_id}/invite/email", :body => JSON.generate(emails))
104
+ end
105
+
106
+ # TODO: POST /teams/#{team_id}/import
107
+
108
+ def get_invite_info(invite_id)
109
+ get("/teams/invite/#{invite_id}")
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,9 @@
1
+ module Mattermost
2
+ module Endpoint
3
+ module Users
4
+ def getMe
5
+ get("/users/me")
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,60 @@
1
+ require 'json'
2
+
3
+ module Mattermost
4
+ module Endpoint
5
+ module Webhooks
6
+
7
+ def create_incoming_webhook(incoming_webhook)
8
+ post("/hooks/incoming", :body => incoming_webhook.to_json)
9
+ end
10
+
11
+ def list_incoming_webhooks(team_id, max = 60)
12
+ get("/hooks/incoming?per_page=#{max}&team_id=#{team_id}")
13
+ end
14
+
15
+ def list_incoming_webhooks_for_system(max = 60)
16
+ get("/hooks/incoming?per_page=#{max}")
17
+ end
18
+
19
+ def get_incoming_webhook(hook_id)
20
+ get("/hooks/incoming/#{hook_id}")
21
+ end
22
+
23
+ def update_incoming_webhook(hook_id, incoming_webhook)
24
+ put("/hooks/incoming/#{hook_id}", :body => incoming_webhook.to_json)
25
+ end
26
+
27
+ def create_outgoing_webhook(outgoing_webhook)
28
+ post("/hooks/outgoing", :body => outgoing_webhook.to_json)
29
+ end
30
+
31
+ def list_outgoing_webhooks(team_id, max = 60)
32
+ get("/hooks/outgoing?per_page=#{max}&team_id=#{team_id}")
33
+ end
34
+
35
+ def list_outgoing_webhooks(team_id, channel_id, max = 60)
36
+ get("/hooks/outgoing?per_page=#{max}&team_id=#{team_id}&channel_id=#{channel_id}")
37
+ end
38
+
39
+ def list_outgoing_webhooks_for_system(max = 60)
40
+ get("/hooks/outgoing?per_page=#{max}")
41
+ end
42
+
43
+ def get_outgoing_webhook(hook_id)
44
+ get("/hooks/outgoing/#{hook_id}")
45
+ end
46
+
47
+ def delete_outgoing_webhook(hook_id)
48
+ delete("/hooks/outgoing/#{hook_id}")
49
+ end
50
+
51
+ def update_outgoing_webhook(hook_id, outgoing_webhook)
52
+ put("/hooks/outgoing/#{hook_id}", outgoing_webhook.to_json)
53
+ end
54
+
55
+ def regenerate_outgoing_webhook_token(hook_id)
56
+ post("/hooks/outgoing/#{hook_id}/regen_token")
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,7 @@
1
+ require 'httparty'
2
+
3
+ module Mattermost
4
+ module Request
5
+ include HTTParty
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "mattermost-api4-ruby"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["Takayuki Maruyama"]
7
+ spec.email = ["bis5.wsys@gmail.com"]
8
+
9
+ spec.summary = %q{Mattermost API v4 client for ruby}
10
+ spec.homepage = "https://github.com/maruTA-bis5/mattermost-api4-ruby"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
14
+ f.match(%r{^(test|spec|features)/})
15
+ end
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.13"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+
24
+ spec.add_dependency "httparty", "~> 0.15"
25
+
26
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mattermost-api4-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Takayuki Maruyama
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-01-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.13'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.13'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.15'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.15'
69
+ description:
70
+ email:
71
+ - bis5.wsys@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/console
84
+ - bin/setup
85
+ - lib/mattermost.rb
86
+ - lib/mattermost/client.rb
87
+ - lib/mattermost/endpoint.rb
88
+ - lib/mattermost/endpoint/brand.rb
89
+ - lib/mattermost/endpoint/channels.rb
90
+ - lib/mattermost/endpoint/cluster.rb
91
+ - lib/mattermost/endpoint/commands.rb
92
+ - lib/mattermost/endpoint/compliance.rb
93
+ - lib/mattermost/endpoint/data_retention.rb
94
+ - lib/mattermost/endpoint/elasticsearch.rb
95
+ - lib/mattermost/endpoint/emoji.rb
96
+ - lib/mattermost/endpoint/files.rb
97
+ - lib/mattermost/endpoint/jobs.rb
98
+ - lib/mattermost/endpoint/ldap.rb
99
+ - lib/mattermost/endpoint/oauth.rb
100
+ - lib/mattermost/endpoint/open_graph.rb
101
+ - lib/mattermost/endpoint/plugins.rb
102
+ - lib/mattermost/endpoint/posts.rb
103
+ - lib/mattermost/endpoint/preferences.rb
104
+ - lib/mattermost/endpoint/reactions.rb
105
+ - lib/mattermost/endpoint/saml.rb
106
+ - lib/mattermost/endpoint/status.rb
107
+ - lib/mattermost/endpoint/system.rb
108
+ - lib/mattermost/endpoint/teams.rb
109
+ - lib/mattermost/endpoint/users.rb
110
+ - lib/mattermost/endpoint/webhooks.rb
111
+ - lib/mattermost/request.rb
112
+ - mattermost-api4-ruby.gemspec
113
+ homepage: https://github.com/maruTA-bis5/mattermost-api4-ruby
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.5.1
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Mattermost API v4 client for ruby
137
+ test_files: []