Before he cast his dramatic vote in the wee hours of the morning to kill his party’s best Obamacare repeal effort, Sen. John McCain took a call from Donald Trump urging him to reconsider. By that point, the Arizona Republican had already made up his mind, and would, as he put it, politely rebuff the president. Moments later, McCain wandered on to the floor and dramatically thrust his thumb down, signaling his no vote.

The moment earned McCain plaudits from Democrats along with the ire of Trump.

It also got him another phone call.

“Among the people who called to thank me was President Obama,” McCain writes in his upcoming book The Restless Wave. The book is due out on May 22, but The Daily Beast obtained an early copy.

McCain and Obama had run against each other for the presidency in 2008. But over time, they had re-established a solid working relationship. Both share a healthy skepticism of the current president, a point the senator appeared to underscore later in the book.

“I appreciated his call, but, as I said, my purpose hadn’t been to preserve his signature accomplishment but to insist on a better alternative, and to give the Senate an opportunity to work together to find one,” the Arizona Republican writes. “He hadn’t called to lobby me before the vote, which I had appreciated. He had last called me not long after the November election, during the transition to the Trump administration, to congratulate me on my re-election. He added that he was counting on me to be an outspoken and independent voice for the causes I believed in as I had been during his presidency. I thanked him, and said I would try to be.”

The book describes the late-night vote in dramatic fashion, with McCain not willing to tip off reporters but first telling Senate Minority Leader Chuck Schumer (D-NY) that he intended to vote no.

Vice President Mike Pence also tried to lobby McCain on the floor but to no avail, eventually opting to put Trump on the phone to make that final attempt.

“I listened quietly as he asked me to reconsider,” McCain writes.

The remainder of the book , co-written with former adviser Mark Salter, is a broader reflection on McCain’s life and some of his regrets, including criticisms of Trump and an appraisal of the current state of American politics .