boardeffect 0.0.1 → 1.0.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 -1
- data/boardeffect.gemspec +4 -4
- data/lib/boardeffect.rb +212 -5
- data/lib/boardeffect/client.rb +1 -1
- data/lib/boardeffect/version.rb +1 -1
- data/spec/boardeffect_spec.rb +298 -30
- data/spec/spec_helper.rb +29 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9739c011100cd41a2140744a1f0dea202c1dd48d
|
4
|
+
data.tar.gz: 0265f328399caaae9de55bad37b1c9b66919da5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db55315e9dba0b1069a1697c46dd9fb14b35113e38853ba97dd086f04fd3752efdc8c4f395bac40c2fbd75a981cf2008aa46d9663a89861b199ce217af364486
|
7
|
+
data.tar.gz: 7ae7d33b4119bea9f6d875b92ac615c4eb5668b604e6e6e86540765273f96fc182535447dd0763a41d0e2936fdf588737759fde869003b179f17af27ebc82fbb
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# boardeffect
|
2
2
|
|
3
|
-
Ruby client for [Version
|
3
|
+
Ruby client for [Version 3 of the BoardEffect API].
|
4
4
|
|
5
5
|
|
6
6
|
## Install
|
@@ -16,4 +16,11 @@ $ gem install boardeffect
|
|
16
16
|
require 'boardeffect'
|
17
17
|
|
18
18
|
boardeffect = BoardEffect::Client.new(access_token: 'YOUR PERSONAL ACCESS TOKEN', host: 'https://yourportalname.boardeffect.com/')
|
19
|
+
|
20
|
+
announcement = boardeffect.create_announcement({title: "This is a test from the console", body: "This is a body description"}, { workroom_id: 2 })
|
21
|
+
p announcement.inspect
|
22
|
+
|
23
|
+
attributes = {title: "Testing api", description: "This is a description", location: "Test location", eventcolor_id: "1", datetime_start: Time.now.to_s, datetime_end: Time.now.to_s}
|
24
|
+
event = boardeffect.create_event(attributes, { workroom_id: 2 })
|
25
|
+
p event.inspect
|
19
26
|
```
|
data/boardeffect.gemspec
CHANGED
@@ -4,13 +4,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'boardeffect/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name
|
8
|
-
spec.version
|
7
|
+
spec.name = "boardeffect"
|
8
|
+
spec.version = BoardEffect::VERSION
|
9
9
|
spec.authors = ['Mark Hunt']
|
10
10
|
spec.email = ['development@boardeffect.com']
|
11
11
|
spec.homepage = 'https://github.com/magicmarkker/boardeffect'
|
12
|
-
spec.description = 'Ruby client for Version
|
13
|
-
spec.summary = 'Ruby client for Version
|
12
|
+
spec.description = 'Ruby client for Version 3 of the BoardEffect API'
|
13
|
+
spec.summary = 'Ruby client for Version 3 of the BoardEffect API'
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files`.split($/)
|
data/lib/boardeffect.rb
CHANGED
@@ -6,23 +6,230 @@ module BoardEffect
|
|
6
6
|
|
7
7
|
# Announcements
|
8
8
|
def get_announcements(params = nil)
|
9
|
-
get("
|
9
|
+
get("/#{workroom_check(params)}announcements.json", params)
|
10
10
|
end
|
11
11
|
|
12
12
|
def create_announcement(attributes, params = nil)
|
13
|
-
post("
|
13
|
+
post("/#{workroom_check(params)}announcements.json", attributes)
|
14
14
|
end
|
15
15
|
|
16
16
|
def update_announcement(announcement_id, attributes, params = nil)
|
17
|
-
put("
|
17
|
+
put("/#{workroom_check(params)}announcements/#{announcement_id}.json", attributes)
|
18
18
|
end
|
19
19
|
|
20
20
|
def get_announcement(announcement_id, params = nil)
|
21
|
-
get("
|
21
|
+
get("/#{workroom_check(params)}announcements/#{announcement_id}.json")
|
22
22
|
end
|
23
23
|
|
24
24
|
def delete_announcement(announcement_id, params = nil)
|
25
|
-
delete("
|
25
|
+
delete("/#{workroom_check(params)}announcements/#{announcement_id}.json")
|
26
|
+
end
|
27
|
+
|
28
|
+
# Events
|
29
|
+
def get_events(params = nil)
|
30
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
31
|
+
get("/events.json", params)
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_event(attributes, params = nil)
|
35
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
36
|
+
post("/workrooms/#{params[:workroom_id]}/events.json", attributes)
|
37
|
+
end
|
38
|
+
|
39
|
+
def update_event(id, attributes, params = nil)
|
40
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
41
|
+
raise Error, "Event ID is required" unless id.is_a? Numeric
|
42
|
+
put("/workrooms/#{params[:workroom_id]}/events/#{id}.json", attributes)
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_event(id, params = nil)
|
46
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
47
|
+
raise Error, "Event ID is required" unless id.is_a? Numeric
|
48
|
+
get("/workrooms/#{params[:workroom_id]}/events/#{id}.json")
|
49
|
+
end
|
50
|
+
|
51
|
+
def delete_event(id, params = nil)
|
52
|
+
raise Error, "Event ID is required" unless id.is_a? Numeric
|
53
|
+
delete("/workrooms/#{params[:workroom_id]}/events/#{id}.json")
|
54
|
+
end
|
55
|
+
|
56
|
+
# RSVPS
|
57
|
+
def get_rsvps(params = nil)
|
58
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
59
|
+
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
60
|
+
get("/workrooms/#{params[:workroom_id]}/events/#{params[:event_id]}/rsvps.json")
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_rsvp(attributes, params = nil)
|
64
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
65
|
+
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
66
|
+
post("/workrooms/#{params[:workroom_id]}/events/#{params[:event_id]}/rsvps.json", attributes)
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_rsvp(rsvp_id, params = nil)
|
70
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
71
|
+
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
72
|
+
raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric
|
73
|
+
get("/workrooms/#{params[:workroom_id]}/events/#{params[:event_id]}/rsvps/#{rsvp_id}.json")
|
74
|
+
end
|
75
|
+
|
76
|
+
def add_invitee(rsvp_id, attributes, params = nil)
|
77
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
78
|
+
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
79
|
+
raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric
|
80
|
+
post("/workrooms/#{params[:workroom_id]}/events/#{params[:event_id]}/rsvps/#{rsvp_id}/add_invitee.json", attributes)
|
81
|
+
end
|
82
|
+
|
83
|
+
def remove_invitee(rsvp_id, attributes, params = nil)
|
84
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
85
|
+
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
86
|
+
raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric
|
87
|
+
post("/workrooms/#{params[:workroom_id]}/events/#{params[:event_id]}/rsvps/#{rsvp_id}/remove_invitee.json", attributes)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Books
|
91
|
+
def get_books(params = nil)
|
92
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
93
|
+
get("/books.json", params)
|
94
|
+
end
|
95
|
+
|
96
|
+
def get_paginated_books(params = nil)
|
97
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
98
|
+
get("/books/paginated.json", params)
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_book(book_id, params = nil)
|
102
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
103
|
+
raise Error, "Book ID is required" unless book_id.is_a? Numeric
|
104
|
+
get("/workrooms/#{params[:workroom_id]}/books/#{book_id}.json")
|
105
|
+
end
|
106
|
+
|
107
|
+
# Clients
|
108
|
+
def get_client(client_id)
|
109
|
+
raise Error, "Client ID is required" unless client_id.is_a? Numeric
|
110
|
+
get("/clients/#{client_id}.json")
|
111
|
+
end
|
112
|
+
|
113
|
+
# Custom Fields
|
114
|
+
def get_custom_fields(params = nil)
|
115
|
+
get("/custom_fields.json")
|
116
|
+
end
|
117
|
+
|
118
|
+
# Discussions
|
119
|
+
def get_discussions(params = nil)
|
120
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
121
|
+
get("/workrooms/#{params[:workroom_id]}/discussions.json")
|
122
|
+
end
|
123
|
+
|
124
|
+
def get_discussion(discussion_id, params = nil)
|
125
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
126
|
+
get("/workrooms/#{params[:workroom_id]}/discussions/#{discussion_id}.json")
|
127
|
+
end
|
128
|
+
|
129
|
+
# Discussion Posts
|
130
|
+
def get_discussion_post(discussion_id, post_id, params = nil)
|
131
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
132
|
+
raise Error, "Discussion ID is required" unless discussion_id.is_a? Numeric
|
133
|
+
raise Error, "Discussion Post ID is required" unless post_id.is_a? Numeric
|
134
|
+
get("/workrooms/#{params[:workroom_id]}/discussions/#{discussion_id}/discussion_posts/#{post_id}.json")
|
135
|
+
end
|
136
|
+
|
137
|
+
# Event Categories
|
138
|
+
def get_event_categories(params = nil)
|
139
|
+
get("/eventcolors.json", params)
|
140
|
+
end
|
141
|
+
|
142
|
+
def create_event_category(attributes, params = nil)
|
143
|
+
post("/eventcolors.json", attributes)
|
144
|
+
end
|
145
|
+
|
146
|
+
def update_event_category(id, attributes, params = nil)
|
147
|
+
raise Error, "Eventcolor ID is required" unless id.is_a? Numeric
|
148
|
+
put("/eventcolors/#{id}.json", attributes)
|
149
|
+
end
|
150
|
+
|
151
|
+
def get_event_category(id, params = nil)
|
152
|
+
raise Error, "Eventcolor ID is required" unless id.is_a? Numeric
|
153
|
+
get("/eventcolors/#{id}.json")
|
154
|
+
end
|
155
|
+
|
156
|
+
def delete_event_category(id, params = nil)
|
157
|
+
raise Error, "Eventcolor ID is required" unless id.is_a? Numeric
|
158
|
+
delete("/eventcolors/#{id}.json")
|
159
|
+
end
|
160
|
+
|
161
|
+
# Surveys
|
162
|
+
def get_surveys(params = nil)
|
163
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
164
|
+
get("/workrooms/#{params[:workroom_id]}/surveys.json")
|
165
|
+
end
|
166
|
+
|
167
|
+
# Userclasses
|
168
|
+
def get_userclasses(params = nil)
|
169
|
+
get("/userclasses.json", params)
|
170
|
+
end
|
171
|
+
|
172
|
+
def create_userclass(attributes, params = nil)
|
173
|
+
post("/userclasses.json", attributes)
|
174
|
+
end
|
175
|
+
|
176
|
+
def update_userclass(userclass_id, attributes, params = nil)
|
177
|
+
raise Error, "Userclass ID is required" unless userclass_id.is_a? Numeric
|
178
|
+
put("/userclasses/#{userclass_id}.json", attributes)
|
179
|
+
end
|
180
|
+
|
181
|
+
def get_userclass(userclass_id, params = nil)
|
182
|
+
raise Error, "Userclass ID is required" unless userclass_id.is_a? Numeric
|
183
|
+
get("/userclasses/#{userclass_id}.json")
|
184
|
+
end
|
185
|
+
|
186
|
+
def delete_userclass(userclass_id, params = nil)
|
187
|
+
raise Error, "Userclass ID is required" unless userclass_id.is_a? Numeric
|
188
|
+
delete("/userclasses/#{userclass_id}.json")
|
189
|
+
end
|
190
|
+
|
191
|
+
# Users
|
192
|
+
def get_users
|
193
|
+
get("/users.json")
|
194
|
+
end
|
195
|
+
|
196
|
+
def get_user(id)
|
197
|
+
raise Error, "User ID is required" unless id.is_a? Numeric
|
198
|
+
get("/users/#{id}.json")
|
199
|
+
end
|
200
|
+
|
201
|
+
# Workgroups
|
202
|
+
def get_workgroups
|
203
|
+
get("/committeegroups.json")
|
204
|
+
end
|
205
|
+
|
206
|
+
def get_workgroup(id)
|
207
|
+
raise Error, "Workgroup ID is required" unless id.is_a? Numeric
|
208
|
+
get("/committeegroups/#{id}.json")
|
209
|
+
end
|
210
|
+
|
211
|
+
# Workrooms
|
212
|
+
def get_workrooms(params = nil)
|
213
|
+
get("/workrooms.json")
|
214
|
+
end
|
215
|
+
|
216
|
+
def create_workroom(attributes, params = nil)
|
217
|
+
post("/workrooms.json", attributes)
|
218
|
+
end
|
219
|
+
|
220
|
+
def update_workroom(id, attributes, params = nil)
|
221
|
+
raise Error, "Workroom ID is required" unless id.is_a? Numeric
|
222
|
+
put("/workrooms/#{id}.json", attributes)
|
223
|
+
end
|
224
|
+
|
225
|
+
def get_workroom(id, params = nil)
|
226
|
+
raise Error, "Workroom ID is required" unless id.is_a? Numeric
|
227
|
+
get("/workrooms/#{id}.json")
|
228
|
+
end
|
229
|
+
|
230
|
+
def delete_workroom(id, params = nil)
|
231
|
+
raise Error, "Workroom ID is required" unless id.is_a? Numeric
|
232
|
+
delete("/workrooms/#{id}.json")
|
26
233
|
end
|
27
234
|
|
28
235
|
private
|
data/lib/boardeffect/client.rb
CHANGED
@@ -8,7 +8,7 @@ module BoardEffect
|
|
8
8
|
class Client
|
9
9
|
def initialize(options = {})
|
10
10
|
if options.key?(:access_token)
|
11
|
-
@auth_header, @auth_value = 'Authorization', "
|
11
|
+
@auth_header, @auth_value = 'Authorization', "Bearer #{options[:access_token]}"
|
12
12
|
else
|
13
13
|
@auth_header, @auth_value = 'X-BoardEffectToken', options.fetch(:token)
|
14
14
|
end
|
data/lib/boardeffect/version.rb
CHANGED
data/spec/boardeffect_spec.rb
CHANGED
@@ -1,42 +1,23 @@
|
|
1
|
-
|
2
|
-
require 'webmock/minitest'
|
3
|
-
require 'boardeffect'
|
1
|
+
require_relative 'spec_helper'
|
4
2
|
|
5
3
|
describe 'BoardEffect::Client' do
|
6
|
-
|
7
|
-
@token = 'd9e982b84b624ab761f718a54f5ab682b0dbf9a11e28ed334812a118eeba34ab2200ec00a923b85eb7c848343aadc601b0386b8ea875f7feb931e2674ceaaf8b'
|
8
|
-
|
9
|
-
@base_url = 'http://boardeffect.local/services/v2'
|
10
|
-
|
11
|
-
@entry_id = @project_id = @id = 1234
|
12
|
-
|
13
|
-
@auth_header = {headers: {'Authorization' => "Token token=#{@token}", 'User-Agent'=>'Ruby BoardEffect::Client', 'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}}
|
14
|
-
|
15
|
-
@json_request = {headers: {'Authorization' => "Token token=#{@token}", 'User-Agent'=>'Ruby BoardEffect::Client', 'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}}
|
16
|
-
|
17
|
-
@json_response = {headers: {'Content-Type' => 'application/json;charset=utf-8'}, body: '{}'}
|
18
|
-
|
19
|
-
@client = BoardEffect::Client.new(access_token: @token)
|
20
|
-
end
|
21
|
-
|
22
|
-
after do
|
23
|
-
assert_requested(@request) if defined?(@request)
|
24
|
-
end
|
4
|
+
include BeforeHelper
|
25
5
|
|
6
|
+
# Announcements
|
26
7
|
describe "get_announcements method" do
|
27
8
|
it "fetches the announcements resources and returns the decoded response object" do
|
28
|
-
@request = stub_request(:get, "#@base_url/announcements").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
9
|
+
@request = stub_request(:get, "#@base_url/announcements.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
29
10
|
@client.get_announcements.must_equal([])
|
30
11
|
end
|
31
12
|
|
32
13
|
it 'makes request to get specific workroom announcements' do
|
33
|
-
@request = stub_request(:get, "#@base_url/announcements?workroom_id=1")
|
14
|
+
@request = stub_request(:get, "#@base_url/announcements.json?workroom_id=1")
|
34
15
|
@client.get_announcements(workroom_id: "1")
|
35
16
|
end
|
36
17
|
|
37
18
|
it 'raises an error if workroom_id is 0' do
|
38
19
|
message = "Workroom ID Can not be 0"
|
39
|
-
@request = stub_request(:get, "#@base_url/announcements?workroom_id=0").to_return(@json_response.merge(status: 400, body: %({"message":"#{message}"})))
|
20
|
+
@request = stub_request(:get, "#@base_url/announcements.json?workroom_id=0").to_return(@json_response.merge(status: 400, body: %({"message":"#{message}"})))
|
40
21
|
exception = proc { @client.get_announcements(workroom_id: "0") }.must_raise(BoardEffect::Error)
|
41
22
|
exception.message.must_include(message)
|
42
23
|
end
|
@@ -44,31 +25,318 @@ describe 'BoardEffect::Client' do
|
|
44
25
|
|
45
26
|
describe "create_announcement method" do
|
46
27
|
it "posts the given attributes to the announcements resource and returns the decoded response object" do
|
47
|
-
@request = stub_request(:post, "#@base_url/announcements").with(@json_request.merge(body: { title: "Testing api", body: "This is a description"})).to_return(@json_response.merge(status: 201))
|
48
|
-
@client.create_announcement(title: "Testing api", body: "This is a description").must_be_instance_of(BoardEffect::Record)
|
28
|
+
@request = stub_request(:post, "#@base_url/announcements.json").with(@json_request.merge(body: { title: "Testing api", body: "This is a description"})).to_return(@json_response.merge(status: 201))
|
29
|
+
@client.create_announcement({title: "Testing api", body: "This is a description"}, {workroom_id: 1}).must_be_instance_of(BoardEffect::Record)
|
49
30
|
end
|
50
31
|
end
|
51
32
|
|
52
33
|
describe "update_announcement method" do
|
53
34
|
it "puts the given attributes to the announcements resource and returns the decoded response object" do
|
54
|
-
@request = stub_request(:put, "#@base_url/announcements/1").with(@json_request.merge(body: { title: "Testing api update", body: "This is a description"})).to_return(@json_response.merge(status: 201))
|
35
|
+
@request = stub_request(:put, "#@base_url/announcements/1.json").with(@json_request.merge(body: { title: "Testing api update", body: "This is a description"})).to_return(@json_response.merge(status: 201))
|
55
36
|
@client.update_announcement(1, {title: "Testing api update", body: "This is a description"}).must_be_instance_of(BoardEffect::Record)
|
56
37
|
end
|
57
38
|
end
|
58
39
|
|
59
40
|
describe "get_announcement method" do
|
60
41
|
it "fetches the announcement resources and returns the decoded response object" do
|
61
|
-
@request = stub_request(:get, "#@base_url/announcements/1").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
42
|
+
@request = stub_request(:get, "#@base_url/announcements/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
62
43
|
@client.get_announcement(1).must_equal([])
|
63
44
|
end
|
64
45
|
end
|
65
46
|
|
66
47
|
describe "delete_announcement method" do
|
67
48
|
it "deletes the announcement resource" do
|
68
|
-
@request = stub_request(:delete, "#@base_url/announcements/1").with(@auth_header).to_return(status: 204)
|
49
|
+
@request = stub_request(:delete, "#@base_url/announcements/1.json").with(@auth_header).to_return(status: 204)
|
69
50
|
@client.delete_announcement(1).must_equal(:no_content)
|
70
51
|
end
|
71
52
|
end
|
53
|
+
|
54
|
+
# Events
|
55
|
+
describe "get_events method" do
|
56
|
+
it "fetches the events resources and returns the decoded response object" do
|
57
|
+
@request = stub_request(:get, "#@base_url/events.json?workroom_id=1").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
58
|
+
@client.get_events(workroom_id: 1).must_equal([])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe "create_event method" do
|
63
|
+
it "posts the given attributes to the events resource and returns the decoded response object" do
|
64
|
+
attributes = {title: "Testing api", description: "This is a description", location: "Test location", eventcolor_id: "1", datetime_start: Time.now.to_s, datetime_end: Time.now.to_s}
|
65
|
+
@request = stub_request(:post, "#@base_url/workrooms/1/events.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
66
|
+
@client.create_event(attributes, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "update_event method" do
|
71
|
+
it "puts the given attributes to the event resource and returns the decoded response object" do
|
72
|
+
attributes = { location: "This is a new location" }
|
73
|
+
@request = stub_request(:put, "#@base_url/workrooms/1/events/1.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
74
|
+
@client.update_event(1, attributes, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "get_event method" do
|
79
|
+
it "fetches the event resources and returns the decoded response object" do
|
80
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
81
|
+
@client.get_event(1, workroom_id: 1).must_equal([])
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "delete_event method" do
|
86
|
+
it "deletes the event resource" do
|
87
|
+
@request = stub_request(:delete, "#@base_url/workrooms/1/events/1.json").with(@auth_header).to_return(status: 204)
|
88
|
+
@client.delete_event(1, workroom_id: 1).must_equal(:no_content)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# RSVPS
|
93
|
+
describe "get_rsvps method" do
|
94
|
+
it "fetches the rsvps resources and returns the decoded response object" do
|
95
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events/1/rsvps.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
96
|
+
@client.get_rsvps(workroom_id: 1, event_id: 1).must_equal([])
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "create_rsvp method" do
|
101
|
+
it "posts the given attributes to the rsvps resource and returns the decoded response object" do
|
102
|
+
attributes = {title: "Testing api", description: "This is a description", location: "Test location", expiration_date: Time.now.to_s}
|
103
|
+
@request = stub_request(:post, "#@base_url/workrooms/1/events/1/rsvps.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
104
|
+
@client.create_rsvp(attributes, { workroom_id: 1, event_id: 1}).must_be_instance_of(BoardEffect::Record)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "get_rsvp method" do
|
109
|
+
it "fetches the rsvp resource and returns the decoded response object" do
|
110
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events/1/rsvps/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
111
|
+
@client.get_rsvp(1, {workroom_id: 1, event_id: 1}).must_equal([])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "add_invitee method" do
|
116
|
+
it "adds an array of user_ids to an rsvp" do
|
117
|
+
@request = stub_request(:post, "#@base_url/workrooms/1/events/1/rsvps/1/add_invitee.json").with(@json_request.merge(body: { ids: "1,2,3"}.to_json)).to_return(@json_response.merge(status: 201))
|
118
|
+
@client.add_invitee(1, {ids: "1,2,3"}, {workroom_id: 1, event_id: 1}).must_be_instance_of(BoardEffect::Record)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "remove_invitee method" do
|
123
|
+
it "removes an array of user_ids to an rsvp" do
|
124
|
+
@request = stub_request(:post, "#@base_url/workrooms/1/events/1/rsvps/1/add_invitee.json").with(@json_request.merge(body: { ids: "1,3"}.to_json)).to_return(@json_response.merge(status: 201))
|
125
|
+
@client.add_invitee(1, {ids: "1,3"}, {workroom_id: 1, event_id: 1}).must_be_instance_of(BoardEffect::Record)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Userclasses
|
130
|
+
describe "get_userclasses method" do
|
131
|
+
it "fetches the userclasses resources and returns the decoded response object" do
|
132
|
+
@request = stub_request(:get, "#@base_url/userclasses.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
133
|
+
@client.get_userclasses.must_equal([])
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe "create_userclass method" do
|
138
|
+
it "posts the given attributes to the userclass resource and returns the decoded response object" do
|
139
|
+
attributes = {title: "New Userclass"}
|
140
|
+
@request = stub_request(:post, "#@base_url/userclasses.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
141
|
+
@client.create_userclass(attributes).must_be_instance_of(BoardEffect::Record)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "update_userclass method" do
|
146
|
+
it "puts the given attributes to the userclass resource and returns the decoded response object" do
|
147
|
+
attributes = { title: "Old Userclass" }
|
148
|
+
@request = stub_request(:put, "#@base_url/userclasses/1.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
149
|
+
@client.update_userclass(1, attributes).must_be_instance_of(BoardEffect::Record)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe "get_userclass method" do
|
154
|
+
it "fetches the userclass resources and returns the decoded response object" do
|
155
|
+
@request = stub_request(:get, "#@base_url/userclasses/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
156
|
+
@client.get_userclass(1).must_equal([])
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe "delete_userclass method" do
|
161
|
+
it "deletes the userclass resource" do
|
162
|
+
@request = stub_request(:delete, "#@base_url/userclasses/1.json").with(@auth_header).to_return(status: 204)
|
163
|
+
@client.delete_userclass(1).must_equal(:no_content)
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Books
|
168
|
+
describe "get_books method" do
|
169
|
+
it "fetches the books resources and returns the decoded response object" do
|
170
|
+
@request = stub_request(:get, "#@base_url/books.json?workroom_id=1").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
171
|
+
@client.get_books(workroom_id: 1).must_equal([])
|
172
|
+
end
|
173
|
+
it "fetches the books resources and returns the decoded response object" do
|
174
|
+
@request = stub_request(:get, "#@base_url/books/paginated.json?workroom_id=1&page=1").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
175
|
+
@client.get_paginated_books(workroom_id: 1, page: 1).must_equal([])
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe "get_book method" do
|
180
|
+
it "fetches the book resource and returns the decoded response object" do
|
181
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/books/1.json?").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
182
|
+
@client.get_book(1, workroom_id: 1).must_equal([])
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Clients
|
187
|
+
describe "get_client method" do
|
188
|
+
it "fetches the client resource and returns the decoded response object" do
|
189
|
+
@request = stub_request(:get, "#@base_url/clients/1.json?").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
190
|
+
@client.get_client(1).must_equal([])
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Custom Fields
|
195
|
+
describe "get_custom_fields method" do
|
196
|
+
it "fetches the custom fields resource and returns the decoded response object" do
|
197
|
+
attributes = { "id" => 0, "label" => "string", "field_type" => "string", "options" => "string"}
|
198
|
+
@request = stub_request(:get, "#@base_url/custom_fields.json?").with(@auth_header).to_return(@json_response.merge(body: attributes.to_json))
|
199
|
+
@client.get_custom_fields.must_be_instance_of(BoardEffect::Record)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
# Discussions
|
204
|
+
describe "get_discussions method" do
|
205
|
+
it "fetches the discussions resource and returns the decoded response object" do
|
206
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/discussions.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
207
|
+
@client.get_discussions(workroom_id: 1).must_equal([])
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "get_discussion method" do
|
212
|
+
it "fetches the discussion resource and returns the decoded response object" do
|
213
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/discussions/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
214
|
+
@client.get_discussion(1, workroom_id: 1).must_equal([])
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
# Discussion Posts
|
219
|
+
describe "get_discussion_post" do
|
220
|
+
it "fetches the discussion post resource and returns the decoded response object" do
|
221
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/discussions/1/discussion_posts/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
222
|
+
@client.get_discussion_post(1, 1, workroom_id: 1).must_equal([])
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# Event Categories
|
227
|
+
describe "get_event_categories" do
|
228
|
+
it "fetches the event category resource and returns the decoded response object" do
|
229
|
+
@request = stub_request(:get, "#@base_url/eventcolors.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
230
|
+
@client.get_event_categories().must_equal([])
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
describe "create_event_category" do
|
235
|
+
it "creates the event category resource and returns the decoded response object" do
|
236
|
+
attributes = {title: "New Event Category", color: 'FFFF00'}
|
237
|
+
@request = stub_request(:post, "#@base_url/eventcolors.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
238
|
+
@client.create_event_category(attributes).must_be_instance_of(BoardEffect::Record)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "update_event_category" do
|
243
|
+
it "updates the event category resource and returns the decoded response object" do
|
244
|
+
attributes = {title: "Updated Event Category", color: 'FFFFCC'}
|
245
|
+
@request = stub_request(:put, "#@base_url/eventcolors/1.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
246
|
+
@client.update_event_category(1, attributes).must_be_instance_of(BoardEffect::Record)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe "get_event_category" do
|
251
|
+
it "fetches the event category resource and returns the decoded response object" do
|
252
|
+
@request = stub_request(:get, "#@base_url/eventcolors/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
253
|
+
@client.get_event_category(1).must_equal([])
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
describe "delete_event_category" do
|
258
|
+
it "fetches the event category resource and returns the decoded response object" do
|
259
|
+
@request = stub_request(:delete, "#@base_url/eventcolors/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
260
|
+
@client.delete_event_category(1).must_equal([])
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Surveys
|
265
|
+
describe "get_surveys" do
|
266
|
+
it "fetches the survey resource and returns the decoded response object" do
|
267
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/surveys.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
268
|
+
@client.get_surveys(workroom_id: 1).must_equal([])
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# Users
|
273
|
+
describe "get_users" do
|
274
|
+
it "fetches the users resource and returns the decoded response object" do
|
275
|
+
@request = stub_request(:get, "#@base_url/users.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
276
|
+
@client.get_users.must_equal([])
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
describe "get_user" do
|
281
|
+
it "fetches the user resource and returns the decoded response object" do
|
282
|
+
@request = stub_request(:get, "#@base_url/users/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
283
|
+
@client.get_user(1).must_equal([])
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
# Workgroups
|
288
|
+
describe "get_workgroups" do
|
289
|
+
it "fetches the workgroups resource and returns the decoded response object" do
|
290
|
+
@request = stub_request(:get, "#@base_url/committeegroups.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
291
|
+
@client.get_workgroups.must_equal([])
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
describe "get_workgroup" do
|
296
|
+
it "fetches the workgroup resource and returns the decoded response object" do
|
297
|
+
@request = stub_request(:get, "#@base_url/committeegroups/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
298
|
+
@client.get_workgroup(1).must_equal([])
|
299
|
+
end
|
300
|
+
end
|
301
|
+
|
302
|
+
# Workrooms
|
303
|
+
describe "get_workrooms method" do
|
304
|
+
it "fetches the workrooms resources and returns the decoded response object" do
|
305
|
+
@request = stub_request(:get, "#@base_url/workrooms.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
306
|
+
@client.get_workrooms.must_equal([])
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe "create_workroom method" do
|
311
|
+
it "posts the given attributes to the workroom resource and returns the decoded response object" do
|
312
|
+
attributes = {name: "New Workroom"}
|
313
|
+
@request = stub_request(:post, "#@base_url/workrooms.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
314
|
+
@client.create_workroom(attributes).must_be_instance_of(BoardEffect::Record)
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
describe "update_workroom method" do
|
319
|
+
it "puts the given attributes to the workroom resource and returns the decoded response object" do
|
320
|
+
attributes = { name: "Updated Workroom" }
|
321
|
+
@request = stub_request(:put, "#@base_url/workrooms/1.json").with(@json_request.merge(body: attributes.to_json)).to_return(@json_response.merge(status: 201))
|
322
|
+
@client.update_workroom(1, attributes).must_be_instance_of(BoardEffect::Record)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
describe "get_workroom method" do
|
327
|
+
it "fetches the workroom resources and returns the decoded response object" do
|
328
|
+
@request = stub_request(:get, "#@base_url/workrooms/1.json").with(@auth_header).to_return(@json_response.merge(body: '[]'))
|
329
|
+
@client.get_workroom(1).must_equal([])
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
describe "delete_workroom method" do
|
334
|
+
it "deletes the workroom resource" do
|
335
|
+
@request = stub_request(:delete, "#@base_url/workrooms/1.json").with(@auth_header).to_return(status: 204)
|
336
|
+
@client.delete_workroom(1).must_equal(:no_content)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
72
340
|
end
|
73
341
|
|
74
342
|
describe 'BoardEffect::Record' do
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'webmock/minitest'
|
3
|
+
require 'boardeffect'
|
4
|
+
|
5
|
+
class Module
|
6
|
+
include Minitest::Spec::DSL
|
7
|
+
end
|
8
|
+
|
9
|
+
module BeforeHelper
|
10
|
+
before do
|
11
|
+
@token = 'b73cbb117c89c9ed9d8009453655e36965bdb1ca491583b22b85c7d499f8a658b1e3fff221fbb2a141880d2be3a466'
|
12
|
+
|
13
|
+
@base_url = 'http://boardeffect.local'
|
14
|
+
|
15
|
+
@entry_id = @project_id = @id = 1234
|
16
|
+
|
17
|
+
@auth_header = {headers: {'Authorization' => "Bearer #{@token}", 'User-Agent'=>'Ruby BoardEffect::Client', 'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}}
|
18
|
+
|
19
|
+
@json_request = {headers: {'Authorization' => "Bearer #{@token}", 'User-Agent'=>'Ruby BoardEffect::Client', 'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}}
|
20
|
+
|
21
|
+
@json_response = {headers: {'Content-Type' => 'application/json;charset=utf-8'}, body: '{}'}
|
22
|
+
|
23
|
+
@client = BoardEffect::Client.new(access_token: @token)
|
24
|
+
end
|
25
|
+
|
26
|
+
after do
|
27
|
+
assert_requested(@request) if defined?(@request)
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boardeffect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Hunt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.0'
|
55
|
-
description: Ruby client for Version
|
55
|
+
description: Ruby client for Version 3 of the BoardEffect API
|
56
56
|
email:
|
57
57
|
- development@boardeffect.com
|
58
58
|
executables:
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/boardeffect/record.rb
|
78
78
|
- lib/boardeffect/version.rb
|
79
79
|
- spec/boardeffect_spec.rb
|
80
|
+
- spec/spec_helper.rb
|
80
81
|
homepage: https://github.com/magicmarkker/boardeffect
|
81
82
|
licenses:
|
82
83
|
- MIT
|
@@ -100,6 +101,7 @@ rubyforge_project:
|
|
100
101
|
rubygems_version: 2.5.2
|
101
102
|
signing_key:
|
102
103
|
specification_version: 4
|
103
|
-
summary: Ruby client for Version
|
104
|
+
summary: Ruby client for Version 3 of the BoardEffect API
|
104
105
|
test_files:
|
105
106
|
- spec/boardeffect_spec.rb
|
107
|
+
- spec/spec_helper.rb
|