Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for getter and setter call stack error #57

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/models/billing-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
Expand Down
6 changes: 3 additions & 3 deletions lib/models/redemption.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`
}
})
Expand Down
8 changes: 4 additions & 4 deletions lib/models/subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down