Giter Site home page Giter Site logo

easypost-node's Introduction

EasyPost Node Client Library

CI Coverage Status npm version

EasyPost, the simple shipping solution. You can sign up for an account at https://easypost.com.

NOTE: This library is intended to be used in a backend Node service and not in a frontend Javascript project via the browser.

Install

npm install --save @easypost/api

NOTE: If you are using @easypost/api prior to v5 and a version of Node less than 6.9, you will need to install and include a polyfill, such as babel-polyfill, and include it in your project:

npm install --save babel-polyfill
// Require the polyfill if necessary:
require('babel-polyfill');

// Require the EasyPost library:
const EasyPost = require('@easypost/api');

You can alternatively download the various built assets from this project's releases page.

Compatibility

v4 and Earlier

  • require('@easypost/api/easypost.8-lts.js') (Node 8.9+)
  • require('@easypost/api/easypost.6-lts.js') (Node 6.9+)
  • require('@easypost/api/easypost.legacy.js') (Node 0.10+)

v5

If using @easypost/api v5, you can require the base project which is built on Node v10 - v16

v6

If using @easypost/api v6, you can require the base project which is built on Node v12+

Note on ES6 Usage

You can import specific versions of the compiled code if you're using later versions of Node and using @easypost/api prior to v5.

// Imports the un-transformed es6
import '@easypost/api/src/easypost';

// Use the following to import mininally transformed versions
import '@easypost/api/easypost.6-lts';
import '@easypost/api/easypost.8-lts';
import '@easypost/api/easypost.legacy.js'; // (v0.10)

Usage

A simple create & buy shipment example:

const EasyPostClient = require('@easypost/api');

const client = new EasyPostClient(process.env.EASYPOST_API_KEY);

const shipment = await client.Shipment.create({
  from_address: {
    street1: '417 MONTGOMERY ST',
    street2: 'FLOOR 5',
    city: 'SAN FRANCISCO',
    state: 'CA',
    zip: '94104',
    country: 'US',
    company: 'EasyPost',
    phone: '415-123-4567',
  },
  to_address: {
    name: 'Dr. Steve Brule',
    street1: '179 N Harbor Dr',
    city: 'Redondo Beach',
    state: 'CA',
    zip: '90277',
    country: 'US',
    phone: '4155559999',
  },
  parcel: {
    length: 8,
    width: 5,
    height: 5,
    weight: 5,
  },
});

const boughtShipment = await client.Shipment.buy(shipment.id, shipment.lowestRate());

console.log(boughtShipment);

Options

You can construct an API instance with certain options:

const client = new EasyPostClient(process.env.EASYPOST_API_KEY, {
  timeout: 120000,
  baseUrl: 'https://api.easypost.com/v2/',
  useProxy: false,
  superagentMiddleware: (s) => s,
  requestMiddleware: (r) => r,
});

timeout

Time in milliseconds that should fail requests.

baseUrl

Change the base URL that the API library uses. Useful if you proxy requests from a frontend through a server.

useProxy

Disable using the API key. Useful if you proxy requests from a frontend through a server.

superagentMiddleware

Function that takes superagent and returns superagent. Useful if you need to wrap superagent in a function, such as many superagent libraries do.

import superagentLib from 'some-superagent-lib';

const client = new EasyPostClient('my-key', {
  superagentMiddleware: (s) => superagentLib(s),
});

requestMiddleware

Function that takes a superagent request and returns that request. Useful if you need to hook into a request:

import superagentLib from 'some-superagent-lib';

const client = new EasyPostClient('my-key', {
  requestMiddleware: (r) => {
    r.someLibFunction(SOME_CONFIG_VALUE);
    return r;
  },
});

Interactive CLI

Replace easypost.js with whatever compatible version you wish, as defined under Compatibility.

API_KEY=yourkey ./repl.js --local easypost.js

HTTP Hooks

If you would need or want to view what requests are being made to the EasyPost API behind the scenes, you can provide functions to listen for the request and/or responses. This can be done with helper functions on the created client.

const client = new EasyPostClient('my-key');

const logOutgoingRequest = (request) => console.log("Outgoing:", request);
const logResponse = (response) => console.log("Response:", response)

// optionally add your hook to listen for outgoing requests
client.addRequestHook(logOutgoingRequest);
// and optionally the hook for the response
client.addResponseHook(logResponse)

// ...do other stuff

// remove that request hook
client.removeRequestHook(logOutgoingRequest);
// and the response one
client.removeResponseHook(logResponse);
// or clear all the hooks at once
client.clearRequestHooks();
client.clearResponseHooks();

Note: You cannot edit or otherwise affect the requests using these hooks. They are purely for debugging or logging purposes.

Documentation

API documentation can be found at: https://easypost.com/docs/api.

Library documentation can be found on the web at: https://easypost.github.io/easypost-node/ or by building them locally via the make docs command.

Upgrading major versions of this project? Refer to the Upgrade Guide.

Support

New features and bug fixes are released on the latest major release of this library. If you are on an older major release of this library, we recommend upgrading to the most recent release to take advantage of new features, bug fixes, and security patches. Older versions of this library will continue to work and be available as long as the API version they are tied to remains active; however, they will not receive updates and are considered EOL.

For additional support, see our org-wide support policy.

Development

# Install dependencies
make install

# Install style guides (Unix only)
make install-styleguide

# Update dependencies
make update

# Build the project
make build

# Lint the project
make lint
make lint-fix

# Run tests (these will be transpiled on the fly)
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make test
EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make coverage

# Run security analysis
make scan

# Generate library documentation
make docs

# Update submodules
make update-examples-submodule

Typescript Definitions

Starting with v5.3.0, this project has Typescript definitions included.

Typescript Exclusions

  • We do not provide a DefinitelyTyped version of these definitions at this time
  • Predefined packages (see Carrier Metadata in our docs for more details)
  • Carrier service levels (see Carrier Metadata in our docs for more details)
  • Carrier list (see Carrier Types in our docs for more details)

Testing

The test suite in this project was specifically built to produce consistent results on every run, regardless of when they run or who is running them. This project uses Pollyjs (AKA: VCR) to record and replay HTTP requests and responses via "cassettes". When the suite is run, the HTTP requests and responses for each test function will be saved to a cassette if they do not exist already and replayed from this saved file if they do, which saves the need to make live API calls on every test run. If you receive errors about a cassette expiring, delete and re-record the cassette to ensure the data is up-to-date.

Sensitive Data: We've made every attempt to include scrubbers for sensitive data when recording cassettes so that PII or sensitive info does not persist in version control; however, please ensure when recording or re-recording cassettes that prior to committing your changes, no PII or sensitive information gets persisted by inspecting the cassette.

Making Changes: If you make an addition to this project, the request/response will get recorded automatically for you. When making changes to this project, you'll need to re-record the associated cassette to force a new live API call for that test which will then record the request/response used on the next run.

Test Data: The test suite has been populated with various helpful fixtures that are available for use, each completely independent from a particular user with the exception of the USPS carrier account ID (see Unit Test API Keys for more information) which has a fallback value of our internal testing user's ID. Some fixtures use hard-coded dates that may need to be incremented if cassettes get re-recorded (such as reports or pickups).

Unit Test API Keys

The following are required on every test run:

  • EASYPOST_TEST_API_KEY
  • EASYPOST_PROD_API_KEY

Some tests may require an EasyPost user with a particular set of enabled features such as a Partner user when creating referrals. We have attempted to call out these functions in their respective docstrings. The following are required when you need to re-record cassettes for applicable tests:

  • USPS_CARRIER_ACCOUNT_ID (eg: one-call buying a shipment for non-EasyPost employees)
  • PARTNER_USER_PROD_API_KEY (eg: creating a referral user)
  • REFERRAL_CUSTOMER_PROD_API_KEY (eg: adding a credit card to a referral user)

easypost-node's People

Contributors

adamlacombe avatar ajacksified avatar bensontrent avatar bnbry avatar brandonros avatar coen-hyde avatar dcaballeroc avatar dependabot[bot] avatar devongovett avatar dfairaizl avatar jchen293 avatar jontsai avatar jordanj77 avatar jstreebin avatar julientregoat avatar justintime50 avatar k-funk avatar m-black avatar mehulbaid avatar mistermuyiwa avatar muteldar avatar nwithan8 avatar ralexmatthews avatar roguelazer avatar rrgrs avatar ryannguyen16 avatar sawyer avatar thyming avatar vfrbgt avatar victoryftw 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

easypost-node's Issues

Allowing Address verify and verify_strict parameters

When using the api directly you can pass verify and verify_strict parameters to the address creation endpoint, but the node.js package does not support them. Can you please add support?

curl -X POST https://api.easypost.com/v2/addresses \
  -u <YOUR_TEST/PRODUCTION_API_KEY>: \
  -d "verify[]=delivery" \
  -d "address[street1]=118 2 St" \
  -d "address[street2]=4" \
  -d "address[city]=SF" \
  -d "address[state]=CA" \
  -d "address[zip]=94105" \
  -d "address[country]=US" \
  -d "address[company]=EasyPost" \
  -d "address[phone]=415-123-4567"

Updating Shipment Parcel for new rate

Good evening! I am using the easypost api for a project and after searching through the documentation I wanted to ask a question about specific functionality. For the EasyPost rates, I see that you have a method for retrieving the rates of a specific shipment like this:

const Easypost = require('@easypost/api');
const api = new Easypost('<YOUR_TEST/PRODUCTION_API_KEY>');

api.Shipment.retrieve('shp_...').then(s => {
  s.regenerateRates()
    .then(s => console.dir(s.rates, {
      depth: null,
    }));
});  

However, I wanted to ask is there a way to update the rates on a shipment after it has been created via editing the parcel weight? Something along the lines of this:

const Easypost = require('@easypost/api');
const api = new Easypost('<YOUR_TEST/PRODUCTION_API_KEY>');

api.Shipment.retrieve('shp_...').then(s => {
s.updateParcel({weight: NewWeight});
});  

Is there anything to what I typed out above? My goal is to be able to update a shipment and retrieve the new rates for that updated shipment, and to achieve this without having to create an entirely new shipment with the updated data. Is this possible with the API and if so how?

Thank you in advance! Michael

Error: Hostname/IP doesn't match certificate's altnames

When using the easypost CLI, I'm getting SSL errors while attempting to communicate with the Easypost servers.

Example:

$ easypost $MY_API_KEY
Choose an option:
  1) Verify a single address
  2) Verify multiple addresses
  3) Get multiple shipment rates
  4) Get shipment rates
  5) Buy postage
  6) Lookup individual label purchased
  7) Get full list of labels purchased
  : 1
Street 1: 760 United Nations Plaza
Street 2: 
City: New York
State NY
Zip: 10017

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Hostname/IP doesn't match certificate's altnames
    at SecurePair.<anonymous> (tls.js:1379:23)
    at SecurePair.EventEmitter.emit (events.js:92:17)
    at SecurePair.maybeInitFinished (tls.js:982:10)
    at CleartextStream.read [as _read] (tls.js:469:13)
    at CleartextStream.Readable.read (_stream_readable.js:320:10)
    at EncryptedStream.write [as _write] (tls.js:366:25)
    at doWrite (_stream_writable.js:226:10)
    at writeOrBuffer (_stream_writable.js:216:5)
    at EncryptedStream.Writable.write (_stream_writable.js:183:11)
    at write (_stream_readable.js:583:24)

webpack-cli as a production dependency

Wondering why webpack-cli is a production dependency? If it isn't necessary can it be moved to a dev dependency? It's causing warnings in NPM install because it has a peer dependency on webpack.

"@easypost/api > [email protected]" has unmet peer dependency "webpack@^4.x.x".

Shipping/Tracking

Hello,

This more of an inquiry, currently working on a project and considering using easypost for it. Does this API handle both tracking a package and shipping for a package?

shipment.buy() is throwing an error

shipment.buy() is throwing an error
it takes the argument {rate: shipment.lowestRate()}

and shipment.lowestRate() has the following return value

{ id: 'rate_eEgxa9nY',
object: 'Rate',
created_at: '2013-10-22T19:31:16Z',
updated_at: '2013-10-22T19:31:16Z',
service: 'First',
rate: '1.69',
carrier: 'USPS',
shipment_id: 'shp_XCuru2Rs' }

printing err gave me
{ message: undefined, param: undefined }

is there anything obvious??

customs_item.value becomes string after .save

new api.CustomsItem({
  description: 'T-shirt',
  quantity: 1,
  value: 10,
  weight: 5,
  hs_tariff_number: '123456',
  origin_country: 'us'
}).save(console.log);

value is now a string. This is problematic when creating a CustomsInfos:
errors: { value: 'Error: Invalid prop `value` of type `string` supplied to `CustomsItem`, expected `number`.' }

Fulfillment

Does the client support fulfillment end points?

curl -X POST "https://api.easypost.com/fulfillment/vendor/v2/orders" \
   -u "<API_KEY>:" \
   -H "Content-Type: application/json" \
   -d '{
      "service": "standard",
      "destination": {
         "name": "John Smith",
         "street1": "1 Montgomery Tower",
         "city": "San Francisco",
         "state": "CA",
         "zip": "94131",
         "country": "US",
         "residential": true
      },
      "line_items": [
         {
            "product": {"barcode": "852125607063"},
            "units": 1
         }
      ]
   }'

Creating child user accounts fails with PARAMETER.REQUIRED

I'm trying to create a child user with the following code pulled from [here]:(https://www.easypost.com/docs/api/node.html#child-users)

const Easypost = require('@easypost/api');
const api = new Easypost('<YOUR_PRODUCTION_API_KEY>');

const user = new api.User({
  name: 'Child Account Name',
})

user.save().then(u => console.log(u.id));

However I'm getting the following error:

RequestError {
  error: 
   { error: 
      { code: 'PARAMETER.REQUIRED',
        message: 'Missing required parameter: user',
        errors: [] } },
  name: 'RequestError',
  status: undefined }

But i'm not sure what exactly is missing given I am performing the save on the user object itself? Using Postman I was able to make the call just fine, just seems to be an issue with this sdk.

No delivery verification returning for from_address in Shipment object

      const shipment = new api.Shipment({
            to_address: new api.Address({
              verify: ['delivery'],
              name: toAddress.name,
              company: '',
              street1: toAddress.address1,
              street2: toAddress.address2,
              city: toAddress.city,
              state: toAddress.state,
              zip: toAddress.zip
            }),
            from_address: new api.Address({
              verify: ['delivery'],
              name: fromAddress.name,
              company: '',
              street1: fromAddress.address1,
              street2: fromAddress.address2,
              city: fromAddress.city,
              state: fromAddress.state,
              zip: fromAddress.zip
            }),
            parcel: new api.Parcel({
              predefined_package: 'Card',
              weight: 1,
            })
        })

        shipment.save().then((s) =>{
             console.log("Shipment saved", s);
        })

Returns an empty object for verifications in the from_address
verifications: {}

How should you ensure the return address (from_address) is valid while creating a shipment?

Order get_rates

There is currently no convenient way to refresh stale rates on an Order object via the NodeJS client library. This functionality was recently added to the API at /v2/orders/:id/rates; can we add support for this in the Node library as well?

shipment.convertLabelFormat('PDF') produces label of wrong size

4x6" PNG labels are resized to 11.5x8" when converted to PDFs using label conversion API.
No documentation was found for how to specify output label dimensions.

Sample of problem:
https://easypost-files.s3-us-west-2.amazonaws.com/files/postage_label/20181219/9888a75052924d729e0bb16239fce015.png
is converted to:
https://easypost-files.s3-us-west-2.amazonaws.com/files/postage_label/20181219/7b6d4c88b13c48e983fb1faec1d119ef.pdf

Additionally, suggested workaround of specifying PDF format and 4x6 size in initial options unworkable as some labels are still being returned as 8.5x11 PDFs, and other labels return error SHIPMENT.POSTAGE.FORMAT_UNAVAILABLE.

Buy API: UnhandledPromiseRejectionWarning and DeprecationWarning in Node

I'm running in to an error when trying to walk through the "Getting Started" document: https://www.easypost.com/getting-started/node.html#step4

Specifically it seems everything works except the Buy Shipment example

This is the error I'm seeing when the buy API is being called:

(node:31575) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): [object Object]
(node:31575) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have tried to call the buy API two ways the first from the Getting Started example the second from the API docs. Both return the same warning and are never successfully called.
Here is the snippet of code I'm using from the document:

  async.waterfall([
    function(callback) {
      const shipment = new api.Shipment({
            to_address: new api.Address({
              name: 'George Costanza',
              company: 'Vandelay Industries',
              street1: '1 E 161st St.',
              city: 'Bronx',
              state: 'NY',
              zip: '10451'
            }),
            from_address: new api.Address({
              company: 'EasyPost',
              street1: '417 Montgomery Street',
              street2: '5th Floor',
              city: 'San Francisco',
              state: 'CA',
              zip: '94104',
              phone: '415-528-7555'
            }),
            parcel: new api.Parcel({
              predefined_package: 'Card',
              weight: 1,
            })
        })
        callback(null, shipment);
    },
    function(shipment, callback) {
        shipment.save().then(console.log)
        callback(null, shipment);
    },
    function(shipment, callback) {
        shipment.buy(shipment.lowestRate(['USPS'], ['First']))
        .then(console.log)
        callback(null, 'done');
    }
  ], function (err, result) {
  });

The second way I tried to call the API using the Shipment ID I recieved in place of shp..

  api.Shipment.retrieve('shp_..').then(s => {
  s.buy(s.lowestRate(), 0).then(console.log);
  });

I'm using Node version 7.5.0 and npm version 4.1.2.

Any help would be appreciated.

Bad_Request error message

I ran the example.js.
why is this error message shown?

{ message:
{ code: 'BAD_REQUEST',
message: 'Invalid parameters were passed and the record could not be persisted.',
errors: [ [Object] ] },
param: undefined }

How can I deal with this error?

Issue calling API

The included library works fine when I'm using our api test key, but using the production key, and we get the following error:

You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
[object Object]
at a. (/var/node/node_modules/@easypost/api/easypost.js:160:5099)
at Generator.throw ()
at d (/var/node/node_modules/@easypost/api/easypost.js:160:2584)
at /var/node/node_modules/@easypost/api/easypost.js:160:2709
at run (/var/node/node_modules/core-js/modules/es6.promise.js:66:22)
at /var/node/node_modules/core-js/modules/es6.promise.js:79:30
at flush (/var/node/node_modules/core-js/modules/_microtask.js:18:9)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Any thoughts?

node v8.5.0
pm2 v2.7.0

module v3.2.1

batch.buy() is not a function

I'm having an issue purchasing batch labels, once I've created a batch, waited until it's been created and retrieved it - I cannot call the .buy() function. I'm currently using version 3.0.0-rc.21 of the library. Any ideas what I can do?

Odd API Response

I'm currently testing out the easypost-node using the code from example.js in the repo with my test apiKey. However I would get a response that says the following:

{ message:
   { code: 'BAD_REQUEST',
     message: 'Invalid parameters were passed and the record could not be persisted.',
     errors: [ [Object] ] },
  param: undefined }

Following this message I receive the log of the shipment from console.log(shipment) statement in the easypost.Shipment.create({...}) call which has the shipment information. I know that the call succeeds because it appears in the test shipments on my 'manage shipments' page on the easypost website.

Im wondering why the BAD_REQUEST` response is happening.

delete() not a function for CarrierAccount

I'm trying to follow the sample code here:

const Easypost = require('@easypost/api');
const api = new Easypost('<YOUR_PRODUCTION_API_KEY>');

api.CarrierAccount.retrieve('ca_...').then(ca => ca.delete());

// or

const ca = new api.CarrierAccount({ id: '<ca_...>' });
ca.delete();

However, both of those ways result in: ca.delete is not a function. Has this been implemented in this library?

Create official Meteor package

Hey guys,

Thank you for the quick bugfix for #18. With the new 2.0.7 release, I also updated andreipopovici/meteor-easypost and published to the Meteor package manager.

If you're open to it, I'd suggest adding Meteor support to easypost-node directly, so I don't accidentally miss any future updates. There's a quick guide here: http://www.meteorpedia.com/read/Packaging_existing_Libraries

In essence, you'd just create a meteor folder and do a meteor publish on each version bump. I'll create a PR for you to evaluate.

Thanks,
Andrei

CarrierAccount - save not implemented

Hey,

Just started integrating with EasyPost, the first thing I tried to do is create a carrier account. However, I'm getting a "NotImplementedError" for the method save() on the CarrierAccount. I'm just trying to follow the docs: https://www.easypost.com/docs/api#carrier-accounts.

This blog article posted in January states that Carrier Accounts is one of the available endpoints: https://www.easypost.com/blog/2017-01-05-node-sdk-v3.html, and is also called out in: #36 as being available.

But: https://github.com/EasyPost/easypost-node/blob/master/src/resources/carrierAccount.js#L30

I have 3.0.10 installed, what am I missing?

Thanks,

Documentation seems misleading

Hi!

I'm really thrilled by the easpost API but I'm not 100% sure that I understand the docs for easypost-node as they currently stand.

You have:
var easypost = require('./lib/main.js')(apiKey);

should this always be ./lib/main.js or can it be mapped to fit within the context of a larger package (ie. ./node_modules/easypost/lib/main.js).

Specific to my use-case, I'm looking to add EasyPost to an MVC Controller using the locomotive framework. My controllers typically start like this:

var locomotive = require('locomotive') , Controller = locomotive.Controller , passport = require('passport') , flash = require('connect-flash');

(where all of these modules are defined in my package.js file)

I'd really like to feel comfortable just doing:

var locomotive = require('locomotive') , Controller = locomotive.Controller , passport = require('passport') , easyPost = require(easypost) , flash = require('connect-flash');

But your documentation seems to force a different convention. Can you comment?

Not able to create reports of any type

Using the examples documented here https://www.easypost.com/docs/api/node#create-a-report I am getting errors such as:

`Logan:nodejs logan.simonsen$ node reports/createReport.js
/Users/logan.simonsen/easypostLibrary/nodejs/reports/createReport.js:18
const shipmentReport = new api.ShipmentReport({
^

TypeError: api.ShipmentReport is not a constructor
at Object. (/Users/logan.simonsen/easypostLibrary/nodejs/reports/createReport.js:18:24)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3`

This happens for each type of shipment attempted. I've checked with other team members and they get the same result.

I've tested creating a report using the python library and that seems to work fine.

Issue with the parcel create method

Hi,

I am trying to create a parcel but every time I call the parcel.create method an empty object is returned. Can you tell me what can be the issue?

var createParcelObject = function createParcelObject(parcel) {
    if (!parcel) {
        console.error('Parameter \'parcel\' required...');
        return;
    }

    return Meteor.wrapAsync(easypost.Parcel.create)(parcel);
};

Meteor.methods({
    createParcelObject: createParcelObject
});

var parcel = {
    "length" : 5,
    "width" : 7,
    "height" : 2,
    "weight" : 10
}

Meteor.call('createParcelObject', parcel, function(err, res) {
    console.log(err);
    if(!err)
    {
            console.log(res); //This is always empty Object {}
    }
    else{
        Alerts.add("Parcel couldn't be created" + err, "danger");
    }
});

Thanks for your help in advance.

Including this with Meteor.js

Something's wrong with my babel configuration inside of Meteor 1.4.4.2. When I try to use this npm module, my console spits out

W20170716-11:30:05.474(-7)? (STDERR) /Users/maxjohansen/.meteor/packages/meteor-tool/.1.4.4_2.ja69s4++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:280
W20170716-11:30:05.475(-7)? (STDERR) 						throw(ex);
W20170716-11:30:05.475(-7)? (STDERR) 						^
W20170716-11:30:05.475(-7)? (STDERR) 
W20170716-11:30:05.475(-7)? (STDERR) ReferenceError: regeneratorRuntime is not defined
W20170716-11:30:05.475(-7)? (STDERR)     at /Users/maxjohansen/projects/hackfactory/Koena/node_modules/@easypost/api/easypost.js:1:49866
W20170716-11:30:05.475(-7)? (STDERR)     at /Users/maxjohansen/projects/hackfactory/Koena/node_modules/@easypost/api/easypost.js:1:50702
W20170716-11:30:05.475(-7)? (STDERR)     at Object.create.constructor.value (/Users/maxjohansen/projects/hackfactory/Koena/node_modules/@easypost/api/easypost.js:1:51051)
W20170716-11:30:05.476(-7)? (STDERR)     at t (/Users/maxjohansen/projects/hackfactory/Koena/node_modules/@easypost/api/easypost.js:1:149)
W20170716-11:30:05.476(-7)? (STDERR)     at e.__esModule.default (/Users/maxjohansen/projects/hackfactory/Koena/node_modules/@easypost/api/easypost.js:1:532)
W20170716-11:30:05.476(-7)? (STDERR)     at Object.<anonymous> (/Users/maxjohansen/projects/hackfactory/Koena/node_modules/@easypost/api/easypost.js:1:542)
W20170716-11:30:05.477(-7)? (STDERR)     at Module._compile (module.js:409:26)
W20170716-11:30:05.477(-7)? (STDERR)     at Object.Module._extensions..js (module.js:416:10)
W20170716-11:30:05.478(-7)? (STDERR)     at Module.load (module.js:343:32)
W20170716-11:30:05.478(-7)? (STDERR)     at Function.Module._load (module.js:300:12)

API Docs

Did you guys plan to have an API doc for this, since it's not on the easypost website? Hopefully it'd be easier to implement than going through the source code. Thx

Codebase is extremely ugly.

This is terrible, unorganized, and ugly. Not human readable. Should be using help functions such as _ or lodash as well.

Wrap with futures for meteor package

Everything in Meteor uses futures. Why not use futures? It should be pretty simple. Easy example:

let easypost = Npm.require('node-easypost')(process.env.EASYPOST_KEY);
let future = Npm.require('fibers/future');
// ...
EasyPost.Shipment.createSync = function (shipment) {
  let future = new Future();
  let done = future.resolver();
  easypost.Address.create_and_verify(function (error, shipment) {
    if (error) {
      done(new Meteor.Error(error.message.code, error.message.message), null);
    } else {
      done(null, shipment.shipment);
    }
  });
  future.wait();
  return future.value;
}

Proxy support

Hi, I need to be able to access the Easypost API with a proxy, library doesnt support it because its using superagent to make the requests, and superagent doesnt support proxies. There might be a way to make it work with https://github.com/TooTallNate/superagent-proxy . Alternatively, a library like request, that supports HTTP_PROXY and HTTPS_PROXY environment variables out of the box could be used.

Thanks

Setting batch in api.Pickup doesn't work

I am getting error PICKUP.REQUEST.INVALIDInvalid request, a batch with shipments or a shipment is required to create a Pickup. while I provide valid shipping batch (with valid shipments) which has label_generated status. Also I noticed that api.Pickup is missing batch param in propTypes while shipment is there. Can you please clarify whether it's an issue or I am missing something. Thanks!

Cannot find module 'nodent-runtime'

Error: Cannot find module 'nodent-runtime'
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/{...}/node_modules/@easypost/api/easypost.js:83:18)

I think you might need to add nodent-runtime to the package.json

EasyPost IRC/Slack/Gitter

Hello,

I wanted to know if there was an easy post IRC/Slack/GItter that developers can use to talk with people who know easypost API well. Similar to how stripe payment company has an IRC for developers to talk to the stripe engineers about their API. If there isn't would EasyPost be willing to create an IRC or Slack or Gitter?

Set up "dev" branch and tag properly

While it's nice to have a version field in the package.json, it's not sufficient in most cases. Please: tag properly and make releases, there's even a dedicated page for it.

Easy and brief tutorial:

# List the last 10 commits with their short hash as one-liner:
$ git log --oneline --max-count=10

# Take a hash and add a new tag
$ git tag -a 1a2b3c4 -m "Hey! This is our newest Nodejs library version!"

# Publish time!
$ git push && git push --tags

# Done! Easy, ain't it?

And please offer a dev branch so we can have a merge target and something that we can use for testing before running with all the new things into a production environment.

# Add a new branch
$ git checkout -b dev

# Make changes or merge here… 
# Then merge the branch into dev with a new commit – so it's easy to revert (just in case)
$ git merge issue-42-new-feature dev --no-ff

# Now push to the remote named "origin" and track it
$ git push -u origin dev

Thanks in advance!

Error creating new Tracker on Meteor server

Version: 3.0.0-rc.14

Platform: macOS 10.11.something

Usage: Meteor/React

In my Meteor /server/main.js, I have the following code:

import { Meteor } from 'meteor/meteor';
import EasyPost from "node-easypost";
var epAPI = new EasyPost(/*omitted*/);

Meteor.startup(() => {
  Meteor.methods({
     createTracker: function (tracking_code, carrier=None) {
        if (carrier) {
           return new epAPI.Tracker({tracking_code: tracking_code, carrier: carrier}).save();
        }
        return new epAPI.Tracker({tracking_code: tracking_code}).save();
     }
 });
});

And it gets called by the client like so (though, in Coffeescript):

usps_ex: Meteor.call 'createTracker',
         "EZ064612938US",
         "USPS"

When this runs (as it's supposed to on page load), Meteor produces the following error in the console:

I20170312-14:29:02.039(-4)? Exception while invoking method 'createTracker' [object Object]
I20170312-14:29:02.040(-4)?     at e.<anonymous> (/Users/james/Workspace/exo/node_modules/node-easypost/easypost.js:2:20361)
I20170312-14:29:02.040(-4)?     at tryCatch (/Users/james/Workspace/exo/node_modules/regenerator-runtime/runtime.js:64:40)
I20170312-14:29:02.041(-4)?     at GeneratorFunctionPrototype.invoke [as _invoke] (/Users/james/Workspace/exo/node_modules/regenerator-runtime/runtime.js:299:22)
I20170312-14:29:02.041(-4)?     at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (/Users/james/Workspace/exo/node_modules/regenerator-runtime/runtime.js:116:21)
I20170312-14:29:02.041(-4)?     at n (/Users/james/Workspace/exo/node_modules/node-easypost/easypost.js:2:16966)
I20170312-14:29:02.042(-4)?     at /Users/james/Workspace/exo/node_modules/node-easypost/easypost.js:2:17091
I20170312-14:29:02.042(-4)?     at /Users/james/.meteor/packages/promise/.0.8.8.bjauo3++os+web.browser+web.cordova/npm/node_modules/meteor-promise/fiber_pool.js:32:39

I feel like I'm doing something wrong here, I'm just not sure what it is.

Thanks in advance!

Label - unable to generate in PDF

Hello all, I tried to generate a PDF label, I tried two things:

  1. Setting label_format: 'PDF' when creating a shipment
  2. Trying shipment.convertLabelFormat('PDF'), to which I got the error:
    console.log(err.message)
    < Status undefined returned from API request to shipments/shp_8e51e7a752064ecdbef7cdf003614cbf/label
    The requested resource could not be found.

Any idea how to generate a label in PDF? It's only generating in PNG for me. Thanks!

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.