ribose-cli 0.1.0 → 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 +5 -5
- data/.rubocop.yml +539 -970
- data/Gemfile +3 -0
- data/README.md +316 -7
- data/bin/ribose +22 -0
- data/lib/ribose/cli/auth.rb +9 -0
- data/lib/ribose/cli/command.rb +55 -0
- data/lib/ribose/cli/commands/base.rb +80 -0
- data/lib/ribose/cli/commands/conversation.rb +114 -0
- data/lib/ribose/cli/commands/file.rb +96 -0
- data/lib/ribose/cli/commands/invitation.rb +81 -0
- data/lib/ribose/cli/commands/join_space.rb +78 -0
- data/lib/ribose/cli/commands/member.rb +81 -0
- data/lib/ribose/cli/commands/message.rb +98 -0
- data/lib/ribose/cli/commands/note.rb +98 -0
- data/lib/ribose/cli/commands/space.rb +86 -0
- data/lib/ribose/cli/rcfile.rb +57 -0
- data/lib/ribose/cli/util.rb +22 -0
- data/lib/ribose/cli/version.rb +2 -2
- data/lib/ribose/cli.rb +21 -2
- data/ribose-cli.gemspec +7 -1
- data/spec/acceptance/config_spec.rb +17 -0
- data/spec/acceptance/conversation_spec.rb +90 -0
- data/spec/acceptance/file_spec.rb +80 -0
- data/spec/acceptance/invitation_spec.rb +109 -0
- data/spec/acceptance/join_space_spec.rb +73 -0
- data/spec/acceptance/member_spec.rb +87 -0
- data/spec/acceptance/message_spec.rb +67 -0
- data/spec/acceptance/note_spec.rb +61 -0
- data/spec/acceptance/space_spec.rb +112 -0
- data/spec/fixtures/.riboserc +3 -0
- data/spec/ribose/cli/rcfile_spec.rb +21 -0
- data/spec/spec_helper.rb +12 -1
- data/spec/support/console_helper.rb +29 -0
- metadata +87 -5
- data/spec/ribose/cli_spec.rb +0 -4
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,337 @@
|
|
1
|
-
# Ribose
|
1
|
+
# Ribose CLI
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/riboseinc/ribose-cli)
|
5
|
+
[](https://codeclimate.com/github/riboseinc/ribose-cli)
|
4
7
|
|
5
|
-
|
8
|
+
The command line interface to the Ribose API.
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
9
12
|
Add this line to your application's Gemfile:
|
10
13
|
|
11
14
|
```ruby
|
12
|
-
gem
|
15
|
+
gem "ribose-cli"
|
13
16
|
```
|
14
17
|
|
15
18
|
And then execute:
|
16
19
|
|
17
|
-
|
20
|
+
```sh
|
21
|
+
$ bundle install
|
22
|
+
```
|
18
23
|
|
19
24
|
Or install it yourself as:
|
20
25
|
|
21
|
-
|
26
|
+
```sh
|
27
|
+
$ gem install ribose-cli
|
28
|
+
```
|
22
29
|
|
23
30
|
## Usage
|
24
31
|
|
25
|
-
|
32
|
+
### Configure
|
33
|
+
|
34
|
+
To start with, we kept it pretty simple, install this gem & then configure your
|
35
|
+
API Token and email using the following interface, This will store your Ribose
|
36
|
+
configuration as `.riboserc` in the home directory.
|
37
|
+
|
38
|
+
```sh
|
39
|
+
ribose config --token="YOUR_API_TOKEN" --email="youremail@example.com"
|
40
|
+
```
|
41
|
+
|
42
|
+
### Spaces
|
43
|
+
|
44
|
+
The `space` command retrieve space related resources, please use the `help`
|
45
|
+
command to see what's sub-commands are available.
|
46
|
+
|
47
|
+
```sh
|
48
|
+
ribose help space
|
49
|
+
```
|
50
|
+
|
51
|
+
#### Listing spaces
|
52
|
+
|
53
|
+
To list out the spaces, please use the `list` command, by default it will print
|
54
|
+
out the basic information in tabular format.
|
55
|
+
|
56
|
+
```sh
|
57
|
+
ribose space list
|
58
|
+
```
|
59
|
+
|
60
|
+
This interface also has support `json` format, if we want the output to be in
|
61
|
+
`json` then we can use the following
|
62
|
+
|
63
|
+
```sh
|
64
|
+
ribose space list --format json
|
65
|
+
```
|
66
|
+
|
67
|
+
#### Show a space details
|
68
|
+
|
69
|
+
```sh
|
70
|
+
ribose space show --space-id 123456789
|
71
|
+
```
|
72
|
+
|
73
|
+
#### Create a new space
|
74
|
+
|
75
|
+
To create a new user space we can use the following interface
|
76
|
+
|
77
|
+
```sh
|
78
|
+
ribose space add --name "Space name" --access "open" --category-id 12 \
|
79
|
+
--description "Space description"
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Update a space
|
83
|
+
|
84
|
+
```sh
|
85
|
+
ribose space update --space-id 123456 --name "New Space Name"
|
86
|
+
```
|
87
|
+
|
88
|
+
#### Remove an existing space
|
89
|
+
|
90
|
+
```sh
|
91
|
+
ribose space remove --space-id 123456789 --confirmation 123456789
|
92
|
+
```
|
93
|
+
|
94
|
+
### Members
|
95
|
+
|
96
|
+
#### List space members
|
97
|
+
|
98
|
+
```sh
|
99
|
+
ribose member list --space-id space_uuid
|
100
|
+
```
|
101
|
+
|
102
|
+
#### Add a new space member
|
103
|
+
|
104
|
+
```sh
|
105
|
+
ribose member add \
|
106
|
+
--space-id space_uuid \
|
107
|
+
--user-id=user-one-uuid:role_one_id user-two-uuid:role_two_id \
|
108
|
+
--email=email-one@example.com:role_one_id email@example.com:role_two_id \
|
109
|
+
--message="Your invitation messages to the invitees"
|
110
|
+
```
|
111
|
+
|
112
|
+
#### Update an existing member
|
113
|
+
|
114
|
+
```sh
|
115
|
+
ribose member update --role-id 135 --member-id 246 --space-id 1234
|
116
|
+
```
|
117
|
+
|
118
|
+
#### Remove a space member
|
119
|
+
|
120
|
+
```sh
|
121
|
+
ribose member remove --member-id 246 --space-id 1234
|
122
|
+
```
|
123
|
+
|
124
|
+
### Space Invitation
|
125
|
+
|
126
|
+
#### List Space Invitation
|
127
|
+
|
128
|
+
```sh
|
129
|
+
ribose invitation list [--query=key:value]
|
130
|
+
```
|
131
|
+
|
132
|
+
#### Send out space invitation
|
133
|
+
|
134
|
+
```sh
|
135
|
+
ribose invitation add \
|
136
|
+
--space-id space_uuid \
|
137
|
+
--user-id=user-one-uuid:role_one_id user-two-uuid:role_two_id \
|
138
|
+
--email=email-one@example.com:role_one_id email@example.com:role_two_id \
|
139
|
+
--message="Your invitation messages to the invitees"
|
140
|
+
```
|
141
|
+
|
142
|
+
#### Update a space invitation
|
143
|
+
|
144
|
+
```sh
|
145
|
+
ribose invitation update --invitation-id 2468 --role-id 246
|
146
|
+
```
|
147
|
+
|
148
|
+
#### Accept a space invitation
|
149
|
+
|
150
|
+
```sh
|
151
|
+
ribose invitation accept --invitation-id 2468
|
152
|
+
```
|
153
|
+
|
154
|
+
#### Reject a space invitation
|
155
|
+
|
156
|
+
```sh
|
157
|
+
ribose invitation reject --invitation-id 2468
|
158
|
+
```
|
159
|
+
|
160
|
+
#### Remove a space invitation
|
161
|
+
|
162
|
+
```sh
|
163
|
+
ribose invitation remove --invitation-id 2468
|
164
|
+
```
|
165
|
+
|
166
|
+
### Join Space Request
|
167
|
+
|
168
|
+
#### List join space requests
|
169
|
+
|
170
|
+
```sh
|
171
|
+
ribose join-space list [--query=space-id:2468]
|
172
|
+
```
|
173
|
+
|
174
|
+
#### Fetch a join space request
|
175
|
+
|
176
|
+
```sh
|
177
|
+
ribose join-space show --request-id 2468
|
178
|
+
```
|
179
|
+
|
180
|
+
#### Add join space request
|
181
|
+
|
182
|
+
```sh
|
183
|
+
ribose join-space add --space-id 1234 [--message "My request message"]
|
184
|
+
```
|
185
|
+
|
186
|
+
#### Accept a join space request
|
187
|
+
|
188
|
+
```sh
|
189
|
+
ribose join-space accept --request-id 2468
|
190
|
+
```
|
191
|
+
|
192
|
+
#### Reject a join space requests
|
193
|
+
|
194
|
+
```sh
|
195
|
+
ribose join-space reject --request-id 2468
|
196
|
+
```
|
197
|
+
|
198
|
+
### Note
|
199
|
+
|
200
|
+
#### Listing space notes
|
201
|
+
|
202
|
+
```sh
|
203
|
+
ribose note list --space-id space_uuid --format json
|
204
|
+
```
|
205
|
+
|
206
|
+
### Show a space note
|
207
|
+
|
208
|
+
```sh
|
209
|
+
ribose note show --note-id 123456 --space-id 78901
|
210
|
+
```
|
211
|
+
|
212
|
+
#### Create a new note
|
213
|
+
|
214
|
+
```sh
|
215
|
+
ribose note add --space-id space_uuid --title "Name of the note"
|
216
|
+
```
|
217
|
+
|
218
|
+
#### Update an existing note
|
219
|
+
|
220
|
+
```sh
|
221
|
+
ribose note update --space-id 1234 --note-id 5678 --title "Name of the note"
|
222
|
+
```
|
223
|
+
|
224
|
+
#### Remove a note
|
225
|
+
|
226
|
+
```sh
|
227
|
+
ribose note remove --space-id space_uuid --note-id note_uuid
|
228
|
+
```
|
229
|
+
|
230
|
+
### Files
|
231
|
+
|
232
|
+
#### Listing files
|
233
|
+
|
234
|
+
Ribose space may contain multiple files, and if we want to retrieve the list of
|
235
|
+
the files of any space then we can use to following interface.
|
236
|
+
|
237
|
+
```sh
|
238
|
+
ribose file list --space-id 123456
|
239
|
+
```
|
240
|
+
|
241
|
+
The above interface will retrieve the basic details in tabular format, but it
|
242
|
+
also support additional `format` option, acceptable option: `json`.
|
243
|
+
|
244
|
+
#### Fetch a file details
|
245
|
+
|
246
|
+
```sh
|
247
|
+
ribose file show --file-id 5678 --space-id 1234 [--format json]
|
248
|
+
```
|
249
|
+
|
250
|
+
#### Add a new file
|
251
|
+
|
252
|
+
Ribose CLI allows us to upload a file in a user space, and to upload a new file
|
253
|
+
we can use the following interface.
|
254
|
+
|
255
|
+
```sh
|
256
|
+
ribose file add full_path_the_file.ext --space-id space_uuid **other_options
|
257
|
+
```
|
258
|
+
|
259
|
+
#### Update a space file
|
260
|
+
|
261
|
+
```sh
|
262
|
+
ribose file update [--file-name "new filename"] \
|
263
|
+
[--description "New description"] \
|
264
|
+
[--tags "tag 1, tag 2, tag 3"] --file-id 5678 --space-id 1234
|
265
|
+
```
|
266
|
+
|
267
|
+
#### Remove a space file
|
268
|
+
|
269
|
+
```sh
|
270
|
+
ribose file remove --file-id 5678 --space-id 1234
|
271
|
+
```
|
272
|
+
|
273
|
+
### Conversations
|
274
|
+
|
275
|
+
#### Listing conversations
|
276
|
+
|
277
|
+
```sh
|
278
|
+
ribose conversation list --space-id 123456789
|
279
|
+
```
|
280
|
+
|
281
|
+
#### Show a conversation details
|
282
|
+
|
283
|
+
```sh
|
284
|
+
ribose conversation show --space-id 123456789 --conversation-id 67890
|
285
|
+
```
|
286
|
+
|
287
|
+
#### Create A New Conversation
|
288
|
+
|
289
|
+
```sh
|
290
|
+
ribose conversation add --space-id 123456789 --title "Conversation Title" \
|
291
|
+
--tags "sample, conversation"
|
292
|
+
```
|
293
|
+
|
294
|
+
#### Update a conversation
|
295
|
+
|
296
|
+
```sh
|
297
|
+
conversation update --conversation-id 5678 --space-id 123456789 --title \
|
298
|
+
"Conversation Title" --tags "sample, conversation"
|
299
|
+
```
|
300
|
+
|
301
|
+
#### Remove A Conversation
|
302
|
+
|
303
|
+
```sh
|
304
|
+
ribose conversation remove --space-id 1234 --conversation-id 5678
|
305
|
+
```
|
306
|
+
|
307
|
+
### Message
|
308
|
+
|
309
|
+
#### Listing conversation messages
|
310
|
+
|
311
|
+
```sh
|
312
|
+
ribose message list --space-id 12345 --conversation-id 56789
|
313
|
+
```
|
314
|
+
|
315
|
+
#### Add a new message to conversation
|
316
|
+
|
317
|
+
```sh
|
318
|
+
ribose message add --space-id 12345 --conversation-id 56789 \
|
319
|
+
--message-body "Welcome to Ribose Space"
|
320
|
+
```
|
321
|
+
|
322
|
+
#### Update an existing message
|
323
|
+
|
324
|
+
|
325
|
+
```sh
|
326
|
+
ribose message update --message-id 123456 --space-id 12345 \
|
327
|
+
--conversation-id 56789 --message-body "Welcome to Ribose Space"
|
328
|
+
```
|
329
|
+
|
330
|
+
#### Remove an existing message
|
331
|
+
|
332
|
+
```sh
|
333
|
+
ribose message remove --message-id 1234 --space-id 12345 --conversation-id 456
|
334
|
+
```
|
26
335
|
|
27
336
|
## Development
|
28
337
|
|
data/bin/ribose
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# resolve bin path, ignoring symlinks
|
5
|
+
require "pathname"
|
6
|
+
bin_file = Pathname.new(__FILE__).realpath
|
7
|
+
|
8
|
+
# add self to libpath
|
9
|
+
$:.unshift File.expand_path("../../lib", bin_file)
|
10
|
+
|
11
|
+
# Fixes https://github.com/rubygems/rubygems/issues/1420
|
12
|
+
require "rubygems/specification"
|
13
|
+
|
14
|
+
class Gem::Specification
|
15
|
+
def this; self; end
|
16
|
+
end
|
17
|
+
|
18
|
+
# start up the CLI
|
19
|
+
require "bundler/setup"
|
20
|
+
require "ribose/cli"
|
21
|
+
|
22
|
+
Ribose::CLI.start(ARGV)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "ribose/cli/rcfile"
|
2
|
+
require "ribose/cli/commands/base"
|
3
|
+
require "ribose/cli/commands/space"
|
4
|
+
require "ribose/cli/commands/file"
|
5
|
+
require "ribose/cli/commands/conversation"
|
6
|
+
require "ribose/cli/commands/message"
|
7
|
+
require "ribose/cli/commands/note"
|
8
|
+
require "ribose/cli/commands/member"
|
9
|
+
require "ribose/cli/commands/invitation"
|
10
|
+
require "ribose/cli/commands/join_space"
|
11
|
+
|
12
|
+
module Ribose
|
13
|
+
module CLI
|
14
|
+
class Command < Thor
|
15
|
+
desc "space", "List, Add or Remove User Space"
|
16
|
+
subcommand :space, Ribose::CLI::Commands::Space
|
17
|
+
|
18
|
+
desc "member", "List, Add or Remove Space Member"
|
19
|
+
subcommand :member, Ribose::CLI::Commands::Member
|
20
|
+
|
21
|
+
desc "note", "List, Add or Remove Space Note"
|
22
|
+
subcommand :note, Ribose::CLI::Commands::Note
|
23
|
+
|
24
|
+
desc "file", "List, Add or Remove Files"
|
25
|
+
subcommand :file, Ribose::CLI::Commands::File
|
26
|
+
|
27
|
+
desc "conversation", "List, Add or Remove Conversation"
|
28
|
+
subcommand :conversation, Ribose::CLI::Commands::Conversation
|
29
|
+
|
30
|
+
desc "message", "List, Add or Remove Message"
|
31
|
+
subcommand :message, Ribose::CLI::Commands::Message
|
32
|
+
|
33
|
+
desc "invitation", "Manage Space Invitations"
|
34
|
+
subcommand :invitation, Ribose::CLI::Commands::Invitation
|
35
|
+
|
36
|
+
desc "join-space", "Manage Join Space Request"
|
37
|
+
subcommand :join_space, Ribose::CLI::Commands::JoinSpace
|
38
|
+
|
39
|
+
desc "config", "Configure API Key and User Email"
|
40
|
+
option :token, required: true, desc: "Your API Token for Ribose"
|
41
|
+
option :email, required: true, desc: "Your email address for Ribose"
|
42
|
+
|
43
|
+
def config
|
44
|
+
Ribose::CLI::RCFile.set(
|
45
|
+
email: options[:email], token: options[:token],
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
desc "version", "The current active version"
|
50
|
+
def version
|
51
|
+
say(Ribose::CLI::VERSION)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Ribose
|
2
|
+
module CLI
|
3
|
+
module Commands
|
4
|
+
class Base < Thor
|
5
|
+
private
|
6
|
+
|
7
|
+
# Table Headers
|
8
|
+
#
|
9
|
+
# Listing resources in table view will invoke this method to
|
10
|
+
# retrieve the list of headers, please override this in the
|
11
|
+
# sub-class and fill it in with actual fields name.
|
12
|
+
#
|
13
|
+
def table_headers
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
# Table Rows
|
18
|
+
#
|
19
|
+
# List resources in table view will invoke this method to build
|
20
|
+
# each of the individual resource row, please override this with
|
21
|
+
# an array that includes the value for headers.
|
22
|
+
#
|
23
|
+
def table_rows
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
# Table field names
|
28
|
+
#
|
29
|
+
# Displaying a single resource in table view will invoke this
|
30
|
+
# method to figure out field name and values for each of the
|
31
|
+
# row in table, please override this with proper attributes
|
32
|
+
#
|
33
|
+
def table_field_names
|
34
|
+
raise NotImplementedError
|
35
|
+
end
|
36
|
+
|
37
|
+
def build_output(resources, options)
|
38
|
+
json_view(resources, options) || table_view(resources)
|
39
|
+
end
|
40
|
+
|
41
|
+
def build_resource_output(resource, options)
|
42
|
+
resource_as_json(resource, options) || resource_as_table(resource)
|
43
|
+
end
|
44
|
+
|
45
|
+
def json_view(resources, options)
|
46
|
+
if options[:format] == "json"
|
47
|
+
resources.map(&:to_h).to_json
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def resource_as_json(resource, options)
|
52
|
+
if options[:format] == "json"
|
53
|
+
resource.to_h.to_json
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def table_view(resources)
|
58
|
+
Ribose::CLI::Util.list(
|
59
|
+
headings: table_headers, rows: table_rows(resources),
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def resource_as_table(resource)
|
64
|
+
Ribose::CLI::Util.list(
|
65
|
+
headings: ["Field", "Value"],
|
66
|
+
rows: table_field_names.map { |key| [key, resource[key.to_s]] },
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def symbolize_keys(options_hash)
|
71
|
+
Hash.new.tap do |hash|
|
72
|
+
options_hash.each_key do |key|
|
73
|
+
hash[(key.to_sym rescue key) || key] = options_hash.fetch(key)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
module Ribose
|
2
|
+
module CLI
|
3
|
+
module Commands
|
4
|
+
class Conversation < Commands::Base
|
5
|
+
desc "list", "Listing A Space Conversations"
|
6
|
+
option :format, aliases: "-f", desc: "Output format, eg: json"
|
7
|
+
option :space_id, required: true, aliases: "-s", desc: "The Space UUID"
|
8
|
+
|
9
|
+
def list
|
10
|
+
say(build_output(list_conversations, options))
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "show", "Show the details for a conversation"
|
14
|
+
option :space_id, required: true, aliases: "-s", desc: "The Space UUID"
|
15
|
+
option :format, aliases: "-f", desc: "Output format, eg: json"
|
16
|
+
|
17
|
+
option(
|
18
|
+
:conversation_id,
|
19
|
+
required: true,
|
20
|
+
aliases: "-c",
|
21
|
+
desc: "The Conversation UUID",
|
22
|
+
)
|
23
|
+
|
24
|
+
def show
|
25
|
+
say(build_resource_output(conversation(options), options))
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "add", "Add a new conversation to Space"
|
29
|
+
option :space_id, required: true, aliases: "-s", desc: "The Space UUID"
|
30
|
+
option :title, required: true, desc: "The title for the conversation"
|
31
|
+
option :tags, aliases: "-t", desc: "The tags for the conversation"
|
32
|
+
|
33
|
+
def add
|
34
|
+
conversation = create_conversation(options)
|
35
|
+
say("New Conversation created! Id: " + conversation.id)
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "update", "Updae an existing conversation"
|
39
|
+
option :title, desc: "The title for the conversation"
|
40
|
+
option :tags, aliases: "-t", desc: "The tags for the conversation"
|
41
|
+
option :space_id, required: true, aliases: "-s", desc: "The Space UUID"
|
42
|
+
option(
|
43
|
+
:conversation_id,
|
44
|
+
required: true,
|
45
|
+
aliases: "-c",
|
46
|
+
desc: "The conversation UUID",
|
47
|
+
)
|
48
|
+
|
49
|
+
def update
|
50
|
+
update_conversation(symbolize_keys(options))
|
51
|
+
say("Your conversation has been updated!")
|
52
|
+
rescue Ribose::UnprocessableEntity
|
53
|
+
say("Something went wrong!, please check required attributes")
|
54
|
+
end
|
55
|
+
|
56
|
+
desc "remove", "Remove A Conversation from Space"
|
57
|
+
option :space_id, required: true, aliases: "-s", desc: "The Space UUID"
|
58
|
+
option :conversation_id, required: true, aliases: "-c"
|
59
|
+
|
60
|
+
def remove
|
61
|
+
remove_conversation(options)
|
62
|
+
say("The Conversation has been removed!")
|
63
|
+
rescue
|
64
|
+
say("Please provide a valid Conversation UUID")
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def conversation(attributes)
|
70
|
+
@conversation ||= Ribose::Conversation.fetch(
|
71
|
+
attributes[:space_id], attributes[:conversation_id]
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def list_conversations
|
76
|
+
@conversations ||= Ribose::Conversation.all(options[:space_id])
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_conversation(options)
|
80
|
+
Ribose::Conversation.create(
|
81
|
+
options[:space_id], name: options[:title], tag_list: options[:tags]
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
def update_conversation(attributes)
|
86
|
+
Ribose::Conversation.update(
|
87
|
+
attributes.delete(:space_id),
|
88
|
+
attributes.delete(:conversation_id),
|
89
|
+
attributes,
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
def remove_conversation(options)
|
94
|
+
Ribose::Conversation.destroy(
|
95
|
+
space_id: options[:space_id],
|
96
|
+
conversation_id: options[:conversation_id],
|
97
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
def table_headers
|
101
|
+
["ID", "Title"]
|
102
|
+
end
|
103
|
+
|
104
|
+
def table_field_names
|
105
|
+
%w(id space_id name number_of_messages allow_comment)
|
106
|
+
end
|
107
|
+
|
108
|
+
def table_rows(conversations)
|
109
|
+
conversations.map { |conv| [conv.id, conv.name] }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|