# Cloud

## AV. Cloud

Source:
  - cloudfunction.js, line 14

Contains functions for calling and declaring

Some functions are only available from Cloud Code.

### Members

#### (static) requestCaptcha

Source:
  - cloudfunction.js, line 127

Request a captcha.

### Methods

#### (static) getServerDate() → {Promise.<Date>}

Source:
  - cloudfunction.js, line 58
Since:
  - 0.5.9

Make a call to request server date time.

##### Returns:

A promise that will be resolved with the result of the function.

Type
  Promise.<Date>

#### (static) requestCaptcha(optionsopt) → {Promise.<AV.Captcha>}

Source:
  - captcha.js, line 133

Request a captcha

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`options`

<optional>

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`width` | Number | <optional> |  | width(px) of the captcha, ranged 60-200
`height` | Number | <optional> |  | height(px) of the captcha, ranged 30-100
`size` | Number | <optional> | `4` | length of the captcha, ranged 3-6. MasterKey required.
`ttl` | Number | <optional> | `60` | time to live(s), ranged 10-180. MasterKey required.

##### Returns:

Type
  Promise.<AV.Captcha>

#### (static) requestSmsCode(data, optionsopt) → {Promise}

Source:
  - cloudfunction.js, line 77

Makes a call to request a sms code for operation verification.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---

`data`

String | Object

The mobile phone number string or a JSON object that contains mobilePhoneNumber,template,sign,op,ttl,name etc.

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`mobilePhoneNumber` | String |  |
`template` | String | <optional> | sms template name
`sign` | String | <optional> | sms signature name

`options`

AuthOptions

<optional>

AuthOptions plus:

###### Properties

Name | Type | Attributes | Description
--- | --- | --- | ---
`validateToken` | String | <optional> | a validate token returned by AV.Cloud.verifyCaptcha

##### Returns:

A promise that will be resolved if the request succeed

Type
  Promise

#### (static) rpc(name, data, options) → {Promise}

Source:
  - cloudfunction.js, line 42

Makes a call to a cloud function, you can send {AV.Object} as param or a field of param; the response from server will also be parsed as an {AV.Object}, array of {AV.Object}, or object includes {AV.Object}

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | The function name.
`data` | Object | The parameters to send to the cloud function.
`options` | AuthOptions |

##### Returns:

A promise that will be resolved with the result of the function.

Type
  Promise

#### (static) run(name, data, options) → {Promise}

Source:
  - cloudfunction.js, line 25

Makes a call to a cloud function.

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | String | The function name.
`data` | Object | The parameters to send to the cloud function.
`options` | AuthOptions |

##### Returns:

A promise that will be resolved with the result of the function.

Type
  Promise

#### (static) useMasterKey()

Source:
  - init.js, line 63

Switches the LeanCloud SDK to using the Master key. The Master key grants priveleged access to the data in LeanCloud and can be used to bypass ACLs and other restrictions that are applied to the client SDKs.

Available in Cloud Code and Node.js only.

#### (static) verifyCaptcha(code, captchaToken) → {Promise.<String>}

Source:
  - cloudfunction.js, line 136

Verify captcha code. This is the low-level API for captcha. Checkout AV.Captcha for high abstract APIs.

##### Parameters:

Name | Type | Description
--- | --- | ---
`code` | String | the code from user input
`captchaToken` | String | captchaToken returned by AV.Cloud.requestCaptcha

##### Returns:

validateToken if the code is valid

Type
  Promise.<String>

#### (static) verifySmsCode(code, phone) → {Promise}

Source:
  - cloudfunction.js, line 101

Makes a call to verify sms code that sent by AV.Cloud.requestSmsCode

##### Parameters:

Name | Type | Description
--- | --- | ---
`code` | String | The sms code sent by AV.Cloud.requestSmsCode
`phone` | phone | The mobile phoner number(optional).

##### Returns:

A promise that will be resolved with the result of the function.

Type
  Promise