Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[INACTIVE] play with creating a public api #90

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/controllers/api/v1/insta_users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Api
module V1
class InstaUsersController < ApplicationController
def index
@insta_users = InstaUser.all
respond_to do |format|
format.json
end
end

def show
@insta_user = InstaUser.find(params[:id])
respond_to do |format|
format.json
end
end
end
end
end
5 changes: 5 additions & 0 deletions app/views/api/v1/insta_users/_insta_user.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
json.extract! insta_user, :id, :remote_id, :username, :account_type, :media_count, :slug, :created_at, :updated_at
json.api_url api_v1_insta_users_path(insta_user, format: :json)
json.url insta_user_posts_url(insta_user, format: :json)

json.media_url insta_user_posts_url(insta_user, format: :json)
1 change: 1 addition & 0 deletions app/views/api/v1/insta_users/index.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.array! @insta_users, partial: 'api/v1/insta_users/insta_user', as: :insta_user
1 change: 1 addition & 0 deletions app/views/api/v1/insta_users/show.json.jbuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
json.partial! 'api/v1/insta_users/insta_user', insta_user: @insta_user
8 changes: 8 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
Rails.application.routes.draw do
# https://api.github.com/users/yshmarov
namespace :api do
namespace :v1 do
get 'insta_users', to: 'insta_users#index'
get 'insta_users/:id', to: 'insta_users#show'
end
end

root 'static_pages#landing_page'
get 'pricing', to: 'static_pages#pricing'
get 'terms', to: 'static_pages#terms'
Expand Down