Closed jameslovejoy closed 11 years ago
James I'm trying to test this but not seeing my subscription widget appear when I'm logged in.
Changes I made:
My server is responding back:
[{"created_at":"2013-05-14T22:44:37Z","customer_id":2,"fanclub_id":1,"id":1,"plan_id":1,"renewal":false,"sales_period_id":5,"start_date":"2013-07-02T00:00:00Z","updated_at":"2013-09-03T22:31:49Z"}]
I'm not sure why there's no end date there but I'm guessing because it's still valid? I confirmed I'm on the correct branch.
I'm seeing an error about start dates in my js console as well but I'm not sure if it's related:
Uncaught TypeError: Cannot read property 'start_date' of undefined
Did you have to do anything else to get this to appear?
For now I'm going to try and get Tim's test harness to work so I can confirm whether it's an issue with how KU is setup or something wrong with the branch.
Still getting the same error on the test harness:
subscription: [ function( data ){
data.subscription.start_date = convertDate( data.subscription.start_date );
Appears to be where it's happening.
I'm going to try and confirm the branch is correct but something appears up with the endpoint -- not sure why data.subscription would be nil -- it's using your branch for services.
Account endpoint
{"status":"ok","customer":{"id":2,"first_name":"Free","last_name":"The World!","email":"timo614+lalskldjjf@gmail.com","birthdate":"1903-02-02","fanclub_id":1,"expired":false,"authentications":[],"subscription":{"plan":{"id":1,"name":"Paid Plan","description":"","online_benefits":"","annotations":""},"start_date":"2013-07-02T00:00:00Z","end_date":"2014-07-02T00:00:00Z","lapsed":false,"affiliates":[{"name":"Tim","codes":["boooo you!"]}]}}}
Subscription endpoint
[{"created_at":"2013-05-14T22:44:37Z","customer_id":2,"fanclub_id":1,"id":1,"plan_id":1,"renewal":false,"sales_period_id":5,"start_date":"2013-07-02T00:00:00Z","updated_at":"2013-09-03T22:31:49Z"}]
From the looks of the code it doesn't look like subscriptions would ever have the end_date associated with it since we're just relying on the to_json functionality for the endpoint and the end_date is calculated.
Was there some sparkart services update that wasn't pushed?
Not sure how it could ever have an end_date but it's there here:
+ subscription: [ function( data ){
+ data.subscription.start_date = convertDate( data.subscription.start_date );
+ data.subscription.end_date = convertDate( data.subscription.end_date );
+ return data;
+ } ],
+ subscriptions: [ function( data ){
+ $( data.subscriptions ).each( function( i, subscription ){
+ subscription.start_date = convertDate( subscription.start_date );
+ subscription.end_date = convertDate( subscription.end_date );
+ });
Also my customer widget has the start and end dates so I think I have everything setup correctly on my end -- not sure what's going on with the endpoint though.
I just checked... I forgot to push the subscriptions endpoint changes to sparkart-services. And I have a bunch of tests to update. Sorry about that. I'll let you know when I've pushed all the changes.
No worries, sounds good!
This should be good to review again. Sparkart-services is updated.
Sorry wrong repo meant for the sparkart-services -- moving comment
subscriptions: [ function( data ){
$( data.subscriptions ).each( function( i, subscription ){
subscription.start_date = convertDate( subscription.start_date );
if( data.subscription.end_date ) {
subscription.end_date = convertDate( subscription.end_date );
}
On the if( data.subscription.end_date ) {
line I'm getting the following error:
Uncaught TypeError: Cannot read property 'end_date' of undefined
When I do subscription for the class instead of subscriptions I get the following error:
subscription: [ function( data ){
data.subscription.start_date = convertDate( data.subscription.start_date );
On the second line.
Uncaught TypeError: Cannot read property 'start_date' of undefined
I'm guessing my subscription is setup in some way that's causing issues?
{"status":"ok","subscriptions":[{"id":1,"name":"Paid Plan","start_date":"2013-07-02T00:00:00Z","end_date":"2014-07-02T00:00:00Z","status":"active","active":true,"expired":false,"lapsed":false}]}
It looks like the endpoint has all the fields though and I have the most up to date sparkart.js installed both on the curry test harness of Tim's and my local KU setup both are returning the error.
Everything looked good after I added the s
in the comment above :+1:
Perfect :+1:
I fixed the one error. The code should have been if( subscription.end_date )
instead of if( data.subscription.end_date )
.
For the other problem with showing a single subscription, you have to add a data-id="1"
attribute to the widget div (using a valid ID). Otherwise, it tries to render a subscription that doesn't exist. (The same kind of error occurs for the event, order, and contest widgets if the ID is missing or invalid.)
Oh I noticed the subscription/subscriptions widgets were missing from the README, can you please add?
Cool, looks good :+1:
Branch: b7v2m5nA-expiration-dates
See https://github.com/SparkartGroupInc/sparkart-services/pull/246