diff --git a/lib/models/billing-info.js b/lib/models/billing-info.js index 8fb680a..57ba4af 100644 --- a/lib/models/billing-info.js +++ b/lib/models/billing-info.js @@ -41,11 +41,11 @@ class BillingInfo extends RecurlyData { }) this.__defineGetter__('account_code', () => { - return this.account_code + return this._account_code }) this.__defineSetter__('account_code', account_code => { - this.properties.account_code = account_code + this.properties._account_code = account_code if (!this.href) { this.href = `${Account.ENDPOINT}/${account_code}/billing_info` } diff --git a/lib/models/redemption.js b/lib/models/redemption.js index 486d99b..6e3be44 100644 --- a/lib/models/redemption.js +++ b/lib/models/redemption.js @@ -20,12 +20,12 @@ class Redemption extends RecurlyData { }) this.__defineGetter__('account_code', () => { - return this.account_code + return this._account_code }) this.__defineSetter__('account_code', account_code => { - this.properties.account_code = account_code - if (!this.href) { + this.properties._account_code = account_code + if (!this.href) { this.href = `${Account.ENDPOINT}/${account_code}/redemption` } }) diff --git a/lib/models/subscription.js b/lib/models/subscription.js index 66368f4..fd045ec 100644 --- a/lib/models/subscription.js +++ b/lib/models/subscription.js @@ -119,16 +119,16 @@ class Subscription extends RecurlyData { } update(options, callback) { + if (!this.id) { + throw (new Error('cannot update a subscription without a uuid')) + } if (!options.timeframe) { throw (new Error('subscription update must include "timeframe" parameter')) } - if (!this.href) { - throw (new Error(`cannot update a subscription without an href ${this.id}`)) - } const body = data2xml(Subscription.SINGULAR, options) - this.put(this.href, body, (err, response, payload) => { + this.put(`${Subscription.ENDPOINT}/${this.id}`, body, (err, response, payload) => { const error = handleRecurlyError(err, response, payload, [ 200, 201 ]) if (error) { return callback(error)