[[linkedin-component]]
= Linkedin Component
:page-source: components/camel-linkedin/camel-linkedin-component/src/main/docs/linkedin-component.adoc

*Available as of Camel version 2.14*


The LinkedIn component provides access to all of LinkedIn REST APIs
documented
at https://developer.linkedin.com/rest[https://developer.linkedin.com/rest]. 

LinkedIn uses OAuth2.0 for all client application authentication. In
order to use camel-linkedin with your account, you'll need to create a
new application for LinkedIn at
https://www.linkedin.com/secure/developer[https://www.linkedin.com/secure/developer].
The LinkedIn application's client id and secret will allow access to
LinkedIn REST APIs which require a current user. A user access token is
generated and managed by component for an end user. Alternatively the
Camel application can register an implementation
of org.apache.camel.component.linkedin.api.OAuthSecureStorage to provide
an org.apache.camel.component.linkedin.apiOAuthToken OAuth token.

Maven users will need to add the following dependency to their pom.xml
for this component:

[source,java]
-----------------------------------------------
    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-linkedin</artifactId>
        <version>${camel-version}</version>
    </dependency>
-----------------------------------------------

== URI format

[source,java]
-------------------------------------------------
    linkedin://endpoint-prefix/endpoint?[options]
-------------------------------------------------

Endpoint prefix can be one of:

* comments
* companies
* groups
* jobs
* people
* posts
* search

== LinkedInComponent




// component options: START
The Linkedin component supports 2 options, which are listed below.



[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *configuration* (common) | To use the shared configuration |  | LinkedInConfiguration
| *resolveProperty Placeholders* (advanced) | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | boolean
|===
// component options: END





// endpoint options: START
The Linkedin endpoint is configured using URI syntax:

----
linkedin:apiName/methodName
----

with the following path and query parameters:

=== Path Parameters (2 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *apiName* | *Required* What kind of operation to perform |  | LinkedInApiName
| *methodName* | *Required* What sub operation to use for the selected operation |  | String
|===


=== Query Parameters (16 parameters):


[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *accessToken* (common) | LinkedIn access token to avoid username and password login. |  | String
| *clientId* (common) | LinkedIn application client ID |  | String
| *clientSecret* (common) | LinkedIn application client secret |  | String
| *expiryTime* (common) | LinkedIn access token expiry time in milliseconds since Unix Epoch, default is 60 days in the future. |  | Long
| *httpParams* (common) | Custom HTTP params, for example proxy host and port, use constants from AllClientPNames |  | Map
| *inBody* (common) | Sets the name of a parameter to be passed in the exchange In Body |  | String
| *lazyAuth* (common) | Flag to enable/disable lazy OAuth, default is true. when enabled, OAuth token retrieval or generation is not done until the first REST call | true | boolean
| *redirectUri* (common) | Application redirect URI, although the component never redirects to this page to avoid having to have a functioning redirect server. So for testing one could use \https://localhost |  | String
| *scopes* (common) | List of LinkedIn scopes as specified at \https://developer.linkedin.com/documents/authentication#granting |  | OAuthScope[]
| *secureStorage* (common) | Callback interface for providing an OAuth token or to store the token generated by the component. The callback should return null on the first call and then save the created token in the saveToken() callback. If the callback returns null the first time, a userPassword MUST be provided |  | OAuthSecureStorage
| *userName* (common) | LinkedIn user account name, MUST be provided |  | String
| *userPassword* (common) | LinkedIn account password |  | String
| *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean
| *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. |  | ExceptionHandler
| *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. |  | ExchangePattern
| *synchronous* (advanced) | Sets whether synchronous processing should be strictly used, or Camel is allowed to use asynchronous processing (if supported). | false | boolean
|===
// endpoint options: END
// spring-boot-auto-configure options: START
== Spring Boot Auto-Configuration

When using Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

[source,xml]
----
<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-linkedin-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>
----


The component supports 15 options, which are listed below.



[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
| *camel.component.linkedin.configuration.access-token* | LinkedIn access token to avoid username and password login. |  | String
| *camel.component.linkedin.configuration.api-name* | What kind of operation to perform |  | LinkedInApiName
| *camel.component.linkedin.configuration.client-id* | LinkedIn application client ID |  | String
| *camel.component.linkedin.configuration.client-secret* | LinkedIn application client secret |  | String
| *camel.component.linkedin.configuration.expiry-time* | LinkedIn access token expiry time in milliseconds since Unix Epoch, default is 60 days in the future. |  | Long
| *camel.component.linkedin.configuration.http-params* | Custom HTTP params, for example proxy host and port, use constants from AllClientPNames |  | Map
| *camel.component.linkedin.configuration.lazy-auth* | Flag to enable/disable lazy OAuth, default is true. when enabled, OAuth token retrieval or generation is not done until the first REST call | true | Boolean
| *camel.component.linkedin.configuration.method-name* | What sub operation to use for the selected operation |  | String
| *camel.component.linkedin.configuration.redirect-uri* | Application redirect URI, although the component never redirects to this page to avoid having to have a functioning redirect server. So for testing one could use \https://localhost |  | String
| *camel.component.linkedin.configuration.scopes* | List of LinkedIn scopes as specified at \https://developer.linkedin.com/documents/authentication#granting |  | OAuthScope[]
| *camel.component.linkedin.configuration.secure-storage* | Callback interface for providing an OAuth token or to store the token generated by the component. The callback should return null on the first call and then save the created token in the saveToken() callback. If the callback returns null the first time, a userPassword MUST be provided |  | OAuthSecureStorage
| *camel.component.linkedin.configuration.user-name* | LinkedIn user account name, MUST be provided |  | String
| *camel.component.linkedin.configuration.user-password* | LinkedIn account password |  | String
| *camel.component.linkedin.enabled* | Enable linkedin component | true | Boolean
| *camel.component.linkedin.resolve-property-placeholders* | Whether the component should resolve property placeholders on itself when starting. Only properties which are of String type can use property placeholders. | true | Boolean
|===
// spring-boot-auto-configure options: END

== Producer Endpoints:

Producer endpoints can use endpoint prefixes followed by endpoint names
and associated options described next. A shorthand alias can be used for
some endpoints. The endpoint URI MUST contain a prefix.

Endpoint options that are not mandatory are denoted by []. When there
are no mandatory options for an endpoint, one of the set of [] options
MUST be provided. Producer endpoints can also use a special
option *inBody* that in turn should contain the name of the endpoint
option whose value will be contained in the Camel Exchange In message.

Any of the endpoint options can be provided in either the endpoint URI,
or dynamically in a message header. The message header name must be of
the format *CamelLinkedIn.<option>*. Note that the *inBody* option
overrides message header, i.e. the endpoint option *inBody=option* would
override a *CamelLinkedIn.option* header.

For more information on the endpoints and options see LinkedIn REST API
documentation
at https://developer.linkedin.com/rest[https://developer.linkedin.com/rest]. 

=== Endpoint prefix _comments_

The following endpoints can be invoked with the prefix *comments* as
follows:

[source,java]
------------------------------------------
    linkedin://comments/endpoint?[options]
------------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|getComment |comment |comment_id, fields |org.apache.camel.component.linkedin.api.model.Comment

|removeComment |comment |comment_id | 
|=======================================================================

[[LinkedIn-URIOptionsforcomments]]
URI Options for _comments_

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|comment_id |String

|fields |String
|=======================================================================

=== Endpoint prefix _companies_

The following endpoints can be invoked with the prefix *companies* as
follows:

[source,java]
-------------------------------------------
    linkedin://companies/endpoint?[options]
-------------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|addCompanyUpdateComment |companyUpdateComment |company_id, update_key, updatecomment |

|addCompanyUpdateCommentAsCompany |companyUpdateCommentAsCompany |company_id, update_key, updatecomment |

|addShare |share |company_id, share |

|getCompanies |companies |email_domain, fields, is_company_admin |org.apache.camel.component.linkedin.api.model.Companies

|getCompanyById |companyById |company_id, fields |org.apache.camel.component.linkedin.api.model.Company

|getCompanyByName |companyByName |fields, universal_name |org.apache.camel.component.linkedin.api.model.Company

|getCompanyUpdateComments |companyUpdateComments |company_id, fields, secure_urls, update_key |org.apache.camel.component.linkedin.api.model.Comments

|getCompanyUpdateLikes |companyUpdateLikes |company_id, fields, secure_urls, update_key |org.apache.camel.component.linkedin.api.model.Likes

|getCompanyUpdates |companyUpdates |company_id, count, event_type, fields, start |org.apache.camel.component.linkedin.api.model.Updates

|getHistoricalFollowStatistics |historicalFollowStatistics |company_id, end_timestamp, start_timestamp, time_granularity |org.apache.camel.component.linkedin.api.model.HistoricalFollowStatistics

|getHistoricalStatusUpdateStatistics |historicalStatusUpdateStatistics |company_id, end_timestamp, start_timestamp, time_granularity, update_key |org.apache.camel.component.linkedin.api.model.HistoricalStatusUpdateStatistics

|getNumberOfFollowers |numberOfFollowers |companySizes, company_id, geos, industries, jobFunc, seniorities |org.apache.camel.component.linkedin.api.model.NumFollowers

|getStatistics |statistics |company_id |org.apache.camel.component.linkedin.api.model.CompanyStatistics

|isShareEnabled |  | company_id |org.apache.camel.component.linkedin.api.model.IsCompanyShareEnabled

|isViewerShareEnabled |  |company_id |org.apache.camel.component.linkedin.api.model.IsCompanyShareEnabled

|likeCompanyUpdate |  | company_id, isliked, update_key |
|=======================================================================

[[LinkedIn-URIOptionsforcompanies]]
URI Options for _companies_

If a value is not provided for one of the option(s) *[companySizes,
count, email_domain, end_timestamp, event_type, geos, industries,
is_company_admin, jobFunc, secure_urls, seniorities, start,
start_timestamp, time_granularity]* either in the endpoint URI or in a
message header, it will be assumed to be *null*. Note that
the *null* value(s) will only be used if other options do not satisfy
matching endpoints.

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|companySizes |java.util.List

|company_id |Long

|count |Long

|email_domain |String

|end_timestamp |Long

|event_type |org.apache.camel.component.linkedin.api.Eventtype

|fields |String

|geos |java.util.List

|industries |java.util.List

|is_company_admin |Boolean

|isliked |org.apache.camel.component.linkedin.api.model.IsLiked

|jobFunc |java.util.List

|secure_urls |Boolean

|seniorities |java.util.List

|share |org.apache.camel.component.linkedin.api.model.Share

|start |Long

|start_timestamp |Long

|time_granularity |org.apache.camel.component.linkedin.api.Timegranularity

|universal_name |String

|update_key |String

|updatecomment |org.apache.camel.component.linkedin.api.model.UpdateComment
|=======================================================================

=== Endpoint prefix _groups_

The following endpoints can be invoked with the prefix *groups* as
follows:

[source,java]
----------------------------------------
    linkedin://groups/endpoint?[options]
----------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|addPost |post |group_id, post |

|getGroup |group |group_id |org.apache.camel.component.linkedin.api.model.Group
|=======================================================================

[[LinkedIn-URIOptionsforgroups]]
URI Options for _groups_

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|group_id |Long

|post |org.apache.camel.component.linkedin.api.model.Post
|=======================================================================

=== Endpoint prefix _jobs_

The following endpoints can be invoked with the prefix *jobs* as
follows:

[source,java]
--------------------------------------
    linkedin://jobs/endpoint?[options]
--------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|addJob |job |job |

|editJob |  | job, partner_job_id |

|getJob |job |fields, job_id |org.apache.camel.component.linkedin.api.model.Job

|removeJob |job |partner_job_id
|=======================================================================

[[LinkedIn-URIOptionsforjobs]]
URI Options for _jobs_

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|fields |String

|job |org.apache.camel.component.linkedin.api.model.Job

|job_id |Long

|partner_job_id |Long
|=======================================================================

=== Endpoint prefix _people_

The following endpoints can be invoked with the prefix *people* as
follows:

[source,java]
----------------------------------------
    linkedin://people/endpoint?[options]
----------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|addActivity |activity |activity |

|addGroupMembership |groupMembership |groupmembership |

|addInvite |invite |mailboxitem |

|addJobBookmark |jobBookmark |jobbookmark |

|addUpdateComment |updateComment |update_key, updatecomment |

|followCompany |  |company |

|getConnections |connections |fields, secure_urls |org.apache.camel.component.linkedin.api.model.Connections

|getConnectionsById |connectionsById |fields, person_id, secure_urls |org.apache.camel.component.linkedin.api.model.Connections

|getConnectionsByUrl |connectionsByUrl |fields, public_profile_url, secure_urls |org.apache.camel.component.linkedin.api.model.Connections

|getFollowedCompanies |followedCompanies |fields |org.apache.camel.component.linkedin.api.model.Companies

|getGroupMembershipSettings |groupMembershipSettings |count, fields, group_id, start |org.apache.camel.component.linkedin.api.model.GroupMemberships

|getGroupMemberships |groupMemberships |count, fields, membership_state, start |org.apache.camel.component.linkedin.api.model.GroupMemberships

|getJobBookmarks |jobBookmarks |  | org.apache.camel.component.linkedin.api.model.JobBookmarks

|getNetworkStats |networkStats |  | org.apache.camel.component.linkedin.api.model.NetworkStats

|getNetworkUpdates |networkUpdates |after, before, count, fields, scope, secure_urls, show_hidden_members,
start, type |org.apache.camel.component.linkedin.api.model.Updates

|getNetworkUpdatesById |networkUpdatesById |after, before, count, fields, person_id, scope, secure_urls,
show_hidden_members, start, type |org.apache.camel.component.linkedin.api.model.Updates

|getPerson |person |fields, secure_urls |org.apache.camel.component.linkedin.api.model.Person

|getPersonById |personById |fields, person_id, secure_urls |org.apache.camel.component.linkedin.api.model.Person

|getPersonByUrl |personByUrl |fields, public_profile_url, secure_urls |org.apache.camel.component.linkedin.api.model.Person

|getPosts |posts |category, count, fields, group_id, modified_since, order, role, start |org.apache.camel.component.linkedin.api.model.Posts

|getSuggestedCompanies |suggestedCompanies |fields |org.apache.camel.component.linkedin.api.model.Companies

|getSuggestedGroupPosts |suggestedGroupPosts |category, count, fields, group_id, modified_since, order, role, start |org.apache.camel.component.linkedin.api.model.Posts

|getSuggestedGroups |suggestedGroups |fields |org.apache.camel.component.linkedin.api.model.Groups

|getSuggestedJobs |suggestedJobs |fields |org.apache.camel.component.linkedin.api.model.JobSuggestions

|getUpdateComments |updateComments |fields, secure_urls, update_key |org.apache.camel.component.linkedin.api.model.Comments

|getUpdateLikes |updateLikes |fields, secure_urls, update_key |org.apache.camel.component.linkedin.api.model.Likes

|likeUpdate |  | isliked, update_key |

|removeGroupMembership |groupMembership |group_id |

|removeGroupSuggestion |groupSuggestion |group_id |

|removeJobBookmark |jobBookmark |job_id |

|share |  | share |org.apache.camel.component.linkedin.api.model.Update

|stopFollowingCompany |  | company_id |

|updateGroupMembership |  | group_id, groupmembership |
|=======================================================================

[[LinkedIn-URIOptionsforpeople]]
URI Options for _people_

If a value is not provided for one of the option(s) *[after, before,
category, count, membership_state, modified_since, order,
public_profile_url, role, scope, secure_urls, show_hidden_members,
start, type]* either in the endpoint URI or in a message header, it will
be assumed to be *null*. Note that the *null* value(s) will only be used
if other options do not satisfy matching endpoints.

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|activity |org.apache.camel.component.linkedin.api.model.Activity

|after |Long

|before |Long

|category |org.apache.camel.component.linkedin.api.Category

|company |org.apache.camel.component.linkedin.api.model.Company

|company_id |Long

|count |Long

|fields |String

|group_id |Long

|groupmembership |org.apache.camel.component.linkedin.api.model.GroupMembership

|isliked |org.apache.camel.component.linkedin.api.model.IsLiked

|job_id |Long

|jobbookmark |org.apache.camel.component.linkedin.api.model.JobBookmark

|mailboxitem |org.apache.camel.component.linkedin.api.model.MailboxItem

|membership_state |org.apache.camel.component.linkedin.api.model.MembershipState

|modified_since |Long

|order |org.apache.camel.component.linkedin.api.Order

|person_id |String 

|public_profile_url |String

|role |org.apache.camel.component.linkedin.api.Role

|scope |String

|secure_urls |Boolean

|share |org.apache.camel.component.linkedin.api.model.Share

|show_hidden_members |Boolean

|start |Long

|type |org.apache.camel.component.linkedin.api.Type

|update_key | String

|updatecomment |org.apache.camel.component.linkedin.api.model.UpdateComment
|=======================================================================

=== Endpoint prefix _posts_

The following endpoints can be invoked with the prefix *posts* as
follows:

[source,java]
---------------------------------------
    linkedin://posts/endpoint?[options]
---------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|addComment |comment |comment, post_id |

|flagCategory |  | post_id, postcategorycode |

|followPost |  | isfollowing, post_id |

|getPost |post |count, fields, post_id, start |org.apache.camel.component.linkedin.api.model.Post

|getPostComments |postComments |count, fields, post_id, start |org.apache.camel.component.linkedin.api.model.Comments

|likePost |  | isliked, post_id |

|removePost |post |post_id |
|=======================================================================
 
[[LinkedIn-URIOptionsforposts]]
URI Options for _posts_

If a value is not provided for one of the option(s) *[count, start]*
either in the endpoint URI or in a message header, it will be assumed to
be *null*. Note that the *null* value(s) will only be used if other
options do not satisfy matching endpoints.

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|comment |org.apache.camel.component.linkedin.api.model.Comment

|count |Long

|fields |String

|isfollowing |org.apache.camel.component.linkedin.api.model.IsFollowing

|isliked |org.apache.camel.component.linkedin.api.model.IsLiked

|post_id |String

|postcategorycode |org.apache.camel.component.linkedin.api.model.PostCategoryCode

|start |Long
|=======================================================================

=== Endpoint prefix _search_

The following endpoints can be invoked with the prefix *search* as
follows:

[source,java]
---------------------------------------
   linkedin://search/endpoint?[options]
---------------------------------------

[width="100%",cols="25%,25%,25%,25%",options="header",]
|=======================================================================
|Endpoint |Shorthand Alias |Options |Result Body Type

|searchCompanies |companies |count, facet, facets, fields, hq_only, keywords, sort, start |org.apache.camel.component.linkedin.api.model.CompanySearch

|searchJobs |jobs |company_name, count, country_code, distance, facet, facets, fields,
job_title, keywords, postal_code, sort, start |org.apache.camel.component.linkedin.api.model.JobSearch

|searchPeople |people |company_name, count, country_code, current_company, current_school,
current_title, distance, facet, facets, fields, first_name, keywords,
last_name, postal_code, school_name, sort, start, title |org.apache.camel.component.linkedin.api.model.PeopleSearch
|=======================================================================

[[LinkedIn-URIOptionsforsearch]]
URI Options for _search_

If a value is not provided for one of the option(s) *[company_name,
count, country_code, current_company, current_school, current_title,
distance, facet, facets, first_name, hq_only, job_title, keywords,
last_name, postal_code, school_name, sort, start, title]* either in the
endpoint URI or in a message header, it will be assumed to be *null*.
Note that the *null* value(s) will only be used if other options do not
satisfy matching endpoints.

[width="100%",cols="50%,50%",options="header",]
|=======================================================================
|Name |Type

|company_name |String

|count |Long

|country_code |String

|current_company |String

|current_school |String

|current_title |String

|distance |org.apache.camel.component.linkedin.api.model.Distance

|facet |String

|facets |String

|fields |String

|first_name |String

|hq_only |String

|job_title |String

|keywords |String

|last_name |String

|postal_code |String

|school_name |String

|sort |String

|start |Long

|title |String
|=======================================================================

== Consumer Endpoints

Any of the producer endpoints can be used as a consumer endpoint.
Consumer endpoints can
use http://camel.apache.org/polling-consumer.html#PollingConsumer-ScheduledPollConsumerOptions[Scheduled
Poll Consumer Options] with a *consumer.* prefix to schedule endpoint
invocation. By default Consumer endpoints that return an array or
collection will generate one exchange per element, and their routes will
be executed once for each exchange. To change this behavior use the
property *consumer.splitResults=true* to return a single exchange for
the entire list or array. 

== Message Headers

Any URI option can be provided in a message header for producer
endpoints with a *CamelLinkedIn.* prefix.

== Message body

All result message bodies utilize objects provided by the Camel LinkedIn
API SDK, which is built using Apache CXF JAX-RS. Producer endpoints can
specify the option name for incoming message body in the *inBody*
endpoint parameter.

== Use cases

The following route gets user's profile:

[source,java]
----------------------------------------
    from("direct:foo")
        .to("linkedin://people/person");
----------------------------------------

The following route polls user's connections every 30 seconds:

[source,java]
-------------------------------------------------------------------------------------
    from("linkedin://people/connections?consumer.timeUnit=SECONDS&consumer.delay=30")
        .to("bean:foo");
-------------------------------------------------------------------------------------

The following route uses a producer with dynamic header options. The
*personId* header has the LinkedIn person ID, so its assigned to the
*CamelLinkedIn.person_id* header as follows:

[source,java]
-----------------------------------------------------------------
    from("direct:foo")
        .setHeader("CamelLinkedIn.person_id", header("personId"))
        .to("linkedin://people/connectionsById")
        .to("bean://bar");
-----------------------------------------------------------------