Skip to content

Commit

Permalink
add work creation service & build
Browse files Browse the repository at this point in the history
  • Loading branch information
samsep committed Oct 16, 2015
1 parent bc7cac6 commit c681f97
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
49 changes: 49 additions & 0 deletions dist/main.js
Expand Up @@ -593,3 +593,52 @@
angular.module('appirio-tech-ng-api-services').factory('MessageUpdateAPIService', srv);

}).call(this);

(function() {
'use strict';
var srv, transformIdOnlyResponse, transformResponse;

transformResponse = function(response) {
var parsed, ref;
parsed = JSON.parse(response);
return parsed != null ? (ref = parsed.result) != null ? ref.content : void 0 : void 0;
};

transformIdOnlyResponse = function(response) {
var parsed, ref;
parsed = JSON.parse(response);
return {
id: parsed != null ? (ref = parsed.result) != null ? ref.content : void 0 : void 0
};
};

srv = function($resource, API_URL) {
var methods, params, url;
url = API_URL + '/v3/projects/:id';
params = {
id: '@id'
};
methods = {
put: {
method: 'PUT',
transformResponse: transformIdOnlyResponse
},
post: {
method: 'POST',
transformResponse: transformIdOnlyResponse
},
get: {
transformResponse: transformResponse
},
query: {
transformResponse: transformResponse
}
};
return $resource(url, params, methods);
};

srv.$inject = ['$resource', 'API_URL'];

angular.module('appirio-tech-ng-api-services').factory('SubmitWorkCreationAPIService', srv);

}).call(this);
2 changes: 2 additions & 0 deletions example/js-files.jade
Expand Up @@ -38,6 +38,8 @@
- scripts.push('copilot-approval-api.service')
- scripts.push('submissions-messages-api.service')
- scripts.push('message-update-api.service')
- scripts.push('submit-work-creation-api.service')



- bowers.push('angular/angular')
Expand Down
38 changes: 38 additions & 0 deletions src/scripts/submit-work-creation-api.service.coffee
@@ -0,0 +1,38 @@
'use strict'

transformResponse = (response) ->
parsed = JSON.parse response

parsed?.result?.content

transformIdOnlyResponse = (response) ->
parsed = JSON.parse response

id: parsed?.result?.content

srv = ($resource, API_URL) ->
url = API_URL + '/v3/projects/:id'

params =
id: '@id'

methods =
put:
method :'PUT'
transformResponse: transformIdOnlyResponse

post:
method :'POST'
transformResponse: transformIdOnlyResponse

get:
transformResponse: transformResponse

query:
transformResponse: transformResponse

$resource url, params, methods

srv.$inject = ['$resource', 'API_URL']

angular.module('appirio-tech-ng-api-services').factory 'SubmitWorkCreationAPIService', srv

0 comments on commit c681f97

Please sign in to comment.