Skip to content

Commit

Permalink
Yay path versions
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtOfCode- committed Dec 14, 2017
1 parent 193783b commit 9c52943
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 24 deletions.
2 changes: 0 additions & 2 deletions app/api/api/announcements_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class AnnouncementsAPI < API::Base
prefix :announcements

get '/' do
std_result Announcement.all.order(id: :desc), filter: 'HNLMH'
end
Expand Down
2 changes: 0 additions & 2 deletions app/api/api/apps_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class AppsAPI < API::Base
prefix :apps

get '/' do
std_result APIKey.all.order(id: :desc), filter: 'MOGLMLJKJKJMNIMGHGKHJKGMOONLMOFGLNIIJLHIFJMLN'
end
Expand Down
17 changes: 8 additions & 9 deletions app/api/api/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class Base < Grape::API
version 'v2.0', using: :accept_version_header
prefix :api
format :json

helpers do
Expand Down Expand Up @@ -60,12 +58,13 @@ def single_result(item, **_opts)
authenticate_app!
end

mount API::DebugAPI
mount API::AnnouncementsAPI
mount API::AppsAPI
mount API::CommitStatusesAPI
mount API::DeletionLogsAPI
mount API::DomainTagsAPI
mount API::FeedbacksAPI
mount API::DebugAPI => 'v2.0/debug'
mount API::AnnouncementsAPI => 'v2.0/announcements'
mount API::AppsAPI => 'v2.0/apps'
mount API::CommitStatusesAPI => 'v2.0/commits'
mount API::DeletionLogsAPI => 'v2.0/deletions'
mount API::DomainTagsAPI => 'v2.0/tags'
mount API::FeedbacksAPI => 'v2.0/feedbacks'
mount API::PostsAPI => 'v2.0/posts'
end
end
2 changes: 0 additions & 2 deletions app/api/api/commit_statuses_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class CommitStatusesAPI < API::Base
prefix :commit_statuses

get '/' do
std_result CommitStatus.all.order(id: :desc), filter: 'GGOFONNHNJHHIHNJLHHGHGNGGGHLFGGGNNMJFFOL'
end
Expand Down
2 changes: 0 additions & 2 deletions app/api/api/debug_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class DebugAPI < API::Base
prefix :debug

get '/' do
{ params: params, ts: DateTime.now }
end
Expand Down
2 changes: 0 additions & 2 deletions app/api/api/deletion_logs_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class DeletionLogsAPI < API::Base
prefix :deletion_logs

get '/' do
std_result DeletionLog.all.order(id: :desc), filter: 'OIFJKOKOMFJOJJGGGGFIHLLJOJHGOLHJGHFIH'
end
Expand Down
2 changes: 0 additions & 2 deletions app/api/api/domain_tags_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

module API
class DomainTagsAPI < API::Base
prefix :domain_tags

get '/' do
std_result DomainTag.all.order(id: :desc), filter: 'NOL'
end
Expand Down
6 changes: 3 additions & 3 deletions app/api/api/feedbacks_api.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module API
class FeedbacksAPI < API::Base
prefix :feedbacks

get '/' do
std_result Feedback.all.order(id: :desc), filter: 'GNIFHNJLJHLIIKHLMIOFKLOOOOKLFKFFNINJ'
end
Expand Down Expand Up @@ -54,4 +54,4 @@ class FeedbacksAPI < API::Base
end
end
end
end
end
52 changes: 52 additions & 0 deletions app/api/api/posts_api.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# frozen_string_literal: true

module API
class PostsAPI < API::Base
get '/' do
std_result Post.all.order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'

This comment has been minimized.

Copy link
@j-f1

j-f1 Dec 15, 2017

Contributor

Could you extract these filters to a class variable of some sort in case they need to change later?

This comment has been minimized.

Copy link
@ArtOfCode-

ArtOfCode- Dec 15, 2017

Author Member
end

params do
requires :key, type: String
requires :from, type: DateTime
requires :to, type: DateTime
end
get 'date_range' do
std_result Post.where('created_at > ?', params[:from]).where('created_at < ?', params[:to]).order(id: :desc),
filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'
end

params do
requires :key, type: String
requires :site, type: String
end
get 'on_site' do
std_result Post.joins(:site).where(site: { site_domain: params[:site] }).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'
end

params do
requires :key, type: String
requires :urls, type: String
end
get 'urls' do
std_result Post.where(post_link: params[:urls].split(';')).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'
end

params do
requires :key, type: String
requires :type, type: String
end
get 'with_feedback' do
std_result Post.joins(:feedbacks).where(feedbacks: { feedback_type: params[:type] }).order(id: :desc),
filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'
end

get 'active' do
std_result Post.where(deleted_at: nil).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'
end

get 'ids/:ids' do
std_result Post.where(id: params[:ids].split(';')).order(id: :desc), filter: 'HKIFJIHNKLGNFNMFLOGIFLNLJLJ'
end
end
end

0 comments on commit 9c52943

Please sign in to comment.