Skip to content

Commit

Permalink
Merge pull request 2600hz#1762 from 2600hz/knm-GET-phone_numbers
Browse files Browse the repository at this point in the history
knm-GET-phone_numbers: replace old way using a view
  • Loading branch information
lazedo committed Apr 10, 2016
2 parents 68af764 + e6045c8 commit ed0bf50
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 535 deletions.
64 changes: 58 additions & 6 deletions applications/crossbar/doc/phone_numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ This lists the numbers an account owns, along with their properties.
- Verb: `GET`
- Url: `/v2/accounts/{{ACCOUNT_ID}}/phone_numbers`
- Payload: none
- Note: one can apply filters such as `?filter_state=in_service` or `?created_from=63627345744`

##### Response

Expand All @@ -233,19 +234,15 @@ This lists the numbers an account owns, along with their properties.
"+14155555555": {
"assigned_to": "4b8c6fec4b2597882c0390202d195419",
"created": 63602230185,
"features": [
"local"
],
"features": {},
"state": "in_service",
"updated": 63602230212,
"used_by": "callflow"
},
"+14158865100": {
"assigned_to": "4b8c6fec4b2597882c0390202d195419",
"created": 63624719324,
"features": [
"local"
],
"features": {},
"state": "in_service",
"updated": 63624719325,
"used_by": ""
Expand All @@ -258,6 +255,61 @@ This lists the numbers an account owns, along with their properties.
}
```

#### List an account's specific phone number

Lists the properties associated with this account's number.

##### Request

- Verb: `GET`
- Url: `/v2/accounts/{{ACCOUNT_ID}}/phone_numbers/{{PHONENUMBER}}`
- Payload: none
- Note: `PHONENUMBER` has to be URL-encoded (e.g. turn `+14155555555` into `%2B14155555555`. Note `4155555555` works too!)

##### Response

###### Success

```json
{
"auth_token": "1a82795e8759f62d77f6552de80ce32e",
"data": {
"id": "+14155555555",
"assigned_to": "4b8c6fec4b2597882c0390202d195419",
"created": 63602230185,
"features": {},
"state": "in_service",
"updated": 63602230212,
"used_by": "callflow"
},
"request_id": "e268c22be3076a12d8581ebab0d89cc8",
"revision": "undefined",
"status": "success"
}
```

###### Failure

Possible reasons for failure:

* Number contains a typo
* Account does not have enough privileges to read number
* Number does not exist

```json
{
"auth_token": "1a82795e8759f62d77f6552de80ce32e",
"data": {
"message": "bad identifier",
"not_found": "The number could not be found"
},
"error": "404",
"message": "bad_identifier",
"request_id": "94cf464971722272dd0b04cbc491303f",
"status": "error"
}
```


#### Search for numbers

Expand Down
18 changes: 0 additions & 18 deletions applications/crossbar/doc/phone_numbers_v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Learn how to use the 2600hz mobile API set to activate and manage numbers.

* [Load classifiers](#user-content-load-classifiers)
* [Classify a number](#user-content-classify-a-number)
* [Get a number](#user-content-get-a-number)
* [Locality](#user-content-locality)
* [Fix](#user-content-fix)

Expand Down Expand Up @@ -87,23 +86,6 @@ Learn how to use the 2600hz mobile API set to activate and manage numbers.
}
```

### Get a number

#### Request

`GET` `http://{{SERVER}}/v2/accounts/{{account_id}}/phone_numbers/{{NUMBER}}`

#### Response

```json
{
"data": {
"id": "+14158551292"
},
"status": "success"
}
```

### Locality

#### Request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"language": "javascript",
"views": {
"crossbar_listing": {
"map": "function(doc) { if(doc.pvt_type != 'number' || doc.pvt_deleted) return; emit(doc._id, {id: doc._id, number: doc._id, state: (typeof doc.pvt_state !== 'undefined') ? doc.pvt_state : doc.pvt_number_state, features: doc.pvt_features, assigned_to: doc.pvt_assigned_to, used_by: doc.pvt_used_by, created: doc.pvt_created, updated: doc.pvt_modified, locality: doc.pvt_locality});}"
"map": "function(doc) { if(doc.pvt_type != 'number' || doc.pvt_deleted) return; emit(doc._id, {state: (typeof doc.pvt_state !== 'undefined') ? doc.pvt_state : doc.pvt_number_state, features: doc.pvt_features, assigned_to: doc.pvt_assigned_to, used_by: doc.pvt_used_by, created: doc.pvt_created, updated: doc.pvt_modified, locality: doc.pvt_locality});}"
}
}
}
240 changes: 0 additions & 240 deletions applications/crossbar/priv/couchdb/schemas/numbers.json

This file was deleted.

Loading

0 comments on commit ed0bf50

Please sign in to comment.