"""Api Episode. API to talk to megaphone for the episode model. """ from podcast.models.api_base import ApiBase class ApiEpisode(ApiBase): """API to talk to megaphone for the episode model.""" def get_all(self, podcast_id, page=1, per_page=50): """Get all episodes.""" return self._paginated_get( 'podcasts/{0}/episodes?page={1}&per_page={2}'.format( podcast_id, page, per_page)) def create(self, podcast_id, episode_data): """Create a episode.""" return self._post( 'podcasts/{0}/episodes'.format(podcast_id), episode_data) def delete(self, podcast_id, episode_id): """Delete a episode.""" return self._delete( 'podcasts/{0}/episodes/{1}'.format(podcast_id, episode_id)) def get(self, podcast_id, episode_id): """Get a single episode.""" return self._get('podcasts/{0}/episodes/{1}'.format( podcast_id, episode_id)) def update(self, podcast_id, episode_id, data): """Update a single episode.""" megaphone_episode_data = self.get(podcast_id, episode_id) return self._put( 'podcasts/{0}/episodes/{1}'.format(podcast_id, episode_id), data, megaphone_episode_data['audioFileProcessing'] )