boardeffect 1.0.0 → 1.0.1
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/Gemfile.lock +1 -1
- data/README.md +1 -1
- data/lib/boardeffect/client.rb +35 -15
- data/lib/boardeffect/version.rb +1 -1
- data/lib/boardeffect.rb +18 -37
- data/spec/boardeffect_spec.rb +65 -81
- data/spec/spec_helper.rb +5 -10
- 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: 551d74adda142b1193fe13a11f9ed0c53dc42dac
|
4
|
+
data.tar.gz: 871729bb257d0901c6742fd252f0a41d1609f3e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5bed368e228340bcb9de96612530a3f1ac82fa5f698f6402e88332c48ff13529949706778179ada9611967de6a8948b567be0de7b68a773eb1d030cd0d470834
|
7
|
+
data.tar.gz: ad1e5bbd92571d76b26a435e4a80d80ce8600168178356ea48b9757c3e7ef29b51682b68dfc3806df17e5c68f01942d733475ca361fedf22577eed3e011b1422
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -15,7 +15,7 @@ $ gem install boardeffect
|
|
15
15
|
```ruby
|
16
16
|
require 'boardeffect'
|
17
17
|
|
18
|
-
boardeffect = BoardEffect::Client.new(access_token: '
|
18
|
+
boardeffect = BoardEffect::Client.new(access_token: 'API KEY', host: 'https://yourportalname.boardeffect.com/')
|
19
19
|
|
20
20
|
announcement = boardeffect.create_announcement({title: "This is a test from the console", body: "This is a body description"}, { workroom_id: 2 })
|
21
21
|
p announcement.inspect
|
data/lib/boardeffect/client.rb
CHANGED
@@ -5,21 +5,31 @@ require 'cgi'
|
|
5
5
|
require 'json'
|
6
6
|
|
7
7
|
module BoardEffect
|
8
|
+
|
8
9
|
class Client
|
10
|
+
|
11
|
+
API_VERSION = 3
|
12
|
+
API_PATH = '/api/v3'
|
13
|
+
|
9
14
|
def initialize(options = {})
|
10
|
-
|
11
|
-
|
15
|
+
setup_client(options)
|
16
|
+
if !options.key?(:test)
|
17
|
+
auth = auth("#{API_PATH}/auth/api_key.json", { api_key: options[:access_token]})
|
18
|
+
if auth[:success] == true
|
19
|
+
@auth_header, @auth_value = 'Authorization', "Bearer #{auth[:data][:token]}"
|
20
|
+
else
|
21
|
+
raise Error, auth[:error][:message]
|
22
|
+
end
|
12
23
|
else
|
13
|
-
|
24
|
+
@auth_header, @auth_value = 'Authorization', "Bearer #{options[:access_token]}"
|
14
25
|
end
|
26
|
+
end
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@http
|
21
|
-
|
22
|
-
@http.use_ssl = (options.key?(:host)) ? true : false
|
28
|
+
def auth(path, attributes)
|
29
|
+
http_request = Net::HTTP::Post.new(path)
|
30
|
+
http_request['Content-Type'] = 'application/json'
|
31
|
+
http_request.body = JSON.generate(attributes)
|
32
|
+
parse(@http.request(http_request))
|
23
33
|
end
|
24
34
|
|
25
35
|
def get(path, params = nil)
|
@@ -28,16 +38,25 @@ module BoardEffect
|
|
28
38
|
|
29
39
|
private
|
30
40
|
|
41
|
+
def setup_client(options = {})
|
42
|
+
@user_agent = options.fetch(:user_agent, 'Ruby BoardEffect::Client')
|
43
|
+
|
44
|
+
@host = (options.key?(:host)) ? options[:host] : 'boardeffect.local'
|
45
|
+
|
46
|
+
@http = Net::HTTP.new(URI.parse(@host).host, Net::HTTP.https_default_port())
|
47
|
+
@http.use_ssl = true
|
48
|
+
end
|
49
|
+
|
31
50
|
def post(path, attributes)
|
32
|
-
request(Net::HTTP::Post.new(path), attributes)
|
51
|
+
request(Net::HTTP::Post.new(request_uri(path)), attributes)
|
33
52
|
end
|
34
53
|
|
35
54
|
def put(path, attributes = nil)
|
36
|
-
request(Net::HTTP::Put.new(path), attributes)
|
55
|
+
request(Net::HTTP::Put.new(request_uri(path)), attributes)
|
37
56
|
end
|
38
57
|
|
39
58
|
def delete(path)
|
40
|
-
request(Net::HTTP::Delete.new(path))
|
59
|
+
request(Net::HTTP::Delete.new(request_uri(path)))
|
41
60
|
end
|
42
61
|
|
43
62
|
def request(http_request, body_object = nil)
|
@@ -70,15 +89,16 @@ module BoardEffect
|
|
70
89
|
when Net::HTTPBadRequest
|
71
90
|
object = JSON.parse(http_response.body, symbolize_names: true)
|
72
91
|
|
73
|
-
raise Error, "boardeffect api error: #{object
|
92
|
+
raise Error, "boardeffect api error: #{object[:error][:message]}"
|
74
93
|
when Net::HTTPUnauthorized
|
75
|
-
raise AuthenticationError
|
94
|
+
raise AuthenticationError, "boardeffect api error: unexpected #{http_response.code} response from #{@host}"
|
76
95
|
else
|
77
96
|
raise Error, "boardeffect api error: unexpected #{http_response.code} response from #{@host}"
|
78
97
|
end
|
79
98
|
end
|
80
99
|
|
81
100
|
def request_uri(path, params = nil)
|
101
|
+
path = API_PATH + path unless path.include? API_PATH
|
82
102
|
return path if params.nil? || params.empty?
|
83
103
|
|
84
104
|
path + '?' + params.map { |k, v| "#{escape(k)}=#{array_escape(v)}" }.join('&')
|
data/lib/boardeffect/version.rb
CHANGED
data/lib/boardeffect.rb
CHANGED
@@ -27,81 +27,65 @@ module BoardEffect
|
|
27
27
|
|
28
28
|
# Events
|
29
29
|
def get_events(params = nil)
|
30
|
-
|
31
|
-
get("/events.json", params)
|
30
|
+
get("/#{workroom_check(params)}events.json", params)
|
32
31
|
end
|
33
32
|
|
34
33
|
def create_event(attributes, params = nil)
|
35
|
-
|
36
|
-
post("/workrooms/#{params[:workroom_id]}/events.json", attributes)
|
34
|
+
post("/#{workroom_check(params)}events.json", attributes)
|
37
35
|
end
|
38
36
|
|
39
37
|
def update_event(id, attributes, params = nil)
|
40
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
41
38
|
raise Error, "Event ID is required" unless id.is_a? Numeric
|
42
|
-
put("
|
39
|
+
put("/#{workroom_check(params)}events/#{id}.json", attributes)
|
43
40
|
end
|
44
41
|
|
45
42
|
def get_event(id, params = nil)
|
46
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
47
43
|
raise Error, "Event ID is required" unless id.is_a? Numeric
|
48
|
-
get("
|
44
|
+
get("/#{workroom_check(params)}events/#{id}.json")
|
49
45
|
end
|
50
46
|
|
51
47
|
def delete_event(id, params = nil)
|
52
48
|
raise Error, "Event ID is required" unless id.is_a? Numeric
|
53
|
-
delete("
|
49
|
+
delete("/#{workroom_check(params)}events/#{id}.json")
|
54
50
|
end
|
55
51
|
|
56
52
|
# RSVPS
|
57
53
|
def get_rsvps(params = nil)
|
58
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
59
54
|
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
60
|
-
get("
|
55
|
+
get("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps.json")
|
61
56
|
end
|
62
57
|
|
63
58
|
def create_rsvp(attributes, params = nil)
|
64
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
65
59
|
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
66
|
-
post("
|
60
|
+
post("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps.json", attributes)
|
67
61
|
end
|
68
62
|
|
69
63
|
def get_rsvp(rsvp_id, params = nil)
|
70
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
71
64
|
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
72
65
|
raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric
|
73
|
-
get("
|
66
|
+
get("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps/#{rsvp_id}.json")
|
74
67
|
end
|
75
68
|
|
76
69
|
def add_invitee(rsvp_id, attributes, params = nil)
|
77
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
78
70
|
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
79
71
|
raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric
|
80
|
-
post("
|
72
|
+
post("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps/#{rsvp_id}/add_invitee.json", attributes)
|
81
73
|
end
|
82
74
|
|
83
75
|
def remove_invitee(rsvp_id, attributes, params = nil)
|
84
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
85
76
|
raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric
|
86
77
|
raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric
|
87
|
-
post("
|
78
|
+
post("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps/#{rsvp_id}/remove_invitee.json", attributes)
|
88
79
|
end
|
89
80
|
|
90
81
|
# Books
|
91
82
|
def get_books(params = nil)
|
92
|
-
|
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)
|
83
|
+
get("/#{workroom_check(params)}books.json", params)
|
99
84
|
end
|
100
85
|
|
101
86
|
def get_book(book_id, params = nil)
|
102
|
-
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
103
87
|
raise Error, "Book ID is required" unless book_id.is_a? Numeric
|
104
|
-
get("
|
88
|
+
get("/#{workroom_check(params)}books/#{book_id}.json")
|
105
89
|
end
|
106
90
|
|
107
91
|
# Clients
|
@@ -117,21 +101,18 @@ module BoardEffect
|
|
117
101
|
|
118
102
|
# Discussions
|
119
103
|
def get_discussions(params = nil)
|
120
|
-
|
121
|
-
get("/workrooms/#{params[:workroom_id]}/discussions.json")
|
104
|
+
get("/#{workroom_check(params)}discussions.json")
|
122
105
|
end
|
123
106
|
|
124
107
|
def get_discussion(discussion_id, params = nil)
|
125
|
-
|
126
|
-
get("/workrooms/#{params[:workroom_id]}/discussions/#{discussion_id}.json")
|
108
|
+
get("/#{workroom_check(params)}discussions/#{discussion_id}.json")
|
127
109
|
end
|
128
110
|
|
129
111
|
# Discussion Posts
|
130
112
|
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
113
|
raise Error, "Discussion ID is required" unless discussion_id.is_a? Numeric
|
133
114
|
raise Error, "Discussion Post ID is required" unless post_id.is_a? Numeric
|
134
|
-
get("
|
115
|
+
get("/#{workroom_check(params)}discussions/#{discussion_id}/discussion_posts/#{post_id}.json")
|
135
116
|
end
|
136
117
|
|
137
118
|
# Event Categories
|
@@ -160,8 +141,7 @@ module BoardEffect
|
|
160
141
|
|
161
142
|
# Surveys
|
162
143
|
def get_surveys(params = nil)
|
163
|
-
|
164
|
-
get("/workrooms/#{params[:workroom_id]}/surveys.json")
|
144
|
+
get("/#{workroom_check(params)}surveys.json")
|
165
145
|
end
|
166
146
|
|
167
147
|
# Userclasses
|
@@ -235,7 +215,8 @@ module BoardEffect
|
|
235
215
|
private
|
236
216
|
|
237
217
|
def workroom_check(params = nil)
|
238
|
-
if !params.nil? && params.key?('workroom_id')
|
218
|
+
if !params.nil? && (params.key?('workroom_id') or params.key?(:workroom_id))
|
219
|
+
raise Error, "Workroom ID is required" unless params[:workroom_id].is_a? Numeric
|
239
220
|
raise Error, "Workroom ID Can not be 0" if params[:workroom_id].to_i == 0
|
240
221
|
"workrooms/#{params[:workroom_id].to_i}/"
|
241
222
|
end
|
data/spec/boardeffect_spec.rb
CHANGED
@@ -6,56 +6,44 @@ describe 'BoardEffect::Client' do
|
|
6
6
|
# Announcements
|
7
7
|
describe "get_announcements method" do
|
8
8
|
it "fetches the announcements resources and returns the decoded response object" do
|
9
|
-
@request = stub_request(:get, "#@base_url/announcements.json").with(@auth_header).to_return(@json_response
|
10
|
-
@client.get_announcements.
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'makes request to get specific workroom announcements' do
|
14
|
-
@request = stub_request(:get, "#@base_url/announcements.json?workroom_id=1")
|
15
|
-
@client.get_announcements(workroom_id: "1")
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'raises an error if workroom_id is 0' do
|
19
|
-
message = "Workroom ID Can not be 0"
|
20
|
-
@request = stub_request(:get, "#@base_url/announcements.json?workroom_id=0").to_return(@json_response.merge(status: 400, body: %({"message":"#{message}"})))
|
21
|
-
exception = proc { @client.get_announcements(workroom_id: "0") }.must_raise(BoardEffect::Error)
|
22
|
-
exception.message.must_include(message)
|
9
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/announcements.json?workroom_id=1").with(@auth_header).to_return(@json_response)
|
10
|
+
@client.get_announcements(workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
23
11
|
end
|
24
12
|
end
|
25
13
|
|
26
14
|
describe "create_announcement method" do
|
27
15
|
it "posts the given attributes to the announcements resource and returns the decoded response object" do
|
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))
|
16
|
+
@request = stub_request(:post, "#@base_url/workrooms/1/announcements.json").with(@json_request.merge(body: { title: "Testing api", body: "This is a description"})).to_return(@json_response.merge(status: 201))
|
29
17
|
@client.create_announcement({title: "Testing api", body: "This is a description"}, {workroom_id: 1}).must_be_instance_of(BoardEffect::Record)
|
30
18
|
end
|
31
19
|
end
|
32
20
|
|
33
21
|
describe "update_announcement method" do
|
34
22
|
it "puts the given attributes to the announcements resource and returns the decoded response object" do
|
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))
|
36
|
-
@client.update_announcement(1, {title: "Testing api update", body: "This is a description"}).must_be_instance_of(BoardEffect::Record)
|
23
|
+
@request = stub_request(:put, "#@base_url/workrooms/1/announcements/1.json").with(@json_request.merge(body: { title: "Testing api update", body: "This is a description"})).to_return(@json_response.merge(status: 201))
|
24
|
+
@client.update_announcement(1, {title: "Testing api update", body: "This is a description"}, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
37
25
|
end
|
38
26
|
end
|
39
27
|
|
40
28
|
describe "get_announcement method" do
|
41
29
|
it "fetches the announcement resources and returns the decoded response object" do
|
42
|
-
@request = stub_request(:get, "#@base_url/announcements/1.json").with(@auth_header).to_return(@json_response
|
43
|
-
@client.get_announcement(1).
|
30
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/announcements/1.json").with(@auth_header).to_return(@json_response)
|
31
|
+
@client.get_announcement(1, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
44
32
|
end
|
45
33
|
end
|
46
34
|
|
47
35
|
describe "delete_announcement method" do
|
48
36
|
it "deletes the announcement resource" do
|
49
|
-
@request = stub_request(:delete, "#@base_url/announcements/1.json").with(@auth_header).to_return(status: 204)
|
50
|
-
@client.delete_announcement(1).must_equal(:no_content)
|
37
|
+
@request = stub_request(:delete, "#@base_url/workrooms/1/announcements/1.json").with(@auth_header).to_return(status: 204)
|
38
|
+
@client.delete_announcement(1, workroom_id: 1).must_equal(:no_content)
|
51
39
|
end
|
52
40
|
end
|
53
41
|
|
54
42
|
# Events
|
55
43
|
describe "get_events method" do
|
56
44
|
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
|
58
|
-
@client.get_events(workroom_id: 1).
|
45
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events.json?workroom_id=1").with(@auth_header).to_return(@json_response)
|
46
|
+
@client.get_events(workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
59
47
|
end
|
60
48
|
end
|
61
49
|
|
@@ -77,8 +65,8 @@ describe 'BoardEffect::Client' do
|
|
77
65
|
|
78
66
|
describe "get_event method" do
|
79
67
|
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
|
81
|
-
@client.get_event(1, workroom_id: 1).
|
68
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events/1.json").with(@auth_header).to_return(@json_response)
|
69
|
+
@client.get_event(1, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
82
70
|
end
|
83
71
|
end
|
84
72
|
|
@@ -92,8 +80,8 @@ describe 'BoardEffect::Client' do
|
|
92
80
|
# RSVPS
|
93
81
|
describe "get_rsvps method" do
|
94
82
|
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
|
96
|
-
@client.get_rsvps(workroom_id: 1, event_id: 1).
|
83
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events/1/rsvps.json").with(@auth_header).to_return(@json_response)
|
84
|
+
@client.get_rsvps(workroom_id: 1, event_id: 1).must_be_instance_of(BoardEffect::Record)
|
97
85
|
end
|
98
86
|
end
|
99
87
|
|
@@ -107,8 +95,8 @@ describe 'BoardEffect::Client' do
|
|
107
95
|
|
108
96
|
describe "get_rsvp method" do
|
109
97
|
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
|
111
|
-
@client.get_rsvp(1, {workroom_id: 1, event_id: 1}).
|
98
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/events/1/rsvps/1.json").with(@auth_header).to_return(@json_response)
|
99
|
+
@client.get_rsvp(1, {workroom_id: 1, event_id: 1}).must_be_instance_of(BoardEffect::Record)
|
112
100
|
end
|
113
101
|
end
|
114
102
|
|
@@ -126,11 +114,11 @@ describe 'BoardEffect::Client' do
|
|
126
114
|
end
|
127
115
|
end
|
128
116
|
|
129
|
-
# Userclasses
|
117
|
+
# # Userclasses
|
130
118
|
describe "get_userclasses method" do
|
131
119
|
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
|
133
|
-
@client.get_userclasses.
|
120
|
+
@request = stub_request(:get, "#@base_url/userclasses.json").with(@auth_header).to_return(@json_response)
|
121
|
+
@client.get_userclasses.must_be_instance_of(BoardEffect::Record)
|
134
122
|
end
|
135
123
|
end
|
136
124
|
|
@@ -152,8 +140,8 @@ describe 'BoardEffect::Client' do
|
|
152
140
|
|
153
141
|
describe "get_userclass method" do
|
154
142
|
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
|
156
|
-
@client.get_userclass(1).
|
143
|
+
@request = stub_request(:get, "#@base_url/userclasses/1.json").with(@auth_header).to_return(@json_response)
|
144
|
+
@client.get_userclass(1).must_be_instance_of(BoardEffect::Record)
|
157
145
|
end
|
158
146
|
end
|
159
147
|
|
@@ -164,70 +152,66 @@ describe 'BoardEffect::Client' do
|
|
164
152
|
end
|
165
153
|
end
|
166
154
|
|
167
|
-
# Books
|
155
|
+
# # Books
|
168
156
|
describe "get_books method" do
|
169
157
|
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
|
171
|
-
@client.get_books(workroom_id: 1).
|
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([])
|
158
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/books.json?workroom_id=1").with(@auth_header).to_return(@json_response)
|
159
|
+
@client.get_books(workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
176
160
|
end
|
177
161
|
end
|
178
162
|
|
179
163
|
describe "get_book method" do
|
180
164
|
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
|
182
|
-
@client.get_book(1, workroom_id: 1).
|
165
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/books/1.json?").with(@auth_header).to_return(@json_response)
|
166
|
+
@client.get_book(1, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
183
167
|
end
|
184
168
|
end
|
185
169
|
|
186
|
-
# Clients
|
170
|
+
# # Clients
|
187
171
|
describe "get_client method" do
|
188
172
|
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
|
190
|
-
@client.get_client(1).
|
173
|
+
@request = stub_request(:get, "#@base_url/clients/1.json?").with(@auth_header).to_return(@json_response)
|
174
|
+
@client.get_client(1).must_be_instance_of(BoardEffect::Record)
|
191
175
|
end
|
192
176
|
end
|
193
177
|
|
194
|
-
# Custom Fields
|
178
|
+
# # Custom Fields
|
195
179
|
describe "get_custom_fields method" do
|
196
180
|
it "fetches the custom fields resource and returns the decoded response object" do
|
197
181
|
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
|
182
|
+
@request = stub_request(:get, "#@base_url/custom_fields.json?").with(@auth_header).to_return(@json_response)
|
199
183
|
@client.get_custom_fields.must_be_instance_of(BoardEffect::Record)
|
200
184
|
end
|
201
185
|
end
|
202
186
|
|
203
|
-
# Discussions
|
187
|
+
# # Discussions
|
204
188
|
describe "get_discussions method" do
|
205
189
|
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
|
207
|
-
@client.get_discussions(workroom_id: 1).
|
190
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/discussions.json").with(@auth_header).to_return(@json_response)
|
191
|
+
@client.get_discussions(workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
208
192
|
end
|
209
193
|
end
|
210
194
|
|
211
195
|
describe "get_discussion method" do
|
212
196
|
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
|
214
|
-
@client.get_discussion(1, workroom_id: 1).
|
197
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/discussions/1.json").with(@auth_header).to_return(@json_response)
|
198
|
+
@client.get_discussion(1, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
215
199
|
end
|
216
200
|
end
|
217
201
|
|
218
|
-
# Discussion Posts
|
202
|
+
# # Discussion Posts
|
219
203
|
describe "get_discussion_post" do
|
220
204
|
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
|
222
|
-
@client.get_discussion_post(1, 1, workroom_id: 1).
|
205
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/discussions/1/discussion_posts/1.json").with(@auth_header).to_return(@json_response)
|
206
|
+
@client.get_discussion_post(1, 1, workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
223
207
|
end
|
224
208
|
end
|
225
209
|
|
226
|
-
# Event Categories
|
210
|
+
# # Event Categories
|
227
211
|
describe "get_event_categories" do
|
228
212
|
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
|
230
|
-
@client.get_event_categories().
|
213
|
+
@request = stub_request(:get, "#@base_url/eventcolors.json").with(@auth_header).to_return(@json_response)
|
214
|
+
@client.get_event_categories().must_be_instance_of(BoardEffect::Record)
|
231
215
|
end
|
232
216
|
end
|
233
217
|
|
@@ -249,61 +233,61 @@ describe 'BoardEffect::Client' do
|
|
249
233
|
|
250
234
|
describe "get_event_category" do
|
251
235
|
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
|
253
|
-
@client.get_event_category(1).
|
236
|
+
@request = stub_request(:get, "#@base_url/eventcolors/1.json").with(@auth_header).to_return(@json_response)
|
237
|
+
@client.get_event_category(1).must_be_instance_of(BoardEffect::Record)
|
254
238
|
end
|
255
239
|
end
|
256
240
|
|
257
241
|
describe "delete_event_category" do
|
258
242
|
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
|
260
|
-
@client.delete_event_category(1).
|
243
|
+
@request = stub_request(:delete, "#@base_url/eventcolors/1.json").with(@auth_header).to_return(@json_response)
|
244
|
+
@client.delete_event_category(1).must_be_instance_of(BoardEffect::Record)
|
261
245
|
end
|
262
246
|
end
|
263
247
|
|
264
|
-
# Surveys
|
248
|
+
# # Surveys
|
265
249
|
describe "get_surveys" do
|
266
250
|
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
|
268
|
-
@client.get_surveys(workroom_id: 1).
|
251
|
+
@request = stub_request(:get, "#@base_url/workrooms/1/surveys.json").with(@auth_header).to_return(@json_response)
|
252
|
+
@client.get_surveys(workroom_id: 1).must_be_instance_of(BoardEffect::Record)
|
269
253
|
end
|
270
254
|
end
|
271
255
|
|
272
|
-
# Users
|
256
|
+
# # Users
|
273
257
|
describe "get_users" do
|
274
258
|
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
|
276
|
-
@client.get_users.
|
259
|
+
@request = stub_request(:get, "#@base_url/users.json").with(@auth_header).to_return(@json_response)
|
260
|
+
@client.get_users.must_be_instance_of(BoardEffect::Record)
|
277
261
|
end
|
278
262
|
end
|
279
263
|
|
280
264
|
describe "get_user" do
|
281
265
|
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
|
283
|
-
@client.get_user(1).
|
266
|
+
@request = stub_request(:get, "#@base_url/users/1.json").with(@auth_header).to_return(@json_response)
|
267
|
+
@client.get_user(1).must_be_instance_of(BoardEffect::Record)
|
284
268
|
end
|
285
269
|
end
|
286
270
|
|
287
|
-
# Workgroups
|
271
|
+
# # Workgroups
|
288
272
|
describe "get_workgroups" do
|
289
273
|
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
|
291
|
-
@client.get_workgroups.
|
274
|
+
@request = stub_request(:get, "#@base_url/committeegroups.json").with(@auth_header).to_return(@json_response)
|
275
|
+
@client.get_workgroups.must_be_instance_of(BoardEffect::Record)
|
292
276
|
end
|
293
277
|
end
|
294
278
|
|
295
279
|
describe "get_workgroup" do
|
296
280
|
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
|
298
|
-
@client.get_workgroup(1).
|
281
|
+
@request = stub_request(:get, "#@base_url/committeegroups/1.json").with(@auth_header).to_return(@json_response)
|
282
|
+
@client.get_workgroup(1).must_be_instance_of(BoardEffect::Record)
|
299
283
|
end
|
300
284
|
end
|
301
285
|
|
302
|
-
# Workrooms
|
286
|
+
# # Workrooms
|
303
287
|
describe "get_workrooms method" do
|
304
288
|
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
|
306
|
-
@client.get_workrooms.
|
289
|
+
@request = stub_request(:get, "#@base_url/workrooms.json").with(@auth_header).to_return(@json_response)
|
290
|
+
@client.get_workrooms.must_be_instance_of(BoardEffect::Record)
|
307
291
|
end
|
308
292
|
end
|
309
293
|
|
@@ -325,8 +309,8 @@ describe 'BoardEffect::Client' do
|
|
325
309
|
|
326
310
|
describe "get_workroom method" do
|
327
311
|
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
|
329
|
-
@client.get_workroom(1).
|
312
|
+
@request = stub_request(:get, "#@base_url/workrooms/1.json").with(@auth_header).to_return(@json_response)
|
313
|
+
@client.get_workroom(1).must_be_instance_of(BoardEffect::Record)
|
330
314
|
end
|
331
315
|
end
|
332
316
|
|
data/spec/spec_helper.rb
CHANGED
@@ -9,18 +9,13 @@ end
|
|
9
9
|
module BeforeHelper
|
10
10
|
before do
|
11
11
|
@token = 'b73cbb117c89c9ed9d8009453655e36965bdb1ca491583b22b85c7d499f8a658b1e3fff221fbb2a141880d2be3a466'
|
12
|
-
|
13
|
-
@base_url = 'http://boardeffect.local'
|
14
|
-
|
12
|
+
@base_url = 'https://boardeffect.local/api/v3'
|
15
13
|
@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
|
-
|
14
|
+
@client = BoardEffect::Client.new(access_token: @token, host: 'http://boardeffect.local', test: true)
|
15
|
+
@auth_header = @auth_value = {headers: {'Authorization' => "Bearer #{@token}", 'User-Agent'=>'Ruby BoardEffect::Client', 'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'}}
|
19
16
|
@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
|
-
@
|
22
|
-
|
23
|
-
@client = BoardEffect::Client.new(access_token: @token)
|
17
|
+
@json_response = {headers: {'Content-Type' => 'application/json;charset=utf-8'}, body: '{ "success": true, "data": [] }'}
|
18
|
+
@json_error = {headers: {'Content-Type' => 'application/json;charset=utf-8'}, body: '{ "success": false, "error": { "title": "There was an error", "message": "Something went wrong"} }'}
|
24
19
|
end
|
25
20
|
|
26
21
|
after do
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
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-09-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|