Hi, just a quick question, for a Rails integration: what is the quickest way to grab a patron’s last paid pledge date via the API? Just a date somewhere or a combination of status + date? To be able to get an up-to-date list of current patrons. Best,
You could request /identity of the user, and over its relationships, get membership and pledges:
https://docs.patreon.com/#apiv2-resource-endpoints
Check out WP plugin’s call which does something similar:
public $access_token;
public function __construct( $access_token ) {
$this->access_token = $access_token;
}
public function fetch_user() {
// We construct the old return from the new returns by combining /me and pledge details
$api_return = $this->__get_json( "identity?include=memberships.currently_entitled_tiers,memberships.campaign&fields[user]=email,first_name,full_name,image_url,last_name,thumb_url,url,vanity,is_email_verified&fields[member]=currently_entitled_amount_cents,lifetime_support_cents,campaign_lifetime_support_cents,last_charge_status,patron_status,last_charge_date,pledge_relationship_start" );
$creator_id = get_option( 'patreon-creator-id', false );
$campaign_id = get_option( 'patreon-campaign-id', false );
if ( isset( $api_return['included'][0] ) AND is_array( $api_return['included'][0] ) ) {
// Iterate through included memberships and find the one that matches the campaign.
foreach ($api_return['included'] as $key => $value) {