Overview

Namespaces

  • Cloudflare
    • Organizations
      • Firewall
        • AccessRules
    • User
      • Billing
        • Subscriptions
      • Firewall
    • Zone
      • Firewall
      • SSL
      • WAF
        • Packages

Classes

  • Cloudflare\Api
  • Cloudflare\Certificates
  • Cloudflare\IPs
  • Cloudflare\Organizations\Firewall\AccessRules\Rules
  • Cloudflare\Organizations\Invites
  • Cloudflare\Organizations\Members
  • Cloudflare\Organizations\Organizations
  • Cloudflare\Organizations\Railguns
  • Cloudflare\Organizations\Roles
  • Cloudflare\Organizations\Virtual_Dns
  • Cloudflare\Railguns
  • Cloudflare\User
  • Cloudflare\User\Billing
  • Cloudflare\User\Billing\Subscriptions\Apps
  • Cloudflare\User\Billing\Subscriptions\Zones
  • Cloudflare\User\Firewall\AccessRules
  • Cloudflare\User\Invites
  • Cloudflare\User\Organizations
  • Cloudflare\User\Virtual_Dns
  • Cloudflare\Zone
  • Cloudflare\Zone\Analytics
  • Cloudflare\Zone\Cache
  • Cloudflare\Zone\CustomPages
  • Cloudflare\Zone\CustomSSL
  • Cloudflare\Zone\Dns
  • Cloudflare\Zone\Firewall\AccessRules
  • Cloudflare\Zone\KeylessSSL
  • Cloudflare\Zone\Pagerules
  • Cloudflare\Zone\Plan
  • Cloudflare\Zone\Railgun
  • Cloudflare\Zone\Settings
  • Cloudflare\Zone\SSL
  • Cloudflare\Zone\SSL\Analyze
  • Cloudflare\Zone\SSL\CertificatePacks
  • Cloudflare\Zone\WAF\Packages
  • Cloudflare\Zone\WAF\Packages\Groups
  • Cloudflare\Zone\WAF\Packages\Rules
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: namespace Cloudflare;
  4: 
  5: /**
  6:  * CloudFlare API wrapper
  7:  *
  8:  * User
  9:  * The currently logged in/authenticated User
 10:  *
 11:  * @author James Bell <[email protected]>
 12:  *
 13:  * @version 1
 14:  */
 15: class User extends Api
 16: {
 17:     /**
 18:      * Default permissions level
 19:      *
 20:      * @var array
 21:      */
 22:     protected $permission_level = ['read' => null, 'edit' => null];
 23: 
 24:     /**
 25:      * User details
 26:      */
 27:     public function user()
 28:     {
 29:         return $this->get('user');
 30:     }
 31: 
 32:     /**
 33:      * Update user
 34:      * Update part of your user details
 35:      *
 36:      * @param string|null $first_name User's first name
 37:      * @param string|null $last_name  User's last name
 38:      * @param string|null $telephone  User's telephone number
 39:      * @param string|null $country    The country in which the user lives. (Full list is here: http://en.wikipedia.org/wiki/List_of_country_calling_codes)
 40:      * @param string|null $zipcode    The zipcode or postal code where the user lives.
 41:      */
 42:     public function update($first_name = null, $last_name = null, $telephone = null, $country = null, $zipcode = null)
 43:     {
 44:         $data = [
 45:             'first_name' => $first_name,
 46:             'last_name'  => $last_name,
 47:             'telephone'  => $telephone,
 48:             'country'    => $country,
 49:             'zipcode'    => $zipcode,
 50:         ];
 51: 
 52:         return $this->patch('user', $data);
 53:     }
 54: 
 55:     /**
 56:      * Change your email address. Note: You must provide your current password.
 57:      *
 58:      * @param string $email         Your contact email address
 59:      * @param string $email_confirm Your contact email address, repeated
 60:      * @param string $password      Your current password
 61:      */
 62:     public function change_email($email, $email_confirm, $password)
 63:     {
 64:         $data = [
 65:             'email'         => $email,
 66:             'confirm_email' => $confirm_email,
 67:             'password'      => $password,
 68:         ];
 69: 
 70:         return $this->put('user/email', $data);
 71:     }
 72: 
 73:     /**
 74:      * Change your password
 75:      *
 76:      * @param string $old_password         Your current password
 77:      * @param string $new_password         Your new password
 78:      * @param string $new_password_confirm Your new password, repeated
 79:      */
 80:     public function change_password($old_password, $new_password, $new_password_confirm)
 81:     {
 82:         $data = [
 83:             'old_password'         => $old_password,
 84:             'new_password'         => $new_password,
 85:             'new_password_confirm' => $new_password_confirm,
 86:         ];
 87: 
 88:         return $this->put('user/password', $data);
 89:     }
 90: 
 91:     /**
 92:      * Change your username. Note: You must provide your current password.
 93:      *
 94:      * @param string $username A username used to access other cloudflare services, like support
 95:      * @param string $password Your current password
 96:      */
 97:     public function change_username($username, $password)
 98:     {
 99:         $data = [
100:             'username' => $username,
101:             'password' => $password,
102:         ];
103: 
104:         return $this->put('user/username', $data);
105:     }
106: 
107:     /**
108:      * Begin setting up CloudFlare two-factor authentication with a given telephone number
109:      *
110:      * @param int    $country_code        The country code of your mobile phone number
111:      * @param string $mobile_phone_number Your mobile phone number
112:      * @param string $current_password    Your current CloudFlare password
113:      */
114:     public function initialize_two_factor_authentication($country_code, $mobile_phone_number, $current_password)
115:     {
116:         $data = [
117:             'country_code'        => $country_code,
118:             'mobile_phone_number' => $mobile_phone_number,
119:             'current_password'    => $current_password,
120:         ];
121: 
122:         return $this->post('/user/two_factor_authentication', $data);
123:     }
124: 
125:     /**
126:      * Finish setting up CloudFlare two-factor authentication with a given telephone number
127:      *
128:      * @param int $auth_token The token provided by the two-factor authenticator
129:      */
130:     public function finalize_two_factor_authentication($auth_token)
131:     {
132:         $data = [
133:             'auth_token' => $auth_token,
134:         ];
135: 
136:         return $this->put('user/two_factor_authentication', $data);
137:     }
138: 
139:     /**
140:      * Disable two-factor authentication for your CloudFlare user account
141:      *
142:      * @param int The token provided by the two-factor authenticator
143:      */
144:     public function disable_two_factor_authentication($auth_token)
145:     {
146:         $data = [
147:             'auth_token' => $auth_token,
148:         ];
149: 
150:         return $this->delete('user/two_factor_authentication', $data);
151:     }
152: }
153: 
API documentation generated by ApiGen