Skip to content

Commit 0ff19e3

Browse files
Tidying up.
1 parent 87da3b5 commit 0ff19e3

5 files changed

Lines changed: 25 additions & 16 deletions

File tree

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ phaxio.faxes.create({
4444
// The `create` method returns a fax object with methods attached to it for doing things
4545
// like cancelling, resending, getting info, etc.
4646

47-
// Wait 5 seconds, then get the status of the fax by getting its info from the API.
47+
// Wait 5 seconds to let the fax send, then get the status of the fax by getting its info from the API.
4848
return setTimeout(() => {
4949
fax.getInfo()
5050
}, 5000)
@@ -72,7 +72,7 @@ phaxio.faxes.listFaxes({ direction: 'sent' })
7272
Phaxio methods are categorized according to the Phaxio API route that they target.
7373
See the [Phaxio Docs]('https://www.phaxio.com/docs/api/v2.1/') for more information about the raw API.
7474
75-
**All** Phaxio methods take one argument: either a single argument such as an ID, or an Object containing
75+
**All Phaxio methods take one argument:** either a single argument such as an ID, or an Object containing
7676
`key: value` parameters.
7777
See the documentation below for specifics.
7878
@@ -162,7 +162,7 @@ The methods attached to a Fax Object take one or no arguments as they already ha
162162
| `faxObject.cancel()` | None | Cancels the fax. |
163163
| `faxObject.resend()` | `callback_url` (optional) | Resends the fax. Default `callback_url` uses the fax's original `callback_url`. Passing a URL string will set the `callback_url` to the new value. |
164164
| `faxObject.getInfo()` | None | Gets the fax's metadata information. |
165-
| `faxObject.getFile()` | `thumbnail` (optional) | Gets the fax's document. The default `thumbnail` is `null`, which gets the full file. Specify a string, `'s'` or `'l'`, to get a small or large thumbnail (respectively) of the first page of the document. |
165+
| `faxObject.getFile()` | `thumbnail` (optional) | Gets the fax's document. The default `thumbnail` is `null`, which gets the full PDF file. Specify a string, `'s'` or `'l'`, to get a small or large JPG thumbnail (respectively) of the first page of the document. |
166166
| `faxObject.deleteFile()` | None | Deletes a document associated with a fax. |
167167
| `faxObject.testDelete()` | None | Deletes a fax created using Test API Credentials. |
168168
@@ -186,6 +186,14 @@ phaxio.faxes.create({ to: '+1234567890', content_url: 'https://google.com' })
186186
})
187187
.then(() => console.log('Insert successful.'))
188188
.catch((err) => { throw err; });
189+
190+
// Write out the thumbnail of a created fax to a file.
191+
phaxio.faxes.create({ to: '+1234567890', content_url: 'https://google.com' })
192+
.then((faxObject) => {
193+
return faxObject.getFile('s')
194+
})
195+
.then(fileString => fs.writeFileSync(`${__dirname}/thumbnail.jpg`, fileString))
196+
.catch((err) => { throw err; });
189197
```
190198
191199
#### `phaxio.faxes.cancel()`
@@ -253,7 +261,7 @@ Arguments (Object):
253261
254262
```javascript
255263
phaxio.faxes.getFile({ id: 987 })
256-
.then(response => console.log(JSON.stringify(response, null, 2)))
264+
.then(fileString => fs.writeFileSync(`${__dirname}/full_file.pdf`, fileString))
257265
.catch((err) => { throw err; });
258266
```
259267
@@ -488,7 +496,9 @@ To run the test suite:
488496
npm run test
489497
```
490498
499+
Note: this test suite uses `setTimeout()` to reduce the likelihood of receiving rate limiting errors.
500+
491501
# LICENSE
492502
MIT Copyright 2018 Phaxio
493503
494-
See LICENSE file for full detail.
504+
See `LICENSE` file for full detail.

m.png

4.44 KB
Loading

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "phaxio-official",
33
"version": "0.1.0",
4-
"description": "The official Node.JS library for talking with the Phaxio API v2.1.0. https://phaxio.com",
4+
"description": "The official Node.JS library for the Phaxio API v2.1.0. https://phaxio.com",
55
"main": "index.js",
66
"scripts": {
77
"test": "mocha --exit --recursive --no-colors"

test/faxes/shared-methods.test.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ describe('shared methods', function () { // eslint-disable-line func-names
3838
.then((ores) => { // eslint-disable-line arrow-body-style
3939
const res = JSON.parse(ores);
4040
firstFax = res.data.id;
41-
return getInfo(url, res.data.id, auth)
42-
.then((gi) => {
43-
expect(gi.success).to.be.ok();
44-
})
45-
.catch((err) => { throw err; });
41+
return getInfo(url, res.data.id, auth);
42+
})
43+
.then((gi) => {
44+
expect(gi.success).to.be.ok();
4645
})
4746
.catch((err) => { throw err; });
4847
});
@@ -63,11 +62,10 @@ describe('shared methods', function () { // eslint-disable-line func-names
6362
return req
6463
.then((ores) => { // eslint-disable-line arrow-body-style
6564
const res = JSON.parse(ores);
66-
return cancel(url, res.data.id, auth)
67-
.then((canc) => {
68-
expect(canc.success).to.be.ok();
69-
})
70-
.catch((err) => { throw err; });
65+
return cancel(url, res.data.id, auth);
66+
})
67+
.then((canc) => {
68+
expect(canc.success).to.be.ok();
7169
})
7270
.catch((err) => { throw err; });
7371
});

test/phone-number/index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe('class: PhoneNumber', function () {
2121
describe('post-instantiation', () => {
2222
let phoneNumber;
2323
let sampleNumber;
24+
2425
before(() => {
2526
phoneNumber = new PhoneNumber(process.env.TEST_APIKEY, process.env.TEST_APISECRET, 'https://api.phaxio.com/v2.1');
2627
});

0 commit comments

Comments
 (0)