@@ -1264,6 +1264,37 @@ angular
12641264 }
12651265 ] ) ;
12661266
1267+
1268+ angular
1269+ . module ( 'tl' )
1270+ . service ( 'tl.answer' , [ 'tl.answer.resource' , 'tl.answer.service' , function ( resource , service ) {
1271+ this . resource = resource ;
1272+ this . service = service ;
1273+ } ] ) ;
1274+ angular
1275+ . module ( 'tl' )
1276+ . factory ( 'tl.answer.resource' , [ 'tl.resource' ,
1277+ function ( resource ) {
1278+
1279+ var endpoint = '/answer' ;
1280+
1281+ return resource ( endpoint , {
1282+ // nothing here
1283+ } , { } ) ;
1284+ }
1285+ ] ) ;
1286+
1287+ angular
1288+ . module ( 'tl' )
1289+ . service ( 'tl.answer.service' , [ 'tl.service' , 'tl.answer.resource' ,
1290+ function ( Service , Answer ) {
1291+
1292+ var AnswerService = Service . extend ( Answer ) ;
1293+
1294+ return new AnswerService ( ) ;
1295+ }
1296+ ] ) ;
1297+
12671298angular
12681299 . module ( 'tl' )
12691300 . service ( 'tl.auth' , [ 'tl.auth.resource' , 'tl.auth.service' ,
@@ -1782,37 +1813,6 @@ angular.module('tl').service('tl.booking.service', [
17821813] ) ;
17831814
17841815
1785- angular
1786- . module ( 'tl' )
1787- . service ( 'tl.answer' , [ 'tl.answer.resource' , 'tl.answer.service' , function ( resource , service ) {
1788- this . resource = resource ;
1789- this . service = service ;
1790- } ] ) ;
1791- angular
1792- . module ( 'tl' )
1793- . factory ( 'tl.answer.resource' , [ 'tl.resource' ,
1794- function ( resource ) {
1795-
1796- var endpoint = '/answer' ;
1797-
1798- return resource ( endpoint , {
1799- // nothing here
1800- } , { } ) ;
1801- }
1802- ] ) ;
1803-
1804- angular
1805- . module ( 'tl' )
1806- . service ( 'tl.answer.service' , [ 'tl.service' , 'tl.answer.resource' ,
1807- function ( Service , Answer ) {
1808-
1809- var AnswerService = Service . extend ( Answer ) ;
1810-
1811- return new AnswerService ( ) ;
1812- }
1813- ] ) ;
1814-
1815-
18161816angular
18171817 . module ( 'tl' )
18181818 . service ( 'tl.campaign' , [ 'tl.campaign.resource' , 'tl.campaign.service' , function ( resource , service ) {
@@ -1930,112 +1930,6 @@ angular
19301930
19311931 return new ClientService ( ) ;
19321932 } ] ) ;
1933- angular
1934- . module ( 'tl' )
1935- . service ( 'tl.feed' , [ 'tl.feed.resource' , 'tl.feed.service' ,
1936- function ( resource , service ) {
1937- this . resource = resource ;
1938- this . service = service ;
1939- }
1940- ] ) ;
1941-
1942- angular
1943- . module ( 'tl' )
1944- . factory ( 'tl.feed.resource' , [ 'tl.resource' ,
1945- function ( resource ) {
1946-
1947- var endpoint = '/feed' ;
1948-
1949- return resource ( endpoint , {
1950- id : '@id' ,
1951- userId : '@userId'
1952- } , {
1953- create : {
1954- method : 'POST' ,
1955- url : endpoint ,
1956- isArray : true
1957- } ,
1958- remove : {
1959- method : 'DELETE' ,
1960- url : endpoint + '/:id' ,
1961- isArray : false
1962- } ,
1963- list : {
1964- method : 'GET' ,
1965- url : endpoint ,
1966- isArray : true
1967- } ,
1968- listUserFeed : {
1969- method : 'GET' ,
1970- url : '/user/:userId/feed' ,
1971- isArray : true
1972- } ,
1973- addLike : {
1974- method : 'POST' ,
1975- url : endpoint + '/:id/like' ,
1976- isArray : false
1977- } ,
1978- removeLike : {
1979- method : 'DELETE' ,
1980- url : endpoint + '/:id/like' ,
1981- isArray : false
1982- }
1983- } ) ;
1984- }
1985- ] ) ;
1986-
1987- angular
1988- . module ( 'tl' )
1989- . service ( 'tl.feed.service' , [ 'tl.service' , 'tl.feed.resource' ,
1990- function ( Service , Feed ) {
1991-
1992- var FeedService = Service . extend ( Feed ) ;
1993-
1994- FeedService . prototype . create = function ( options ) {
1995- if ( ! options ) throw new Error ( 'FeedService.create - options is required' ) ;
1996-
1997- return Feed . create ( { } , options ) . $promise ;
1998- } ;
1999-
2000- FeedService . prototype . remove = function ( feedId , options ) {
2001- if ( ! feedId ) throw new Error ( 'FeedService.remove - feedId is required' ) ;
2002- options = options || { } ;
2003-
2004- options . id = feedId ;
2005-
2006- return Feed . remove ( options ) . $promise ;
2007- } ;
2008-
2009- FeedService . prototype . list = function ( options ) {
2010- options = options || { } ;
2011- return Feed . list ( options ) . $promise ;
2012- } ;
2013-
2014- FeedService . prototype . listUserFeed = function ( userId , options ) {
2015- if ( ! userId ) throw new Error ( 'FeedService.listUserFeed - userId is required' ) ;
2016- options = options || { } ;
2017-
2018- options . userId = userId ;
2019-
2020- return Feed . listUserFeed ( options ) . $promise ;
2021- } ;
2022-
2023- FeedService . prototype . addLike = function ( feedId , options ) {
2024- if ( ! feedId ) throw new Error ( 'FeedService.addLike - feedId is required' ) ;
2025-
2026- return Feed . addLike ( { id : feedId } , options ) . $promise ;
2027- } ;
2028-
2029- FeedService . prototype . removeLike = function ( feedId , options ) {
2030- if ( ! feedId ) throw new Error ( 'FeedService.removeLike - feedId is required' ) ;
2031-
2032- return Feed . removeLike ( { id : feedId } , options ) . $promise ;
2033- } ;
2034-
2035- return new FeedService ( ) ;
2036- }
2037- ] ) ;
2038-
20391933
20401934angular
20411935 . module ( 'tl' )
@@ -2176,6 +2070,112 @@ angular
21762070 return new EventService ( ) ;
21772071 } ] ) ;
21782072
2073+ angular
2074+ . module ( 'tl' )
2075+ . service ( 'tl.feed' , [ 'tl.feed.resource' , 'tl.feed.service' ,
2076+ function ( resource , service ) {
2077+ this . resource = resource ;
2078+ this . service = service ;
2079+ }
2080+ ] ) ;
2081+
2082+ angular
2083+ . module ( 'tl' )
2084+ . factory ( 'tl.feed.resource' , [ 'tl.resource' ,
2085+ function ( resource ) {
2086+
2087+ var endpoint = '/feed' ;
2088+
2089+ return resource ( endpoint , {
2090+ id : '@id' ,
2091+ userId : '@userId'
2092+ } , {
2093+ create : {
2094+ method : 'POST' ,
2095+ url : endpoint ,
2096+ isArray : true
2097+ } ,
2098+ remove : {
2099+ method : 'DELETE' ,
2100+ url : endpoint + '/:id' ,
2101+ isArray : false
2102+ } ,
2103+ list : {
2104+ method : 'GET' ,
2105+ url : endpoint ,
2106+ isArray : true
2107+ } ,
2108+ listUserFeed : {
2109+ method : 'GET' ,
2110+ url : '/user/:userId/feed' ,
2111+ isArray : true
2112+ } ,
2113+ addLike : {
2114+ method : 'POST' ,
2115+ url : endpoint + '/:id/like' ,
2116+ isArray : false
2117+ } ,
2118+ removeLike : {
2119+ method : 'DELETE' ,
2120+ url : endpoint + '/:id/like' ,
2121+ isArray : false
2122+ }
2123+ } ) ;
2124+ }
2125+ ] ) ;
2126+
2127+ angular
2128+ . module ( 'tl' )
2129+ . service ( 'tl.feed.service' , [ 'tl.service' , 'tl.feed.resource' ,
2130+ function ( Service , Feed ) {
2131+
2132+ var FeedService = Service . extend ( Feed ) ;
2133+
2134+ FeedService . prototype . create = function ( options ) {
2135+ if ( ! options ) throw new Error ( 'FeedService.create - options is required' ) ;
2136+
2137+ return Feed . create ( { } , options ) . $promise ;
2138+ } ;
2139+
2140+ FeedService . prototype . remove = function ( feedId , options ) {
2141+ if ( ! feedId ) throw new Error ( 'FeedService.remove - feedId is required' ) ;
2142+ options = options || { } ;
2143+
2144+ options . id = feedId ;
2145+
2146+ return Feed . remove ( options ) . $promise ;
2147+ } ;
2148+
2149+ FeedService . prototype . list = function ( options ) {
2150+ options = options || { } ;
2151+ return Feed . list ( options ) . $promise ;
2152+ } ;
2153+
2154+ FeedService . prototype . listUserFeed = function ( userId , options ) {
2155+ if ( ! userId ) throw new Error ( 'FeedService.listUserFeed - userId is required' ) ;
2156+ options = options || { } ;
2157+
2158+ options . userId = userId ;
2159+
2160+ return Feed . listUserFeed ( options ) . $promise ;
2161+ } ;
2162+
2163+ FeedService . prototype . addLike = function ( feedId , options ) {
2164+ if ( ! feedId ) throw new Error ( 'FeedService.addLike - feedId is required' ) ;
2165+
2166+ return Feed . addLike ( { id : feedId } , options ) . $promise ;
2167+ } ;
2168+
2169+ FeedService . prototype . removeLike = function ( feedId , options ) {
2170+ if ( ! feedId ) throw new Error ( 'FeedService.removeLike - feedId is required' ) ;
2171+
2172+ return Feed . removeLike ( { id : feedId } , options ) . $promise ;
2173+ } ;
2174+
2175+ return new FeedService ( ) ;
2176+ }
2177+ ] ) ;
2178+
21792179angular
21802180 . module ( 'tl' )
21812181 . service ( 'tl.image' , [ 'tl.image.resource' , 'tl.image.service' ,
@@ -4012,6 +4012,13 @@ angular
40124012 method : "DELETE" ,
40134013 url : endpoint + '/subscription'
40144014 } ,
4015+ subscriptionAction : {
4016+ method : "POST" ,
4017+ url : endpoint + '/subscription/:subscriptionId/action' ,
4018+ params : {
4019+ subscriptionId : '@subscriptionId' ,
4020+ } ,
4021+ } ,
40154022 findByReferral : {
40164023 method : "GET" ,
40174024 url : '/referral/:code'
@@ -4079,6 +4086,10 @@ angular
40794086 USER_UPDATED : 'tl.user.updated'
40804087 } ;
40814088
4089+ var SUBSCRIPTION_ACTION = {
4090+ UPDATE_PAYMENT_METHOD : 'UPDATE_PAYMENT_METHOD' ,
4091+ } ;
4092+
40824093 var UserService = Service . extend ( User ) ;
40834094
40844095 UserService . prototype . list = function list ( options ) {
@@ -4348,6 +4359,32 @@ angular
43484359 } , success , error ) ;
43494360 } ;
43504361
4362+ /**
4363+ * Update the payment profile for a user's subscription
4364+ *
4365+ * @method updateSubscriptionPaymentMethod
4366+ * @param {Object } options
4367+ * @param {String } [options.userId] - user to subscribe
4368+ * @param {String } [options.subscriptionId] - id of subscription to update
4369+ * @param {String } [options.paymentProfileId] - payment profile to charge
4370+ */
4371+ UserService . prototype . updateSubscriptionPaymentMethod = function ( options , success , error ) {
4372+ if ( ! options ) throw new Error ( 'options is required' ) ;
4373+ if ( ! options . userId ) throw new Error ( 'options.userId is required' ) ;
4374+ if ( ! options . subscriptionId ) throw new Error ( 'options.subscriptionId is required' ) ;
4375+ if ( ! options . paymentProfileId ) throw new Error ( 'options.paymentProfileId is required' ) ;
4376+
4377+ var body = {
4378+ type : SUBSCRIPTION_ACTION . UPDATE_PAYMENT_METHOD ,
4379+ paymentProfileId : options . paymentProfileId ,
4380+ } ;
4381+
4382+ return User . subscriptionAction ( {
4383+ id : options . userId ,
4384+ subscriptionId : options . subscriptionId ,
4385+ } , body , success , error ) ;
4386+ } ;
4387+
43514388 /**
43524389 * Find a user's name and photo by their referral code
43534390 */
0 commit comments