Skip to content

Commit

Permalink
Update api-reference
Browse files Browse the repository at this point in the history
  • Loading branch information
jdwuarin committed Jan 26, 2018
1 parent 7b331fe commit 5a06d7d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 76 deletions.
40 changes: 16 additions & 24 deletions api-reference/base-bot.md
Expand Up @@ -42,14 +42,6 @@ in the subclasses in order for them to work.
| --- | --- | --- |
| settings | <code>object</code> | inheritors of BaseBot take a settings object as first param. |

**Example**
```js
// In general however, one can instantiate a bot object like this:
const bot = new BaseBotSubClass({ // e.g. MessengerBot
credentials: <my_base_bot_sub_class_credentials>,
webhookEnpoint: 'someEndpoint' // only if class requires them
})
```
<a name="BaseBot+createOutgoingMessage"></a>

### baseBot.createOutgoingMessage(message) ⇒ <code>OutgoingMessage</code>
Expand All @@ -60,7 +52,7 @@ it with all its helper functions

This is the instance version of this method

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. The same object passed in with
all the helper functions from OutgoingMessage

Expand All @@ -77,7 +69,7 @@ new outgoingMessage object

This is the instance version of this method

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. A valid OutgoingMessage object with recipient set.

| Param | Type | Description |
Expand All @@ -91,7 +83,7 @@ sendMessage() falls back to the sendMessage implementation of whatever
subclass inherits form BaseBot. The expected format is normally any type of
message object that could be sent on to messenger

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object (see example)

| Param | Type | Description |
Expand Down Expand Up @@ -127,7 +119,7 @@ bot.sendMessage(outgoingMessage);
sendMessageTo() Just makes it easier to send a message without as much
structure.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand All @@ -153,7 +145,7 @@ bot.sendMessageTo(message, update.sender.id);
sendTextMessageTo() Just makes it easier to send a text message with
minimal structure.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand All @@ -174,7 +166,7 @@ reply() Another way to easily send a text message. In this case,
we just send the update that came in as is and then the text we
want to send as a reply.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand All @@ -194,7 +186,7 @@ bot.reply(update, 'something super important!');
sendAttachmentTo() makes it easier to send an attachment message with
less structure.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand Down Expand Up @@ -222,7 +214,7 @@ bot.sendAttachmentTo(attachment, update.sender.id);
sendAttachmentFromUrlTo() makes it easier to send an attachment message with
minimal structure.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand All @@ -244,7 +236,7 @@ sendDefaultButtonMessageTo() makes it easier to send a default set of
buttons. The default button type is the Messenger quick_replies, where
the payload is the same as the button title and the content_type is text.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand All @@ -267,7 +259,7 @@ bot.sendDefaultButtonMessageTo(buttonArray,
sendIsTypingMessageTo() just sets the is typing status to the platform
if available.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with a body object
(see `sendMessage` example)

Expand All @@ -287,7 +279,7 @@ bot.sendIsTypingMessageTo(update.sender.id);
sendCascade() allows developers to send a cascade of messages
in a sequence. All types of messages can be sent (including raw messages).

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with an array of body objects
(see `sendMessage` example for one said object)

Expand Down Expand Up @@ -317,7 +309,7 @@ bot.sendCascade(messageArray);
sendTextCascadeTo() is simply a helper function around sendCascadeTo.
It allows developers to send a cascade of text messages more easily.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves with an array of body objects
(see `sendMessage` example for one said object)

Expand All @@ -339,7 +331,7 @@ calls __sendMessage in each botClass without calling formatOutgoingMessage
before. It's really just sugar around __sendMessage which shouldn't be used
directly.

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise

| Param | Type |
Expand All @@ -351,7 +343,7 @@ directly.
### baseBot.getUserInfo(userId) ⇒ <code>Promise</code>
Retrieves the basic user info from a user if platform supports it

**Kind**: instance method of <code>[BaseBot](#BaseBot)</code>
**Kind**: instance method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>Promise</code> - promise that resolves into the user info or an empty
object by default

Expand All @@ -369,7 +361,7 @@ it with all its helper functions

This is the static version of this method

**Kind**: static method of <code>[BaseBot](#BaseBot)</code>
**Kind**: static method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. The same object passed in with
all the helper functions from OutgoingMessage

Expand All @@ -386,7 +378,7 @@ new outgoingMessage object

This is the static version of this method

**Kind**: static method of <code>[BaseBot](#BaseBot)</code>
**Kind**: static method of [<code>BaseBot</code>](#BaseBot)
**Returns**: <code>OutgoingMessage</code> - outgoingMessage. A valid OutgoingMessage object with recipient set.

| Param | Type | Description |
Expand Down
53 changes: 18 additions & 35 deletions api-reference/botmaster.md
Expand Up @@ -7,12 +7,12 @@ The Botmaster class to rule them all

* [Botmaster](#Botmaster)
* [new Botmaster(settings)](#new_Botmaster_new)
* [.addBot(bot)](#Botmaster+addBot) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.addBot(bot)](#Botmaster+addBot)[<code>Botmaster</code>](#Botmaster)
* [.getBot(options)](#Botmaster+getBot) ⇒ <code>BaseBot</code>
* [.getBots(botType)](#Botmaster+getBots) ⇒ <code>Array</code>
* [.removeBot(bot)](#Botmaster+removeBot) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.use(middleware)](#Botmaster+use) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.useWrapped(incomingMiddleware, outgoingMiddleware)](#Botmaster+useWrapped) ⇒ <code>[Botmaster](#Botmaster)</code>
* [.removeBot(bot)](#Botmaster+removeBot)[<code>Botmaster</code>](#Botmaster)
* [.use(middleware)](#Botmaster+use)[<code>Botmaster</code>](#Botmaster)
* [.useWrapped(incomingMiddleware, outgoingMiddleware)](#Botmaster+useWrapped)[<code>Botmaster</code>](#Botmaster)

<a name="new_Botmaster_new"></a>

Expand All @@ -25,30 +25,13 @@ as a parameter. If not, it creates its own http server
| --- | --- |
| settings | <code>object</code> |

**Example**
```js
// attach the botmaster generated server to port 5000 rather than the default 3000
const botmaster = new Botmaster({
port: 5000,
});
```
**Example**
```js
const http = require('http');

const myServer = http.createServer()
// use my own server rather than letting botmaster creat its own.
const botmaster = new Botmaster({
server: myServer,
});
```
<a name="Botmaster+addBot"></a>

### botmaster.addBot(bot) ⇒ <code>[Botmaster](#Botmaster)</code>
### botmaster.addBot(bot) ⇒ [<code>Botmaster</code>](#Botmaster)
Add an existing bot to this instance of Botmaster

**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object for chaining
**Kind**: instance method of [<code>Botmaster</code>](#Botmaster)
**Returns**: [<code>Botmaster</code>](#Botmaster) - returns the botmaster object for chaining

| Param | Type | Description |
| --- | --- | --- |
Expand All @@ -59,7 +42,7 @@ Add an existing bot to this instance of Botmaster
### botmaster.getBot(options) ⇒ <code>BaseBot</code>
Extract First bot of given type or provided id.

**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Kind**: instance method of [<code>Botmaster</code>](#Botmaster)
**Returns**: <code>BaseBot</code> - The bot found of a class that inherits of BaseBot

| Param | Type | Description |
Expand All @@ -71,7 +54,7 @@ Extract First bot of given type or provided id.
### botmaster.getBots(botType) ⇒ <code>Array</code>
Extract all bots of given type.

**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Kind**: instance method of [<code>Botmaster</code>](#Botmaster)
**Returns**: <code>Array</code> - Array of bots found

| Param | Type | Description |
Expand All @@ -80,24 +63,24 @@ Extract all bots of given type.

<a name="Botmaster+removeBot"></a>

### botmaster.removeBot(bot) ⇒ <code>[Botmaster](#Botmaster)</code>
### botmaster.removeBot(bot) ⇒ [<code>Botmaster</code>](#Botmaster)
Remove an existing bot from this instance of Botmaster

**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object for chaining
**Kind**: instance method of [<code>Botmaster</code>](#Botmaster)
**Returns**: [<code>Botmaster</code>](#Botmaster) - returns the botmaster object for chaining

| Param | Type |
| --- | --- |
| bot | <code>Object</code> |

<a name="Botmaster+use"></a>

### botmaster.use(middleware) ⇒ <code>[Botmaster](#Botmaster)</code>
### botmaster.use(middleware) ⇒ [<code>Botmaster</code>](#Botmaster)
Add middleware to this botmaster object
This function is just sugar for `middleware.__use` in them

**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object so you can chain middleware
**Kind**: instance method of [<code>Botmaster</code>](#Botmaster)
**Returns**: [<code>Botmaster</code>](#Botmaster) - returns the botmaster object so you can chain middleware

| Param | Type |
| --- | --- |
Expand Down Expand Up @@ -131,14 +114,14 @@ This function is just sugar for `middleware.__use` in them
```
<a name="Botmaster+useWrapped"></a>

### botmaster.useWrapped(incomingMiddleware, outgoingMiddleware) ⇒ <code>[Botmaster](#Botmaster)</code>
### botmaster.useWrapped(incomingMiddleware, outgoingMiddleware) ⇒ [<code>Botmaster</code>](#Botmaster)
Add wrapped middleware to this botmaster instance. Wrapped middleware
places the incoming middleware at beginning of incoming stack and
the outgoing middleware at end of outgoing stack.
This function is just sugar `middleware.useWrapped`.

**Kind**: instance method of <code>[Botmaster](#Botmaster)</code>
**Returns**: <code>[Botmaster](#Botmaster)</code> - returns the botmaster object so you can chain middleware
**Kind**: instance method of [<code>Botmaster</code>](#Botmaster)
**Returns**: [<code>Botmaster</code>](#Botmaster) - returns the botmaster object so you can chain middleware

| Param | Type | Description |
| --- | --- | --- |
Expand Down

0 comments on commit 5a06d7d

Please sign in to comment.