Class: Applications

Inherits:
ChinoBaseAPI show all
Defined in:
lib/chino_ruby.rb

Instance Method Summary collapse

Methods inherited from ChinoBaseAPI

#delete_resource, #get_resource, #initialize, #parse_response, #patch_resource, #post_resource, #post_resource_with_string_result, #put_resource, #return_uri

Methods inherited from CheckValues

#check_boolean, #check_int, #check_json, #check_string

Constructor Details

This class inherits a constructor from ChinoBaseAPI

Instance Method Details

#create_application(name, grant_type, redirect_url) ⇒ Object



370
371
372
373
374
375
376
377
378
# File 'lib/chino_ruby.rb', line 370

def create_application(name, grant_type, redirect_url)
    check_string(name)
    check_string(grant_type)
    check_string(redirect_url)
    data = {"name": name, "grant_type": grant_type, "redirect_url": redirect_url}.to_json
    app = Application.new
    app.from_json(post_resource("/auth/applications", data).to_json, true)
    app
end

#delete_application(app_id, force) ⇒ Object



391
392
393
394
395
# File 'lib/chino_ruby.rb', line 391

def delete_application(app_id, force)
    check_string(app_id)
    check_boolean(force)
    delete_resource("/auth/applications/#{app_id}", force)
end

#get_application(app_id) ⇒ Object



345
346
347
348
349
350
# File 'lib/chino_ruby.rb', line 345

def get_application(app_id)
    check_string(app_id)
    app = Application.new
    app.from_json(get_resource("/auth/applications/#{app_id}").to_json, true)
    app
end

#list_applications(limit = nil, offset = nil) ⇒ Object



352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/chino_ruby.rb', line 352

def list_applications(limit=nil, offset=nil)
    apps = GetApplicationsResponse.new
    if limit==nil && offset==nil
      apps.from_json(get_resource("/auth/applications", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
    else
      apps.from_json(get_resource("/auth/applications", limit, offset).to_json)
    end
    as = apps.applications
    apps.applications = []
    as.each do |a|
        app = Application.new
        app.app_id = a['app_id']
        app.app_name = a['app_name']
        apps.applications.push(app)
    end
    apps
end

#update_application(app_id, name, grant_type, redirect_url) ⇒ Object



380
381
382
383
384
385
386
387
388
389
# File 'lib/chino_ruby.rb', line 380

def update_application(app_id, name, grant_type, redirect_url)
    check_string(name)
    check_string(grant_type)
    check_string(redirect_url)
    check_string(app_id)
    data = {"name": name, "grant_type": grant_type, "redirect_url": redirect_url}.to_json
    app = Application.new
    app.from_json(put_resource("/auth/applications/#{app_id}", data).to_json, true)
    app
end