Nexmo / nexmo-cli

Nexmo CLI (Command Line Interface)
https://nexmo.com
MIT License
78 stars 52 forks source link

Add setup:number #9

Closed cbetta closed 8 years ago

cbetta commented 8 years ago

@sammachin could you clarify what API call you see this mapping too? I'm having difficulty determining this.

From the doc:

Setup Number
nexmo number:setup $number [app|sms|voicefwd|voicexml]
[app]
-name [$name|$appid]
[sms]
    -url $url 
[voicefwd]
    -address [$e164Num|$sipuri]
    -statusurl $statusCallbackURL *optional
[voicexml]
-url $URLofVXML
    -statusurl $statusCallbackURL *optional

Sets up the number for either app usage or legacy SMS or Voice service, voice has the option of forwarding to a number/sip URI or to a VoiceXML application.
Note, currently you can setup a number for both app which will configure voice to goto VAPI and then legacy SMS to a URL, however app|voicexml|voicefwd are mutually exclusive
sammachin commented 8 years ago

It's the application API might not be in the public docs yet, @leggetter should be able to point you in the right direction or if he's not sure ask Roland

On Friday, 6 May 2016, Cristiano Betta notifications@github.com wrote:

@sammachin https://github.com/sammachin could you clarify what API call you see this mapping too? I'm having difficulty determining this.

From the doc:

Setup Number nexmo number:setup $number [app|sms|voicefwd|voicexml] [app] -name [$name|$appid] [sms] -url $url [voicefwd] -address [$e164Num|$sipuri] -statusurl $statusCallbackURL optional [voicexml] -url $URLofVXML -statusurl $statusCallbackURL optional

Sets up the number for either app usage or legacy SMS or Voice service, voice has the option of forwarding to a number/sip URI or to a VoiceXML application. Note, currently you can setup a number for both app which will configure voice to goto VAPI and then legacy SMS to a URL, however app|voicexml|voicefwd are mutually exclusive

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/Nexmo/nexmo-cli/issues/9

cbetta commented 8 years ago

@leggetter would love some clarification on this. The docs (https://docs.nexmo.com/tools/application-api) only show the basic CRUD as far as I can see.

leggetter commented 8 years ago

See the section with the para:

Use the following code examples to make a POST request with Developer API and associate the application_id with your virtual number.

https://docs.nexmo.com/tools/application-api#apps_quickstart

Is that what you're after?

cbetta commented 8 years ago

@leggetter Not really. Isn't that the app:create function in the CLI docs?

leggetter commented 8 years ago

Use the following code examples to make a POST request with Developer API and associate the application_id with your virtual number.

#!/bin/bash

base_url='https://rest.nexmo.com'
version=''
action='/number/update'
application_id='APPLICATION_ID'
key='API_KEY'
secret='API_SECRET'
country='XX'
msisdn='441632960960'

curl -X POST $base_url$version$action \
-d api_key=$key \
-d api_secret=$secret \
-d country=$country \
-d msisdn=$msisdn \
-d voiceCallbackType='app' \
-d voiceCallbackValue=$application_id

As per the text, this is used to associate a number with an app. Isn't that what we're trying to do here?

cbetta commented 8 years ago

@leggetter I think I'm starting to get it. All of the number:setup calls reflect the number->update API.

https://docs.nexmo.com/tools/developer-api/number-update

So let's rewrite this:

nexmo number:setup $number [app|sms|voicefwd|voicexml]
[app]
-name [$name|$appid]
[sms]
    -url $url 
[voicefwd]
    -address [$e164Num|$sipuri]
    -statusurl $statusCallbackURL *optional
[voicexml]
-url $URLofVXML
    -statusurl $statusCallbackURL *optional

As:

nexmo number:update app <number> <app_id>
nexmo number:update sip <???>
nexmo number:update tel <???>
nexmo number:update vxml <???>

As I'm not quite familiar yet with Nexmo, can someone explain to me what the relevant params are for the sip, tel, and vxml types? I've read the docs but it's not made things clearer. It's hard to tell what's required for which type.

leggetter commented 8 years ago

Do we assign a number to an app or an app to a number?

To me it feels like you have a number and you then assign it to an application.

nexmo app:add-number <app_id> <number>

But... A number can only be associated with one app. In fact, we have an idea of number pools where you can create number pools and assign a pool to a number. But there is still some work going on in this space.

cbetta commented 8 years ago

@leggetter honestly no idea. You're the expert :). I'd say a number can be assigned to a few things. This is what the API suggests. So specifying what the number belongs to on the number level might make more sense (and is what the API does, I think). Honestly it's all up to you and what you want. I'd be happy to do either but need some clarity.

leggetter commented 8 years ago

I'm certainly no expert.

Based on a conversation from just over a week ago the docs stating application_type is actually wrong. Apps (will) have different capabilities. A voice is the the only capability right now.

Apps can then have number pools (groups of numbers) associated with them. Or you could say that an app has number pools associated with it. I don't believe we expose number pools right now. So associating single numbers is the best we can do, and I think that's fine for now.

So both

  1. app:add-number <app_id> <number>
  2. number:update <number> <app_id>

may be valid.

My vote would be for 1. @sammachin - what do you think?

cbetta commented 8 years ago

@sammachin thoughts on this?

cbetta commented 8 years ago

I've been thinking:

nexmo link <number> <app_id>
nexmo unlink <number>

That seems the most elegant way to me for now. Does that work?

cbetta commented 8 years ago

Down the line we can make this backwards compatible like this:

nexmo link <number> <xid> --type <type>

Where type is by default app?

cbetta commented 8 years ago

@leggetter @sammachin I got the nexmo link working using the updateNumber() API. Any idea how to unlink an app from a number? I tried setting voiceCallbackType to null or a blank string but no luck.

cbetta commented 8 years ago

Ok @sammachin confirmed this is probably not possible yet.

Have release this for now as a simple nexmo link <number> <app_id>.