Class: Auth::ClientsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/auth/clients_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_resource!, #build_model_from_params, #check_for_create, #check_for_destroy, #check_for_update, #from_bson, #from_view, #get_model_class_name, #instantiate_classes, #not_found

Instance Method Details

#createObject

POST /clients



42
43
44
# File 'app/controllers/auth/clients_controller.rb', line 42

def create
  render :nothing => true, :status => 200
end

#destroyObject

response status of 404 or 204 is ok. 404 means client doesnt exist 204 means it was destroyed. DELETE /clients/1



71
72
73
74
75
# File 'app/controllers/auth/clients_controller.rb', line 71

def destroy
  @client.destroy
  #redirect_to clients_url, notice: 'Client was successfully destroyed.'
  respond_with(status: 200)
end

#editObject

GET /clients/1/edit



36
37
38
39
# File 'app/controllers/auth/clients_controller.rb', line 36

def edit
  ## edit should show forms for adding an app id.
  ## design the form.
end

#indexObject

GET /clients



18
19
20
# File 'app/controllers/auth/clients_controller.rb', line 18

def index
  render :nothing => true, :status => 200
end

#newObject

GET /clients/new



30
31
32
33
# File 'app/controllers/auth/clients_controller.rb', line 30

def new
  #@client = Client.new
  render :nothing => true, :status => 200
end

#showObject

GET /clients/1



23
24
25
# File 'app/controllers/auth/clients_controller.rb', line 23

def show
  respond_with @client
end

#updateObject

response code of 204 is ok. anything else means fail. PATCH/PUT /clients/1



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/controllers/auth/clients_controller.rb', line 49

def update
  

  @client.redirect_urls << client_params[:add_redirect_url] if client_params[:add_redirect_url]
  
  @client.app_ids << BSON::ObjectId.new.to_s if client_params[:add_app_id]
  
  
  @client.versioned_update({"redirect_urls" => 1, "app_ids" => 1})

  if @client.op_success?
    render "show"
  else
    render "edit"
  end
  
end