Giter Site home page Giter Site logo

chartmogul-node's Issues

Any chance of releasing 2.0.0?

Right now there is a mismatch between the readme and the API, as the readme is already updated with the new API Key config based while the latest version 1.9.0 works with the old token and secret.

Pagination for Metrics.Customer.subscriptions

Hi, I’m writing a script to fetch subscriptions for a particular customer, and I’m using the method Metrics.Customer.subscriptions to do that.

It works well, except that I don’t know how to pass pagination parameters (per_page and page), since the method doesn’t seem to take an options object (unlike Customer.all). Is this a current limitation of the library? Is there a workaround for this? Cheers!

Importing invoice fails

If I attempt to import this invoice using the library, it fails, but, using curl it works fine.

code:

        canceled_at = sub.autorenewing == false ? sub.expiry_dt : null;

        lineItems = [{
          type: 'subscription',
          subscription_external_id: sub.order_id,
          plan_uuid: planMap[sub.order_sku],
          service_period_start: sub.order_dt.toString(),
          due_date: sub.order_dt.toString(),
          service_period_end: sub.expiry_dt ? sub.expiry_dt.toString() : null,
          //cancelled_at: canceled_at ? canceled_at.toString() : null,
          amount_in_cents: sub.amount_in_cents
        }];
        data = {
          external_id: sub.id,
          date: sub.order_dt ? sub.order_dt.toString() : null,
          currency: sub.currency_code,
          line_items: lineItems
        };
        console.log(data)
        ChartMogul.Import.Invoice.create(config, cust.uuid, data, (err, res) => {
          if (err)
            defer.reject(err);
          else
            defer.resolve(res);
        });

Console log of data:

{ external_id: 'Zr6AlcCIRQ6xR4gyZzeTFA',
  date: 'Sun Jul 26 2015 03:38:55 GMT-0700 (PDT)',
  currency: 'CAD',
  line_items:
   [ { type: 'subscription',
       subscription_external_id: 'GPA.1343-7803-4956-35795',
       plan_uuid: 'pl_196e2566-2346-4263-9599-f9e164e0f308',
       service_period_start: 'Sun Jul 26 2015 03:38:55 GMT-0700 (PDT)',
       due_date: 'Sun Jul 26 2015 03:38:55 GMT-0700 (PDT)',
       service_period_end: 'Mon Sep 12 2016 22:59:40 GMT-0700 (PDT)',
       amount_in_cents: 349 } ] }

Error:

{ SchemaInvalidError: JSON schema validation hasn't passed.
    at new SchemaInvalidError (/Users/alex/dev/is/web/node_modules/chartmogul-node/lib/chartmogul/errors/schema-invalid-error.js:7:11)
    at Request.request [as _callback] (/Users/alex/dev/is/web/node_modules/chartmogul-node/lib/chartmogul/resource.js:80:19)
    at Request.self.callback (/Users/alex/dev/is/web/node_modules/chartmogul-node/node_modules/request/request.js:187:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/alex/dev/is/web/node_modules/chartmogul-node/node_modules/request/request.js:1044:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/alex/dev/is/web/node_modules/chartmogul-node/node_modules/request/request.js:965:12)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:975:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
  name: 'SchemaInvalidError',
  response: { error: 'The property \'#/\' did not contain a required property of \'invoices\'' },
  httpStatus: 400 }

curl:

curl -i -X POST "https://api.chartmogul.com/v1/import/customers/cus_3e8226d6-d613-407b-a0bb-fd6e504eff97/invoices" \
     -u TOKEN:SECRET \
     -H "Content-Type: application/json" \
     -d '{
     "invoices":[
{ "external_id": "Zr6AlcCIRQ6xR4gyZzeTFA",
  "date": "Sun Jul 26 2015 03:38:55 GMT-0700 (PDT)",
  "currency": "CAD",
  "line_items":
   [ { "type": "subscription",
       "subscription_external_id": "GPA.1343-7803-4956-35795",
       "plan_uuid": "pl_196e2566-2346-4263-9599-f9e164e0f308",
       "service_period_start": "Sun Jul 26 2015 03:38:55 GMT-0700 (PDT)",
       "due_date": "Sun Jul 26 2015 03:38:55 GMT-0700 (PDT)",
       "service_period_end": "Mon Sep 12 2016 22:59:40 GMT-0700 (PDT)",
       "amount_in_cents": 349 } ] }
        ]
     }'

HTTP/1.1 201 Created
Server: nginx/1.9.10
Date: Sun, 14 Aug 2016 03:23:57 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
ETag: W/"2f29292d7b287d93de52197e33d4e2ab"
Cache-Control: max-age=0, private, must-revalidate
X-Request-Id: eaf45e86-d9c7-48f5-a25e-94a38d3d9ae5
X-Runtime: 0.125522
Strict-Transport-Security: max-age=15768000

{"invoices":[{"uuid":"inv_99492f7f-f29d-4419-978d-3daedde77a11","external_id":"Zr6AlcCIRQ6xR4gyZzeTFA","date":"2015-07-26T10:38:55.000Z","due_date":null,"currency":"CAD","line_items":[{"uuid":"li_caa3a567-da86-46cc-a6f8-d5e044283aff","external_id":null,"type":"subscription","subscription_uuid":"sub_2f6f9937-6114-49f5-8190-6e8ee4b666cd","plan_uuid":"pl_196e2566-2346-4263-9599-f9e164e0f308","prorated":false,"service_period_start":"2015-07-26T10:38:55.000Z","service_period_end":"2016-09-13T05:59:40.000Z","amount_in_cents":349,"quantity":1,"discount_code":"","discount_amount_in_cents":0,"tax_amount_in_cents":0}],"transactions":[]}]}Alexs-MacBook-Pro:web alex$

SchemaInvalidError has a fake specificity

When making a call with an incorrectly specified type, eg:

await(ChartMogul.CustomAttribute.add(cmConfig, entry.uuid, {
    custom: [
           { type: 'String', value: '560dccca5963a44522dd76fd', key: 'shoelaceId' },
           { type: 'Date', value: '2015-10-02T00:16:10.000Z', key: 'phone' }
    ]
}));

A fairly specific error is throw:

{ SchemaInvalidError: JSON schema validation hasn't passed. {"code":400,"message":"Parameter \"custom[0][type]\" does not have a valid value","param":"custom[0][type]"}

This would appear to imply that the first entry is at fault when actually, the second error is the broken one here.

Import API 422 error message not provided

When importing an invoice with type subscription but without a plan_uuid value, a 422 error is returned but without a useful error message such as 'plan_uuid is a required field'.

Reproduction steps:

  1. Import a customer into ChartMogul using the Import API and Node library
  2. Use the request below
  3. The following response will be provided: "Failed to created invoices <invoice_id> for customer (): The Invoice could not be created or updated. ResourceInvalidError 422".

Request:

ChartMogul.Import.Invoice.create(config,
   "cus_f466e33d-ff2b-4a11-8f85-417eb02157a7",
   {
     "invoices":[
       {
          "external_id": "INV0001",
          "date": "2015-11-01 00:00:00",
          "currency": "USD",
          "line_items": [
            {
              "type": "subscription",
              "subscription_external_id": "sub_0001",
              "service_period_start": "2015-11-01 00:00:00",
              "service_period_end": "2015-12-01 00:00:00",
              "amount_in_cents": 5000,
              "quantity": 1,
              "discount_code": "PSO86",
              "discount_amount_in_cents": 1000,
              "tax_amount_in_cents": 900
            }
          ]
       }
     ]
     },
   function (err, res) {
   // asynchronously called
});

@types/chartmogul-node are outdated. Miss-match right of the bat `@types/chartmogul-node`

@types/chartmogul-node are outdated. Miss-match right of the bat @types/chartmogul-node

export class Config {
    VERSION: string;
    API_BASE: string;
    retries: number;

    constructor(token: string, secret: string, base?: string);
    getAccountToken(): string;
    getSecretKey(): string;
}

vs chartmogul-node

class Config {
  constructor (apiKey, apiBase) {
    this.apiKey = apiKey;
    this.apiBase = apiBase || API_BASE;
  }
[Nest] 87015  - 03/12/2022, 6:08:58 AM   ERROR [ExceptionsHandler] Invalid URI "abcd12312312312312apikey/v1/ping"
Error: Invalid URI "abcd12312312312312apikey/v1/ping"
    at Request.init (/Users/okhomenko/chartmogul-integration/node_modules/request/request.js:273:31)
    at new Request (/Users/okhomenko/chartmogul-integration/node_modules/request/request.js:127:8)
    at request (/Users/okhomenko/chartmogul-integration/node_modules/request/index.js:53:10)
    at RetryOperation._fn (/Users/okhomenko/chartmogul-integration/node_modules/chartmogul-node/lib/chartmogul/util/retry.js:46:5)
    at RetryOperation.attempt (/Users/okhomenko/chartmogul-integration/node_modules/retry/lib/retry_operation.js:112:8)
    at Object.retryRequest (/Users/okhomenko/chartmogul-integration/node_modules/chartmogul-node/lib/chartmogul/util/retry.js:45:13)
    at /Users/okhomenko/chartmogul-integration/node_modules/chartmogul-node/lib/chartmogul/resource.js:68:12
    at new Promise (<anonymous>)
    at Function.request (/Users/okhomenko/chartmogul-integration/node_modules/chartmogul-node/lib/chartmogul/resource.js:40:21)
    at Function.ping (/Users/okhomenko/chartmogul-integration/node_modules/chartmogul-node/lib/chartmogul/resource.js:145:19)

Originally posted by @okhomenko in #28 (comment)

Query string not passed after replacing `request` library with `superagent`

Issue Description:

We have encountered a significant issue after transitioning from the request library to superagent for HTTP requests. Specifically, when attempting to fetch all metrics from your endpoint, the start-date query parameter, crucial for this request, is not being passed along, leading to failed requests due to the API's requirement for this parameter.

Search throws error for empty result

If you search email address, and no results are found, an error is thrown:

{ NotFoundError: The requested Resource could not be found. {"code":404,"message":"Can't find any customers with email: \"alex+11223@[domain].com\"","param":"email"}

That's pretty unexpected. Would expect to get back an empty search result since this isn't an error, it's just no result.

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.