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
- #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
- #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
- #send_invitation(emails, params = {}, headers = nil) ⇒ Object
- #signed_url(file_path, params = nil, 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
102 103 104 |
# File 'lib/esa/api_methods.rb', line 102 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
90 91 92 |
# File 'lib/esa/api_methods.rb', line 90 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
114 115 116 |
# File 'lib/esa/api_methods.rb', line 114 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
46 47 48 |
# File 'lib/esa/api_methods.rb', line 46 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
126 127 128 |
# File 'lib/esa/api_methods.rb', line 126 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
151 152 153 |
# File 'lib/esa/api_methods.rb', line 151 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
122 123 124 |
# File 'lib/esa/api_methods.rb', line 122 def categories(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/categories", params, headers) end |
#comment(comment_id, params = nil, headers = nil) ⇒ Object
62 63 64 |
# File 'lib/esa/api_methods.rb', line 62 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
98 99 100 |
# File 'lib/esa/api_methods.rb', line 98 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
54 55 56 57 58 59 60 |
# File 'lib/esa/api_methods.rb', line 54 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 |
#create_comment(post_number, params = nil, headers = nil) ⇒ Object
66 67 68 |
# File 'lib/esa/api_methods.rb', line 66 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
159 160 161 162 |
# File 'lib/esa/api_methods.rb', line 159 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
38 39 40 |
# File 'lib/esa/api_methods.rb', line 38 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
78 79 80 |
# File 'lib/esa/api_methods.rb', line 78 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
74 75 76 |
# File 'lib/esa/api_methods.rb', line 74 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
106 107 108 |
# File 'lib/esa/api_methods.rb', line 106 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
164 165 166 |
# File 'lib/esa/api_methods.rb', line 164 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
26 27 28 |
# File 'lib/esa/api_methods.rb', line 26 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
50 51 52 |
# File 'lib/esa/api_methods.rb', line 50 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
94 95 96 |
# File 'lib/esa/api_methods.rb', line 94 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
82 83 84 |
# File 'lib/esa/api_methods.rb', line 82 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
118 119 120 |
# File 'lib/esa/api_methods.rb', line 118 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
155 156 157 |
# File 'lib/esa/api_methods.rb', line 155 def emojis(params = nil, headers = nil) send_get("/v1/teams/#{current_team}/emojis", params, headers) end |
#invitation(params = nil, headers = nil) ⇒ Object
134 135 136 |
# File 'lib/esa/api_methods.rb', line 134 def invitation(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/invitation", params, headers) end |
#members(params = nil, headers = nil) ⇒ Object
22 23 24 |
# File 'lib/esa/api_methods.rb', line 22 def members(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/members", params, headers) end |
#pending_invitations(params = nil, headers = nil) ⇒ Object
142 143 144 |
# File 'lib/esa/api_methods.rb', line 142 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
34 35 36 |
# File 'lib/esa/api_methods.rb', line 34 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
86 87 88 |
# File 'lib/esa/api_methods.rb', line 86 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
30 31 32 |
# File 'lib/esa/api_methods.rb', line 30 def posts(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts", params, headers) end |
#regenerate_invitation(params = nil, headers = nil) ⇒ Object
138 139 140 |
# File 'lib/esa/api_methods.rb', line 138 def regenerate_invitation(params = nil, headers = nil) send_post("/v1/teams/#{current_team!}/invitation_regenerator", params, headers) end |
#send_invitation(emails, params = {}, headers = nil) ⇒ Object
146 147 148 149 |
# File 'lib/esa/api_methods.rb', line 146 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
195 196 197 |
# File 'lib/esa/api_methods.rb', line 195 def signed_url(file_path, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/signed_url/#{file_path}", params, headers) end |
#stats(params = nil, headers = nil) ⇒ Object
18 19 20 |
# File 'lib/esa/api_methods.rb', line 18 def stats(params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/stats", params, headers) end |
#tags(params = nil, headers = nil) ⇒ Object
130 131 132 |
# File 'lib/esa/api_methods.rb', line 130 def (params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/tags", params, headers) end |
#team(team_name, params = nil, headers = nil) ⇒ Object
14 15 16 |
# File 'lib/esa/api_methods.rb', line 14 def team(team_name, params = nil, headers = nil) send_get("/v1/teams/#{team_name}", params, headers) end |
#teams(params = nil, headers = nil) ⇒ Object
10 11 12 |
# File 'lib/esa/api_methods.rb', line 10 def teams(params = nil, headers = nil) send_get("/v1/teams", params, headers) end |
#update_comment(comment_id, params = nil, headers = nil) ⇒ Object
70 71 72 |
# File 'lib/esa/api_methods.rb', line 70 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
42 43 44 |
# File 'lib/esa/api_methods.rb', line 42 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
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/esa/api_methods.rb', line 178 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::UploadIO.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
6 7 8 |
# File 'lib/esa/api_methods.rb', line 6 def user(params = nil, headers = nil) send_get("/v1/user", params, headers) end |
#watchers(post_number, params = nil, headers = nil) ⇒ Object
110 111 112 |
# File 'lib/esa/api_methods.rb', line 110 def watchers(post_number, params = nil, headers = nil) send_get("/v1/teams/#{current_team!}/posts/#{post_number}/watchers", params, headers) end |