@@ -71,7 +71,6 @@ public enum HeaderType
7171
7272 private readonly string wsapiVersion ;
7373 internal HttpService Service { get ; set ; }
74- private readonly Dictionary < string , DynamicJsonObject > typeDefs = new Dictionary < string , DynamicJsonObject > ( ) ;
7574
7675 internal string DecodeHeaderName ( HeaderType type )
7776 {
@@ -168,15 +167,15 @@ protected Uri GetFullyQualifiedUri(string aRef)
168167 return new Uri ( GetFullyQualifiedRef ( aRef ) ) ;
169168 }
170169
171- internal Uri FormatCreateString ( string type )
170+ internal Uri FormatCreateString ( string typePath )
172171 {
173- return new Uri ( Service . Server . AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + type + "/create.js" ) ;
172+ return new Uri ( Service . Server . AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + typePath + "/create.js" ) ;
174173 }
175174
176- internal Uri FormatUpdateString ( string type , long objectId )
175+ internal Uri FormatUpdateString ( string typePath , long objectId )
177176 {
178177 return
179- new Uri ( Service . Server . AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + type + "/" + objectId +
178+ new Uri ( Service . Server . AbsoluteUri + "slm/webservice/" + wsapiVersion + "/" + typePath + "/" + objectId +
180179 ".js" ) ;
181180 }
182181
@@ -348,13 +347,13 @@ public dynamic GetSubscription(params string[] fetchedFields)
348347 /// <summary>
349348 /// Get the object described by the specified type and object id.
350349 /// </summary>
351- /// <param name="type ">the type</param>
350+ /// <param name="typePath ">the type</param>
352351 /// <param name="oid">the object id</param>
353352 /// <param name="fetchedFields">the list of object fields to be fetched</param>
354353 /// <returns>The requested object</returns>
355- public dynamic GetByReference ( string type , long oid , params string [ ] fetchedFields )
354+ public dynamic GetByReference ( string typePath , long oid , params string [ ] fetchedFields )
356355 {
357- return GetByReference ( string . Format ( "/{0}/{1}" , type , oid ) , fetchedFields ) ;
356+ return GetByReference ( string . Format ( "/{0}/{1}" , typePath , oid ) , fetchedFields ) ;
358357 }
359358
360359 /// <summary>
@@ -391,12 +390,12 @@ public dynamic GetByReference(string aRef, params string[] fetchedFields)
391390 /// <summary>
392391 /// Delete the object described by the specified type and object id.
393392 /// </summary>
394- /// <param name="type ">the type</param>
393+ /// <param name="typePath ">the type</param>
395394 /// <param name="oid">the object id</param>
396395 /// <returns>An OperationResult with information on the status of the request</returns>
397- public OperationResult Delete ( string type , long oid )
396+ public OperationResult Delete ( string typePath , long oid )
398397 {
399- return Delete ( string . Format ( "/{0}/{1}" , type , oid ) ) ;
398+ return Delete ( string . Format ( "/{0}/{1}" , typePath , oid ) ) ;
400399 }
401400
402401 /// <summary>
@@ -420,17 +419,17 @@ public OperationResult Delete(string aRef)
420419 /// <summary>
421420 /// Create an object of the specified type from the specified object
422421 /// </summary>
423- /// <param name="type ">the type to be created</param>
422+ /// <param name="typePath ">the type to be created</param>
424423 /// <param name="obj">the object to be created</param>
425424 /// <returns></returns>
426- public CreateResult Create ( string type , DynamicJsonObject obj )
425+ public CreateResult Create ( string typePath , DynamicJsonObject obj )
427426 {
428427 var createResponse = new CreateResult ( ) ;
429428 var data = new DynamicJsonObject ( ) ;
430- data [ type ] = obj ;
429+ data [ typePath ] = obj ;
431430 string postData = serializer . Serialize ( data ) ;
432431 dynamic response =
433- serializer . Deserialize ( Service . Post ( FormatCreateString ( type ) , postData , GetProcessedHeaders ( ) ) ) ;
432+ serializer . Deserialize ( Service . Post ( FormatCreateString ( typePath ) , postData , GetProcessedHeaders ( ) ) ) ;
434433 if ( response . CreateResult . HasMember ( "Object" ) )
435434 {
436435 createResponse . Reference = response . CreateResult . Object . _ref as string ;
@@ -456,18 +455,18 @@ public OperationResult Update(string reference, DynamicJsonObject obj)
456455 /// Update the item described by the specified type and object id with
457456 /// the fields of the specified object
458457 /// </summary>
459- /// <param name="type ">the type of the item to be updated</param>
458+ /// <param name="typePath ">the type of the item to be updated</param>
460459 /// <param name="oid">the object id of the item to be updated</param>
461460 /// <param name="obj">the object fields to update</param>
462461 /// <returns>An OperationResult describing the status of the request</returns>
463- public OperationResult Update ( string type , long oid , DynamicJsonObject obj )
462+ public OperationResult Update ( string typePath , long oid , DynamicJsonObject obj )
464463 {
465464 var result = new OperationResult ( ) ;
466465 var data = new DynamicJsonObject ( ) ;
467- data [ type ] = obj ;
466+ data [ typePath ] = obj ;
468467 string postData = serializer . Serialize ( data ) ;
469468 dynamic response =
470- serializer . Deserialize ( Service . Post ( FormatUpdateString ( type , oid ) , postData , GetProcessedHeaders ( ) ) ) ;
469+ serializer . Deserialize ( Service . Post ( FormatUpdateString ( typePath , oid ) , postData , GetProcessedHeaders ( ) ) ) ;
471470 result . Errors . AddRange ( DecodeArrayList ( response . OperationResult . Errors ) ) ;
472471 result . Warnings . AddRange ( DecodeArrayList ( response . OperationResult . Warnings ) ) ;
473472 return result ;
@@ -476,63 +475,12 @@ public OperationResult Update(string type, long oid, DynamicJsonObject obj)
476475 /// <summary>
477476 /// Get the allowed values for the specified type and attribute
478477 /// </summary>
479- /// <param name="type ">the type</param>
478+ /// <param name="typePath ">the type</param>
480479 /// <param name="attribute">the attribute to retireve allowed values for</param>
481480 /// <returns>The allowed values for the specified attribute</returns>
482- public DynamicJsonObject GetAllowedAttributeValues ( string type , string attribute )
481+ public DynamicJsonObject GetAllowedAttributeValues ( string typePath , string attribute )
483482 {
484- return MakeRequest ( GetFullyQualifiedUri ( string . Format ( "/{0}/{1}/allowedValues.js" , type , attribute ) ) ) ;
485- }
486-
487- public List < DynamicJsonObject > GetTypeAttributes ( string typeName , Boolean cache )
488- {
489- DynamicJsonObject typeDef = GetTypeDef ( typeName , cache ) ;
490- var attributes = typeDef [ "Attributes" ] as ArrayList ;
491- return attributes . Cast < DynamicJsonObject > ( ) . OrderBy ( a => a [ "Name" ] ) . ToList ( ) ;
492- }
493-
494- public DynamicJsonObject GetTypeDef ( string typeName , Boolean cache )
495- {
496- if ( ! wsapiVersion . ToLower ( ) . Equals ( DEFAULT_WSAPI_VERSION . ToLower ( ) ) )
497- {
498- float apiVersion ;
499-
500- if ( float . TryParse ( wsapiVersion , out apiVersion ) )
501- {
502- if ( apiVersion < 1.25 )
503- throw new ArgumentOutOfRangeException ( String . Format ( "webServiveVersion must be '1.25' or greater to use this method. Received '{1}'" , wsapiVersion ) ) ;
504- }
505- else
506- {
507- throw new ArgumentException ( String . Format ( "webServiveVersion must be '{0}' or a floating point number. Received '{1}'" , DEFAULT_WSAPI_VERSION , wsapiVersion ) ) ;
508- }
509- }
510-
511- DynamicJsonObject typeDef = null ;
512-
513- if ( typeDefs . ContainsKey ( typeName ) )
514- {
515- typeDef = typeDefs [ typeName ] ;
516- }
517- else
518- {
519- var typeDefRequest = new Request ( "TypeDefinition" ) ;
520- typeDefRequest . Fetch = new List < string > ( ) { "true" } ;
521- typeDefRequest . Query = new Query ( "Name" , RestApi . Query . Operator . Equals , typeName ) ;
522- QueryResult result = Query ( typeDefRequest ) ;
523- if ( ! result . Success )
524- throw new Exception ( String . Format ( "Error fetching TypeDef for '{0}'\n \n {1}" , typeName , String . Join ( "\n " , result . Errors ) ) ) ;
525- else if ( result . TotalResultCount == 0 )
526- throw new Exception ( String . Format ( "No TypeDef found for '{0}'" , typeName ) ) ;
527- else if ( result . TotalResultCount > 1 )
528- throw new Exception ( String . Format ( "Too many ({0}) TypeDefs found for '{1}'" , result . TotalResultCount , typeName ) ) ;
529- typeDef = result . Results . First ( ) ;
530-
531- if ( cache )
532- typeDefs [ typeName ] = typeDef ;
533- }
534-
535- return typeDef ;
483+ return MakeRequest ( GetFullyQualifiedUri ( string . Format ( "/{0}/{1}/allowedValues.js" , typePath , attribute ) ) ) ;
536484 }
537485
538486 /// <summary>
0 commit comments