# Context

Helpers for extracting information from the webhook event, which can be passed to GitHub API calls.

## Constructor

#### new Context()

##### Properties:

Name | Type | Description
--- | --- | ---
`github` | `github` | An authenticated GitHub API client
`payload` | `payload` | The webhook event payload
`log` | `logger` | A logger

Source:
  - context.js, line 12

### Members

#### isBot :boolean

Returns a boolean if the actor on the event was a bot.

Source:
  - context.js, line 63

##### Type:

- `boolean`

### Methods

#### config(fileName, defaultConfigopt) → {Promise.<Object>}

Reads the app configuration from the given YAML file in the `.github` directory of the repository.

Source:
  - context.js, line 100

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`fileName` | `string` |  | Name of the YAML file in the `.github` directory
`defaultConfig` | `object` | <optional> | An object of default config options

##### Returns:

Type:
  `Promise.<Object>`

- Configuration object read from the file

##### Examples

Contents of `.github/myapp.yml`.

    close: true
    comment: Check the specs on the rotary girder.

App that reads from `.github/myapp.yml`.

    // Load config from .github/myapp.yml in the repository
    const config = await context.config('myapp.yml')

    if (config.close) {
      context.github.issues.comment(context.issue({body: config.comment}))
      context.github.issues.edit(context.issue({state: 'closed'}))
    }

Using a `defaultConfig` object.

    // Load config from .github/myapp.yml in the repository and combine with default config
    const config = await context.config('myapp.yml', {comment: 'Make sure to check all the specs.'})

    if (config.close) {
      context.github.issues.comment(context.issue({body: config.comment}));
      context.github.issues.edit(context.issue({state: 'closed'}))
    }

#### issue(objectopt)

Return the `owner`, `repo`, and `number` params for making API requests against an issue or pull request. The object passed in will be merged with the repo params.

Source:
  - context.js, line 52

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`object` | `object` | <optional> | Params to be merged with the issue params.

##### Example

    const params = context.issue({body: 'Hello World!'})
    // Returns: {owner: 'username', repo: 'reponame', number: 123, body: 'Hello World!'}

#### repo(objectopt)

Return the `owner` and `repo` params for making API requests against a repository.

Source:
  - context.js, line 31

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`object` | `object` | <optional> | Params to be merged with the repo params.

##### Example

    const params = context.repo({path: '.github/stale.yml'})
    // Returns: {owner: 'username', repo: 'reponame', path: '.github/stale.yml'}