GithubHelp home page GithubHelp logo

nexmo / nexmo-cli Goto Github PK

View Code? Open in Web Editor NEW
78.0 23.0 52.0 1.28 MB

Nexmo CLI (Command Line Interface)

Home Page: https://nexmo.com

License: MIT License

JavaScript 100.00%
nexmo cli command-line command-line-tool vonage developer-destination

nexmo-cli's Introduction

Nexmo CLI

Contributor Covenant npm version Build Status Known Vulnerabilities codecov

Nexmo is now known as Vonage

❗ Th CLI has moved! It is now the Vonage CLI.

We will support this repository for 12 months, ending October 2022, with any needed bug or security fixes for the last release. New features will be released under the Vonage CLI`, so to take advantage of those please make sure to switch as soon as possible so you don't miss out!

Installation | Usage | Contributing | License

Installation

The Nexmo CLI requires Node.js 4 or above. If you don't have Node.js installed on your system, go to https://nodejs.org/en/download/ and download the appropriate installer for your system.

With Node.js installed, you can then install the nexmo-cli package from the npm registry.

npm install nexmo-cli -g   # Using npm
yarn global add nexmo-cli  # Using yarn

If you see an EACCES error when you try to install a package globally, follow the steps outlined at How to Prevent Permissions Errors.

After installation, set up the CLI with your Nexmo API key and secret:

> nexmo setup <api_key> <api_secret>
Credentials written to /Users/yourname/.nexmorc

This will save your credentials to ~/.nexmorc. If you want to use different credentials per project, you can pass the --local flag as follows:

> nexmo setup <api_key> <api_secret> --local

This will save the config to your local folder instead.

Usage

Flags | Account | Pricing | Numbers | SMS | Applications | Linking | Insight | JWT

Flags

Use --quiet to silence all but errors and warnings, and use --verbose to get more detailed output.

Account

Account login

> nexmo setup <api_key> <api_secret>
Credentials written to /home/username/.nexmorc

Alias: nexmo s.

Account info

> nexmo account
API Key:    <api_key>
API Secret: <api_secret>

> nexmo account:key
<api_key>

> nexmo account:secret
<api_secret>

Alias: nexmo a.

Account balance

> nexmo balance
18.96 EUR

> nexmo balance -v
18.9589 EUR

Alias: nexmo b

Pricing

Price to send an SMS to a number

> nexmo price:sms 44555555555
0.03140000 EUR

Alias: nexmo ps

Price to make a call to a number

> nexmo price:voice 44555555555
0.02400000 EUR

Alias: nexmo pv

Price for outbound SMS per country

> nexmo price:country GB
0.03140000 EUR

> nexmo price:country LU -v

network           | mtPrice
------------------------------
POST Luxembourg   | 0.01280000
Orange Luxembourg | 0.01280000
Join Experience   | 0.01280000
Tango             | 0.01280000

Alias: nexmo pc

Numbers

List all numbers on your account

  • Optional flags:

    • --size The number of results to return
    • --page The page of results to return
    • --pattern <pattern> to be matched in number (use * to match end or start of number)
> nexmo numbers:list
31555555555
44655555555
44555555555

> nexmo numbers:list --verbose
Item 1-3 of 3

msisdn      | country | type       | features  | voiceCallbackType | voiceCallbackValue | moHttpUrl | voiceStatusCallbackUrl
----------------------------------------------------------------------------------------------------------------------------
31555555555 | NL      | mobile-lvn | VOICE,SMS | app               | b6d9f957           | undefined | https://example.com
44655555555 | GB      | mobile-lvn | VOICE,SMS | app               | b6d9f957           | undefined | https://example.com
44555555555 | GB      | mobile-lvn | SMS       | app               | b6d9f957           | undefined | https://example.com

Alias: nexmo nl, nexmo numbers and nexmo number:list.

Search for new numbers

Parameters:

  • country_code - an ISO 3166-2 country code for the country you are trying to find a number for.

  • Optional flags:

    • --pattern <pattern> to be matched in number (use * to match end or start of number)
    • --voice to search for voice-enabled numbers
    • --sms search for SMS enabled numbers
    • --size the number of results to return
    • --page the page of results to return
> nexmo number:search US
12057200555
12069396555
12069396555
12155961555

> nexmo number:search NL --sms --pattern *007 --verbose
msisdn      | country | cost | type       | features
-----------------------------------------------------
31655551007 | NL      | 3.00 | mobile-lvn | VOICE,SMS
31655552007 | NL      | 3.00 | mobile-lvn | VOICE,SMS
31655553007 | NL      | 3.00 | mobile-lvn | VOICE,SMS

Alias: nexmo ns and nexmo numbers:search.

Buying a number

Parameters:

  • number - The number to buy
  • or country_code and pattern - The country and search pattern to find a number for and directly buy.
> nexmo number:buy 12069396555
Buying 12069396555\. This operation will charge your account.

Please type "confirm" to continue: confirm

Number purchased

> nexmo number:buy US *555
Buying 12069396555\. This operation will charge your account.

Please type "confirm" to continue: confirm

Number purchased: 12069396555

> nexmo number:buy 12069396555 --confirm
Number purchased: 12069396555

Alias: nexmo nb and nexmo numbers:buy.

Cancelling a number

> nexmo number:cancel 12069396555
This operation can not be reversed.

Please type "confirm" to continue: confirm

Number cancelled: 12069396555

> nexmo number:cancel 12069396555 --confirm
Number cancelled: 12069396555

Alias: nexmo nc and nexmo numbers:cancel.

Update a number

For shortcuts of these options see Linking.

> nexmo number:update 445555555555 --voice_callback_type app --voice_callback_value asdasdas-asdd-2344-2344-asdasdasd345
Number updated

Alias: nexmo nu and nexmo numbers:update.

SMS

Send an SMS

Send a message through Nexmo to any number. Either provide a from number, name, or leave it blank to sends as "Nexmo CLI".

> nexmo sms <destination_number> Hello world! --confirm
Message sent to:   <destination_number>
Remaining balance: 26.80110000 EUR
Message price:     0.03330000 EUR

> nexmo sms  <destination_number> Hello world! --from "Acme Inc" --confirm
Message sent to:   <destination_number>
Remaining balance: 26.80110000 EUR
Message price:     0.03330000 EUR

Note: Some carriers (e.g. US and Canadian) do not allow alphanumeric senders. In these cases, you must use one of your Nexmo virtual numbers in the from parameter. For example:

nexmo sms <to_number> Hello world! --from <from_number> --confirm

Applications

List your Applications

  • Optional flags:

    • --size The number of results to return
    • --page The page of results to return
> nexmo app:list
asdasdas-asdd-2344-2344-asdasdasd123 | Test Application 1
asdasdas-asdd-2344-2344-asdasdasd234 | Test Application 1
asdasdas-asdd-2344-2344-asdasdasd345 | Test Application 2

> nexmo app:list --verbose
Item 1-3 of 3

id                                   | name
---------------------------------------------------------
asdasdas-asdd-2344-2344-asdasdasd123 | Test Application 1
asdasdas-asdd-2344-2344-asdasdasd234 | Test Application 1
asdasdas-asdd-2344-2344-asdasdasd345 | Test Application 2

Alias: nexmo al and nexmo apps.

Create a new Application

Parameters:

  • name - the custom name of your application.

  • answer_url - the URL where your webhook delivers the Nexmo Call Control Object that governs this call.

  • event_url - the URL the platform sends event information asynchronously to when the call_status changes

  • Optional flags:

    • --keyfile <keyfile> The file to save your private key to
    • --type <type> The product you want to access with this application. (Default: voice)
    • --answer_method <answer_method> The http method for the answer_url. (Default: GET)
    • --event_method <event_method> The http method for the event_url. (Default: GET)
> nexmo app:create "Test Application 1" http://example.com http://example.com  --keyfile private.key
Application created: asdasdas-asdd-2344-2344-asdasdasd345
Private Key saved to: private.key

> nexmo app:create "Test Application 1" http://example.com http://example.com -v
[id]
asdasdas-asdd-2344-2344-asdasdasd345

[name]
Test Application 1

[voice.webhooks.0.endpoint_type]
event_url

[voice.webhooks.0.endpoint]
http://example.com

[voice.webhooks.0.http_method]
POST

[voice.webhooks.1.endpoint_type]
answer_url

[voice.webhooks.1.endpoint]
http://example.com

[voice.webhooks.1.http_method]
GET

[keys.public_key]
...

[keys.private_key]
...

[_links.self.href]
/applications/asdasdas-asdd-2344-2344-asdasdasd345

Alias: nexmo ac.

Show details for an Application

> nexmo app:show asdasdas-asdd-2344-2344-asdasdasd345
[id]
asdasdas-asdd-2344-2344-asdasdasd345

[name]
Test Application 1

[voice.webhooks.0.endpoint_type]
event_url

[voice.webhooks.0.endpoint]
http://example.com

[voice.webhooks.0.http_method]
POST

[voice.webhooks.1.endpoint_type]
answer_url

[voice.webhooks.1.endpoint]
http://example.com

[voice.webhooks.1.http_method]
GET

[keys.public_key]
...

[_links.self.href]
/applications/asdasdas-asdd-2344-2344-asdasdasd345


Private Key saved to: private.key

Alias: nexmo as and nexmo app.

Update an Application

Parameters:

  • app_id - the UUID of your application.

  • name - the custom name of your application.

  • answer_url - the URL where your webhook delivers the Nexmo Call Control Object that governs this call.

  • event_url - the URL the platform sends event information asynchronously to when the call_status changes

  • Optional flags:

    • --type <type> The product you want to access with this application. (Default: voice)
    • --answer_method <answer_method> The http method for the answer_url. (Default: GET)
    • --event_method <event_method> The http method for the event_url. (Default: GET)
> nexmo app:update asdasdas-asdd-2344-2344-asdasdasd345 "Test Application 1" http://example.com http://example.com
Application updated: asdasdas-asdd-2344-2344-asdasdasd345

> nexmo app:update asdasdas-asdd-2344-2344-asdasdasd345 "Test Application 1" http://example.com http://example.com -v
[id]
asdasdas-asdd-2344-2344-asdasdasd345

[name]
Test Application 1

[voice.webhooks.0.endpoint_type]
event_url

[voice.webhooks.0.endpoint]
http://example.com

[voice.webhooks.0.http_method]
POST

[voice.webhooks.1.endpoint_type]
answer_url

[voice.webhooks.1.endpoint]
http://example.com

[voice.webhooks.1.http_method]
GET

[keys.public_key]
...

[keys.private_key]
...

[_links.self.href]
/applications/asdasdas-asdd-2344-2344-asdasdasd345

Alias: nexmo au.

Delete an application

Parameters:

  • app_id - The UUID of your application.
> nexmo app:delete asdasdas-asdd-2344-2344-asdasdasd345
This operation can not be reversed.

Please type "confirm" to continue: confirm

Application deleted

> nexmo app:delete asdasdas-asdd-2344-2344-asdasdasd345 --confirm
Application deleted

Alias: nexmo ad.

Show numbers for an application

Parameters:

  • app_id - The UUID of your application.

  • Optional flags:

    • --size The amount of results to return
    • --page The page of results to return
> nexmo app:numbers asdasdas-asdd-2344-2344-asdasdasd345
31555555555
44655555555
44555555555

> nexmo app:numbers asdasdas-asdd-2344-2344-asdasdasd345 --verbose
Item 1-3 of 3

msisdn      | country | type       | features  | voiceCallbackType | voiceCallbackValue | moHttpUrl | voiceStatusCallbackUrl
----------------------------------------------------------------------------------------------------------------------------
31555555555 | NL      | mobile-lvn | VOICE,SMS | app               | b6d9f957           | undefined | https://example.com
44655555555 | GB      | mobile-lvn | VOICE,SMS | app               | b6d9f957           | undefined | https://example.com
44555555555 | GB      | mobile-lvn | SMS       | app               | b6d9f957           | undefined | https://example.com

Alias: nexmo an and nexmo apps:numbers.

Linking

Link a number to an app

> nexmo link:app 12057200555 asdasdas-asdd-2344-2344-asdasdasd345
Number updated

> nexmo unlink:app 12057200555
Number updated

Alias: nexmo la

Link a number to another phone number

> nexmo link:tel 12057200555 4455555555
Number updated

> nexmo unlink:tel 12057200555
Number updated

Alias: nexmo lt

Link a number to an SMS callback URL

> nexmo link:sms 12057200555 http://example.com/callback
Number updated

> nexmo unlink:sms 12057200555
Number updated

Alias: nexmo lsms

Link a number to a Voice XML callback URL

> nexmo link:vxml 12057200555 http://example.com/callback
Number updated

> nexmo unlink:vxml 12057200555
Number updated

Alias: nexmo lv

Link a number to SIP URI

> nexmo link:sip 12057200555 sip:[email protected]
Number updated

> nexmo unlink:sip 12057200555
Number updated

Alias: nexmo lsip

Insight

Insight Basic

This is the free Number Insight API:

> nexmo insight:basic 447555555555
447555555555 | GB

Alias: nexmo insight and nexmo ib

Insight Standard

This API will charge your account but provide additional details:

> nexmo insight:standard 447555555555 --confirm
447555555555 | GB | Telefonica UK Limited

Verbose mode will return additional information.

Alias: nexmo is

Insight Advanced

This API will charge your account but provide additional details:

> nexmo insight:advanced 447555555555 --confirm
447555555555 | GB | Telefonica UK Limited

Verbose mode will return additional information.

Alias: nexmo ia

JWT

Generate

jwt:generate [options] <private_key> [claim=value...]

Generate a JWT for your voice application.

> nexmo jwt:generate path/to/private.key application_id=asdasdas-asdd-2344-2344-asdasdasd345

Generate a JWT for the Client SDK

> nexmo jwt:generate path/to/private.key subject=username application_id=asdasdas-asdd-2344-2344-asdasdasd345

Contributing

This project is written in ES2015 and compiled using Babel. The source can be found in the /src folder, and the build is compiled to the /lib folder.

To add changes, fork and clone the project.

npm install        # to install all dependencies
npm run build      # to explicitly build the source
npm install -g ./  # to implicitly build the source, and then install the `nexmo` binary into your PATH
npm test           # to run all tests
npm run watch:test # to watch for changes and run tests

You can run the nexmo command with the --debug / -d flag to get extra debug info from the underlying Node.js library.

License

This library is released under the MIT License

nexmo-cli's People

Contributors

alexlakatos avatar amitmerchant1990 avatar aslafy-z avatar bihanviranga avatar carolgilabert avatar cbetta avatar chovin avatar cr0wst avatar dependabot[bot] avatar dharmendra-lingaiah avatar fauna5 avatar guykh avatar jacobherrington avatar jamesgeorge007 avatar jugaldb avatar kellyjandrews avatar leggetter avatar lornajane avatar mheap avatar michaeljolley avatar rajatsablok avatar robincher avatar sammachin avatar shams-ahmed avatar sudiptog81 avatar surajv311 avatar thecodingaviator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nexmo-cli's Issues

Alias every app command to apps and vice versa

IN the commands the term app and apps should be interchangable, sometimes the plural makes more sense.

eg nexmo app:create or nexmo apps:list are logical
However nexmo apps:create and nexmo app:list should also still work.

Add a way to inspect my API credentials

Currently my go-to method to get my API key and secret is to run: cat ~/.nexmorc as it is faster than going to my dashboard. It might be interesting to just add this to the CLI itself. It would also be handy when trying to see what API credentials a project is using.

Set User-Agent header so usage can be tracked

It'll be really handy if we can track usage of the library via interactions with our API endpoints.

This will require an update to nexmo-node so that the User-Agent is added to the headers and so that the value can be configured.

Maybe a value of nexmo-cli/node/{version}.

nexmo-cli is the client. node is the runtime (maybe we'll create another CLI in another language?) and {version} is the nexmo-cli version pulled from package.json.

Oh, and nexmo-cli could also be retrieved from the package.json.

Use NI Basic to automatically determine country code

Currently the number:add and number:cancel require a country code, even though this should be derivable from the number.

A good idea would be to derive this using Number Insights Basic but this doesn't seem to be present in the Node lib.

Verify credentials on setup

Currently we do not actually verify the credentials on setup. We should probably do so, maybe make a simple balance query and see if it fails.

Pagination

Not all APIs or methods in the Node library support pagination. Once this has been added we can add pagination to the appropriate CLI methods.

nexmo insight:standard throws exception with SMS Shortcode

Steps to reproduce

› nexmo insight:standard {Long Virtual Number} e.g. SMS Shortcode
This operation will charge your account.

Please type "confirm" to continue: confirm

/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185
      this.emitter.list(response.international_format_number + ' | ' + response.country_code + ' | ' + response.current_carrier.name, response);
                                                                                                                               ^

TypeError: Cannot read property 'name' of undefined
    at Response.insightStandard (/usr/local/lib/node_modules/nexmo-cli/distribution/response.js:185:128)
    at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:257:19)
    at emitNone (events.js:85:20)
    at IncomingMessage.emit (events.js:179:7)
    at endReadableNT (_stream_readable.js:913:12)
    at _combinedTickCallback (node.js:377:13)
    at process._tickCallback (node.js:401:11)

Expected behavior

I would not expect an exception.

Actual behavior

As above, we get an exception logged to the console.

System configuration

Node version: v5.7.1

NPM version: 3.6.0

Operating system: OSX 10.11.4

Can't set the answer_method when updating an app

when I update an app and set —answer_method POST it doesn’t put an & in the query string so answer_method=POST gets added to the URL

Sams-Air:~ smachin$ nexmo app:update 26afecbf-28cb-42f5-b4a3-f1e98cb7de91 VAPI_Voicemail http://sammachin.ngrok.io/call http://sammachin.ngrok.io/call --answer_method POST --debug
{ host: 'api.nexmo.com',
  port: 443,
  path: '/beta/account/applications/26afecbf-28cb-42f5-b4a3-f1e98cb7de91?name=VAPI_Voicemail&type=voice&answer_url=http://sammachin.ngrok.io/call&event_url=http://sammachin.ngrok.io/callanswer_method=POST&&api_key=XXX&api_secret=XXX',
  method: 'PUT',
  headers: 
   { 'Content-Type': 'application/x-www-form-urlencoded',
     accept: 'application/json' } }
response ended
Validator.response() - Error: 
null
Validator.response() - Response: 
{ id: '26afecbf-28cb-42f5-b4a3-f1e98cb7de91',
  name: 'VAPI_Voicemail',
  voice: { webhooks: [ [Object], [Object] ] },
  keys: { public_key: '-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnRW29LazggDtIeiD0TV5\n+/Xv0jjbYSoKKa4m4K6RVk+b2WW6HFCUkIM0GDAwws7L5MRObfQD2Q5BRyH6idwY\n7eKxqsNJQ0Ut5IaQQZHMsOKDUl/FbuXOjzjR8NkSuqb7BmC/ZuVuwhI5CHV449AM\nJmD07gV9VkwpX3toTb66D3v1AZJxdErZFbmQvOKNXYBe858ojfCfZzRGpTqxf7AJ\ngAiSWCprkgwxDD1JahQri1o2vknuI4H5q4MyXHXo3ysvoBU1gYiQN5WiilCI3xGD\nPFv1QzS1RAH1rivH6KY7eQ7GolK5pVYGy4F/tEsP065pkJXzd7NLlgA7KK6H0xhn\nEQIDAQAB\n-----END PUBLIC KEY-----\n' },
  _links: { self: { href: '/applications/26afecbf-28cb-42f5-b4a3-f1e98cb7de91' } } }
End Validator.response()
Application updated: 26afecbf-28cb-42f5-b4a3-f1e98cb7de91

SMS Pricing for Country can be a range

For some counties (for example GB) the SMS Price can vary depending on the network being sent to, the default country price returned is 0.0314 whereas all the known mobile networks are 0.0333. (The 0.0314 is for UNKNOWN e.g. landlines)

The problem for users is that the price:country command without -v just returns the default country price and in the UK case nearly all mobile will be slightly higher and may mislead users causing additional support overhead.

I suggest we modify the price:country non verbose response to be a range of the lowest and highest values returned by the API so for GB it should show 0.0314 - 0.0333 EUR

The number specific price queries are unaffected as this will always be a single value returned from our rating system

When creating an app the private key must be saved/displayed

When I create an app the API responds with a private key, this is the only time that key is sent from Nexmo and can't be recorvered therefore it should be saved to a local file called something like [appid].key and a big red warning message displayed to the developer.

`npm install -g nexmo-cli` fails on `prepublish`

Steps to reproduce

Debug:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.7.0/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'install',
1 verbose cli   'nexmo-cli',
1 verbose cli   '-g' ]
2 info using [email protected]
3 info using [email protected]
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData nexmo-cli
8 silly fetchDirectoryPackageData nexmo-cli
9 silly install normalizeTree
10 silly loadCurrentTree Finishing
11 silly loadIdealTree Starting
12 silly install loadIdealTree
13 silly cloneCurrentTree Starting
14 silly install cloneCurrentTreeToIdealTree
15 silly cloneCurrentTree Finishing
16 silly loadShrinkwrap Starting
17 silly install loadShrinkwrap
18 silly loadShrinkwrap Finishing
19 silly loadAllDepsIntoIdealTree Starting
20 silly install loadAllDepsIntoIdealTree
21 silly resolveWithNewModule [email protected] checking installable status
22 silly cache add args [ 'nexmo-cli', null ]
23 verbose cache add spec nexmo-cli
24 silly cache add parsed spec Result {
24 silly cache add   raw: 'nexmo-cli',
24 silly cache add   scope: null,
24 silly cache add   escapedName: 'nexmo-cli',
24 silly cache add   name: null,
24 silly cache add   rawSpec: 'nexmo-cli',
24 silly cache add   spec: '/Users/user_name/nexmo-cli',
24 silly cache add   type: 'directory' }
25 verbose addLocalDirectory /Users/user_name/.npm/nexmo-cli/0.2.0/package.tgz not in flight; packing
26 verbose correctMkdir /Users/user_name/.npm correctMkdir not in flight; initializing
27 verbose makeDirectory /Users/user_name/.npm creation not in flight; initializing
28 silly makeDirectory /Users/user_name/.npm uid: 860087178 gid: 20
29 info lifecycle [email protected]~prepublish: [email protected]
30 verbose lifecycle [email protected]~prepublish: unsafe-perm in lifecycle true
31 verbose lifecycle [email protected]~prepublish: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/user_name/nexmo-cli/node_modules/.bin:/usr/local/Cellar/node/6.7.0/bin:/Users/user_name/DevApps/activator-dist-1.3.10/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin
32 verbose lifecycle [email protected]~prepublish: CWD: /Users/user_name/nexmo-cli
33 silly lifecycle [email protected]~prepublish: Args: [ '-c', 'npm run build' ]
34 silly lifecycle [email protected]~prepublish: Returned: code: 1  signal: null
35 info lifecycle [email protected]~prepublish: Failed to exec prepublish script
36 error addLocal Could not install /Users/user_name/nexmo-cli
37 silly rollbackFailedOptional Starting
38 silly rollbackFailedOptional Finishing
39 silly runTopLevelLifecycles Finishing
40 silly install printInstalled
41 verbose stack Error: [email protected] prepublish: `npm run build`
41 verbose stack Exit status 1
41 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
41 verbose stack     at emitTwo (events.js:106:13)
41 verbose stack     at EventEmitter.emit (events.js:191:7)
41 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
41 verbose stack     at emitTwo (events.js:106:13)
41 verbose stack     at ChildProcess.emit (events.js:191:7)
41 verbose stack     at maybeClose (internal/child_process.js:877:16)
41 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
42 verbose pkgid [email protected]
43 verbose cwd /Users/user_name
44 error Darwin 15.6.0
45 error argv "/usr/local/Cellar/node/6.7.0/bin/node" "/usr/local/bin/npm" "install" "nexmo-cli" "-g"
46 error node v6.7.0
47 error npm  v3.10.7
48 error code ELIFECYCLE
49 error [email protected] prepublish: `npm run build`
49 error Exit status 1
50 error Failed at the [email protected] prepublish script 'npm run build'.
50 error Make sure you have the latest version of node.js and npm installed.
50 error If you do, this is most likely a problem with the nexmo-cli package,
50 error not with npm itself.
50 error Tell the author that this fails on your system:
50 error     npm run build
50 error You can get information on how to open an issue for this project with:
50 error     npm bugs nexmo-cli
50 error Or if that isn't available, you can get their info via:
50 error     npm owner ls nexmo-cli
50 error There is likely additional logging output above.
51 verbose exit [ 1, true ]

Expected behavior

Should install without error

Actual behavior

Errors as shown in log

See: npm/npm#3059

System configuration

Node version: v6.7.0

NPM version: 3.10.7

Operating system: Darwin 15.6.0

Create CLI steering guidelines

What are the main motivations for the CLI? Who is it for? How should it be used?

Some background: We decided to create the CLI so that we could more quickly (in a few commands) get to the point where we could start building (writing code) Voice API v2 functionality.

We then realised that a CLI is just really handy. We can perform quick number lookups (insight), buy numbers, check account balance etc. Others at Nexmo are also finding it really useful e.g. support and sales engineers.

I think we should be able to create a few bullet points that help us guide the decisions we make about the CLI.

Strip leading + on any number.

If the user enteres a number with a + the cli should strip that off currently you get a 'method failed' errror

nexmo price:sms +447970513607
method failed

Split documentation into multiple pages

This will help with reading and browsing for answer. Proposed solution would be to have some simple samples in the README, and the full breakdown in /docs.

Create JWTs with command

It would be great if the CLI could create a JWT. This functionality will eventually be within the library (we should probably add to nexmo-node for this), but it would be very handy to be able to quickly create a JWT.

Something like:

nexmo jwt:generate application_id key_file_path

Open to improvements upon the above suggested command/parameters.

There may be a jwt:validate or jwt:verify. One thing to consider here is that we avoid confusion with the Verify product.

Add CHANGELOG.md

We should keep track of what changes in releases in a CHANGELOG

Balance doesn't say the currency

The API will always return the account balance as EUR as that is the nexmo 'virtual currency' however within the dashboard users can opt to display their balance in USD but we still hold that internally as EUR.

Therefore can we add an EUR label to the output of the nexmo balance command in case they get confused.

Can't buy numbers

I seem to be getting a new error for something that used to work. Wonder if the underlying API changed.

nexmo nb 447507332052 --confirm
Missing Mandatory fields (number and/or callback url)

Creating an app throws an error

Sams-iMac:~ smachin$ nexmo app:create "CLI Test App 1" http://home.sammachin.com http://home.sammachin.com
_http_client.js:50
    throw new TypeError('Request path contains unescaped characters.');
    ^

TypeError: Request path contains unescaped characters.
    at new ClientRequest (_http_client.js:50:11)
    at Object.exports.request (http.js:31:10)
    at Object.socket.once.exports.request (https.js:182:15)
    at sendRequest (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:228:27)
    at Object.exports.createApplication (/usr/local/lib/node_modules/nexmo-cli/node_modules/easynexmo/lib/nexmo.js:407:7)
    at Request.applicationCreate (/usr/local/lib/node_modules/nexmo-cli/distribution/request.js:135:30)
    at Command.listener (/usr/local/lib/node_modules/nexmo-cli/node_modules/commander/index.js:301:8)
    at emitTwo (events.js:87:13)
    at Command.emit (events.js:172:7)
    at Command.parseArgs (/usr/local/lib/node_modules/nexmo-cli/node_modules/commander/index.js:615:12)

node v4.4.4
nexmo-cli v0.0.1

Fast buy functionality

Currently the API allows for searching of numbers by certain specifications and then buying the number.

> nexmo number:search NL --pattern *007
31635251007
31635252007
31635253007
31635254007
31635255007
31635256007
31635257007
31635258007
31635259007

>  nexmo number:buy 31635251007
This is operation will charge your account.

Please type "confirm" to continue: confirm

Number purchased

It would be interesting if we could achieve this all in 1 step:

> nexmo number:buy NL --pattern *007 --confirm
Number purchased: 31635251007

# or
> nexmo number:search NL --pattern *007 --buy --confirm
Number purchased: 31635251007

# or
> nexmo number:smartbuy NL --pattern *007 --confirm
Number purchased: 31635251007

The first 2 options have the downside of overcomplicating the now relatively simple number:buy and number:search. The latter has the downside of being a new command.

Setting a Voice link removes the SMS one

If I have a number with a current linked SMS url (moHTTPUrl) and I then go to set a voice link for example to forward it to a tel number nexmo link:tel 44.. it removes the SMS link.

I can set the SMS after the voice and it keeps both.

I should be able to set voice without removing sms.

Add setup:number

@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

When using --confirm with `number:buy` (or anytime, really) the confirmation should show the number that was purchased

It's specifically a problem if you do something like the following which purchases the first number returned from a search:

nexmo number:search GB | sed -n 1p | xargs -I{} nexmo number:buy {} --confirm

Because the output of the first command isn't show and is instead piped to sed and then accessed via xargs.

Result:

› nexmo number:search GB | sed -n 1p | xargs -I{} nexmo number:buy {} --confirm
Number purchased

What number did I purchase?

There may be a way to also output the number via the above command. But this request seems reasonable none the less.

Add unlink

Current API does not support setting voiceCallbackType or voiceCallbackValue to blank which is a stopper for this.

`nexmo account` should not fail if not logged in

Current if the nexmo cli is not logged in the nexmo account command errors. This should probably be caught nicely.

~  nexmo account
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/cbetta/.nexmorc'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Config.read (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/lib/config.js:31:47)
    at Request.accountInfo (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/lib/request.js:41:45)
    at Command.listener (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/node_modules/commander/index.js:301:8)
    at emitTwo (events.js:106:13)
    at Command.emit (events.js:191:7)
    at Command.parseArgs (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/node_modules/commander/index.js:615:12)
    at Command.parse (/Users/cbetta/.nvm/versions/node/v6.3.1/lib/node_modules/nexmo-cli/node_modules/commander/index.js:458:21)

Private key can't be used as-is when downloaded

If you try to use the private key when it's downloaded, upon signing you are likely to get an error:

asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag

If you're seeing errors such as asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag then you should run the following on your key.txt:

openssl rsa -in key.txt -out key.txt

It may be that there are newline characters in the downloaded file that need to be stripped. Or some other set of characters. I've been informed that it's newline characters, but I haven't checked.

Add application_id to number:list

Not sure if we can get this from the API, but if an app is assigned to a number it would be nice to add it to the table shown when running number:list.

Feature: Get a list of numbers associated with my application

As I'm building apps I'm frequently thinking to myself "What numbers are associated with this application?"

It'd be great to be able to do something like:

nexmo app:numbers APP_ID

And get a list of the numbers that are associated with the APP_ID.

For the moment, the only way I can do this is:

nexmo numbers --verbose --size 50

And manually look for my application ID in the output.

Open to the feedback that I'm just being lazy or rubbish at CLIs 😄

nexmo apps:list --size does not show a list of the expected size

In the following command I would expect 50 entries to be shown. But only 10 are shown.

› nexmo apps:list --verbose --size 50
Item 1-50 of 52

id                                   | name
------------------------------------------------------
019cb774-4ad0-4b22-a9db-86a8e7df1d34 | nexmo-node-test
01f7e4a5-ea15-48da-a3c3-f792089443a0 | First Voice App
03f31f24-c2e9-4193-9d71-7a5fd9fc0c70 | First Voice App
0b5d3fec-eac5-4b55-b71c-60874f981659 | First Voice App
0b5f2c87-1355-438b-99b9-7046eec89476 | 1473368357732
0ce0271e-a438-4fdb-8eb2-ca03932b5f2c | my-voice-app
178c9b62-571c-4328-959c-0cf9a49b354f | watson-test
18cdaa6c-e69f-475a-b2e6-b63b9ce20674 | First Voice App
1cc45c5a-0d08-4bff-9f36-5b0dbfa69881 | Blah
22edf392-bd50-42ad-b885-98f891da4b6a | First Voice App

The number list should show the total number of numbers in verbose mode

Steps to reproduce

I have more than 10 numbers on my account, nexmo numbers:list only returns the first 10, in the dashboard I can see more. By default the API pagenates at 10 numbers.

Expected behavior

CLI should show all numbers on the account

Actual behavior

CLI only shows the 10 'lowest' numbers

System configuration

Node version:

NPM version:

Operating system:

Allow user to configure default size param

As as user I want to be able to set the default number of results to be displayed, currently this is set to 10 across the system.

add nexmo config size XX command to set a default request size

This value should then be saved in the .nexmorc file and used in the appropriate requests, unless a --size param is passed with the request.

Add a way to run the CLI without storing credentials

I'm thinking it would be nice to be able to run the CLI without first signing in. This can be useful on shared PCs but mainly is also useful for running it as a one of command as part of build scripts or CI servers:

Example:

nexmo sms 447555555555 "Build succeeded" --api-key abc123 --api-secret cde234

Long Dutch Numbers can't be used

We have some 'longer than normal' dutch numbers in inventory which support SMS.
for example +31 970 1024 0032

Unfortunalty the Number Insight API fails to validate them which means that you can't configure them using the CLI tool.

I've raised this as bug with number insight but putting here mainly for tracking

Deduplicate bin.js

Currently bin.js has a lot of replication because commander.js doesn't support multiple aliases per command. I've opened a proposal to add this: tj/commander.js#531

Number insight

Wondering if its worth implementing number insight (at least basic maybe std to?)

something line nexmo insight:basic 447970513607
or nexmo insight:std 447970513607

advanced might be harder as I think that needs a webhook url

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.