Permalink
Browse files

- API v1 Launch changes

  • Loading branch information...
1 parent 239040b commit 129c91a95fcbce4f2722eb71b0501d4c6ba421f3 @d33psky d33psky committed Mar 6, 2013
View
@@ -6,6 +6,7 @@ Sample applications for the Shapeways REST API in various languages.
## Languages
- PHP/PECL
+- PHP/CURL
- NodeJS
## TODO
@@ -14,7 +15,6 @@ Sample applications for the Shapeways REST API in various languages.
- C++
- Java
- Perl
-- PHP/CURL
- Python
- Ruby
View
@@ -51,7 +51,7 @@ app.get '/upload', (req, res) ->
# Display file upload dialog
res.render 'model/upload.jade'
-app.post '/model/upload', (req, res) ->
+app.post '/models/upload', (req, res) ->
# Process model upload
if !isLoggedIn(req.session)
res.redirect '/login'
@@ -60,7 +60,7 @@ app.post '/model/upload', (req, res) ->
model.putModel req.files.modelUpload, req.session.oauth_access_token, req.session.oauth_access_token_secret, (callback) ->
res.render 'model/upload_success.jade', { "callback": JSON.parse callback }
-app.get '/model/:id', (req, res) ->
+app.get '/models/:id', (req, res) ->
if !isLoggedIn(req.session)
res.redirect '/login'
else
View
@@ -68,7 +68,7 @@
}
});
- app.post('/model/upload', function(req, res) {
+ app.post('/models/upload', function(req, res) {
if (!isLoggedIn(req.session)) {
return res.redirect('/login');
} else {
@@ -80,7 +80,7 @@
}
});
- app.get('/model/:id', function(req, res) {
+ app.get('/models/:id', function(req, res) {
if (!isLoggedIn(req.session)) {
return res.redirect('/login');
} else {
@@ -9,7 +9,7 @@ exports.Model = class Model
getModels: (oauth_access_token, oauth_access_token_secret, callback) ->
# Note: getModels, getModel should utilize same function with overloaded optional parameter :modelId
- auth.oa.getProtectedResource "http://#{cfg.API_SERVER}/model/#{cfg.API_VERSION}", 'GET', oauth_access_token, oauth_access_token_secret, (error, data, response) ->
+ auth.oa.getProtectedResource "http://#{cfg.API_SERVER}/models/#{cfg.API_VERSION}", 'GET', oauth_access_token, oauth_access_token_secret, (error, data, response) ->
if error
console.log 'error :' + JSON.stringify error
@@ -18,7 +18,7 @@ exports.Model = class Model
getModel: (id, oauth_access_token, oauth_access_token_secret, callback) ->
# Note: getModel should utilize same function with overloaded optional parameter :modelId
- auth.oa.getProtectedResource "http://#{cfg.API_SERVER}/model/#{id}/#{cfg.API_VERSION}", 'GET', oauth_access_token, oauth_access_token_secret, (error, data, response) ->
+ auth.oa.getProtectedResource "http://#{cfg.API_SERVER}/models/#{id}/#{cfg.API_VERSION}", 'GET', oauth_access_token, oauth_access_token_secret, (error, data, response) ->
if error
console.log 'error :' + JSON.stringify error
@@ -38,11 +38,11 @@ exports.Model = class Model
acceptTermsAndConditions: 1
}
- auth.oa.post "http://#{cfg.API_SERVER}/model/#{cfg.API_VERSION}", oauth_access_token, oauth_access_token_secret, upload, (error, data, response) ->
+ auth.oa.post "http://#{cfg.API_SERVER}/models/#{cfg.API_VERSION}", oauth_access_token, oauth_access_token_secret, upload, (error, data, response) ->
if error
console.log 'ERROR:'
console.log error
# Redirect to error page?
else
# Send model information
- callback data
+ callback data
View
@@ -20,7 +20,7 @@
function Model() {}
Model.prototype.getModels = function(oauth_access_token, oauth_access_token_secret, callback) {
- return auth.oa.getProtectedResource("http://" + cfg.API_SERVER + "/model/" + cfg.API_VERSION, 'GET', oauth_access_token, oauth_access_token_secret, function(error, data, response) {
+ return auth.oa.getProtectedResource("http://" + cfg.API_SERVER + "/models/" + cfg.API_VERSION, 'GET', oauth_access_token, oauth_access_token_secret, function(error, data, response) {
if (error) {
console.log('error :' + JSON.stringify(error));
}
@@ -29,7 +29,7 @@
};
Model.prototype.getModel = function(id, oauth_access_token, oauth_access_token_secret, callback) {
- return auth.oa.getProtectedResource("http://" + cfg.API_SERVER + "/model/" + id + "/" + cfg.API_VERSION, 'GET', oauth_access_token, oauth_access_token_secret, function(error, data, response) {
+ return auth.oa.getProtectedResource("http://" + cfg.API_SERVER + "/models/" + id + "/" + cfg.API_VERSION, 'GET', oauth_access_token, oauth_access_token_secret, function(error, data, response) {
if (error) {
console.log('error :' + JSON.stringify(error));
}
@@ -48,7 +48,7 @@
ownOrAuthorizedModel: 1,
acceptTermsAndConditions: 1
});
- return auth.oa.post("http://" + cfg.API_SERVER + "/model/" + cfg.API_VERSION, oauth_access_token, oauth_access_token_secret, upload, function(error, data, response) {
+ return auth.oa.post("http://" + cfg.API_SERVER + "/models/" + cfg.API_VERSION, oauth_access_token, oauth_access_token_secret, upload, function(error, data, response) {
if (error) {
console.log('ERROR:');
return console.log(error);
View
@@ -1,6 +1,6 @@
{
"name": "shapeways"
- , "version": "0.0.1"
+ , "version": "0.0.2"
, "description": "API Wrapper for the Shapeways API in NodeJS"
, "homepage": "http://www.shapeways.com"
, "keywords": ["shapeways", "3d", "printing"]
@@ -26,4 +26,4 @@
, "scripts": {
"test": "make test"
}
-}
+}
@@ -16,7 +16,7 @@
}
try {
- $oauth->fetch($api_url_base ."/api/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/api/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -22,7 +22,7 @@
"scale" => 1,
);
$data_string = json_encode($data);
- $oauth->fetch($api_url_base ."/cart/v1", $data_string, OAUTH_HTTP_METHOD_POST);
+ $oauth->fetch($api_url_base ."/orders/cart/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -15,7 +15,7 @@
}
try {
- $oauth->fetch($api_url_base ."/cart/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/orders/cart/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -16,7 +16,7 @@
try {
$materialId = 26; # CHANGEME
- $oauth->fetch($api_url_base ."/material/$materialId/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/materials/$materialId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -15,7 +15,7 @@
}
try {
- $oauth->fetch($api_url_base ."/material/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/materials/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -16,7 +16,8 @@
try {
$modelId = 1234567; # CHANGEME
- $oauth->fetch($api_url_base ."/model/$modelId/v1", null, OAUTH_HTTP_METHOD_GET);
+ $modelVersion = 0; # CHANGEME
+ $oauth->fetch($api_url_base ."/models/$modelId/files/$modelVersion/v1?file=true", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -16,7 +16,7 @@
try {
$modelId = 1234567; # CHANGEME
- $oauth->fetch($api_url_base ."/model/$modelId/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/models/$modelId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -23,7 +23,7 @@
"acceptTermsAndConditions" => 1,
);
$data_string = json_encode($data);
- $oauth->fetch($api_url_base ."/model/v1", $data_string, OAUTH_HTTP_METHOD_POST);
+ $oauth->fetch($api_url_base ."/models/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -35,7 +35,7 @@
);
$data_string = json_encode($data);
- $oauth->fetch($api_url_base ."/price/model/v1", $data_string, OAUTH_HTTP_METHOD_POST);
+ $oauth->fetch($api_url_base ."/price/v1", $data_string, OAUTH_HTTP_METHOD_POST, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -16,7 +16,7 @@
try {
$printerId=1;
- $oauth->fetch($api_url_base ."/printer/$printerId/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/printers/$printerId/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {
@@ -15,7 +15,7 @@
}
try {
- $oauth->fetch($api_url_base ."/printer/v1", null, OAUTH_HTTP_METHOD_GET);
+ $oauth->fetch($api_url_base ."/printers/v1", null, OAUTH_HTTP_METHOD_GET, array("Accept" => "application/json"));
$response = $oauth->getLastResponse();
$json = json_decode($response);
if (null == $json) {

0 comments on commit 129c91a

Please sign in to comment.