Skip to content
This repository has been archived by the owner on Jun 13, 2019. It is now read-only.

Commit

Permalink
OicClient: Remove suffix "Resource" from CRUD methods
Browse files Browse the repository at this point in the history
Change-Id: Idaf935960c9e8cebcfe240f1340137be205fe024
  • Loading branch information
Gabriel Schulhof committed Apr 22, 2016
1 parent 472f99f commit 6d32fdf
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions js/high-level-resource-creation-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ new Promise( function( fulfill, reject ) {
} );
} ).then( function( deviceId ) {
console.log( "deviceId discovered" );
return device.createResource( {
return device.create( {
id: {
deviceId: deviceId,
path: "/a/new-resource"
Expand All @@ -56,7 +56,7 @@ new Promise( function( fulfill, reject ) {
} ).then( function( resource ) {
console.log( "remote resource successfully created with id " +
JSON.stringify( resource.id ) );
return device.deleteResource( resource.id );
return device.delete( resource.id );
} ).then( function() {
console.log( "remote resource successfully deleted" );
} ).catch( throwError );
16 changes: 8 additions & 8 deletions lib/OicClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ _.extend( devicePrototype, {
}, this ) );
},

createResource: function( resource ) {
create: function( resource ) {
return this._oneShotRequest( {
prefix: "createResource",
prefix: "create",
resourceId: resource.id,
method: "OC_REST_POST",
payload: _.extend( utils.objectToPayload( resource.properties ), {
Expand All @@ -519,9 +519,9 @@ _.extend( devicePrototype, {
} );
},

retrieveResource: function( id, queryParameters ) {
retrieve: function( id, queryParameters ) {
return this._oneShotRequest( {
prefix: "retrieveResource",
prefix: "retrieve",
resourceId: _.extend( {}, id, queryParameters ? {
path: id.path + "?" + querystring.stringify( queryParameters )
} : {} ),
Expand All @@ -535,18 +535,18 @@ _.extend( devicePrototype, {
} );
},

updateResource: function( resource ) {
update: function( resource ) {
return this._oneShotRequest( {
prefix: "updateResource",
prefix: "update",
resourceId: resource.id,
method: "OC_REST_PUT",
payload: utils.objectToPayload( resource.properties )
} );
},

deleteResource: function( id ) {
delete: function( id ) {
return this._oneShotRequest( {
prefix: "deleteResource",
prefix: "delete",
resourceId: id,
method: "OC_REST_DELETE",
createAnswer: function deleteResourceFromResponse() {
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/API Complex Payload/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async.series( [
},

function performRetrieve( callback ) {
device.retrieveResource( resource.id ).then(
device.retrieve( resource.id ).then(
function( resource ) {
testUtils.assert( "deepEqual", resource.properties, {
primitiveValue: 42,
Expand All @@ -58,7 +58,7 @@ async.series( [
},

function performUpdate( callback ) {
device.updateResource( _.extend( resource, {
device.update( _.extend( resource, {
properties: {
putValue: "A string",
anotherPutValue: 23.7,
Expand Down
6 changes: 3 additions & 3 deletions tests/tests/API Create Delete/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ async.series( [
},

function createRemoteResource( callback ) {
device.createResource( newRemoteResourceTemplate ).then(
device.create( newRemoteResourceTemplate ).then(
function( resource ) {

// Use the newly created remote resource instead of the initial resource that we
Expand All @@ -86,7 +86,7 @@ async.series( [
},

function createDuplicateRemoteResource( callback ) {
device.createResource( newRemoteResourceTemplate ).then(
device.create( newRemoteResourceTemplate ).then(
function() {
callback( new Error( "Server created duplicate resource" ) );
}, function() {
Expand All @@ -97,7 +97,7 @@ async.series( [
},

function deleteRemoteResource( callback ) {
device.deleteResource( remoteResource.id ).then(
device.delete( remoteResource.id ).then(
function() {
utils.assert( "ok", true, "Client: Deleting the remote resource has succeeded" );
console.log( JSON.stringify( { killPeer: true } ) );
Expand Down
6 changes: 3 additions & 3 deletions tests/tests/API Error Propagation/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ async.series( [
},

function performFirstRetrieve( callback ) {
device.retrieveResource( id ).then(
device.retrieve( id ).then(
function() {
myUtils.die( "Client: First retrieve succeeded" );
},
function( error ) {
myUtils.assert( "ok", util.isError( error ),
"Client: First retrieve failed with Error" );
myUtils.assert( "strictEqual", error.message,
"retrieveResource: OCDoResource response failed",
"retrieve: OCDoResource response failed",
"Client: First error message is correct" );
myUtils.assert( "deepEqual", _.extend( {}, error ), {
result: 21,
Expand All @@ -59,7 +59,7 @@ async.series( [
},

function performSecondRetrieve( callback ) {
device.retrieveResource( id ).then(
device.retrieve( id ).then(
function() {
myUtils.die( "Client: Second retrieve succeeded" );
},
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/API Presence/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async.series( [

// Start the presence cycling
theResource.properties.op = "cyclePresence";
device.updateResource( theResource ).catch( cleanup );
device.update( theResource ).catch( cleanup );
}

], function( error ) {
Expand Down
4 changes: 2 additions & 2 deletions tests/tests/API Query Parameters/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ new Promise( function discoverTheResource( fulfill, reject ) {
device.addEventListener( "resourcefound", resourcefound );
device.findResources().catch( teardown );
} ).then( function retrieveTheResourceInGerman( resource ) {
return device.retrieveResource( resource.id, { language: "de" } );
return device.retrieve( resource.id, { language: "de" } );
} ).then( function checkGermanAndRetrieveInHungarian( resource ) {
utils.assert( "deepEqual", resource.properties,
{ "How many angels can dance on the head of a pin?": "As many as wanting." },
"Client: Answer for language de is as expected" );
return device.retrieveResource( resource.id, { language: "hu" } );
return device.retrieve( resource.id, { language: "hu" } );
} ).then( function checkHungarianAndQuit( resource ) {
utils.assert( "deepEqual", resource.properties,
{ "How many angels can dance on the head of a pin?": "Ahány akar." },
Expand Down
8 changes: 4 additions & 4 deletions tests/tests/API Retrieve/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ console.log( JSON.stringify( { assertionCount: 5 } ) );

async.series( [
function attemptFakeRetrieve( callback ) {
device.retrieveResource( { deviceId: "SomethingCrazy", path: "/going/nuts/here" } ).then(
device.retrieve( { deviceId: "SomethingCrazy", path: "/going/nuts/here" } ).then(
function( resource ) {
utils.assert( "ok", false, "Client: Retrieving fake resource succeeded: " +
JSON.stringify( resource ) );
callback();
},
function( error ) {
utils.assert( "strictEqual", "" + error,
"Error: retrieveResource: device not found",
"Error: retrieve: device not found",
"Client: Retrieving fake resource failed locally" );
callback();
} );
Expand All @@ -54,7 +54,7 @@ async.series( [
}, teardown );
},
function retrieveTheResource( callback ) {
device.retrieveResource( theResource.id ).then(
device.retrieve( theResource.id ).then(
function( resource ) {
utils.assert( "deepEqual", resource.properties, {
"How many angels can dance on the head of a pin?": "As many as wanting."
Expand All @@ -64,7 +64,7 @@ async.series( [
callback );
},
function retrieveTheResourceAgain( callback ) {
device.retrieveResource( theResource.id ).then(
device.retrieve( theResource.id ).then(
function() {
utils.assert( "ok", false,
"Client: Retrieving the resource a second time succeeded" );
Expand Down

0 comments on commit 6d32fdf

Please sign in to comment.