Giter Club home page Giter Club logo

taurus's Introduction

TAURUS

The official client library for connecting to Bullhorn REST API


Dependency Status XO code style npm version semantic-release


WebsiteDocsBlog

What can Taurus do?

  • Authentication - built-in authentication functionality.
  • Realtime bindings - Synchronize database collections as objects or lists.
  • Note - Taurus is designed for use only in client side environments.

Install

npm install --save @bullhorn/taurus @bullhorn/bullhorn-types

Authentication

First, in the src folder create an app.js file. Then, you will need setup your Application with the credentials provided to you by Bullhorn.

Note: Don't have a clientId? Partner keys are only available directly from Bullhorn. If you are interested in becoming a partner, send a email message to [email protected] or fill out the form available at the Bullhorn Marketplace.

app.js

import { Staffing, StaffingCredentialsAuthProvider } from '@bullhorn/taurus';

const provider = new StaffingCredentialsAuthProvider('docsamson', 'secrets');
const staffing: Staffing = new Staffing({
  restUrl: 'https://login.bullhorn.com',
  BhRestToken: '~BULLHORN_REST_TOKEN~',
});

staffing.login(provider).then(() => {
  console.log('We Are Doing it!');
});

// or

const app = Staffing.loginWithPopup('https://login.bullhorn.com');

Getting the data

Now we need to get some data. Taurus provides several convience function to Search and retrieve entities within the system.

Object Data

For this example we are going to get and entiy by id.

import { EntityTypes, Candidate } from '@bullhorn/bullhorn-types';
import { Entity } from '@bullhorn/taurus';

let record: Entity<Candidate> = new Entity(EntityTypes.Candidate).fields('id', 'name');
// Populate from server with data for Candidate #100
record.get(100);
// Listen for changes
record.subscribe((response) => {
  console.log(record.data);
  // output: {id: 100, name: 'Theodore'}
});

List Data

For this example we are going to search for some Jobs and display a list of them.

import { EntityTypes, Candidate } from '@bullhorn/bullhorn-types';
import { EntityList } from '@bullhorn/taurus';

let list: EntityList<Candidate> = new EntityList(EntityTypes.Candidate, {
  fields: ['id', 'name'],
  startAt: 0,
  limitTo: 25,
  filter: { isDeleted: 0 },
});

list.subscribe((response) => {
  let total = list.info.total;
  // TODO: Finish this
});

Lets Get Started

This tutorial will take you through creating a simple application using Taurus and briefly explain its main concepts. We assume you are familiar with JavaScript, HTML, and CSS. To get a quick overview, we recommend you skip down to the section titled "Setting Up The HTML Page" so you can see how to use Taurus straight away. To view the completed results of this tutorial, please have a look at our examples project.

Configuring Your Environment

Let's start by getting you set up with a great set of tools that you can use to build modern JavaScript applications. All our tooling is built on Node.js. If you have that installed already, great! If not, you should go to the official web site, download and install it. Everything else we need will be installed via Node's package manager (npm).

Setting Up The HTML Page

If you've followed along this far, you now have all the libraries, build configuration and tools you need to create amazing JavaScript apps with Taurus. The next thing we need to do is create our index.html file in the root of our project folder. Create that now and use the markup below.

index.html

<!doctype html>
<html>
  <head>
	<link rel="stylesheet" type="text/css" href="//cdn.bullhorn.com/bullhorncss/1.0/bullhorn.css">
	<script src="//unpkg.com/@reactivex/[email protected]/dist/global/Rx.js"></script>
	<script src="//unpkg.com/axios/dist/axios.min.js"></script>
	<script src="//unpkg.com/@bullhorn/[email protected]/lib/index.umd.js"></script>
	<script>
        var provider = new taurus.StaffingCredentialsAuthProvider('docsamson', 'secretpassword');
        var staffing = new taurus.Staffing({
            useCookies: false,
            client_id: '~~YOUR-BULLHORN-CLIENT-ID~~',
            apiVersion: '*',
            redirect_url: 'http://your-app.com',
            authorization_url: 'http://auth.bullhornstaffing.com/oauth/authorize',
            token_url: 'http://auth.bullhornstaffing.com/oauth/token',
            login_url: 'http://rest.bullhornstaffing.com/rest-services/login'
        });

        staffing.login(provider).then(() => {
            // Now we are authenticated
            var list = new taurus.EntityList('Candidate', {
                fields: ['id', 'name'],
                startAt: 0,
                limitTo: 25,
                filter: { isDeleted: 0 }
            });
            list.subscribe((results) => {
				// The list has retrieved your results
                console.log('Results: ', results);
                console.log('Total Candidate: ', list.info.total);
            });
        });
    </script>
  </head>
  <body>
  </body>
</html>

Yes, that's it. This is the only HTML page in our application.

View the page

We can install another npm package called live-server. This with host our application and watch the directory structure for any changes, there is no configuration, so it always works.

npm install -g live-server

You can now browse to http://localhost:8080/ to see the app.

Let's recap. To add a page to your app:

  1. Add your SDK Credentials
  2. Authenticate
  3. Get data from Bullhorn
  4. Celebrate.

Conclusion

With its strong focus on developer experience, Taurus can enable you to not only create amazing applications, but also enjoy the process. We've designed it with simple conventions in mind so you don't need to waste time with tons of configuration or write boilerplate code just to satisfy a stubborn or restrictive framework.

If you need more help, check out the Documentation and Api Reference


  built by Bullhorn, copyright (c) forever!

taurus's People

Contributors

adrianossi avatar amrutha-rajiv avatar bvkimball avatar charlesabarnes avatar chasitywickenhauser-bh avatar dvoegelin avatar escarre avatar hiqbal01 avatar jgodi avatar martinmicunda avatar michaeldill avatar monroepe avatar ndickerson avatar nickle799 avatar sajjansarkar avatar shylendrapandravisam avatar tbo47 avatar

Stargazers

 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

taurus's Issues

UnhandledPromiseRejectionWarning Error

Hi @bvkimball

It seems like Taurus doesn't work with promises correctly:

Issue 1: If I try to query for none existing candidate I would expect to handle the error in my subscription, however, the Taurus is throwing the error and it doesn't pass the error to subscription.

let record: Entity<Candidate> = new Entity(EntityTypes.Candidate).fields('id', 'name');
// use none existing canditate id
record.get(100);
record.subscribe((response) => {
	console.log(record.data);
}, (error) => console.error('should print the error', error));

Error message:

(node:31240) UnhandledPromiseRejectionWarning: Error: Request failed with status code 404
    at createError (/Users/martinmicunda/projects/bigbang/aviation-api.cae.com/node_modules/@bullhorn/taurus/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/Users/martinmicunda/projects/bigbang/aviation-api.cae.com/node_modules/@bullhorn/taurus/node_modules/axios/lib/core/settle.js:18:12)
    at IncomingMessage.handleStreamEnd (/Users/martinmicunda/projects/bigbang/aviation-api.cae.com/node_modules/@bullhorn/taurus/node_modules/axios/lib/adapters/http.js:192:11)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)
(node:31240) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:31240) [DEP0018] 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.

Issue 2: In my application I prefer to use Promises and not observables and as the observable has toPromise() the below code should work, however it seems like promise is lost somewehere
as console.log or console.error are not executed.

let record: Entity<Candidate> = new Entity(EntityTypes.Candidate).fields('id', 'name');
record.get(100);
try {
  await record.toPromise();
  console.log('print me');
} catch (error) {
   console.error('print error', error);
}

Add FileAttachment Service

/file | /entityFiles | /fileAttachments | /file/pdfMerge

/rest-services/1hs/entity/ClientCorporation/137773/fileAttachments?fields=id,dateAdded,name,type,isPrivate,fileSize,fileExtension&meta=basic&start=0&count=1&query=isDeleted=false&showTotalMatched=true

Add Event Subscription Service

/event
Lets you subscribe and unsubscribe to event types and get entity events, field map change events, and job match search events.

Subscribe
HTTP Method

PUT

URL Specification

[corporation-token]/event/subscription/[subscription ID]

URL Parameters

Required

type

entity | fieldMapChange | jobMatchSearch

names

Required with "entity" type. A comma-separated list of entity names.

eventTypes

Required with "entity" type. A comma-separated list of entity event types: INSERTED, UPDATED, DELETED

Optional

BhRestToken

Token that represents a session established by the login process. Must be sent with all subsequent requests to the API. The session key can be provided in the BhRestToken query string, a cookie, or a special HTTP header. See Session Key for details on how to provide it.

Examples

Sample URL

https://rest.bullhorn.com/e999/event/subscription/abcde?type=entity&names=Candidate&eventTypes=INSERTED,UPDATED,DELETED

Sample Response

{'lastRequestId': 0,
'subscriptionId': 'abcde',
'createdOn': 1335285871323,
'jmsSelector': "JMSType='ENTITY' AND BhCorpId=44 AND BhEntityName='Candidate' AND BhEntityEventType IN ('UPDATED','INSERTED','DELETED')"}
Get Events
HTTP Method

GET

URL Specification

[corporation-token]/event/subscription/[subscription ID]

URL Parameters

Required

maxEvents

Integer specifying the maximum number of events to be returned.

Optional

BhRestToken

Token that represents a session established by the login process. Must be sent with all subsequent requests to the API. The session key can be provided in the BhRestToken query string, a cookie, or a special HTTP header. See Session Key for details on how to provide it.

Examples

Sample URL

https://rest.bullhorn.com/e999/event/subscription/abcde?maxEvents=100

Sample Response

{'requestId': 1,
'events': [{'eventId': 'ID:JBM-40004219',
'eventType': 'ENTITY',
'entityName': 'Candidate',
'eventMetadata': {},
'updatedProperties': ['phone'],
'entityEventType': 'UPDATED',
'eventTimestamp': 1335286112652,
'entityId': 123}]}

Add Options Service

Investigate LookUp calls and see if these effort can be combined into one

FEATURE: Allow Alternate Authentication Storage Options

Currently, Taurus uses Cache.ts to store the BhRestToken, etc. Cache.ts uses HTML5 Storage (window.localstorage), which is not available on NodeJS, and therefore prevents Taurus from being used for API User authentication.

Could you please consider providing alternative options to override authentication storage, such as using a database to store variables set by Taurus?

Cheers

StaffingOAuthPopupProvider - Invalid Client Id

While using the StaffingOAuthPopupProvider service, we receive an invalid client id error in the popup. I believe the 'clientId' parameter in the request should be 'client_id'.

Not sure if this is because of our implementation of BH, of if this is a typo in the service.

Incorrect
https://auth.bullhornstaffing.com/oauth/authorize?response_type=code&clientId=xxx&redirect_uri=https://localhost:4200

Correct:
https://auth.bullhornstaffing.com/oauth/authorize?response_type=code&client_id=xxx&redirect_uri=https://localhost:4200

Thank You

Attempt to authenticate so I can query candidates in the system

Hi,

I am using React (react-boilerplate) and this library with the intention to allow visitors to a website to query the candidates in the bullhorn system.

I am aware I will need to hide the variables in use by the system, but regardless I just want to do the above first in a rough and ready way initially.

This is the code I have, with obvious omissions, but the URL for login returns a 404 – yet it is taken exactly from the docs.

import React, { Component } from 'react';
import { Staffing, StaffingCredentialsAuthProvider } from '@bullhorn/taurus';

const provider = new StaffingCredentialsAuthProvider(
  'USERNAME',
  'PASSWORD',
);

const staffing = new Staffing({
  useCookies: false,
  client_id: 'CLIENT_ID',
  apiVersion: '*',
  redirect_url: 'http://0.0.0.0:3000',
  authorization_url: 'http://auth.bullhornstaffing.com/oauth/authorize',
  token_url: 'http://auth.bullhornstaffing.com/oauth/token',
  login_url: 'http://rest.bullhornstaffing.com/rest-services/login',
});

class SearchPage extends Component {
  doSearch = () => {
    console.log(`Login Attempt`);

    staffing.login(provider).then(() => {
      console.log('2');
      // never reached
    });

    console.log('1');
  };

  render() {
    this.doSearch();

    return (
      <>
          <h1>search</h1>
      </>
    );
  }
}

export default SearchPage;

Are these urls different now - or am I making a mess of this; the documentation is a little unclear, but I would have thought search candidates from the system would be quite straight forward?

Many 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.