Skip to content

Commit 44ddc7e

Browse files
authored
Merge pull request #71 from ConvertKit/v4-api-delete-resource-timestamp
v4 API: Delete Resource Timestamp
2 parents c33a558 + 0aa8f83 commit 44ddc7e

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

src/class-convertkit-resource-v4.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,7 @@ public function get_cron_event_next_scheduled() {
512512
public function delete() {
513513

514514
delete_option( $this->settings_name );
515+
delete_option( $this->settings_name . '_last_queried' );
515516

516517
}
517518

tests/wpunit/ResourceTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,13 @@ public function testRefreshForms()
308308
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_FORM_ID'], $resources);
309309
$this->assertArrayHasKey('embed_url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ]);
310310
$this->assertEquals('https://api.convertkit.com/api/v3/forms/' . $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] . '.html?api_key=' . $_ENV['CONVERTKIT_API_KEY'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_FORM_ID'] ]['embed_url']);
311+
312+
// Delete resources.
313+
$this->resource->delete();
314+
315+
// Confirm resources no longer stored in WordPress options.
316+
$this->assertFalse(get_option($this->resource->settings_name));
317+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
311318
}
312319

313320
/**
@@ -355,6 +362,13 @@ public function testRefreshLandingPages()
355362
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources);
356363
$this->assertArrayHasKey('url', $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]);
357364
$this->assertEquals('https://app.convertkit.com/landing_pages/' . $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'], $resources[ $_ENV['CONVERTKIT_API_LEGACY_LANDING_PAGE_ID'] ]['url']);
365+
366+
// Delete resources.
367+
$this->resource->delete();
368+
369+
// Confirm resources no longer stored in WordPress options.
370+
$this->assertFalse(get_option($this->resource->settings_name));
371+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
358372
}
359373

360374
/**
@@ -396,6 +410,13 @@ public function testRefreshTags()
396410

397411
// Assert array keys are preserved.
398412
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_TAG_ID'], $resources);
413+
414+
// Delete resources.
415+
$this->resource->delete();
416+
417+
// Confirm resources no longer stored in WordPress options.
418+
$this->assertFalse(get_option($this->resource->settings_name));
419+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
399420
}
400421

401422
/**
@@ -438,6 +459,13 @@ public function testRefreshCustomFields()
438459

439460
// Assert array keys are preserved.
440461
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_CUSTOM_FIELD_ID'], $resources);
462+
463+
// Delete resources.
464+
$this->resource->delete();
465+
466+
// Confirm resources no longer stored in WordPress options.
467+
$this->assertFalse(get_option($this->resource->settings_name));
468+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
441469
}
442470

443471
/**
@@ -479,6 +507,13 @@ public function testRefreshSequences()
479507

480508
// Assert array keys are preserved.
481509
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_SEQUENCE_ID'], $resources);
510+
511+
// Delete resources.
512+
$this->resource->delete();
513+
514+
// Confirm resources no longer stored in WordPress options.
515+
$this->assertFalse(get_option($this->resource->settings_name));
516+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
482517
}
483518

484519
/**
@@ -520,6 +555,13 @@ public function testRefreshProducts()
520555

521556
// Assert array keys are preserved.
522557
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_PRODUCT_ID'], $resources);
558+
559+
// Delete resources.
560+
$this->resource->delete();
561+
562+
// Confirm resources no longer stored in WordPress options.
563+
$this->assertFalse(get_option($this->resource->settings_name));
564+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
523565
}
524566

525567
/**
@@ -563,6 +605,13 @@ public function testRefreshPosts()
563605

564606
// Assert array keys are preserved.
565607
$this->assertArrayHasKey($_ENV['CONVERTKIT_API_POST_ID'], $resources);
608+
609+
// Delete resources.
610+
$this->resource->delete();
611+
612+
// Confirm resources no longer stored in WordPress options.
613+
$this->assertFalse(get_option($this->resource->settings_name));
614+
$this->assertFalse(get_option($this->resource->settings_name . '_last_queried'));
566615
}
567616

568617
/**

0 commit comments

Comments
 (0)