Class: ChinoRuby::UserSchemas

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_user_schema(description, fields) ⇒ Object



567
568
569
570
571
572
573
574
# File 'lib/chino_ruby/classes.rb', line 567

def create_user_schema(description, fields)
  check_string(description)
  check_json(fields)
  data = {"description": description, "structure": { "fields": fields}}.to_json
  schema = UserSchema.new
  schema.from_json(post_resource("/user_schemas", data).to_json, true)
  schema
end

#delete_user_schema(user_schema_id, force) ⇒ Object



586
587
588
589
590
# File 'lib/chino_ruby/classes.rb', line 586

def delete_user_schema(user_schema_id, force)
  check_string(user_schema_id)
  check_boolean(force)
  delete_resource("/user_schemas/#{user_schema_id}", force)
end

#get_user_schema(user_schema_id) ⇒ Object



543
544
545
546
547
548
# File 'lib/chino_ruby/classes.rb', line 543

def get_user_schema(user_schema_id)
  check_string(user_schema_id)
  u = UserSchema.new
  u.from_json(get_resource("/user_schemas/#{user_schema_id}").to_json, true)
  u
end

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



550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
# File 'lib/chino_ruby/classes.rb', line 550

def list_user_schemas(limit=nil, offset=nil)
  schemas = GetUserSchemasResponse.new
  if limit==nil && offset==nil
    schemas.from_json(get_resource("/user_schemas", ChinoRuby::QUERY_DEFAULT_LIMIT, 0).to_json)
  else
    schemas.from_json(get_resource("/user_schemas", limit, offset).to_json)
  end
  us = schemas.user_schemas
  schemas.user_schemas = []
  us.each do |u|
    schema = UserSchema.new
    schema.from_json(u.to_json)
    schemas.user_schemas.push(schema)
  end
  schemas
end

#update_user_schema(user_schema_id, description, fields) ⇒ Object



576
577
578
579
580
581
582
583
584
# File 'lib/chino_ruby/classes.rb', line 576

def update_user_schema(user_schema_id, description, fields)
  check_string(user_schema_id)
  check_string(description)
  check_json(fields)
  data = {"description": description, "structure": { "fields": fields}}.to_json
  schema = UserSchema.new
  schema.from_json(put_resource("/user_schemas/#{user_schema_id}", data).to_json, true)
  schema
end