add new api

This commit is contained in:
Sunandar
2017-02-08 17:35:47 +06:30
parent 26d42631c7
commit 43ada02033
18 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the api/products controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the products controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,19 @@
class Api::ProductsController < ApplicationController
skip_before_filter :verify_authenticity_token
def index
session_token=params[:session_token]
check_member= Member.authenticate_session_token(session_token)
if !check_member.nil?
categories =ProductCategory.all
arr_category=Array.new
categories.each do |cat|
str={:id => cat.id,:name => cat.name}
arr_category.push(str)
end
@out=true,arr_category
else
@out=false,"Sorry!Unauthorized user!"
end
end
end

View File

@@ -0,0 +1,2 @@
module Api::ProductsHelper
end

View File

@@ -0,0 +1,2 @@
module ProductsHelper
end

View File

@@ -0,0 +1,3 @@
class ProductCategory < ApplicationRecord
end

View File

@@ -0,0 +1,2 @@
class ProductType < ApplicationRecord
end

View File

@@ -0,0 +1,7 @@
if @out[0] == true
json.set! :status, @out[0]
json.set! :data, @out[1]
else
json.set! :status, @out[0]
json.set! :message,@out[1]
end