# templately/2.0.0/includes/API/Profile.php

Templately – Elementor &amp; Gutenberg Template Library: 6500+ Free &amp; Pro Ready Templates And Cloud!, version 2.0.0. 75 lines.

- Page: https://pluginprobe.com/plugins/templately/2.0.0/code/includes/API/Profile.php
- Raw: https://pluginprobe.com/plugins/templately/2.0.0/raw/includes/API/Profile.php
- Modified: 2022-10-03T09:36:30+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/templately/2.0.0/code/includes/API/Profile.php#L10-L20`.

```php
<?php

namespace Templately\API;

use WP_REST_Request;

class Profile extends API {

	public function register_routes() {
		$this->register_endpoint( 'profile', [ $this, 'get_profile' ] );
		$this->get( 'profile/download-history', [ $this, 'get_download_history' ] );
		$this->get( 'profile/my-favourites', [ $this, 'get_my_favourites' ] );
	}

	public function get_profile( WP_REST_Request $request ) {

	}

	public function get_download_history() {
		$page     = $this->get_param( 'page', 1, 'intval' );
		$per_page = $this->get_param( 'per_page', 10, 'intval' );

		$response = $this->http()->mutation(
			'myDownloadHistory',
			'data{ name, thumbnail, downloaded_at, slug, type }, current_page, total_page',
			[
				'api_key'  => $this->api_key,
				'per_page' => $per_page,
				"page"     => $page
			]
		)->post();

		if ( is_wp_error( $response ) ) {
			return $this->error(
				'invalid_download_history_response',
				__( $response->get_error_message(), 'templately' ),
				'profile/download-history',
				$response->get_error_code()
			);
		}

		return $response;
	}

	public function get_my_favourites() {
		$type      = $this->get_param( 'itemType', 'all' );
		$plan      = $this->get_param( 'plan', 'all' );
		$plan_type = $this->get_plan( $plan );
		$page      = $this->get_param( 'page', 1, 'intval' );
		$per_page  = $this->get_param( 'per_page', 20, 'intval' );

		$funcArgs = [
			'api_key'   => $this->api_key,
			"page"      => $page,
			"per_page"  => $per_page,
			"plan_type" => $plan_type
		];

		if( $type != 'all' ) {
			$funcArgs['type'] = $type;
		}

		$response = $this->http()->mutation(
			'myFavouriteItem',
			'total_page, current_page, data { id, name, rating, type, slug, favourite_count, thumbnail, thumbnail2, thumbnail3, price, author{ display_name, name, joined } }',
			$funcArgs
		)->post();

		if ( is_wp_error( $response ) ) {
			return $this->error( 'invalid_my_favourites_response', __( $response->get_error_message(), 'templately' ), 'profile/my-favourites', $response->get_error_code() );
		}

		return $response;
	}
}
```
