<commit_before># GoJunebug 
This is a proof of concept of using golang for an SMPP gateway like Kannel. It doesn't do much of anything yet, it is mostly for me learning Go.

## Running
First update junebug.conf to have the appropriate settings. Specifically make sure all the revelant directories exit.

```bash
% export GOPATH=`pwd`
% go install github.com/nyaruka/junebug
% ./bin/junebug --settings=junebug.conf
2015/07/19 16:35:25 Starting server on http://localhost:8000
2015/07/19 16:35:25 	POST /connection                      - Add a connection
2015/07/19 16:35:25 	GET  /connection                      - List Connections
2015/07/19 16:35:25 	GET  /connection/[uuid]               - Read Connection Status
2015/07/19 16:35:25 	POST /connection/[uuid]/send          - Send Message
2015/07/19 16:35:25 	GET  /connection/[uuid]/status/[id]   - Get Message Status
```

### Sender Types
Currently there are two types of senders ```echo``` which after a configurable pause, will send the message back, and ```twitter``` that will send and receive Twitter DM's.

#### Echo Config

```pause``` - integer as string, representing how many seconds to pause before sending back an echo. Can be zero for no delay.

#### Twitter Config

```username``` - string, the username of the user sending and receiving DMs
```access_token``` - string, the access token for the user sending and receiving DMs
```access_token_secret``` - string, the access token secret for the user sending and receiving DMs

### Receiver Types
Currently there is only one type of receiver ```http```, which will POST the incoming msg to the URL provided on incoming messages.

#### HTTP Config

```url``` - string, the URL to POST to with new messages

## Endpoints
All interactions with Junebug are through HTTP endpoints

### Creating Connection
```json
PUT /connection
{
  "senders": {
    "type": "echo",
    "count": 5,
    "config": {
      "pause": "1"
    }
  },
  "receivers": {
    "receiver_type": "http",
    "count": 5,
    "config": {
      "url": "http://myhost.com/receive"
    }
  }
}
```
You will receive a response containing the connection created, and it's UUID:
```json
{
  "uuid": "3958bba4-8eae-43b8-b30c-534db207b279",
  "Senders": {
    "type": "echo",
    "count": 5,
    "config": {
      "pause": "1"
    }
  },
  "Receivers": {
    "type": "http",
    "count": 5,
    "config": {
      "url": "http://myhost.com/receive"
    }
  }
}
```

### Listing Connections
```json
GET /connection
```
You will receive a list of the active connections:
```json
{
  "connections": [
    {
      "uuid": "3958bba4-8eae-43b8-b30c-534db207b279",
      "senders": {
        "type": "echo",
        "count": 5,
        "config": {
          "pause": "1"
        }
      },
      "receivers": {
        "type": "http",
        "count": 5,
        "config": {
          "url": "http://myhost.com/receive"
        }
      }
    }
  ]
}
```

### Getting the status of a connection
```
GET /connection/[connection_uuid]
```
You will receive the connection configuration as well as it's status of queued incoming and outgoing messages:
```json
{
  "connection": {
  "uuid": "3958bba4-8eae-43b8-b30c-534db207b279",
  "Senders": {
    "type": "echo",
    "count": 5,
    "config": {
      "pause": "1"
    }
  },
  "Receivers": {
    "type": "http",
    "count": 5,
    "config": {
      "url": "http://myhost.com/receive"
    }
   }
  },
  "status": {
    "outgoing_queued": 0,
    "incoming_queued": 0,
    "handled_results": 1050,
    "sent_results": 1050
  }
}
```
<commit_msg>Few more typos in README.md<commit_after># GoJunebug 
This is a proof of concept of using golang for an SMPP gateway like Kannel. It doesn't do much of anything yet, it is mostly for me learning Go.

## Running
First update junebug.conf to have the appropriate settings. Specifically make sure all the relevant directories exist.

```bash
% export GOPATH=`pwd`
% go install github.com/nyaruka/junebug
% ./bin/junebug --settings=junebug.conf
2015/07/19 16:35:25 Starting server on http://localhost:8000
2015/07/19 16:35:25 	POST /connection                      - Add a connection
2015/07/19 16:35:25 	GET  /connection                      - List Connections
2015/07/19 16:35:25 	GET  /connection/[uuid]               - Read Connection Status
2015/07/19 16:35:25 	POST /connection/[uuid]/send          - Send Message
2015/07/19 16:35:25 	GET  /connection/[uuid]/status/[id]   - Get Message Status
```

### Sender Types
Currently there are two types of senders: ```echo``` which after a configurable pause, will send the message back, and ```twitter``` that will send and receive Twitter DMs.

#### Echo Config

```pause``` - integer as string, representing how many seconds to pause before sending back an echo. Can be zero for no delay.

#### Twitter Config

```username``` - string, the username of the user sending and receiving DMs
```access_token``` - string, the access token for the user sending and receiving DMs
```access_token_secret``` - string, the access token secret for the user sending and receiving DMs

### Receiver Types
Currently there is only one type of receiver ```http```, which will POST the incoming msg to the URL provided on incoming messages.

#### HTTP Config

```url``` - string, the URL to POST to with new messages

## Endpoints
All interactions with Junebug are through HTTP endpoints.

### Creating Connection
```json
PUT /connection
{
  "senders": {
    "type": "echo",
    "count": 5,
    "config": {
      "pause": "1"
    }
  },
  "receivers": {
    "receiver_type": "http",
    "count": 5,
    "config": {
      "url": "http://myhost.com/receive"
    }
  }
}
```
You will receive a response containing the connection created, and its UUID:
```json
{
  "uuid": "3958bba4-8eae-43b8-b30c-534db207b279",
  "Senders": {
    "type": "echo",
    "count": 5,
    "config": {
      "pause": "1"
    }
  },
  "Receivers": {
    "type": "http",
    "count": 5,
    "config": {
      "url": "http://myhost.com/receive"
    }
  }
}
```

### Listing Connections
```json
GET /connection
```
You will receive a list of the active connections:
```json
{
  "connections": [
    {
      "uuid": "3958bba4-8eae-43b8-b30c-534db207b279",
      "senders": {
        "type": "echo",
        "count": 5,
        "config": {
          "pause": "1"
        }
      },
      "receivers": {
        "type": "http",
        "count": 5,
        "config": {
          "url": "http://myhost.com/receive"
        }
      }
    }
  ]
}
```

### Getting the status of a connection
```
GET /connection/[connection_uuid]
```
You will receive the connection configuration as well as its status of queued incoming and outgoing messages:
```json
{
  "connection": {
  "uuid": "3958bba4-8eae-43b8-b30c-534db207b279",
  "Senders": {
    "type": "echo",
    "count": 5,
    "config": {
      "pause": "1"
    }
  },
  "Receivers": {
    "type": "http",
    "count": 5,
    "config": {
      "url": "http://myhost.com/receive"
    }
   }
  },
  "status": {
    "outgoing_queued": 0,
    "incoming_queued": 0,
    "handled_results": 1050,
    "sent_results": 1050
  }
}
```

{'fraction_non_alphanumeric': 0.14747191011235955, 'fraction_numerical': 0.047752808988764044, 'mean_word_length': 2.793819925412893, 'pattern_counts': {'":': 100, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6375789', 'n_tokens_mistral': 2620, 'n_tokens_neox': 2311, 'n_words': 744}