npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-linkedin-sdk

v0.2.0

Published

An Angular (Angular 2 & Angular 4) wrapper for LinkedIn official Javascript SDK. To know more about the official documentation please visit [here](https://developer.linkedin.com/docs/getting-started-js-sdk).

Downloads

315

Readme

angular-linkedin-sdk

An Angular (Angular 2 & Angular 4) wrapper for LinkedIn official Javascript SDK. To know more about the official documentation please visit here.

All features of the original Javascript SDK are available through the service LinkedInService. The IN.Event.on(..) and IN.Event.onOnce(...) handler registration methods aren't exposed from original API, because you should subscribe to the isInitialized$ and isUserAuthenticated$ observables instead.

This library is published in an early state. The exposed interfaces might still be subject to change. Please don't expect a stable interface before version 0.2.x

NPM NPM

Build Status codecov dependencies Status devDependencies Status peerDependencies Status Build Status Build Status

Demo

To try the out the demo project clone the repository and run

$ npm install

Edit the demo/src/app/app.module.ts and paste you own LinkedIn API key

{ provide: 'apiKey', useValue: 'YOUR_API_KEY' },

followed by

$ npm run-script demo

Install

$ npm install angular-linkedin-sdk

ES2015 / UMD

If your project is based on Angular CLI / WebPack everything will work as expected.

SystemJS / UMD support is not yet available, but planned for version 0.2.x

Angular Universal

Server side rendering is not supported, since the original LinkedIn Javascript SDK is using JSONP and can't run outside browser environments.

We are working on browser-agnostic support for the library. As mentioned it's not up to us to support server side rendering but in future release we will avoid initialization on non-browser platforms to make the library invisible. It might cause crashes in Angular Universal environments because of DOCUMENT and window object usage. You can specify whether to run in browser or server in the providers as seen in the Usage example.

Usage

In the Angular AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

// Import the library
import { LinkedInSdkModule } from 'angular-linkedin-sdk';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,

    // Specify your library as an import
    LinkedInSdkModule
  ],
  providers: [
    // Inject apiKey and, optionally, authorize to integrate with LinkedIN official API
    { provide: 'apiKey', useValue: 'YOUR_API_KEY' },
    { provide: 'authorize', useValue: 'true/false' }, // OPTIONAL by default: false
    { provide: 'isServer', useValue: 'true/false' }  // OPTIONAL by default: false
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

LinkedInService

import {
    LinkedInService
} from 'angular-linkedin-sdk';

export class AppComponent implements OnInit {
    public isUserAuthenticated;
    public constructor(private _linkedInService: LinkedInService) {
    }
}    

API

isInitialized

An observable that emits true and completes when library has finished loading.

Example

public subscribeToisInitialized(){
    this._linkedInService.isInitialized$.subscribe({
    next: (state) => {
      // state will always return true when API finishes loading
    },
    complete: () => {
      // Completed
    }
  });
}

isUserAuthenticated

An observable that has an initial value of undefined. It emits a boolean value when the library has finished loading and when a login or logout is performed.

Example

ngOnInit() {
  // Subscribe to any values the observable will emit about logged in state
  this._linkedInService.isUserAuthenticated$.subscribe({
    next: (state) => {
      this.isUserAuthenticated = state;
    }
  });
}

getSdkIN

Gets the IN variable from the LinkedIN SDK. Allows access to variables from the SDK that are or are not documented officially.

Example

public getApiKeyFromSdkIN() {
    // Retrieve the API key used in the library through the SDK IN variable
    this.apiKey = this._linkedInService.getSdkIN().ENV.auth.api_key;
  }

login

Returns an observable that emits true and completes when authenticated. Waits for the library to finish loading. isUserAuthenticated$ also emits an updated value.

Example

public subscribeToLogin(){
  this._linkedInService.login().subscribe({
    next: (state) => {
      // state will always return true when login completed 
    },
    complete: () => {
      // Completed
    }
  });
}

logout

Returns an observable that emits with no value and completes when logout is finished. Waits for the library to finish loading. isUserAuthenticated$ also emits an updated value.

Example

public subscribeToLogout(){
  this._linkedInService.logout().subscribe({
    next: () => {
      // does not emit a value 
    },
    complete: () => {
      // Completed
    }
  });
}

raw

Enables authenticated calls to the LinkedIn REST API using the generic call wrapper. The original fluent API is fully encapsulated.

Parameters

  • url The API URL to invoke: should not include https://api.linkedin.com/v1.

Example

public rawApiCall(){
    const url = '/people/~?format=json';
    this._linkedInService.raw(url)
      .asObservable()
        .subscribe({
          next: (data) => {
            console.log(data);
          },
          error: (err) => {
            console.log(err);
          },
          complete: () => {
            console.log('RAW API call completed');
          }
        });
}

refresh

Refreshes a member token for an additional 30 minutes. Repeated continual use of the refresh() function to keep a member indefinitely logged in can result in your application being disabled. Use this call sparingly.

Example

public refresh() {
    this._linkedInService.refresh().subscribe({
      next: (value) => {
        console.log(`Refresh result: ${value}`);
      },
      complete: () => {
        console.log('Refresh call completed');
      }
    });
  }

Contribution

We are always looking for quality contributions and will be happy to accept your Pull Requests. For now, please make sure your PR has accompanying tests and all the tests are passing.

We will setup a CI system for the build very soon.

License

MIT © Evodeck Software

Evodeck Software