Module: Esa::ApiMethods
- Included in:
- Client
- Defined in:
- lib/esa/api_methods.rb
Defined Under Namespace
Classes: PathStringIO
Constant Summary collapse
- HTTP_REGEX =
%r{^https?://}
Instance Method Summary collapse
- #add_comment_star(comment_id, params = nil, headers = nil) ⇒ Object
- #add_post_star(post_number, params = nil, headers = nil) ⇒ Object
- #add_watch(post_number, params = nil, headers = nil) ⇒ Object
- #append_post(post_number, params = nil, headers = nil) ⇒ Object
- #batch_move_category(params = nil, headers = nil) ⇒ Object
- #cancel_invitation(code, params = nil, headers = nil) ⇒ Object
- #categories(params = nil, headers = nil) ⇒ Object
- #comment(comment_id, params = nil, headers = nil) ⇒ Object
- #comment_stargazers(comment_id, params = nil, headers = nil) ⇒ Object
- #comments(post_number = nil, params = nil, headers = nil) ⇒ Object
- #compare_revisions(post_number, from_revision_number, to_revision_number, params = nil, headers = nil) ⇒ Object
- #create_comment(post_number, params = nil, headers = nil) ⇒ Object
- #create_emoji(params = nil, headers = nil) ⇒ Object
- #create_post(params = nil, headers = nil) ⇒ Object
- #create_sharing(post_number, params = nil, headers = nil) ⇒ Object
- #delete_comment(comment_id, params = nil, headers = nil) ⇒ Object
- #delete_comment_star(comment_id, params = nil, headers = nil) ⇒ Object
- #delete_emoji(emoji_code, params = nil, headers = nil) ⇒ Object
- #delete_member(screen_name, params = nil, headers = nil) ⇒ Object
- #delete_post(post_number, params = nil, headers = nil) ⇒ Object
- #delete_post_star(post_number, params = nil, headers = nil) ⇒ Object
- #delete_sharing(post_number, params = nil, headers = nil) ⇒ Object
- #delete_watch(post_number, params = nil, headers = nil) ⇒ Object
- #emojis(params = nil, headers = nil) ⇒ Object
- #invitation(params = nil, headers = nil) ⇒ Object
- #member(identifier, params = nil, headers = nil) ⇒ Object
- #members(params = nil, headers = nil) ⇒ Object
- #pending_invitations(params = nil, headers = nil) ⇒ Object
- #post(post_number, params = nil, headers = nil) ⇒ Object
- #post_stargazers(post_number, params = nil, headers = nil) ⇒ Object
- #posts(params = nil, headers = nil) ⇒ Object
- #regenerate_invitation(params = nil, headers = nil) ⇒ Object
- #revision(post_number, revision_number, params = nil, headers = nil) ⇒ Object
- #revisions(post_number, params = nil, headers = nil) ⇒ Object
- #send_invitation(emails, params = {}, headers = nil) ⇒ Object
- #signed_url(file_path, params = nil, headers = nil) ⇒ Object
- #signed_urls(file_urls, params = {}, headers = nil) ⇒ Object
- #stats(params = nil, headers = nil) ⇒ Object
- #tags(params = nil, headers = nil) ⇒ Object
- #team(team_name, params = nil, headers = nil) ⇒ Object
- #teams(params = nil, headers = nil) ⇒ Object
- #update_comment(comment_id, params = nil, headers = nil) ⇒ Object
- #update_post(post_number, params = nil, headers = nil) ⇒ Object
-
#upload_attachment(path_or_file_or_url, params = {}, headers = nil) ⇒ Object
beta.
- #user(params = nil, headers = nil) ⇒ Object
- #watchers(post_number, params = nil, headers = nil) ⇒ Object
Instance Method Details
#add_comment_star(comment_id, params = nil, headers = nil) ⇒ Object
120 121 122 |
# File 'lib/esa/api_methods.rb', line 120 def add_comment_star(comment_id, params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/comments/#{comment_id}/star", params, headers) end |
#add_post_star(post_number, params = nil, headers = nil) ⇒ Object
108 109 110 |
# File 'lib/esa/api_methods.rb', line 108 def add_post_star(post_number, params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/posts/#{post_number}/star", params, headers) end |
#add_watch(post_number, params = nil, headers = nil) ⇒ Object
132 133 134 |
# File 'lib/esa/api_methods.rb', line 132 def add_watch(post_number, params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/posts/#{post_number}/watch", params, headers) end |
#append_post(post_number, params = nil, headers = nil) ⇒ Object
52 53 54 |
# File 'lib/esa/api_methods.rb', line 52 def append_post(post_number, params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/posts/#{post_number}/append", wrap(params, :post), headers) end |
#batch_move_category(params = nil, headers = nil) ⇒ Object
144 145 146 |
# File 'lib/esa/api_methods.rb', line 144 def batch_move_category(params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/categories/batch_move", params, headers) end |
#cancel_invitation(code, params = nil, headers = nil) ⇒ Object
169 170 171 |
# File 'lib/esa/api_methods.rb', line 169 def cancel_invitation(code, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/invitations/#{code}", params, headers) end |
#categories(params = nil, headers = nil) ⇒ Object
140 141 142 |
# File 'lib/esa/api_methods.rb', line 140 def categories(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/categories", params, headers) end |
#comment(comment_id, params = nil, headers = nil) ⇒ Object
80 81 82 |
# File 'lib/esa/api_methods.rb', line 80 def comment(comment_id, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/comments/#{comment_id}", params, headers) end |
#comment_stargazers(comment_id, params = nil, headers = nil) ⇒ Object
116 117 118 |
# File 'lib/esa/api_methods.rb', line 116 def comment_stargazers(comment_id, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/comments/#{comment_id}/stargazers", params, headers) end |
#comments(post_number = nil, params = nil, headers = nil) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/esa/api_methods.rb', line 72 def comments(post_number = nil, params = nil, headers = nil) if post_number.nil? send_get("/v1/teams/#{current_team!}/comments", params, headers) else send_get("/v1/teams/#{current_team!}/posts/#{post_number}/comments", params, headers) end end |
#compare_revisions(post_number, from_revision_number, to_revision_number, params = nil, headers = nil) ⇒ Object
64 65 66 |
# File 'lib/esa/api_methods.rb', line 64 def compare_revisions(post_number, from_revision_number, to_revision_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}/revisions/compare/#{from_revision_number}...#{to_revision_number}", params, headers) end |
#create_comment(post_number, params = nil, headers = nil) ⇒ Object
84 85 86 |
# File 'lib/esa/api_methods.rb', line 84 def create_comment(post_number, params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/posts/#{post_number}/comments", wrap(params, :comment), headers) end |
#create_emoji(params = nil, headers = nil) ⇒ Object
177 178 179 180 |
# File 'lib/esa/api_methods.rb', line 177 def create_emoji(params = nil, headers = nil) params[:image] = Base64.strict_encode64(File.read(params[:image])) if params[:image] send_post("/v1/teams/#{current_team!}/emojis", wrap(params, :emoji), headers) end |
#create_post(params = nil, headers = nil) ⇒ Object
44 45 46 |
# File 'lib/esa/api_methods.rb', line 44 def create_post(params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/posts", wrap(params, :post), headers) end |
#create_sharing(post_number, params = nil, headers = nil) ⇒ Object
96 97 98 |
# File 'lib/esa/api_methods.rb', line 96 def create_sharing(post_number, params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/posts/#{post_number}/sharing", params, headers) end |
#delete_comment(comment_id, params = nil, headers = nil) ⇒ Object
92 93 94 |
# File 'lib/esa/api_methods.rb', line 92 def delete_comment(comment_id, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/comments/#{comment_id}", params, headers) end |
#delete_comment_star(comment_id, params = nil, headers = nil) ⇒ Object
124 125 126 |
# File 'lib/esa/api_methods.rb', line 124 def delete_comment_star(comment_id, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/comments/#{comment_id}/star", params, headers) end |
#delete_emoji(emoji_code, params = nil, headers = nil) ⇒ Object
182 183 184 |
# File 'lib/esa/api_methods.rb', line 182 def delete_emoji(emoji_code, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/emojis/#{emoji_code}", params, headers) end |
#delete_member(screen_name, params = nil, headers = nil) ⇒ Object
32 33 34 |
# File 'lib/esa/api_methods.rb', line 32 def delete_member(screen_name, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/members/#{screen_name}", params, headers) end |
#delete_post(post_number, params = nil, headers = nil) ⇒ Object
68 69 70 |
# File 'lib/esa/api_methods.rb', line 68 def delete_post(post_number, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/posts/#{post_number}", params, headers) end |
#delete_post_star(post_number, params = nil, headers = nil) ⇒ Object
112 113 114 |
# File 'lib/esa/api_methods.rb', line 112 def delete_post_star(post_number, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/posts/#{post_number}/star", params, headers) end |
#delete_sharing(post_number, params = nil, headers = nil) ⇒ Object
100 101 102 |
# File 'lib/esa/api_methods.rb', line 100 def delete_sharing(post_number, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/posts/#{post_number}/sharing", params, headers) end |
#delete_watch(post_number, params = nil, headers = nil) ⇒ Object
136 137 138 |
# File 'lib/esa/api_methods.rb', line 136 def delete_watch(post_number, params = nil, headers = nil) send_delete("/v1/teams/#{current_team!}/posts/#{post_number}/watch", params, headers) end |
#emojis(params = nil, headers = nil) ⇒ Object
173 174 175 |
# File 'lib/esa/api_methods.rb', line 173 def emojis(params = nil, headers = nil) send_get("/v1/teams/#{current_team}/emojis", params, headers) end |
#invitation(params = nil, headers = nil) ⇒ Object
152 153 154 |
# File 'lib/esa/api_methods.rb', line 152 def invitation(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/invitation", params, headers) end |
#member(identifier, params = nil, headers = nil) ⇒ Object
28 29 30 |
# File 'lib/esa/api_methods.rb', line 28 def member(identifier, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/members/#{identifier}", params, headers) end |
#members(params = nil, headers = nil) ⇒ Object
24 25 26 |
# File 'lib/esa/api_methods.rb', line 24 def members(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/members", params, headers) end |
#pending_invitations(params = nil, headers = nil) ⇒ Object
160 161 162 |
# File 'lib/esa/api_methods.rb', line 160 def pending_invitations(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/invitations", params, headers) end |
#post(post_number, params = nil, headers = nil) ⇒ Object
40 41 42 |
# File 'lib/esa/api_methods.rb', line 40 def post(post_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}", params, headers) end |
#post_stargazers(post_number, params = nil, headers = nil) ⇒ Object
104 105 106 |
# File 'lib/esa/api_methods.rb', line 104 def post_stargazers(post_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}/stargazers", params, headers) end |
#posts(params = nil, headers = nil) ⇒ Object
36 37 38 |
# File 'lib/esa/api_methods.rb', line 36 def posts(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts", params, headers) end |
#regenerate_invitation(params = nil, headers = nil) ⇒ Object
156 157 158 |
# File 'lib/esa/api_methods.rb', line 156 def regenerate_invitation(params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/invitation_regenerator", params, headers) end |
#revision(post_number, revision_number, params = nil, headers = nil) ⇒ Object
60 61 62 |
# File 'lib/esa/api_methods.rb', line 60 def revision(post_number, revision_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}/revisions/#{revision_number}", params, headers) end |
#revisions(post_number, params = nil, headers = nil) ⇒ Object
56 57 58 |
# File 'lib/esa/api_methods.rb', line 56 def revisions(post_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}/revisions", params, headers) end |
#send_invitation(emails, params = {}, headers = nil) ⇒ Object
164 165 166 167 |
# File 'lib/esa/api_methods.rb', line 164 def send_invitation(emails, params = {}, headers = nil) params = params.merge(member: { emails: emails } ) send_post("/v1/teams/#{current_team!}/invitations", params, headers) end |
#signed_url(file_path, params = nil, headers = nil) ⇒ Object
213 214 215 |
# File 'lib/esa/api_methods.rb', line 213 def signed_url(file_path, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/signed_url/#{file_path}", params, headers) end |
#signed_urls(file_urls, params = {}, headers = nil) ⇒ Object
217 218 219 220 |
# File 'lib/esa/api_methods.rb', line 217 def signed_urls(file_urls, params = {}, headers = nil) params = params.merge(urls: file_urls) send_post("/v1/teams/#{current_team!}/signed_urls", params, headers) end |
#stats(params = nil, headers = nil) ⇒ Object
20 21 22 |
# File 'lib/esa/api_methods.rb', line 20 def stats(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/stats", params, headers) end |
#tags(params = nil, headers = nil) ⇒ Object
148 149 150 |
# File 'lib/esa/api_methods.rb', line 148 def (params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/tags", params, headers) end |
#team(team_name, params = nil, headers = nil) ⇒ Object
16 17 18 |
# File 'lib/esa/api_methods.rb', line 16 def team(team_name, params = nil, headers = nil) send_get("/v1/teams/#{team_name}", params, headers) end |
#teams(params = nil, headers = nil) ⇒ Object
12 13 14 |
# File 'lib/esa/api_methods.rb', line 12 def teams(params = nil, headers = nil) send_get("/v1/teams", params, headers) end |
#update_comment(comment_id, params = nil, headers = nil) ⇒ Object
88 89 90 |
# File 'lib/esa/api_methods.rb', line 88 def update_comment(comment_id, params = nil, headers = nil) send_patch("/v1/teams/#{current_team!}/comments/#{comment_id}", wrap(params, :comment), headers) end |
#update_post(post_number, params = nil, headers = nil) ⇒ Object
48 49 50 |
# File 'lib/esa/api_methods.rb', line 48 def update_post(post_number, params = nil, headers = nil) send_patch("/v1/teams/#{current_team!}/posts/#{post_number}", wrap(params, :post), headers) end |
#upload_attachment(path_or_file_or_url, params = {}, headers = nil) ⇒ Object
beta
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/esa/api_methods.rb', line 196 def (path_or_file_or_url, params = {}, headers = nil) file = file_from(path_or_file_or_url) setup_params_for_upload(params, file) response = send_post("/v1/teams/#{current_team!}/attachments/policies", params, headers) return response unless response.status == 200 = response.body['attachment'] form_data = response.body['form'].merge(file: Faraday::FilePart.new(file, params[:type])) s3_response = send_s3_request(:post, ['endpoint'], form_data) return s3_response unless s3_response.status == 204 response.body.delete('form') response end |
#user(params = nil, headers = nil) ⇒ Object
8 9 10 |
# File 'lib/esa/api_methods.rb', line 8 def user(params = nil, headers = nil) send_get("/v1/user", params, headers) end |
#watchers(post_number, params = nil, headers = nil) ⇒ Object
128 129 130 |
# File 'lib/esa/api_methods.rb', line 128 def watchers(post_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}/watchers", params, headers) end |