Skip to content

Instantly share code, notes, and snippets.

@genslein
Created April 7, 2022 20:51
Show Gist options
  • Select an option

  • Save genslein/faa381928c7bbdbab3e98230b0d741f9 to your computer and use it in GitHub Desktop.

Select an option

Save genslein/faa381928c7bbdbab3e98230b0d741f9 to your computer and use it in GitHub Desktop.

Revisions

  1. genslein created this gist Apr 7, 2022.
    62 changes: 62 additions & 0 deletions CelsiusApiExample.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,62 @@
    const { Celsius, AUTH_METHODS, ENVIRONMENT } = require('celsius-sdk');
    const FormData = require('form-data')
    const axios = require("axios");
    // const partnerKey = process.env.PARTNER_TOKEN // Should be kept secret
    const partnerToken = "27ad54f93337ddf5ac9b3c3df7623d05";

    const bodyFormData = new FormData({
    "first_name": "Jane",
    "last_name": "Doe",
    "middle_name": "Middle",
    "email": "[email protected]",
    "title": "Mrs",
    "date_of_birth": "1990-04-14",
    "citizenship": "United States",
    "country": "United States",
    "state": "California",
    "city": "Los Angeles",
    "zip": "90001",
    "street": "3rd Street",
    "building_number": "22a",
    "flat_number": "1b",
    "ssn": "571-59-3333",
    "itin": "123-456-789",
    "national_id": "123-456-789",
    "gender": "female",
    "phone_number": "+1-202-555-0103",
    "user_token": "10a42df0-999d-49da-981d-27117e15310a",
    });

    Celsius({
    authMethod: AUTH_METHODS.USER_TOKEN, // We are telling the SDK that we are authenticating different users using user tokens.
    partnerKey: partnerToken,
    environment: ENVIRONMENT.STAGING // If not present, default is production.
    }).then((celsius) => {
    // your code

    return celsius.currencies;
    // SDK code
    // celsius.createUser(CreateUser.constructor(
    //
    // ))
    })

    let result = axios({
    method: "post",
    url: "https://wallet-api.staging.celsius.network/users",
    data: bodyFormData,
    headers: {
    "Content-Type": "multipart/form-data",
    "X-Cel-Partner-Token": partnerToken,
    },
    })
    .then(function (response) {
    //handle success
    console.log(response);
    })
    .catch(function (response) {
    //handle error
    console.log(response);
    });

    console.log(result);