Skip to content

Commit

Permalink
fix table and add CSV example (2600hz#3611)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti authored and fenollp committed Apr 19, 2017
1 parent 4901cc4 commit f20ce4b
Showing 1 changed file with 79 additions and 17 deletions.
96 changes: 79 additions & 17 deletions applications/tasks/doc/rates.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ An account can be assigned a ratedeck; if no ratedeck is assigned, the default r

## Fields

|Name|Description|Required|
|`account_id`|reseller's account (see **Note 1** below)| |
|`description`|description for rate| |
|`direction`|direction of call leg ("inbound", "outbound"), if not set - rate matches both directions| |
|`iso_country_code`|[ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements) code for prefix's country| |
|`prefix`|prefix for match DID number| `true` |
|`pvt_rate_cost`|internal rate cost, used for `weight` calculation| |
|`pvt_rate_surcharge`|internal rate surcharge| |
|`rate_cost`|per minute cost| `true` |
|`rate_increment`|billing "steps" for rate| |
|`rate_minimum`|minimum call duration| |
|`rate_name`|short name for rate, if this field not set it will be generated from `prefix`, `iso_country_code` and `direction` fields| |
|`rate_nocharge_time`|"free" call time, if call duration less then this value (seconds), then call not charged| |
|`rate_surcharge`|charge amount on connect (answer)| |
|`rate_version`|rate version| |
|`ratedeck_name`| ratedeck name, assigned to account via service plan| |
|`weight`|when found several rates with same prefix, used rate with higher weight. If not set - calculated from `prefix` length and `rate_cost` (`pvt_rate_cost`)| |
Name | Description | Required
---- | ----------- | --------
`account_id`|reseller's account (see **Note 1** below)|
`description`|description for rate|
`direction`|direction of call leg ("inbound", "outbound"), if not set - rate matches both directions|
`iso_country_code`|[ISO 3166-1](https://en.wikipedia.org/wiki/ISO_3166-1#Officially_assigned_code_elements) code for prefix's country|
`prefix`|prefix for match DID number| `true`
`pvt_rate_cost`|internal rate cost, used for `weight` calculation|
`pvt_rate_surcharge`|internal rate surcharge|
`rate_cost`|per minute cost| `true`
`rate_increment`|billing "steps" for rate|
`rate_minimum`|minimum call duration|
`rate_name`|short name for rate, if this field not set it will be generated from `prefix`, `iso_country_code` and `direction` fields|
`rate_nocharge_time`|"free" call time, if call duration less then this value (seconds), then call not charged|
`rate_surcharge`|charge amount on connect (answer)|
`rate_version`|rate version|
`ratedeck_name`| ratedeck name, assigned to account via service plan|
`weight`|when found several rates with same prefix, used rate with higher weight. If not set - calculated from `prefix` length and `rate_cost` (`pvt_rate_cost`)|

CSV files for all actions use the same list of fields. Names of fields match the names of keys in the CouchDB [rate document](../../crossbar/doc/rates.md#schema).

Expand Down Expand Up @@ -67,6 +68,67 @@ curl -v -X GET \
'http://{SERVER}:8000/v2/tasks/{TASK_ID}'
```

#### Sample CSV

First, query the API to see what fields must be defined and what fields are optional:

```bash
curl 'http://{SERVER}:8000/v2/tasks?category=rates&action=import'
```
```json
{
"data": {
"tasks": {
"rates": {
"import": {
"description": "Bulk-import rates to a specified ratedeck",
"doc": "Creates rates from file",
"expected_content": "text/csv",
"mandatory": [
"prefix",
"rate_cost"
],
"optional": [
"account_id",
"carrier",
"description",
"direction",
"internal_rate_cost",
"iso_country_code",
"options",
"rate_increment",
"rate_minimum",
"rate_name",
"rate_nocharge_time",
"rate_surcharge",
"rate_version",
"ratedeck_id",
"routes",
"weight"
]
}
}
}
},
"request_id": "{REQUEST_ID}",
"status": "success",
"timestamp": "2017-04-19T21:58:45",
"version": "4.0.0"
}
```

The CSV must then define a header row with at least the mandatory fields defined.

```csv
"prefix","rate_cost","rate_name"
1,0.1,"US/Canada Default"
1415,0.05,"San Francisco"
```

Prefixes will match against the E164 number with the '+' stripped. Longest prefix matched wins.

Any fields not in the **mandatory** or **optional** list will be ignored. Order of the columns is irrelevant.

### Export

Export all rates into CSV.
Expand Down

0 comments on commit f20ce4b

Please sign in to comment.