0.0.33 • Published 1 year ago

@fern-api/primer v0.0.33

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

Primer Node Library

npm shield

The Primer Node library provides access to the Primer API from JavaScript/TypeScript.

Documentation

API documentation is available at https://apiref.primer.io/reference.

Usage

Open in StackBlitz

import { PrimerApiClient } from '@fern-api/primer';

const primerToken = 'abc123';
const primer = new PrimerApiClient({
  apiVersion: '2.2',
  auth: {
    environment: 'Sandbox',
    apiKey: primerToken,
  },
});

const createClientResponse = await primer.clientSession.create({
  orderId: 'my-order-id',
  amount: 200,
});

console.log('Received response from Primer!', createClientResponse);

SDK Examples

Below are a few examples of how to use the SDK to hit different endpoints. Checkout our API Reference to see all of our endpoints.

Searching Payments

const searchResponse = await primer.payments.search({
  paypalEmail: "customer@acme.com",
  limit: 10,
  paymentMethodType: "PAYPAL",
});

if (!searchResponse.ok) {
  throw new Error(`Encountered error ${searchResponse.error.errorName}`);
}

for (const searchPaymentResponse of searchResponse.body.data) {
  console.log(
    `Found payment of ${searchPaymentResponse.amount} ${searchPaymentResponse.currencyCode}`
  );
}

Save payment method token

const saveTokenResponse = await primer.paymentMethod.saveToken({
  paymentMethodToken: "my-payment-method-token",
  _body: {
    customerId: "customer-id",
  },
});

if (!saveTokenResponse.ok) {
  throw new Error(`Encountered error ${saveTokenResponse.error}`);
}

console.log("Saved token!", saveTokenResponse.body.token);

Beta status

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning the package version to a specific version in your package.json file. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.29

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.23

1 year ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago