Class: BoardEffect::Client
- Inherits:
-
Object
- Object
- BoardEffect::Client
- Defined in:
- lib/boardeffect.rb,
lib/boardeffect/client.rb
Constant Summary collapse
- API_VERSION =
3- API_PATH =
'/api/v3'
Instance Method Summary collapse
- #add_invitee(rsvp_id, attributes, params = nil) ⇒ Object
- #auth(path, attributes) ⇒ Object
- #create_announcement(attributes, params = nil) ⇒ Object
- #create_event(attributes, params = nil) ⇒ Object
- #create_event_category(attributes, params = nil) ⇒ Object
- #create_rsvp(attributes, params = nil) ⇒ Object
- #create_userclass(attributes, params = nil) ⇒ Object
- #create_workroom(attributes, params = nil) ⇒ Object
- #delete_announcement(announcement_id, params = nil) ⇒ Object
- #delete_event(id, params = nil) ⇒ Object
- #delete_event_category(id, params = nil) ⇒ Object
- #delete_userclass(userclass_id, params = nil) ⇒ Object
- #delete_workroom(id, params = nil) ⇒ Object
- #get(path, params = nil) ⇒ Object
- #get_announcement(announcement_id, params = nil) ⇒ Object
-
#get_announcements(params = nil) ⇒ Object
Announcements.
- #get_book(book_id, params = nil) ⇒ Object
-
#get_books(params = nil) ⇒ Object
Books.
-
#get_client(client_id) ⇒ Object
Clients.
-
#get_custom_fields(params = nil) ⇒ Object
Custom Fields.
- #get_discussion(discussion_id, params = nil) ⇒ Object
-
#get_discussion_post(discussion_id, post_id, params = nil) ⇒ Object
Discussion Posts.
-
#get_discussions(params = nil) ⇒ Object
Discussions.
- #get_event(id, params = nil) ⇒ Object
-
#get_event_categories(params = nil) ⇒ Object
Event Categories.
- #get_event_category(id, params = nil) ⇒ Object
-
#get_events(params = nil) ⇒ Object
Events.
- #get_rsvp(rsvp_id, params = nil) ⇒ Object
-
#get_rsvps(params = nil) ⇒ Object
RSVPS.
-
#get_surveys(params = nil) ⇒ Object
Surveys.
- #get_user(id) ⇒ Object
- #get_userclass(userclass_id, params = nil) ⇒ Object
-
#get_userclasses(params = nil) ⇒ Object
Userclasses.
-
#get_users ⇒ Object
Users.
- #get_workgroup(id) ⇒ Object
-
#get_workgroups ⇒ Object
Workgroups.
- #get_workroom(id, params = nil) ⇒ Object
-
#get_workrooms(params = nil) ⇒ Object
Workrooms.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #remove_invitee(rsvp_id, attributes, params = nil) ⇒ Object
- #update_announcement(announcement_id, attributes, params = nil) ⇒ Object
- #update_event(id, attributes, params = nil) ⇒ Object
- #update_event_category(id, attributes, params = nil) ⇒ Object
- #update_userclass(userclass_id, attributes, params = nil) ⇒ Object
- #update_workroom(id, attributes, params = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/boardeffect/client.rb', line 14 def initialize( = {}) setup_client() if !.key?(:test) auth = auth("#{API_PATH}/auth/api_key.json", { api_key: [:access_token]}) if auth[:success] == true @auth_header, @auth_value = 'Authorization', "Bearer #{auth[:data][:token]}" else raise Error, auth[:error][:message] end else @auth_header, @auth_value = 'Authorization', "Bearer #{options[:access_token]}" end end |
Instance Method Details
#add_invitee(rsvp_id, attributes, params = nil) ⇒ Object
69 70 71 72 73 |
# File 'lib/boardeffect.rb', line 69 def add_invitee(rsvp_id, attributes, params = nil) raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric post("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps/#{rsvp_id}/add_invitee.json", attributes) end |
#auth(path, attributes) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/boardeffect/client.rb', line 28 def auth(path, attributes) http_request = Net::HTTP::Post.new(path) http_request['Content-Type'] = 'application/json' http_request.body = JSON.generate(attributes) parse(@http.request(http_request)) end |
#create_announcement(attributes, params = nil) ⇒ Object
12 13 14 |
# File 'lib/boardeffect.rb', line 12 def create_announcement(attributes, params = nil) post("/#{workroom_check(params)}announcements.json", attributes) end |
#create_event(attributes, params = nil) ⇒ Object
33 34 35 |
# File 'lib/boardeffect.rb', line 33 def create_event(attributes, params = nil) post("/#{workroom_check(params)}events.json", attributes) end |
#create_event_category(attributes, params = nil) ⇒ Object
123 124 125 |
# File 'lib/boardeffect.rb', line 123 def create_event_category(attributes, params = nil) post("/eventcolors.json", attributes) end |
#create_rsvp(attributes, params = nil) ⇒ Object
58 59 60 61 |
# File 'lib/boardeffect.rb', line 58 def create_rsvp(attributes, params = nil) raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric post("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps.json", attributes) end |
#create_userclass(attributes, params = nil) ⇒ Object
152 153 154 |
# File 'lib/boardeffect.rb', line 152 def create_userclass(attributes, params = nil) post("/userclasses.json", attributes) end |
#create_workroom(attributes, params = nil) ⇒ Object
196 197 198 |
# File 'lib/boardeffect.rb', line 196 def create_workroom(attributes, params = nil) post("/workrooms.json", attributes) end |
#delete_announcement(announcement_id, params = nil) ⇒ Object
24 25 26 |
# File 'lib/boardeffect.rb', line 24 def delete_announcement(announcement_id, params = nil) delete("/#{workroom_check(params)}announcements/#{announcement_id}.json") end |
#delete_event(id, params = nil) ⇒ Object
47 48 49 50 |
# File 'lib/boardeffect.rb', line 47 def delete_event(id, params = nil) raise Error, "Event ID is required" unless id.is_a? Numeric delete("/#{workroom_check(params)}events/#{id}.json") end |
#delete_event_category(id, params = nil) ⇒ Object
137 138 139 140 |
# File 'lib/boardeffect.rb', line 137 def delete_event_category(id, params = nil) raise Error, "Eventcolor ID is required" unless id.is_a? Numeric delete("/eventcolors/#{id}.json") end |
#delete_userclass(userclass_id, params = nil) ⇒ Object
166 167 168 169 |
# File 'lib/boardeffect.rb', line 166 def delete_userclass(userclass_id, params = nil) raise Error, "Userclass ID is required" unless userclass_id.is_a? Numeric delete("/userclasses/#{userclass_id}.json") end |
#delete_workroom(id, params = nil) ⇒ Object
210 211 212 213 |
# File 'lib/boardeffect.rb', line 210 def delete_workroom(id, params = nil) raise Error, "Workroom ID is required" unless id.is_a? Numeric delete("/workrooms/#{id}.json") end |
#get(path, params = nil) ⇒ Object
35 36 37 |
# File 'lib/boardeffect/client.rb', line 35 def get(path, params = nil) request(Net::HTTP::Get.new(request_uri(path, params))) end |
#get_announcement(announcement_id, params = nil) ⇒ Object
20 21 22 |
# File 'lib/boardeffect.rb', line 20 def get_announcement(announcement_id, params = nil) get("/#{workroom_check(params)}announcements/#{announcement_id}.json") end |
#get_announcements(params = nil) ⇒ Object
Announcements
8 9 10 |
# File 'lib/boardeffect.rb', line 8 def get_announcements(params = nil) get("/#{workroom_check(params)}announcements.json", params) end |
#get_book(book_id, params = nil) ⇒ Object
86 87 88 89 |
# File 'lib/boardeffect.rb', line 86 def get_book(book_id, params = nil) raise Error, "Book ID is required" unless book_id.is_a? Numeric get("/#{workroom_check(params)}books/#{book_id}.json") end |
#get_books(params = nil) ⇒ Object
Books
82 83 84 |
# File 'lib/boardeffect.rb', line 82 def get_books(params = nil) get("/#{workroom_check(params)}books.json", params) end |
#get_client(client_id) ⇒ Object
Clients
92 93 94 95 |
# File 'lib/boardeffect.rb', line 92 def get_client(client_id) raise Error, "Client ID is required" unless client_id.is_a? Numeric get("/clients/#{client_id}.json") end |
#get_custom_fields(params = nil) ⇒ Object
Custom Fields
98 99 100 |
# File 'lib/boardeffect.rb', line 98 def get_custom_fields(params = nil) get("/custom_fields.json") end |
#get_discussion(discussion_id, params = nil) ⇒ Object
107 108 109 |
# File 'lib/boardeffect.rb', line 107 def get_discussion(discussion_id, params = nil) get("/#{workroom_check(params)}discussions/#{discussion_id}.json") end |
#get_discussion_post(discussion_id, post_id, params = nil) ⇒ Object
Discussion Posts
112 113 114 115 116 |
# File 'lib/boardeffect.rb', line 112 def get_discussion_post(discussion_id, post_id, params = nil) raise Error, "Discussion ID is required" unless discussion_id.is_a? Numeric raise Error, "Discussion Post ID is required" unless post_id.is_a? Numeric get("/#{workroom_check(params)}discussions/#{discussion_id}/discussion_posts/#{post_id}.json") end |
#get_discussions(params = nil) ⇒ Object
Discussions
103 104 105 |
# File 'lib/boardeffect.rb', line 103 def get_discussions(params = nil) get("/#{workroom_check(params)}discussions.json") end |
#get_event(id, params = nil) ⇒ Object
42 43 44 45 |
# File 'lib/boardeffect.rb', line 42 def get_event(id, params = nil) raise Error, "Event ID is required" unless id.is_a? Numeric get("/#{workroom_check(params)}events/#{id}.json") end |
#get_event_categories(params = nil) ⇒ Object
Event Categories
119 120 121 |
# File 'lib/boardeffect.rb', line 119 def get_event_categories(params = nil) get("/eventcolors.json", params) end |
#get_event_category(id, params = nil) ⇒ Object
132 133 134 135 |
# File 'lib/boardeffect.rb', line 132 def get_event_category(id, params = nil) raise Error, "Eventcolor ID is required" unless id.is_a? Numeric get("/eventcolors/#{id}.json") end |
#get_events(params = nil) ⇒ Object
Events
29 30 31 |
# File 'lib/boardeffect.rb', line 29 def get_events(params = nil) get("/#{workroom_check(params)}events.json", params) end |
#get_rsvp(rsvp_id, params = nil) ⇒ Object
63 64 65 66 67 |
# File 'lib/boardeffect.rb', line 63 def get_rsvp(rsvp_id, params = nil) raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric get("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps/#{rsvp_id}.json") end |
#get_rsvps(params = nil) ⇒ Object
RSVPS
53 54 55 56 |
# File 'lib/boardeffect.rb', line 53 def get_rsvps(params = nil) raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric get("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps.json") end |
#get_surveys(params = nil) ⇒ Object
Surveys
143 144 145 |
# File 'lib/boardeffect.rb', line 143 def get_surveys(params = nil) get("/#{workroom_check(params)}surveys.json") end |
#get_user(id) ⇒ Object
176 177 178 179 |
# File 'lib/boardeffect.rb', line 176 def get_user(id) raise Error, "User ID is required" unless id.is_a? Numeric get("/users/#{id}.json") end |
#get_userclass(userclass_id, params = nil) ⇒ Object
161 162 163 164 |
# File 'lib/boardeffect.rb', line 161 def get_userclass(userclass_id, params = nil) raise Error, "Userclass ID is required" unless userclass_id.is_a? Numeric get("/userclasses/#{userclass_id}.json") end |
#get_userclasses(params = nil) ⇒ Object
Userclasses
148 149 150 |
# File 'lib/boardeffect.rb', line 148 def get_userclasses(params = nil) get("/userclasses.json", params) end |
#get_users ⇒ Object
Users
172 173 174 |
# File 'lib/boardeffect.rb', line 172 def get_users get("/users.json") end |
#get_workgroup(id) ⇒ Object
186 187 188 189 |
# File 'lib/boardeffect.rb', line 186 def get_workgroup(id) raise Error, "Workgroup ID is required" unless id.is_a? Numeric get("/committeegroups/#{id}.json") end |
#get_workgroups ⇒ Object
Workgroups
182 183 184 |
# File 'lib/boardeffect.rb', line 182 def get_workgroups get("/committeegroups.json") end |
#get_workroom(id, params = nil) ⇒ Object
205 206 207 208 |
# File 'lib/boardeffect.rb', line 205 def get_workroom(id, params = nil) raise Error, "Workroom ID is required" unless id.is_a? Numeric get("/workrooms/#{id}.json") end |
#get_workrooms(params = nil) ⇒ Object
Workrooms
192 193 194 |
# File 'lib/boardeffect.rb', line 192 def get_workrooms(params = nil) get("/workrooms.json") end |
#remove_invitee(rsvp_id, attributes, params = nil) ⇒ Object
75 76 77 78 79 |
# File 'lib/boardeffect.rb', line 75 def remove_invitee(rsvp_id, attributes, params = nil) raise Error, "Event ID is required" unless params[:event_id].is_a? Numeric raise Error, "RSVP ID is required" unless rsvp_id.is_a? Numeric post("/#{workroom_check(params)}events/#{params[:event_id]}/rsvps/#{rsvp_id}/remove_invitee.json", attributes) end |
#update_announcement(announcement_id, attributes, params = nil) ⇒ Object
16 17 18 |
# File 'lib/boardeffect.rb', line 16 def update_announcement(announcement_id, attributes, params = nil) put("/#{workroom_check(params)}announcements/#{announcement_id}.json", attributes) end |
#update_event(id, attributes, params = nil) ⇒ Object
37 38 39 40 |
# File 'lib/boardeffect.rb', line 37 def update_event(id, attributes, params = nil) raise Error, "Event ID is required" unless id.is_a? Numeric put("/#{workroom_check(params)}events/#{id}.json", attributes) end |
#update_event_category(id, attributes, params = nil) ⇒ Object
127 128 129 130 |
# File 'lib/boardeffect.rb', line 127 def update_event_category(id, attributes, params = nil) raise Error, "Eventcolor ID is required" unless id.is_a? Numeric put("/eventcolors/#{id}.json", attributes) end |
#update_userclass(userclass_id, attributes, params = nil) ⇒ Object
156 157 158 159 |
# File 'lib/boardeffect.rb', line 156 def update_userclass(userclass_id, attributes, params = nil) raise Error, "Userclass ID is required" unless userclass_id.is_a? Numeric put("/userclasses/#{userclass_id}.json", attributes) end |
#update_workroom(id, attributes, params = nil) ⇒ Object
200 201 202 203 |
# File 'lib/boardeffect.rb', line 200 def update_workroom(id, attributes, params = nil) raise Error, "Workroom ID is required" unless id.is_a? Numeric put("/workrooms/#{id}.json", attributes) end |