Class: ChinoRuby::Applications

Inherits:
ChinoBaseAPI show all
Defined in:
lib/chino_ruby/classes.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 ChinoRuby::ChinoBaseAPI

Instance Method Details

#create_application(name, grant_type, redirect_url) ⇒ Object



301
302
303
304
305
306
307
308
309
# File 'lib/chino_ruby/classes.rb', line 301

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



322
323
324
325
326
# File 'lib/chino_ruby/classes.rb', line 322

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



276
277
278
279
280
281
# File 'lib/chino_ruby/classes.rb', line 276

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



283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/chino_ruby/classes.rb', line 283

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



311
312
313
314
315
316
317
318
319
320
# File 'lib/chino_ruby/classes.rb', line 311

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