2013-04-29 09:23:34 +04:00
|
|
|
/*
|
2015-05-17 22:09:42 +03:00
|
|
|
REST API item list ("Feed") implementation
|
|
|
|
Copyright (C) 2015 Vitaliy Filippov
|
2013-04-29 09:23:34 +04:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation version 2
|
|
|
|
of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
#include "CommonUri.hh"
|
|
|
|
#include "Feed2.hh"
|
|
|
|
#include "Entry2.hh"
|
2013-04-29 09:23:34 +04:00
|
|
|
|
|
|
|
#include "http/Agent.hh"
|
|
|
|
#include "http/Header.hh"
|
2015-05-17 16:54:04 +03:00
|
|
|
#include "json/Val.hh"
|
2013-05-02 20:40:04 +04:00
|
|
|
#include "json/ValResponse.hh"
|
2013-04-29 09:23:34 +04:00
|
|
|
|
|
|
|
#include <iostream>
|
2015-05-17 16:54:04 +03:00
|
|
|
#include <boost/format.hpp>
|
2013-04-29 09:23:34 +04:00
|
|
|
|
|
|
|
namespace gr { namespace v2 {
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
Feed2::Feed2( const std::string& url ):
|
|
|
|
Feed( url )
|
2013-04-29 09:23:34 +04:00
|
|
|
{
|
2013-04-29 10:50:54 +04:00
|
|
|
}
|
|
|
|
|
2019-02-10 01:01:00 +03:00
|
|
|
Feed2::~Feed2()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
bool Feed2::GetNext( http::Agent *http )
|
2013-04-29 10:50:54 +04:00
|
|
|
{
|
2015-05-17 16:54:04 +03:00
|
|
|
if ( m_next.empty() )
|
|
|
|
return false ;
|
|
|
|
|
2015-05-17 12:29:00 +03:00
|
|
|
http::ValResponse out ;
|
2016-08-05 20:29:48 +03:00
|
|
|
http->Get( m_next, &out, http::Header(), 0 ) ;
|
2015-05-17 16:54:04 +03:00
|
|
|
Val m_content = out.Response() ;
|
2015-05-17 12:29:00 +03:00
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
Val::Array items = m_content["items"].AsArray() ;
|
|
|
|
m_entries.clear() ;
|
|
|
|
for ( Val::Array::iterator i = items.begin() ; i != items.end() ; ++i )
|
|
|
|
m_entries.push_back( Entry2( *i ) );
|
2015-05-17 12:29:00 +03:00
|
|
|
|
2013-05-02 20:40:04 +04:00
|
|
|
Val url ;
|
2015-05-17 16:54:04 +03:00
|
|
|
m_next = m_content.Get( "nextLink", url ) ? url : std::string( "" ) ;
|
|
|
|
return true ;
|
2013-04-29 09:23:34 +04:00
|
|
|
}
|
|
|
|
|
2015-05-17 16:54:04 +03:00
|
|
|
} } // end of namespace gr::v2
|