diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644
index 1ec6e757..00000000
--- a/.circleci/config.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-version: 2.1
-
-jobs:
- build:
- docker:
- - image: cimg/openjdk:8.0
-
- working_directory: ~/intercom-java
-
- steps:
- - checkout
-
- - run: chmod +x ./gradlew
- - run: TERM="dumb" ./gradlew dependencies
- - run: TERM="dumb" ./gradlew test
diff --git a/.fernignore b/.fernignore
new file mode 100644
index 00000000..084a8ebb
--- /dev/null
+++ b/.fernignore
@@ -0,0 +1 @@
+# Specify files that shouldn't be modified by Fern
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
deleted file mode 100644
index 7932aff1..00000000
--- a/.github/ISSUE_TEMPLATE.md
+++ /dev/null
@@ -1,19 +0,0 @@
-Please use the following template to submit your issue. Following this template will allow us to quickly investigate and help you with your issue. Please be aware that issues which do not conform to this template may be closed.
-
-For feature requests please contact us at team@intercom.io
-
-
-## Version info
- - intercom-java version:
- - Java version:
-
-## Expected behavior
-
-## Actual behavior
-
-## Steps to reproduce
- 1.
- 2.
- 3.
-
-## Logs
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
deleted file mode 100644
index 7c94e728..00000000
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ /dev/null
@@ -1,5 +0,0 @@
-#### Why?
-Why are you making this change?
-
-#### How?
-Technical details on your change
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
deleted file mode 100644
index 2fd88763..00000000
--- a/.github/dependabot.yml
+++ /dev/null
@@ -1,14 +0,0 @@
-version: 2
-updates:
- - package-ecosystem: "gradle"
- directory: "/"
- schedule:
- interval: "weekly"
- open-pull-requests-limit: 5
- commit-message:
- prefix: "chore"
-
- - package-ecosystem: "github-actions"
- directory: "/"
- schedule:
- interval: "weekly"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000..260533c2
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,38 @@
+name: ci
+
+on: [push]
+
+jobs:
+ compile:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repo
+ uses: actions/checkout@v3
+
+ - name: Set up Java
+ id: setup-jre
+ uses: actions/setup-java@v1
+ with:
+ java-version: "11"
+ architecture: x64
+
+ - name: Compile
+ run: ./gradlew compileJava
+
+ test:
+ needs: [ compile ]
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repo
+ uses: actions/checkout@v3
+
+ - name: Set up Java
+ id: setup-jre
+ uses: actions/setup-java@v1
+ with:
+ java-version: "11"
+ architecture: x64
+
+ - name: Test
+ run: ./gradlew test
diff --git a/.gitignore b/.gitignore
index dcac0a87..d4199abc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,21 +1,24 @@
-*/**/Spike*.java
-.gradle
*.class
-out/*
+.project
+.gradle
+?
+.classpath
+.checkstyle
+.settings
+.node
+build
+
+# IntelliJ
*.iml
*.ipr
*.iws
-build
-out
-*/build/*
-*/build/**/*.jar
-*.war
-*.ear
-hs_err_pid*
-.idea
-/bin/
+.idea/
+out/
-intercom-java/.project
+# Eclipse/IntelliJ APT
+generated_src/
+generated_testSrc/
+generated/
-.project
-securing.gpg
+bin
+build
\ No newline at end of file
diff --git a/CHANGES.md b/CHANGES.md
deleted file mode 100644
index 8f9933c9..00000000
--- a/CHANGES.md
+++ /dev/null
@@ -1,288 +0,0 @@
-### Changes
-
-### 2.8.2
-
-#### Add support for has_inbox_seat field (#272)
-Added mapping for the has_inbox_seat field to the Admin user model.
-### 2.8.1
-
-#### Add support for delivered_as field (#264)
-Added mapping for the delivered_as field on the Conversation model.
-
-#### Add support for customer_first_reply field (#263)
-Added mapping for the customer_first_reply field on the Conversation model.
-
-### 2.8.0
-There are a number of new features and changes in this release so will move to version 2.8.
-The most important one from a breaking change point of view is that the use of API keys is no longer allowed.
-You should now be using Access Tokens to access the API
-For more information on any of the changes please see the README.
-We have added examples for all of the new features
-
-#### Remove API Key references (#230)
-API Keys are no longer valid. We now use Acces tokens.
-So removing reference to use API keys in the SDK
-
-#### Add support for snooze (#236)
-Added appropriate code to be able to snooze conversation and to read the conversation model for snooze attributes
-
-#### Add conversation ratings (#235)
-Add extra code to support reading conversation ratings
-
-#### Add support for marking conversation as read (#234)
-Add ability to make a conversation as read
-
-#### Add support for display_as when finding conversation (#239)
-Add a new find that allows extra parameters
-
-#### Support running assignment rules (#243)
-Build support for recent API feature to allow running assignment rules on a conversation
-https://developers.intercom.com/intercom-api-reference/reference#run-conversation-assignment-rules
-
-#### Support Event Summaries (#244)
-List event summaries of a user
-https://developers.intercom.com/intercom-api-reference/reference#view-user-events-summaries
-
-#### Extract Iterator implementation into TypedDataCollection (#247)
-First thing, TypedDataCollection now implements Iterator, it is delegating the hasNext(), next() and remove() methods to a TypedDataCollectionIterator instance.
-Second, I have removed all specific implementations of Iterator from all Collection classes, which were just copy-paste.
-
-#### Update webhook topics and add ping (#245)
-Added support for more topics
-
-#### Allow parsing of responses from DELETE requests (#248)
-Now we check if DELETE response has data if it does proceed to process it as any other normal data
-If there is no data just return null
-
-### 2.7.0
-This update includes the removal of an option which is not possible viua the API.
-There was an option in the SDK to manually update the company sessions account but this is not possible vai the API.
-It is doubbtful that it was being used but just in case we will make this release 2.7.0
-
-#232 - Add the visitor endpoint functionality for the java SDK.
-#233 - Remove option to set company session count since it returns error as it is not possible to set it
-
-#### 2.6.0
-There a number of changed in this version so updating to 2.6
-Highlights are adding more attributes to the company resource and new features on admin resource.
-For more info see the specific PR or issue noted here and/or the updated readme
-- use thread local (optionally) for context setting (#204)
-- Add support for more company attributes (#183)
-- Add deletion by ID and User ID (#200)
-- Add support for new Admin endpoints and attributes (#198)
-- Add tests for companies (#215)
-- Update readme to document permanent deletion and rename old delete method to archive (#228)
-
-#### 2.5.2
-- Adding tagging abilities to Contacts.
-
-#### 2.5.1
-- Adding new release due to issues with previous.
-
-#### 2.5.0
-- Fix for #207 to remove a non-existent API call (PR #211)
-- Fix for #197 to prioritise user_id when tagging users (PR #199)
-- Update of Jackson dependencies (PR #203)
-- Fix for #197 to prioritise user_id when tagging users (PR #199)
-- Fix for #202 to enable retrieving company session count (PR #213)
-- Update Gradle (PR #216)
-- Add template for Pull Requests (PR #217)
-- Removal of Travis (PR #219)
-
-#### 2.4.0
-- Fix for gradle release issue #192
-- Update related to API user archive and permanent delete option #195
-
-#### 2.3.3
-- Fix for #185: scroll issue where requests not reaching endpoint (PR #186)
-
-#### 2.3.2
-- fix for #(174) to Handle records with no avatars (#181)
-
-#### 2.3.1
-- Updating release versions due to number of new features ebing added
-- Add support for deletion by user_id or email (#175)
-- Add support for listing events (#173)
-- Add support for updating avatars for Users and Contacts/Leads (#174)
-- Add support for more message attributes: url, id and attachments (#177)
-
-#### 2.2.12
-- Update readme with more list examples (#165)
-- Remove restrictions on listing conversations via user and admin (#171)
-
-#### 2.2.11
-- Add support for retrieving conversation tags
-
-#### 2.2.10
-- Add option to create events with ID
-- Fix issues with README headers
-
-#### 2.2.7
-- Add scroll to companies
-
-#### 2.2.6
-- Add rate limit fields to `RateLimitException` (submitted by @loonydevil)
-
-#### 2.2.5
-- Add scroll to contacts and users
-
-#### 2.2.4
-
-- Add phone attribute
-- Fix infinite recursive call on get conversation parts
-
-#### 2.2.3
-
-- Add next page size check for pagination
-
-#### 2.2.2
-
-- Add data_type for bulk user actions
-
-#### 2.2.1
-
-- Add attachment support for replies
-- Fix remove user from company bug
-
-#### 2.2.0
-
-- Include company custom attributes when updating a user with an embedded company object
-- Include support for Personal Access Token API access
-
-#### 2.1.0
-
-- Dynamically retrieve the parts for a conversation if not present
-
-#### 2.0.0
-
-- Fixes subscription metadata deserialization
-
-#### 1.3.1
-
-- Fixes company removal
-
-#### 1.3.0
-
-- Is a rollup of the 1.3.0 beta releases.
-
-#### 1.3.0-b3
-
-- Configure Jackson ObjectMapper once [76](https://github.com/intercom/intercom-java/issues/76)
-
-#### 1.3.0-b2
-
-- Allow users to be removed from companies.
-
-#### 1.3.0-b1
-
-- Support bulk user and event submission. Save your request rate limit for
-a rainy day! You can post and delete users, and post events.
-
-- Add a currentTimestamp() helper to Intercom. This divides currentTimeMillis
-by 1000 to produce a second level value.
-
-#### 1.2.1
-
-- Do not send empty company arrays for user updates. Honestly, what's the point?
-
-#### 1.2.0
-
-- Allow conversations to be assigned to others on your team. Conversations
-are the most beautiful things, and now you can share them with others through
-the API.
-
-- Support closing and opening conversations, either directly or with a reply.
-
-
-#### 1.1.2
-
- - make setUserAgentData public. Previously this was a protected method.
-
-#### 1.1.1
-
- - add support for [Contact Messaging](https://github.com/intercom/intercom-java#conversations)
-
-#### 1.1.0
-
- - add support for [Contacts](https://github.com/intercom/intercom-java#contacts)
-
-#### 1.0.9
-
- - remove secondary getters on user that stop older jackson versions working [48](https://github.com/intercom/intercom-java/issues/45) (caused in [40](https://github.com/intercom/intercom-java/issues/48)). Doing a bang up job on regression bugs atm.
-
-#### 1.0.8
-
- - fix user update regression [45](https://github.com/intercom/intercom-java/issues/45) (caused in [40](https://github.com/intercom/intercom-java/issues/40))
-
- - don't send values for `unsubscribed_from_emails`, `update_last_request_at` or `new_session` unless set
-
-#### 1.0.7
-
- - handle more kinds of social urls [35](https://github.com/intercom/intercom-java/issues/35)
-
-#### 1.0.6
-
- - fix user message sending [40](https://github.com/intercom/intercom-java/issues/40)
-
-#### 1.0.5
-
-allow the signed_up_at user field to be submitted
-
-#### 1.0.4
-
-allow the intercom user id field to be submitted
-
-#### 1.0.3
-
-encode social profile urls for user objects
-
-#### 1.0.2
-
-- fix NPE when errors have no data [30](https://github.com/intercom/intercom-java/pull/30)
-
-#### 1.0.1
-
- - send custom company attributes on update
-
- - fix NPE when company has no plan on update
-
- - invalidate setSessionCount on Company [27](https://github.com/intercom/intercom-java/issues/27)
-
-#### 1.0.0
-
- - removed tag methods requiring collections
-
- - handle non-json error entities from server
-
-#### 0.1.0
-
- - support untag of users and companies
-
- - renamed of current page and page methods on collections (breaking)
-
-#### 0.0.5
-
-- fix bulk user tagging when using fully populated users [13](https://github.com/intercom/intercom-java/issues/13)
-- add client side validation of events [14](https://github.com/intercom/intercom-java/issues/14)
-- fix npe when updating users [15](https://github.com/intercom/intercom-java/issues/15)
-
-
-#### 0.0.4
-
-- send false boolean values for user updates [8](https://github.com/intercom/intercom-java/issues/8)
-
-#### 0.0.3
-
-- only send allowed fields when adding a company to a user [7](https://github.com/intercom/intercom-java/issues/7)
-
-#### 0.0.2
-
- - add toString methods on some classes
-
-#### 0.0.1
-
- - fix bintray publication task (was sending empty jars)
-
-#### 0.0.0
-
- - initial client
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 305509fc..00000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
-TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
-2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
-3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
-4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
-5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
-6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
-7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
-8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
-9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
-END OF TERMS AND CONDITIONS
-
-APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
-Copyright 2014 Intercom, Inc.
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
\ No newline at end of file
diff --git a/README.md b/README.md
deleted file mode 100644
index f8f09d12..00000000
--- a/README.md
+++ /dev/null
@@ -1,825 +0,0 @@
-# intercom-java
-
-[](https://circleci.com/gh/intercom/intercom-java)
-[](https://search.maven.org/artifact/io.intercom/intercom-java)
-
-
-> Java bindings for the [Intercom API](https://api.intercom.io/docs)
-
-## Project Updates
-
-### Retirement of Bintray/JCenter
-
-This project was previously publishing releases to JCenter, which is being retired by JFrog on May 1st 2021.
-
-To allow continued access to past versions, we've migrated them to Maven Central.
-
-### Maintenance
-
-We're currently building a new team to provide in-depth and dedicated SDK support.
-
-In the meantime, we'll be operating on limited capacity, meaning all pull requests will be evaluated on a best effort basis and will be limited to critical issues.
-
-We'll communicate all relevant updates as we build this new team and support strategy in the coming months.
-
-- [Installation](#add-a-dependency)
-- [Resources](#resources)
-- [Authorization](#authorization)
-- [Usage](#usage)
-- [Idioms](#idioms)
-- [Configuration](#configuration)
-
-## Add a dependency
-
-The distribution is hosted on [mavenCentral](https://search.maven.org/artifact/io.intercom/intercom-java).
-To use the client, you can add the mavenCentral repository to your dependencies.
-
-### Maven
-
-Add the project declaration to your `pom.xml`:
-
-```xml
-
- io.intercom
- intercom-java
- 2.8.2
-
-```
-
-### Gradle
-
-Add mavenCentral to your `repositories` block:
-
-```groovy
-repositories {
- mavenCentral()
-}
-```
-
-and add the project to the `dependencies` block in your `build.gradle`:
-
-```groovy
-dependencies {
- implementation 'io.intercom:intercom-java:2.8.2'
-}
-```
-
-### SBT
-
-Add mavenCentral to your `resolvers` in your `build.sbt`:
-
-```scala
-resolvers += "mavenCentral" at "https://repo1.maven.org/maven2"
-```
-
-and add the project to your `libraryDependencies` in your `build.sbt`:
-
-```scala
-libraryDependencies += "io.intercom" % "intercom-java" % "2.8.2"
-```
-
-## Resources
-
-Resources this API supports:
-
-- [Users](#users)
-- [Contacts](#contacts)
-- [Visitors](#visitors)
-- [Companies](#companies)
-- [Admins](#admins)
-- [Events](#events)
-- [Tags](#tags)
-- [Segments](#segments)
-- [Notes](#notes)
-- [Conversations](#conversations)
-- [Webhooks](#webhooks)
-- [Counts](#counts)
-
-## Authorization
-
-> If you already have an access token you can find it [here](https://app.intercom.com/developers/_). If you want to create or learn more about access tokens then you can find more info [here](https://developers.intercom.io/docs/personal-access-tokens).
-
-```java
-# With an OAuth or Access token:
-Intercom.setToken("da39a3ee5e6b4b0d3255bfef95601890afd80709");
-```
-
-If you are building a third party application you can get your OAuth token by [setting-up-oauth](https://developers.intercom.io/page/setting-up-oauth) for Intercom.
-
-## Usage
-
-### Users
-
-```java
-// Create a user
-User user = new User()
- .setEmail("malcolm@serenity.io")
- .setUserId("1")
- .addCustomAttribute(CustomAttribute.newStringAttribute("role", "sergeant"))
- .addCustomAttribute(CustomAttribute.newBooleanAttribute("browncoat", true));
-User created = User.create(user);
-
-// Find user by id
-user = User.find("541a144b201ebf2ec5000001");
-
-// Find user by email
-Map params = Maps.newHashMap();
-params.put("email", "malcolm@serenity.io");
-user = User.find(params);
-
-// Find user by user_id
-params = Maps.newHashMap();
-params.put("user_id", "1");
-user = User.find(params);
-
-// Update custom_attributes for a user
-user.addCustomAttribute(CustomAttribute.newStringAttribute("role", "captain"));
-User.update(user);
-
-// Iterate over all users (up to 10k records, to read all use Scroll API)
-UserCollection users = User.list();
-while(users.hasNext()) {
- System.out.println(users.next().getUserId());
-}
-
-// List users (sorting)
-Map params = Maps.newHashMap();
-params.put("sort", "updated_at");
-params.put("order", "asc");
-UserCollection users = User.list(params);
-
-// List users (created within the past X days)
-Map params = Maps.newHashMap();
-params.put("created_since", "2");
-UserCollection users = User.list(params);
-
-// List users by tag
-Map params = Maps.newHashMap();
-params.put("tag_id", "12345");
-UserCollection users = User.list(params);
-
-// List users by segment
-Map params = Maps.newHashMap();
-params.put("segment_id", "1234567890abcdef12345678");
-UserCollection users = User.list(params);
-
-// Retrieve users via Scroll API
-ScrollableUserCollection usersScroll = User.scroll();
-List users = usersScroll.getPage();
-usersScroll = usersScroll.scroll();
-
-// Archive a user by Intercom ID
-User user = User.find("541a144b201ebf2ec5000001");
-User.archive(user.getId());
-
-// Archive a user by user_id
-Map params = Maps.newHashMap();
-params.put("user_id", "1");
-User.archive(params);
-
-// Archive a user by email
-Map params = Maps.newHashMap();
-params.put("email", "malcolm@serenity.io");
-User.archive(params);
-
-// Permanently delete a user by Intercom ID
-User.permanentDelete("541a144b201ebf2ec5000001");
-```
-
-### Contacts
-
-_Contacts were added in version 1.1 of the client._
-
-```java
-// Create a Contact
-Contact contact = new Contact()
- .setEmail("fantastic@serenity.io")
- .addCustomAttribute(newStringAttribute("role", "fence"));
-Contact created = Contact.create(contact);
-
-// Find a single contact by server supplied user id or id
-contact = Contact.findByID("541a144b201ebf2ec5000002");
-contact = Contact.findByUserID("e1a7d875-d83a-46f7-86f4-73be98a98584");
-
-// Update a contact
-contact.setName("Stitch Hessian");
-Contact updated = Contact.update(contact);
-
-// Update a contact by ID
-Contact contact = new Contact().setID("541a144b201ebf2ec5000002").setName("Stitch Hessian");
-Contact updated = Contact.update(contact);
-
-// Update a contact by User ID
-Contact contact = new Contact().setUserID("e1a7d875-d83a-46f7-86f4-73be98a98584").setName("Stitch Hessian");
-Contact updated = Contact.update(contact);
-
-// Read a contact list by email
-ContactCollection contacts = Contact.listByEmail("jubal@serenity.io");
-while(contacts.hasNext()) {
- System.out.println(contacts.next());
-}
-
-// Iterate over all contacts (up to 10k records, to read all use Scroll API)
-ContactCollection allContacts = Contact.list();
-while(allContacts.hasNext()) {
- System.out.println(allContacts.next());
-}
-
-// Retrieve contacts via Scroll API
-ScrollableContactCollection contactsScroll = Contact.scroll();
-List contacts = contactsScroll.getPage();
-contactsScroll = contactsScroll.scroll();
-
-// List contacts (sorting)
-Map params = Maps.newHashMap();
-params.put("sort", "created_at");
-params.put("order", "asc");
-ContactCollection contacts = Contact.list(params);
-
-// Remove a contact
-Contact.delete(contact);
-
-// Remove a contact by id
-Contact.delete(contact.getID());
-
-// Remove a contact by user_id
-Contact.deleteByUserID(contact.getUserID());
-
-// Convert a contact
-User converted = Contact.convert(contact, user);
-```
-
-### Visitors
-
-```java
-// Find visitor by ID
-Visitor visitor = Visitor.findByID("5b69565fa737210d1c2127f1");
-
-// Find visitor by User ID
-Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50");
-
-// Update a visitor
-Visitor visitor = Visitor.findByID("5b69565fa737210d1c2127f1");
-visitor.setName("Visitor's Name");
-Visitor.update(visitor);
-
-// Delete a visitor by ID
-Visitor.delete("5b69565fa737210d1c2127f1");
-
-// Delete a visitor
-Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50");
-Visitor.delete(visitor);
-
-// Convert a visitor to a lead
-Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50");
-Contact contact = Visitor.convertToContact(visitor);
-
-// Convert a visitor to a user
-Visitor visitor = Visitor.findByUserID("6a347bc9-0b96-4925-bbbc-1f8b11f94c50");
-User user = new User();
-user.setUserId("1");
-User convertUser = Visitor.convertToUser(visitor, user);
-```
-
-### Companies
-
-```java
-// Create a company
-Company company = new Company();
- company.setName("Blue Sun");
- company.setCompanyID("1");
- company.setMonthlySpend(123.10f);
- company.setPlan(new Company.Plan("premium"));
- company.addCustomAttribute(CustomAttribute.newIntegerAttribute("foddstuff-items", 246));
- company.addCustomAttribute(CustomAttribute.newStringAttribute("bestseller", "fruity oaty bar"));
-Company.create(company);
-
-// Find a company by company_id
-map = Maps.newHashMap();
-map.put("company_id", "1");
-Company company = Company.find(map);
-
-// Find a company by name
-map = Maps.newHashMap();
-map.put("name", "Blue Sun");
-Company company = Company.find(map);
-
-// Find a company by id
-Company company = Company.find("541a144b201ebf2ec5000001");
-
-// Update a company
-company.setName("Blue Sun Corporation");
-Company.update(company);
-
-// Iterate over all companies
-CompanyCollection companies = Company.list();
-while(companies.hasNext()) {
- System.out.println(companies.next().getName());
-}
-
-// Retrieve companies via Scroll API
-ScrollableCompanyCollection companiesScroll = Company.scroll();
-List companies = companiesScroll.getPage();
-companiesScroll = companiesScroll.scroll();
-
-// Get a list of users in a company
-map = Maps.newHashMap();
-map.put("company_id", "6");
-UserCollection users = Company.listUsers(map);
-
-// Add a user to one or more companies
-User user = User.find("541a144b201ebf2ec5000001");
-user.addCompany(company);
-User.update(user);
-```
-
-### Admins
-
-```java
-// Iterate over all admins
-AdminCollection admins = Admin.list();
-while(admins.hasNext()) {
- System.out.println(admins.next().getName());
-}
-
-// Find admin by ID
-Admin admin = Admin.find("123456");
-
-// Set admin as away and enable away mode reassignment
-Admin admin = Admin.setAwayMode("123456", true, true);
-```
-
-### Events
-
-```java
-// Create an event with a user ID
-// This is only valid for users
-Event event = new Event()
- .setEventName("bought-hat")
- .setUserID("1")
- .putMetadata("invitee_email", "jayne@serenity.io")
- .putMetadata("found_date", System.currentTimeMillis())
- .putMetadata("new_signup", true);
-Event.create(event);
-
-// Create an event with an email
-// This is only valid for users
-Event event = new Event()
- .setEventName("bought-hat")
- .setEmail("test@example.com");
-Event.create(event);
-
-// Create an event with an ID
-// This is valid for both users and leads
-Event event = new Event()
- .setEventName("bought-hat")
- .setId("599d6aeeda850883ed8ba7c2");
-Event.create(event);
-
-
-// List events of a user
-Map params = Maps.newHashMap();
-params.put("type", "user");
-params.put("user_id", "1");
-// Alternatively list by Intercom ID
-// params.put("intercom_user_id", "541a144b201ebf2ec5000001");
-// Or by email
-// params.put("email", "river@serenity.io");
-EventCollection events = Event.list(params);
-while (events.hasNext()) {
- System.out.println(events.next().getEventName());
-}
-
-// List event summaries of a user
-Map params = Maps.newHashMap();
-params.put("type", "user");
-params.put("user_id", "1");
-// Alternatively list by Intercom ID
-// params.put("intercom_user_id", "541a144b201ebf2ec5000001");
-// Or by email
-// params.put("email", "river@serenity.io");
-EventSummaryCollection eventSummaryCollection = Event.listSummary(params);
-for(EventSummary eventSummary : eventSummaryCollection.getEventSummaries()){
- System.out.println(eventSummary);
-}
-```
-
-### Tags
-
-```java
-// create a tag
-Tag tag = new Tag().setName("alliance");
-tag = Tag.create(tag);
-
-// update a tag
-tag.setName("independent");
-tag = Tag.update(tag);
-
-// tag and untag users
-User one = new User().setEmail("river@serenity.io");
-User two = new User().setEmail("simon@serenity.io").untag();
-User.create(one);
-User.create(two);
-Tag.tag(tag, one, two);
-
-// tag and untag contacts
-Contact contact1 = Contact.findByID("5ab313046e4997e35bc13e7c");
-Contact contact2 = Contact.findByUserID("697ea3e0-227d-4d70-b776-1652e94f9583").untag();
-Tag.tag(tag, contact1, contact2);
-
-// iterate over all tags
-final TagCollection tags = Tag.list();
-while (tags.hasNext()) {
- System.out.println(tags.next().getId());
-}
-
-// tag and untag companies
-Company c1 = new Company().setCompanyID("1");
-Company c2 = new Company().setCompanyID("2").untag();
-Company.create(c1);
-Company.create(c2);
-Tag.tag(tag, c1, c2);
-
-// delete a tag
-Tag.delete(tag);
-```
-
-### Segments
-
-```java
-// Find a segment
-Segment segment = Segment.find("1");
-
-// Update a segment
-segment.setName("new name");
-Segment.update(segment);
-
-// Iterate over all segments
-SegmentCollection segments = Segment.list();
-while(segments.hasNext()) {
- System.out.println(segments.next().getId());
-}
-```
-
-### Notes
-
-```java
-// create a user note
-User user = new User().setId("5310d8e8598c9a0b24000005");
-Author author = new Author().setId("1");
-Note note = new Note()
- .setUser(user)
- .setAuthor(author)
- .setBody("The note");
-Note.create(note);
-
-// Find a note by id
-note = Note.find("1");
-
-// Iterate over all notes for a user via their user_id
-Map params = Maps.newHashMap();
-params.put("user_id", "1");
-NoteCollection notes = Note.list(params);
-while(notes.hasNext()) {
- System.out.println(notes.next().getBody());
-}
-
-// Iterate over all notes for a user via their email address
-params = Maps.newHashMap();
-params.put("email", "malcolm@serenity.io");
-notes = Note.list(params);
-while(notes.hasNext()) {
- System.out.println(notes.next().getBody());
-}
-```
-
-### Conversations
-
-```java
-// send a message to a user
-User user = new User().setId("5310d8e8598c9a0b24000005");
-Admin admin = new Admin().setId("1");
-AdminMessage adminMessage = new AdminMessage()
- .setAdmin(admin)
- .setUser(user)
- .setSubject("This Land")
- .setBody("Har har har! Mine is an evil laugh!")
- .setMessageType("email")
- .setTemplate("plain");
-Conversation.create(adminMessage);
-
-// send a message from a user
-UserMessage userMessage = new UserMessage()
- .setBody("Hey! Is there, is there a reward?")
- .setFrom(user);
-Conversation.create(userMessage);
-
-// send a message from a contact
-ContactMessage contactMessage = new ContactMessage()
- .setBody("Hey! Is there, is there a reward?")
- .setFrom(contact);
-Conversation.create(contactMessage);
-
-//list all conversations
-ConversationCollection conversations = Conversation.list();
-while (conversations.hasNext()) {
- Conversation conversation = conversations.next();
-}
-
-// find admin conversations
-Map params = Maps.newHashMap();
-params.put("type", "admin");
-params.put("admin_id", "1");
-ConversationCollection adminConversations = Conversation.list(params);
-while (adminConversations.hasNext()) {
- Conversation conversation = adminConversations.next();
-}
-
-// find user conversations
-params = Maps.newHashMap();
-params.put("type", "user");
-params.put("user_id", "1");
-ConversationCollection userConversations = Conversation.list(params);
-while (userConversations.hasNext()) {
- Conversation conversation = userConversations.next();
-}
-
-// find a conversation by id
-final Conversation conversation = Conversation.find("66");
-ConversationMessage conversationMessage = conversation.getConversationMessage();
-ConversationPartCollection parts = conversation.getConversationPartCollection();
-List partList = parts.getPage();
-for (ConversationPart part : partList) {
- String partType = part.getPartType();
- Author author = part.getAuthor();
- String body = part.getBody();
-}
-ConversationPart part = conversation.getMostRecentConversationPart();
-Admin assignee = conversation.getAssignee();
-User user = conversation.getUser();
-
-// Find all open conversations assigned to an admin and render as plaintext
-params = Maps.newHashMap();
-params.put("type", "admin");
-params.put("admin_id", "7");
-params.put("display_as", "plaintext");
-ConversationCollection openForAdmin = Conversation.list(params);
-
-// admin reply
-Admin admin = new Admin().setId("1");
-AdminReply adminReply = new AdminReply(admin);
-adminReply.setBody("These apples are healthsome");
-adminReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
-Conversation.reply("66", adminReply);
-
-// admin close
-Admin admin = new Admin().setId("1");
-AdminReply adminReply = new AdminReply(admin);
-adminReply.setMessageType("close");
-Conversation.reply("66", adminReply);
-
-// admin snooze
-Admin admin = new Admin().setId("1");
-AdminReply adminReply = new AdminReply(admin);
-adminReply.setSnoozedUntil(1549092382);
-Conversation.reply("66", adminReply);
-
-// admin open / unsnooze
-Admin admin = new Admin().setId("1");
-AdminReply adminReply = new AdminReply(admin);
-adminReply.setMessageType("open");
-Conversation.reply("66", adminReply);
-
-// user reply
-User user1 = new User().setId("5310d8e8598c9a0b24000005");
-UserReply userReply = new UserReply(user1);
-userReply.setBody("Mighty fine shindig");
-userReply.setAttachmentUrls(new String[]{"http://www.example.com/attachment.jpg"}); // optional - list of attachments
-System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply));
-Conversation.reply("66", userReply);
-
-// run assignment rules
-Conversation.runAssignmentRules("19240007891");
-
-// mark conversation as read
-Conversation.markAsRead("66");
-```
-
-### Webhooks
-
-```java
-// create a subscription
-Subscription subscription = new Subscription();
-subscription.setUrl(new URI("https://example.org/webhooks/1"));
-subscription.addTopic(Subscription.Topic.USER_CREATED);
-subscription.addTopic(Subscription.Topic.USER_TAG_CREATED);
-Subscription.create(subscription);
-
-// create a subscribtion and subscribe to events
-Subscription subscription = new Subscription();
-subscription.addTopic(Subscription.Topic.EVENT_CREATED);
-Map> metadata = new HashMap>();
-ArrayList events = new ArrayList(Arrays.asList("cart"));
-metadata.put("event_names", events);
-subscription.setMetadata(metadata);
-subscription.setMetadata(metadata);
-Subscription.create(subscription);
-
-// update a subscription
-Subscription subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd");
-subscription.addTopic(Subscription.Topic.COMPANY_CREATED);
-Subscription updatedSubscription = Subscription.update(subscription);
-
-// delete a subscription
-Subscription subscription = new Subscription();
-subscription.setId("nsub_83793feb-8394-4cb6-91d6-68ef4dd08a8e");
-Subscription deletedSubscription = Subscription.delete(subscription);
-
-// find a subscription
-subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd");
-
-// ping a subscription by ID
-Subscription.ping("nsub_60ca7690-4020-11e4-b789-4961958e51bd");
-// ping a subscription by subscription object
-subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd");
-Subscription.ping(subscription);
-
-// list subscriptions
-SubscriptionCollection list = Subscription.list();
-while(list.hasNext()) {
- Subscription sub = list.next();
- String appID = sub.getAppID();
- String serviceType = sub.getServiceType();
- List topics = sub.getTopics();
- String hubSecret = sub.getHubSecret();
-}
-
-// notification sent feed
-NotificationCollection sent = Subscription.sentFeed(subscription.getId());
-while(sent.hasNext()) {
- Notification notification = sent.next();
- String id = notification.getId();
- String topic = notification.getTopic();
- NotificationData data = notification.getData();
- String type = data.getType();
- // raw map representation of the payload
- Map item = data.getItem();
-}
-
-// notification error feed
-NotificationErrorCollection errors = Subscription.errorFeed(subscription.getId());
-while (errors.hasNext()) {
- NotificationError notificationError = errors.next();
- RequestResponseCapture capture = notificationError.getCapture();
- URI requestURI = capture.getRequestURI();
- String requestMethod = capture.getRequestMethod();
- Map requestHeaders = capture.getRequestHeaders();
- String requestEntity = capture.getRequestEntity();
- int statusCode = capture.getResponseStatusCode();
- Map responseHeaders = capture.getResponseHeaders();
- String responseEntity = capture.getResponseEntity();
-}
-
-// consume a webhook notification
-InputStream jsonStream = ...;
-final Notification notification = Notification.readJSON(jsonStream);
-
-String jsonString = ...;
-final Notification notification = Notification.readJSON(jsonString);
-```
-
-### Counts
-
-```java
-// app totals
-Counts.Totals totals = Counts.appTotals();
-System.out.println("companies: " + totals.getCompany().getValue());
-System.out.println("segments: :" + totals.getSegment().getValue());
-System.out.println("tags: :" + totals.getTag().getValue());
-System.out.println("users: :" + totals.getUser().getValue());
-
-// conversation totals
-Counts.Conversation conversationTotals = Counts.conversationTotals();
-System.out.println("assigned: " + conversationTotals.getAssigned());
-System.out.println("closed: :" + conversationTotals.getClosed());
-System.out.println("open: :" + conversationTotals.getOpen());
-System.out.println("unassigned: :" + conversationTotals.getUnassigned());
-
-// admin open/close counts
-Counts.Conversation adminCounts = Counts.conversationAdmins();
-List admins = adminCounts.getAdmins();
-for (Admin admin : admins) {
- System.out.println(admin.getName() + ": " + admin.getClosed() + ", " + admin.getOpen());
-}
-
-// tag user counts
-System.out.println("tag user counts: ");
-List tags = Counts.userTags();
-for (Counts.CountItem tag : tags) {
- System.out.println(tag.getName()+": " +tag.getValue());
-}
-
-// segment user counts
-List segments = Counts.userSegments();
-for (Counts.CountItem segment : segments) {
- System.out.println(segment.getName()+": " +segment.getValue());
-}
-
-// company user counts
-List companyUsers = Counts.companyUsers();
-for (Counts.CountItem company : companyUsers) {
- System.out.println(company.getName()+": " +company.getValue());
-}
-
-// company tag counts
-List companyTags = Counts.companyTags();
-for (Counts.CountItem tag : companyTags) {
- System.out.println(tag.getName()+": " +tag.getValue());
-}
-```
-
-## Idioms
-
-### HTTP requests
-
-To signal local versus remote methods, calls that result in HTTP requests are performed
-using static methods, for example `User.find()`. The objects returned by static methods
-are built from server responses. The exception to the static idiom is where the `next()`,
-`hasNext()` and `nextPage()` methods on Collections are used to abstract over pagination.
-
-### Pagination
-
-Some API classes have static `list()` methods that correspond to paginated API responses.
-These return a Collection object (eg `UserCollection`) which can be iterated in two
- ways
-
-- The collection's `getPage()`, `hasNextPage()` and `nextPage()` methods - these are useful when you want to fetch one or just a few pages directly.
-
-- Java's inbuilt iterator methods `next()` and `hasNext()` - these are useful when you want to fetch data without manually handling pagination.
-
-- User and Contact listing only works up to 10k records. To retrieve all records use the Scroll API via `scroll()`
-
-### Error handling
-
-You do not need to deal with the HTTP response from an API call directly.
-If there is an unsuccessful response then an IntercomException or a subclass
-of IntercomException will be thrown. The exception will have Error objects
- that can be examined via `getErrorCollection` and `getFirstError` for more detail.
-
-The API throws the following runtime exceptions -
-
-- AuthorizationException: for a 401 or 403 response
-- InvalidException: for a 422 response or a local validation failure
-- RateLimitException: for a 429 rate limit exceeded response
-- ClientException: for a general 4xx response
-- ServerException: for a 500 or 503 response
-- IntercomException: general exception
-
-## Configuration
-
-### HTTP
-
-The client can be configured to accept any http stack that implements
-`java.net.HttpURLConnection` by implementing the `HttpConnectorSupplier`
- interface.
-
-For example, to use [OkHttp](https://square.github.io/okhttp/) as a connection
-supplier, create a supplier class -
-
-```java
-public class OkHttpSupplier implements HttpConnectorSupplier {
- private final OkUrlFactory urlFactory;
-
- public OkHttpSupplier(OkUrlFactory urlFactory) {
- this.urlFactory = urlFactory;
- }
-
- @Override
- public HttpURLConnection connect(URI uri) throws IOException {
- return urlFactory.open(uri.toURL());
- }
-}
-```
-
-and hand a supplier to the Intercom object -
-
-```java
-final OkHttpClient client = new OkHttpClient();
-final OkUrlFactory factory = new OkUrlFactory(client);
-final OkHttpSupplier supplier = new OkHttpSupplier(factory);
-Intercom.setHttpConnectorSupplier(supplier);
-```
-
-#### Timeouts
-
-The default connection and request timeouts can be set in milliseconds using the
-`Intercom.setConnectionTimeout` and `Intercom.setRequestTimeout` methods.
-
-### Target API Server
-
-The base URI to target can be changed for testing purposes
-
-```java
-URI baseURI = new URI("https://example.org/server");
-Intercom.setApiBaseURI(baseURI);
-```
diff --git a/build.gradle b/build.gradle
index d7e82c26..d311e1f8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,41 +1,51 @@
plugins {
- id 'idea'
- id 'signing'
+ id 'java-library'
+ id 'maven-publish'
+ id 'com.diffplug.spotless' version '6.11.0'
}
-subprojects {
- repositories {
+repositories {
mavenCentral()
- }
-
- ext {
- jacksonVersion = '2.9.10'
- jacksonDatabindVersion = "$jacksonVersion.8"
- powermockVersion = '1.6.6'
- }
-
- apply plugin: 'maven'
- apply plugin: 'maven-publish'
- apply plugin: 'java'
- apply plugin: 'signing'
-
- sourceCompatibility = 1.7
- targetCompatibility = 1.7
-
- //noinspection GroovyAssignabilityCheck
- dependencies {
- compile "com.fasterxml.jackson.core:jackson-core:$jacksonVersion"
- compile "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
- compile "com.fasterxml.jackson.core:jackson-databind:$jacksonDatabindVersion"
- compile "com.google.guava:guava:17.0"
- compile "org.slf4j:slf4j-api:2.0.17"
- compile "commons-codec:commons-codec:1.18.0"
- testCompile "junit:junit:4.13.2"
- testCompile "org.powermock:powermock-module-junit4:$powermockVersion"
- testCompile "org.powermock:powermock-api-mockito:$powermockVersion"
- }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/releases/'
+ }
}
-wrapper {
- gradleVersion = '4.9'
+dependencies {
+ api 'com.squareup.okhttp3:okhttp:4.12.0'
+ api 'com.fasterxml.jackson.core:jackson-databind:2.17.2'
+ api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.17.2'
+ api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
+
+
+sourceCompatibility = 1.8
+targetCompatibility = 1.8
+
+tasks.withType(Javadoc) {
+ failOnError false
+ options.addStringOption('Xdoclint:none', '-quiet')
+}
+
+spotless {
+ java {
+ palantirJavaFormat()
+ }
+}
+
+
+java {
+ withSourcesJar()
+ withJavadocJar()
+}
+
+
+test {
+ useJUnitPlatform()
+ testLogging {
+ showStandardStreams = true
+ }
+}
+
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index 57c50ded..00000000
--- a/gradle.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-version: 2.8.2
-
-groupId: io.intercom
-
-modules: \
- intercom-java
-
-org.gradle.daemon: true
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 0d4a9516..9bbc975c 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a95009c3..37f853b1 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index cccdd3d5..faf93008 100755
--- a/gradlew
+++ b/gradlew
@@ -1,78 +1,129 @@
-#!/usr/bin/env sh
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# This is normally unused
+# shellcheck disable=SC2034
+APP_BASE_NAME=${0##*/}
+# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
+APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -81,92 +132,120 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD=java
+ if ! command -v java >/dev/null 2>&1
+ then
+ die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
+ fi
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
+ # shellcheck disable=SC2039,SC3045
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=$((i+1))
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=$(save "$@")
-
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Collect all arguments for the java command:
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
+# and any embedded shellness will be escaped.
+# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
+# treated as '${Hostname}' itself on the command line.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Stop when "xargs" is not available.
+if ! command -v xargs >/dev/null 2>&1
+then
+ die "xargs is not available"
fi
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index e95643d6..9b42019c 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,4 +1,22 @@
-@if "%DEBUG%" == "" @echo off
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+@rem SPDX-License-Identifier: Apache-2.0
+@rem
+
+@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -9,25 +27,29 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
+if "%DIRNAME%"=="" set DIRNAME=.
+@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
+if %ERRORLEVEL% equ 0 goto execute
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
@@ -35,48 +57,36 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-if exist "%JAVA_EXE%" goto init
+if exist "%JAVA_EXE%" goto execute
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
+echo. 1>&2
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
+echo. 1>&2
+echo Please set the JAVA_HOME variable in your environment to match the 1>&2
+echo location of your Java installation. 1>&2
goto fail
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
+if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
+set EXIT_CODE=%ERRORLEVEL%
+if %EXIT_CODE% equ 0 set EXIT_CODE=1
+if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
+exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
diff --git a/intercom-java/.gitignore b/intercom-java/.gitignore
deleted file mode 100644
index ae3c1726..00000000
--- a/intercom-java/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/bin/
diff --git a/intercom-java/build.gradle b/intercom-java/build.gradle
deleted file mode 100644
index 9ce44ea4..00000000
--- a/intercom-java/build.gradle
+++ /dev/null
@@ -1,134 +0,0 @@
-import java.text.SimpleDateFormat
-
-final publicationVersion = new Version(version)
-def rawVersion = version
-
-group = 'io.intercom'
-version = publicationVersion
-status = version.status
-
-ext {
- mvnUser = System.getenv('MVN_REPO_USER') ?: "dev"
- mvnPass = System.getenv('MVN_REPO_PASS') ?: "dev"
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives sourcesJar, javadocJar
-}
-
-publishing {
- publications {
- mavenJava(MavenPublication) {
- from components.java
-
- artifact sourcesJar {
- classifier "sources"
- }
-
- artifact javadocJar {
- classifier "javadoc"
- }
- }
- }
-}
-
-signing {
- if (project.hasProperty('signing.keyId') && project.hasProperty('signing.secretKeyRingFile')) {
- sign configurations.archives
- }
-}
-
-task printVersion {
- doLast {
- println "publication version: ${publicationVersion}"
- println "raw version: ${rawVersion}"
- }
-}
-
-uploadArchives {
- repositories.mavenDeployer {
- beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-
- repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
- authentication(userName: mvnUser, password: mvnPass)
- }
-
- snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
- authentication(userName: mvnUser, password: mvnPass)
- }
-
- pom.project {
- name 'intercom-java'
- artifactId 'intercom-java'
- packaging 'jar'
- description 'Java bindings for the Intercom API'
- url 'https://github.com/intercom/intercom-java'
-
- scm {
- url 'http://github.com/intercom/intercom-java/tree/master'
- }
-
- licenses {
- license {
- name 'The Apache License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- }
- }
-
- developers {
- developer {
- id 'intercom'
- name 'Intercom'
- email 'team-dp@intercom.io'
- }
- }
- }
- }
-}
-
-/**
- * A version object for use in the publication and tagging tasks.
- * If the version ends with SNAPSHOT, that will be replaced with a timestamp.
- *
- * Based on https://github.com/bintray/bintray-examples
- */
-class Version {
- //
- String originalVersion
- String thisVersion
- String status
- Date buildTime
-
- Version(String versionValue) {
- buildTime = new Date()
- originalVersion = versionValue
- if (originalVersion.endsWith('-SNAPSHOT')) {
- status = 'integration'
- thisVersion = originalVersion.substring(0, originalVersion.length() - 'SNAPSHOT'.length()) + getTimestamp()
- } else {
- status = 'release'
- thisVersion = versionValue
- }
- }
-
- String getTimestamp() {
- // Convert local file timestamp to UTC
- def format = new SimpleDateFormat('yyyyMMddHHmmss')
- format.setCalendar(Calendar.getInstance(TimeZone.getTimeZone('UTC')));
- return format.format(buildTime)
- }
-
- String toString() {
- thisVersion
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Admin.java b/intercom-java/src/main/java/io/intercom/api/Admin.java
deleted file mode 100644
index 18302c5a..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Admin.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class Admin extends TypedData implements Replier {
-
- private static final Map SENTINEL = Maps.newHashMap();
-
- public static final String TYPE_NOBODY = "nobody_admin";
-
- // don't make public for now
- static AdminCollection list(Map params)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.list(params, "admins", AdminCollection.class);
- }
-
- public static AdminCollection list()
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.list(SENTINEL, "admins", AdminCollection.class);
- }
-
- public static Admin find(String id)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("admins").path(id).build());
- return resource.get(Admin.class);
- }
-
- public static Admin setAwayMode(String id, boolean away_mode_enabled, boolean away_mode_reassign) {
- final URI uri = UriBuilder.newBuilder()
- .path("admins")
- .path(id)
- .path("away")
- .build();
- return new HttpClient(uri)
- .put(Admin.class, new AdminAwayMode(id, away_mode_enabled, away_mode_reassign));
- }
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private String type = "admin";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("email")
- private String email;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("open")
- private long open;
-
- @JsonProperty("closed")
- private long closed;
-
- @JsonProperty("away_mode_enabled")
- private boolean awayModeEnabled;
-
- @JsonProperty("away_mode_reassign")
- private boolean awayModeReassign;
-
- @JsonProperty("has_inbox_seat")
- private boolean hasInboxSeat;
-
- @JsonProperty("avatar")
- private Avatar avatar;
-
- @JsonProperty("team_ids")
- private List teamIds;
-
- @JsonProperty("admin_ids")
- private List adminIds;
-
- public Admin() {
- }
-
- @JsonIgnore
- public String getReplyType() {
- return getType() + "_reply";
- }
-
- public String getType() {
- return type;
- }
-
- @JsonIgnore
- public boolean isNobody() {
- return TYPE_NOBODY.equalsIgnoreCase(getType());
- }
-
- @JsonIgnore
- public boolean isSomebody() {
- return (!isNobody()) && (getId() != null);
- }
-
- public String getId() {
- return id;
- }
-
- public Admin setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public String getEmail() {
- return email;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public long getOpen() {
- return open;
- }
-
- public long getClosed() {
- return closed;
- }
-
- public boolean getAwayModeEnabled(){
- return awayModeEnabled;
- }
-
- public boolean getAwayModeReassign(){
- return awayModeReassign;
- }
-
- public boolean getHasInboxSeat(){
- return hasInboxSeat;
- }
-
- public Avatar getAvatar(){
- return avatar;
- }
-
- public List getTeamIds(){
- return teamIds;
- }
- public List getAdminIds(){
- return adminIds;
- }
-
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Admin admin = (Admin) o;
-
- if (closed != admin.closed) return false;
- if (createdAt != admin.createdAt) return false;
- if (open != admin.open) return false;
- if (updatedAt != admin.updatedAt) return false;
- if (email != null ? !email.equals(admin.email) : admin.email != null) return false;
- if (id != null ? !id.equals(admin.id) : admin.id != null) return false;
- if (name != null ? !name.equals(admin.name) : admin.name != null) return false;
- if (awayModeEnabled != admin.awayModeEnabled) return false;
- if (awayModeReassign != admin.awayModeReassign) return false;
- if (avatar != null ? !avatar.equals(admin.avatar) : admin.avatar != null) return false;
- if (teamIds != null ? !teamIds.equals(admin.teamIds) : admin.teamIds != null) return false;
- if (adminIds != null ? !adminIds.equals(admin.adminIds) : admin.adminIds != null) return false;
-
- //noinspection RedundantIfStatement
- if (!type.equals(admin.type)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (email != null ? email.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (int) (open ^ (open >>> 32));
- result = 31 * result + (int) (closed ^ (closed >>> 32));
- result = 31 * result + (awayModeEnabled ? 1 : 0);
- result = 31 * result + (awayModeReassign ? 1 : 0);
- result = 31 * result + (avatar != null ? avatar.hashCode() : 0);
- result = 31 * result + (teamIds != null ? teamIds.hashCode() : 0);
- result = 31 * result + (adminIds != null ? adminIds.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Admin{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", email='" + email + '\'' +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", awayModeEnabled=" + awayModeEnabled +
- ", awayModeReassign=" + awayModeReassign +
- ", teamIds=" + teamIds +
- ", adminIds=" + adminIds+
- ", avatar=" + avatar+
- "} " + super.toString();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java b/intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java
deleted file mode 100644
index 280fe191..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminAwayMode.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package io.intercom.api;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class AdminAwayMode extends TypedData {
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("away_mode_enabled")
- private boolean awayModeEnabled;
-
- @JsonProperty("away_mode_reassign")
- private boolean awayModeReassign;
-
- public AdminAwayMode(String Id, boolean awayModeEnabled, boolean awayModeReassign) {
- this.id = id;
- this.awayModeEnabled = awayModeEnabled;
- this.awayModeReassign = awayModeReassign;
- }
- String getId() {
- return id;
- }
- public boolean getAwayModeEnabled(){
- return awayModeEnabled;
- }
-
- public boolean getAwayModeReassign(){
- return awayModeReassign;
- }
-
- @Override
- public String toString() {
- return "AdminAwayMode{" +
- "id='" + id + '\'' +
- ", awayModeEnabled=" + awayModeEnabled +
- ", awayModeReassign=" + awayModeReassign +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/AdminCollection.java b/intercom-java/src/main/java/io/intercom/api/AdminCollection.java
deleted file mode 100644
index a9978dc6..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminCollection.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class AdminCollection extends TypedDataCollection {
-
- public AdminCollection() {
- type = "company.list";
- }
-
- @Override
- public AdminCollection nextPage() {
- return fetchNextPage(AdminCollection.class);
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("admins")
- @Override
- public List getPage() {
- return super.getPage();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/AdminMessage.java b/intercom-java/src/main/java/io/intercom/api/AdminMessage.java
deleted file mode 100644
index 47ec3325..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminMessage.java
+++ /dev/null
@@ -1,173 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.annotations.VisibleForTesting;
-
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class AdminMessage extends TypedData {
-
- @JsonProperty("type")
- private final String type = "admin_message";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("message_type")
- private String messageType;
-
- @JsonProperty("subject")
- private String subject=""; // Set default to blank string so null pointer exception won't thrown if messageType = inapp and subject not set
-
- @JsonProperty("body")
- private String body;
-
- @JsonProperty("template")
- private String template="plain"; // Set default to plain so null pointer exception won't thrown if messageType = inapp and template not set
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("from")
- private Admin admin;
-
- @JsonProperty("to")
- private User user;
-
- public AdminMessage() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getId() {
- return id;
- }
-
- @SuppressWarnings("UnusedReturnValue")
- @VisibleForTesting
- AdminMessage setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getMessageType() {
- return messageType;
- }
-
- public AdminMessage setMessageType(String messageType) {
- this.messageType = messageType;
- return this;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public AdminMessage setSubject(String subject) {
- this.subject = subject;
- return this;
- }
-
- public String getBody() {
- return body;
- }
-
- public AdminMessage setBody(String body) {
- this.body = body;
- return this;
- }
-
- public String getTemplate() {
- return template;
- }
-
- public AdminMessage setTemplate(String template) {
- this.template = template;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- @SuppressWarnings("UnusedReturnValue")
- public AdminMessage setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public Admin getAdmin() {
- return admin;
- }
-
- public AdminMessage setAdmin(Admin admin) {
- this.admin = admin;
- return this;
- }
-
- public User getUser() {
- return user;
- }
-
- public AdminMessage setUser(User user) {
- this.user = user;
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- AdminMessage message = (AdminMessage) o;
-
- if (createdAt != message.createdAt) return false;
- if (admin != null ? !admin.equals(message.admin) : message.admin != null) return false;
- if (body != null ? !body.equals(message.body) : message.body != null) return false;
- if (id != null ? !id.equals(message.id) : message.id != null) return false;
- if (messageType != null ? !messageType.equals(message.messageType) : message.messageType != null) return false;
- if (subject != null ? !subject.equals(message.subject) : message.subject != null) return false;
- if (template != null ? !template.equals(message.template) : message.template != null) return false;
- if (!type.equals(message.type)) return false;
- //noinspection RedundantIfStatement
- if (user != null ? !user.equals(message.user) : message.user != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (messageType != null ? messageType.hashCode() : 0);
- result = 31 * result + (subject != null ? subject.hashCode() : 0);
- result = 31 * result + (body != null ? body.hashCode() : 0);
- result = 31 * result + (template != null ? template.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (admin != null ? admin.hashCode() : 0);
- result = 31 * result + (user != null ? user.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "AdminMessage{" +
- "id='" + id + '\'' +
- ", messageType='" + messageType + '\'' +
- ", subject='" + subject + '\'' +
- ", body='" + body + '\'' +
- ", template='" + template + '\'' +
- ", createdAt=" + createdAt +
- ", admin=" + admin +
- ", user=" + user +
- "} " + super.toString();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java b/intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java
deleted file mode 100644
index 9e55d20e..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminMessageResponse.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-class AdminMessageResponse extends TypedData {
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("message_type")
- private String messageType;
-
- @JsonProperty("subject")
- private String subject;
-
- @JsonProperty("body")
- private String body;
-
- @JsonProperty("template")
- private String template;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("owner")
- private Admin admin;
-
- @JsonProperty("to")
- private User user;
-
- public AdminMessageResponse() {
- }
-
- public String getType() {
- return "admin_message";
- }
-
- public String getId() {
- return id;
- }
-
- public AdminMessageResponse setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getMessageType() {
- return messageType;
- }
-
- public AdminMessageResponse setMessageType(String messageType) {
- this.messageType = messageType;
- return this;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public AdminMessageResponse setSubject(String subject) {
- this.subject = subject;
- return this;
- }
-
- public String getBody() {
- return body;
- }
-
- public AdminMessageResponse setBody(String body) {
- this.body = body;
- return this;
- }
-
- public String getTemplate() {
- return template;
- }
-
- public AdminMessageResponse setTemplate(String template) {
- this.template = template;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public AdminMessageResponse setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public AdminMessageResponse setUpdatedAt(long updatedAt) {
- this.updatedAt = updatedAt;
- return this;
- }
-
- public Admin getAdmin() {
- return admin;
- }
-
- public AdminMessageResponse setAdmin(Admin admin) {
- this.admin = admin;
- return this;
- }
-
- public User getUser() {
- return user;
- }
-
- public AdminMessageResponse setUser(User user) {
- this.user = user;
- return this;
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/AdminReply.java b/intercom-java/src/main/java/io/intercom/api/AdminReply.java
deleted file mode 100644
index f2040ad6..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminReply.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class AdminReply extends Reply {
-
- @SuppressWarnings("UnusedDeclaration")
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- static class AdminStringReply {
-
- private AdminReply reply;
-
- public AdminStringReply(AdminReply reply) {
- this.reply = reply;
- }
-
- @JsonProperty("type")
- public String getType() {
- return reply.getType();
- }
-
- @JsonProperty("message_type")
- public String getMessageType() {
- return reply.getMessageType();
- }
-
- @JsonProperty("snoozed_until")
- public long getSnoozedUntil() {
- return reply.getSnoozedUntil();
- }
-
- @JsonProperty("body")
- public String getBody() {
- return reply.getBody();
- }
-
- @JsonProperty("admin_id")
- public String getAdminID() {
- return reply.getFrom().getId();
- }
-
- @JsonProperty("assignee_id")
- public String getAssigneeID() {
- return reply.getAssigneeID();
- }
-
- @JsonProperty("attachment_urls")
- private String[] getAttachmentUrls() {
- return reply.getAttachmentUrls();
- }
- }
-
- @JsonProperty("assignee_id")
- private String assigneeID;
-
- @JsonProperty("snoozed_until")
- private long snoozedUntil;
-
- public AdminReply(Admin admin) {
- this.from = admin;
- }
-
- public Reply setMessageType(String messageType) {
- return setMessageReplyType(messageType);
- }
-
- public String getAssigneeID() {
- return assigneeID;
- }
-
- public Reply setAssigneeID(String assigneeID) {
- this.assigneeID = assigneeID;
- this.setMessageType(Conversation.MESSAGE_TYPE_ASSIGNMENT);
- return this;
- }
-
- public long getSnoozedUntil() {
- return snoozedUntil;
- }
-
- public Reply setSnoozedUntil(long snoozedUntil) {
- this.snoozedUntil = snoozedUntil;
- this.setMessageType(Conversation.MESSAGE_TYPE_SNOOZED);
- return this;
- }
-
- @Override
- public String toString() {
- return "AdminReply{} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Attachment.java b/intercom-java/src/main/java/io/intercom/api/Attachment.java
deleted file mode 100644
index 86af659a..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Attachment.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class Attachment extends TypedData {
-
- @JsonProperty("type")
- private final String type = "upload";
- @JsonProperty("name")
- private String name;
- @JsonProperty("url")
- private String url;
- @JsonProperty("content_type")
- private String contentType;
- @JsonProperty("filesize")
- private long filesize;
- @JsonProperty("width")
- private long width;
- @JsonProperty("height")
- private long height;
-
- public Attachment() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getName() {
- return name;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getContentType() {
- return contentType;
- }
-
- public long getFilesize() {
- return filesize;
- }
-
- public long getWidth() {
- return width;
- }
-
- public long getHeight() {
- return height;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Attachment attachment = (Attachment) o;
-
- if (name != null ? !name.equals(attachment.name) : attachment.name != null) return false;
- if (url != null ? !url.equals(attachment.url) : attachment.url != null) return false;
- if (contentType != null ? !contentType.equals(attachment.contentType) : attachment.contentType != null) return false;
- if (filesize != attachment.filesize) return false;
- if (height != attachment.height) return false;
- if (width != attachment.width) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (url != null ? url.hashCode() : 0);
- result = 31 * result + (contentType != null ? contentType.hashCode() : 0);
- result = 31 * result + (int) (filesize ^ (filesize >>> 32));
- result = 31 * result + (int) (height ^ (height>>> 32));
- result = 31 * result + (int) (width ^ (width>>> 32));
- return result;
- }
-
- @Override
- public String toString() {
- return "Avatar{" +
- "type='" + type + '\'' +
- ", name='" + name + '\'' +
- ", url='" + url + '\'' +
- ", content_type'=" + contentType + '\'' +
- ", filesize=" + filesize +
- ", height=" + height +
- ", widht=" + width +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Author.java b/intercom-java/src/main/java/io/intercom/api/Author.java
deleted file mode 100644
index 204c84b9..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Author.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class Author extends TypedData {
-
- @JsonProperty("type")
- private String type;
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("email")
- private String email;
-
- @JsonProperty("user_id")
- private String userId;
-
- public Author() {
- }
-
- public String getType() {
- return type;
- }
-
- @JsonIgnore
- public boolean isUser() {
- return "user".equalsIgnoreCase(getType());
- }
-
- @JsonIgnore
- public boolean isAdmin() {
- return "admin".equalsIgnoreCase(getType());
- }
-
- public String getId() {
- return id;
- }
-
- public Author setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public Author setName(String name) {
- this.name = name;
- return this;
- }
-
- public String getEmail() {
- return email;
- }
-
- public Author setEmail(String email) {
- this.email = email;
- return this;
- }
-
- public String getUserId() {
- return userId;
- }
-
- public Author setUserId(String userId) {
- this.userId = userId;
- return this;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (email != null ? email.hashCode() : 0);
- result = 31 * result + (userId != null ? userId.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Author author = (Author) o;
-
- if (email != null ? !email.equals(author.email) : author.email != null) return false;
- if (id != null ? !id.equals(author.id) : author.id != null) return false;
- if (name != null ? !name.equals(author.name) : author.name != null) return false;
- //noinspection RedundantIfStatement
- if (userId != null ? !userId.equals(author.userId) : author.userId != null) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "Author{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", email='" + email + '\'' +
- ", userId='" + userId + '\'' +
- "} " + super.toString();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/AuthorizationException.java b/intercom-java/src/main/java/io/intercom/api/AuthorizationException.java
deleted file mode 100644
index 4ecc7584..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AuthorizationException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.intercom.api;
-
-public class AuthorizationException extends IntercomException {
-
- private static final long serialVersionUID = 2917082281352001861L;
-
- public AuthorizationException(String message) {
- super(message);
- }
-
- public AuthorizationException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public AuthorizationException(ErrorCollection errorCollection) {
- super(errorCollection);
- }
-
- public AuthorizationException(ErrorCollection errorCollection, Throwable cause) {
- super(errorCollection, cause);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Avatar.java b/intercom-java/src/main/java/io/intercom/api/Avatar.java
deleted file mode 100644
index ab700ec1..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Avatar.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.net.URI;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class Avatar extends TypedData {
-
- @JsonProperty("type")
- private final String type = "avatar";
-
- @JsonProperty("image_url")
- private URI imageURL;
-
- public Avatar() {
- }
-
- public String getType() {
- return type;
- }
-
- public URI getImageURL() {
- return imageURL;
- }
-
- public Avatar setImageURL(String imageURL) {
- if(imageURL != null) {
- this.imageURL = URI.create(imageURL);
- }
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Avatar avatar = (Avatar) o;
-
- if (imageURL != null ? !imageURL.equals(avatar.imageURL) : avatar.imageURL != null) return false;
- //noinspection RedundantIfStatement
- if (!type.equals(avatar.type)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (imageURL != null ? imageURL.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Avatar{" +
- "type='" + type + '\'' +
- ", imageURL=" + imageURL +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ClientException.java b/intercom-java/src/main/java/io/intercom/api/ClientException.java
deleted file mode 100644
index e670983f..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ClientException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.intercom.api;
-
-public class ClientException extends IntercomException {
-
- private static final long serialVersionUID = -2111295679006526646L;
-
- public ClientException(String message) {
- super(message);
- }
-
- public ClientException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public ClientException(ErrorCollection errorCollection) {
- super(errorCollection);
- }
-
- public ClientException(ErrorCollection errorCollection, Throwable cause) {
- super(errorCollection, cause);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Company.java b/intercom-java/src/main/java/io/intercom/api/Company.java
deleted file mode 100644
index 2b9328a0..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Company.java
+++ /dev/null
@@ -1,444 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class Company extends TypedData {
-
- private static final Map SENTINEL = Maps.newHashMap();
-
- public static Company find(String id) throws InvalidException, AuthorizationException {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("companies").path(id).build());
- return resource.get(Company.class);
- }
-
- public static Company find(Map params) throws InvalidException, AuthorizationException {
- if (!params.containsKey("company_id") && !params.containsKey("name")) {
- throw new InvalidException("a company find must include a company_id or name parameter");
- }
- return DataResource.find(params, "companies", Company.class);
- }
-
- public static Company create(Company company) throws InvalidException, AuthorizationException {
- return update(company);
- }
-
- public static Company update(Company company) throws InvalidException, AuthorizationException {
- // because the data is asymmetric on the plan field
- final CompanyWithStringPlan entity = new CompanyWithStringPlan();
- entity.setCompanyID(company.getCompanyID());
- entity.setName(company.getName());
- entity.setMonthlySpend(company.getMonthlySpend());
- entity.setRemoteCreatedAt(company.getRemoteCreatedAt());
- entity.setIndustry(company.getIndustry());
- entity.setSize(company.getSize());
- entity.setWebsite(company.getWebsite());
- if(company.getCustomAttributes() != null) {
- entity.getCustomAttributes().putAll(company.getCustomAttributes());
- }
- if(company.getPlan() !=null ) {
- entity.setPlan(company.getPlan().getName());
- }
- return DataResource.update(entity, "companies", Company.class);
- }
-
- public static CompanyCollection list(Map params) throws InvalidException, AuthorizationException {
- return DataResource.list(params, "companies", CompanyCollection.class);
- }
-
- public static CompanyCollection list() throws InvalidException, AuthorizationException {
- return DataResource.list(SENTINEL, "companies", CompanyCollection.class);
- }
-
- public static ScrollableCompanyCollection scroll()
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.scroll(null, "companies", ScrollableCompanyCollection.class);
- }
-
- public static UserCollection listUsers(Map params) throws InvalidException, AuthorizationException {
- URI usersURI;
- if (params.containsKey("company_id")) {
- usersURI = UriBuilder.newBuilder()
- .path("companies")
- .query("company_id", params.get("company_id"))
- .query("type", "users")
- .build();
- } else if (params.containsKey("id")) {
- usersURI = UriBuilder.newBuilder()
- .path("companies")
- .path(params.get("id"))
- .path("users")
- .build();
- } else {
- throw new InvalidException("a company user list query must supply a company_id or id parameter");
- }
- final HttpClient resource = new HttpClient(usersURI);
- return resource.get(UserCollection.class);
- }
-
- @SuppressWarnings("UnusedDeclaration")
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- @JsonIgnoreProperties(ignoreUnknown = true)
- public static class Plan extends TypedData {
-
- @JsonProperty("type")
- protected String type;
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("name")
- private String name;
-
- public Plan() {
- type = "plan";
- }
-
- public Plan(String name) {
- this();
- this.name = name;
- }
-
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getType() {
- return type;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Plan plan = (Plan) o;
-
- if (id != null ? !id.equals(plan.id) : plan.id != null) return false;
- //noinspection RedundantIfStatement
- if (name != null ? !name.equals(plan.name) : plan.name != null) return false;
-
- return true;
- }
-
-
- @Override
- public String toString() {
- return "Plan{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- "} " + super.toString();
- }
-
-
- }
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private final String type = "company";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("company_id")
- private String companyID;
-
- @JsonProperty("session_count")
- private int sessionCount;
-
- @JsonProperty("monthly_spend")
- private float monthlySpend;
-
- @JsonProperty("remote_created_at")
- private long remoteCreatedAt;
-
- @JsonProperty("last_request_at")
- private long lastRequestAt;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("plan")
- private Plan plan;
-
- @JsonProperty("user_count")
- private Integer userCount;
-
- @JsonProperty("size")
- private int size;
-
- @JsonProperty("website")
- private String website;
-
- @JsonProperty("industry")
- private String industry;
-
- @JsonIgnoreProperties(ignoreUnknown = false)
- @JsonProperty("custom_attributes")
- private Map customAttributes = Maps.newHashMap();
-
- @JsonProperty("segments")
- private SegmentCollection segmentCollection = new SegmentCollection();
-
- @JsonProperty("tags")
- private TagCollection tagCollection = new TagCollection();
-
- private Boolean untag;
-
- public Company() {
- }
-
- public Company untag() {
- untag = Boolean.TRUE;
- return this;
- }
-
- public String getType() {
- return type;
- }
-
- public String getId() {
- return id;
- }
-
- @VisibleForTesting
- Company setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public Company setName(String name) {
- this.name = name;
- return this;
- }
-
- public int getSize() {
- return size;
- }
-
- public Company setSize(int size) {
- this.size = size;
- return this;
- }
-
- public String getWebsite() {
- return website;
- }
-
- public Company setWebsite(String website) {
- this.website = website;
- return this;
- }
-
- public String getIndustry() {
- return industry;
- }
-
- public Company setIndustry(String industry) {
- this.industry = industry;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public String getCompanyID() {
- return companyID;
- }
-
- public Company setCompanyID(String companyID) {
- this.companyID = companyID;
- return this;
- }
-
- public int getSessionCount() {
- return sessionCount;
- }
-
- public long getRemoteCreatedAt() {
- return remoteCreatedAt;
- }
-
- public Company setRemoteCreatedAt(long remoteCreatedAt) {
- this.remoteCreatedAt = remoteCreatedAt;
- return this;
- }
-
- public long getLastRequestAt() {
- return lastRequestAt;
- }
-
- public Company setLastRequestAt(long lastRequestAt) {
- this.lastRequestAt = lastRequestAt;
- return this;
- }
-
- public Map getCustomAttributes() {
- return customAttributes;
- }
-
- public Company setCustomAttributes(Map customAttributes) {
- this.customAttributes = customAttributes;
- return this;
- }
-
- public Company addCustomAttribute(CustomAttribute customAttribute) {
- this.customAttributes.put(customAttribute.getName(), customAttribute);
- return this;
- }
-
- public Plan getPlan() {
- return plan;
- }
-
- public Company setPlan(Plan plan) {
- this.plan = plan;
- return this;
- }
-
- public Integer getUserCount() {
- return userCount;
- }
-
- public float getMonthlySpend() {
- return monthlySpend;
- }
-
- public Company setMonthlySpend(float monthlySpend) {
- this.monthlySpend = monthlySpend;
- return this;
- }
-
- public SegmentCollection getSegmentCollection() {
- return segmentCollection;
- }
-
- public TagCollection getTagCollection() {
- return tagCollection;
- }
-
- boolean isUntag() {
- return untag == null ? false : untag;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Company company = (Company) o;
-
- if (createdAt != company.createdAt) return false;
- if (Float.compare(company.monthlySpend, monthlySpend) != 0) return false;
- if (remoteCreatedAt != company.remoteCreatedAt) return false;
- if (sessionCount != company.sessionCount) return false;
- if (updatedAt != company.updatedAt) return false;
- if (lastRequestAt != company.lastRequestAt) return false;
- if (companyID != null ? !companyID.equals(company.companyID) : company.companyID != null) return false;
- if (customAttributes != null ? !customAttributes.equals(company.customAttributes) : company.customAttributes != null)
- return false;
- if (id != null ? !id.equals(company.id) : company.id != null) return false;
- if (name != null ? !name.equals(company.name) : company.name != null) return false;
- if (plan != null ? !plan.equals(company.plan) : company.plan != null) return false;
- if (segmentCollection != null ? !segmentCollection.equals(company.segmentCollection) : company.segmentCollection != null)
- return false;
- if (tagCollection != null ? !tagCollection.equals(company.tagCollection) : company.tagCollection != null)
- return false;
- if (!type.equals(company.type)) return false;
- if (untag != null ? !untag.equals(company.untag) : company.untag != null) return false;
- //noinspection RedundantIfStatement
- if (userCount != null ? !userCount.equals(company.userCount) : company.userCount != null) return false;
- if (size != company.size) return false;
- if (website != null ? !website.equals(company.website) : company.website != null) return false;
- if (industry != null ? !industry.equals(company.industry) : company.industry != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (companyID != null ? companyID.hashCode() : 0);
- result = 31 * result + sessionCount;
- result = 31 * result + (monthlySpend != +0.0f ? Float.floatToIntBits(monthlySpend) : 0);
- result = 31 * result + (int) (remoteCreatedAt ^ (remoteCreatedAt >>> 32));
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32));
- result = 31 * result + (plan != null ? plan.hashCode() : 0);
- result = 31 * result + (userCount != null ? userCount.hashCode() : 0);
- result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0);
- result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0);
- result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0);
- result = 31 * result + (untag != null ? untag.hashCode() : 0);
- result = 31 * result + size;
- result = 31 * result + (website != null ? website.hashCode() : 0);
- result = 31 * result + (industry != null ? industry.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Company{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", companyID='" + companyID + '\'' +
- ", sessionCount=" + sessionCount +
- ", monthlySpend=" + monthlySpend +
- ", remoteCreatedAt=" + remoteCreatedAt +
- ", createdAt=" + createdAt +
- ", lastRequestAt=" + lastRequestAt +
- ", updatedAt=" + updatedAt +
- ", plan=" + plan +
- ", customAttributes=" + customAttributes +
- ", segmentCollection=" + segmentCollection +
- ", tagCollection=" + tagCollection +
- ", size=" + size +
- ", website='" + website + '\'' +
- ", industry='" + industry + '\'' +
- "} " + super.toString();
- }
-
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java b/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java
deleted file mode 100644
index 57b7bdc8..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class CompanyCollection extends TypedDataCollection {
-
- @JsonProperty("total_count")
- private long totalCount;
-
- public CompanyCollection() {
- type = "company.list";
- }
-
- public CompanyCollection(List companies) {
- this();
- this.page = companies;
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("companies")
- @Override
- public List getPage() {
- return super.getPage();
- }
-
- public long getTotalCount() {
- return totalCount;
- }
-
- @Override
- public CompanyCollection nextPage() {
- return fetchNextPage(CompanyCollection.class);
- }
-
- @Override
- public String toString() {
- return "CompanyCollection{" +
- ", totalCount=" + totalCount +
- "} " + super.toString();
- }
-
- void addCompany(Company company) {
- page.add(company);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java b/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java
deleted file mode 100644
index 2608c686..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package io.intercom.api;
-
-import com.google.common.base.Objects;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
-class CompanyUpdateBuilder {
-
- /**
- * Provide restrictions on the company data that can be sent via a user update
- */
- static List buildUserUpdateCompanies(CompanyCollection add, CompanyCollection remove) {
-
- final List updatableCompanies = Lists.newArrayList();
- if (add != null) {
- final List companies = add.getPage();
- for (Company company : companies) {
- if (!isCompanyInList(company, remove)) {
- updatableCompanies.add(prepareUpdatableCompany(company));
- }
- }
- }
-
- if (remove != null) {
- final List companies = remove.getPage();
- for (Company company : companies) {
- updatableCompanies.add(prepareUpdatableCompany(company).setRemove(Boolean.TRUE));
- }
- }
-
- return updatableCompanies;
- }
-
- private static boolean isCompanyInList(final Company company, CompanyCollection companyCollection) {
- if (companyCollection == null) {
- return false;
- }
-
- return Iterables.any(companyCollection.getPage(), new Predicate() {
- @Override
- public boolean apply(Company e) {
- return Objects.equal(company.getCompanyID(), e.getCompanyID())
- || Objects.equal(company.getId(), e.getId());
- }
- });
- }
-
- private static CompanyWithStringPlan prepareUpdatableCompany(Company company) {
- final CompanyWithStringPlan updatableCompany = new CompanyWithStringPlan();
- updatableCompany.setId(company.getId());
- updatableCompany.setCompanyID(company.getCompanyID());
- updatableCompany.setName(company.getName());
- updatableCompany.setMonthlySpend(company.getMonthlySpend());
- updatableCompany.setRemoteCreatedAt(company.getRemoteCreatedAt());
- updatableCompany.setIndustry(company.getIndustry());
- updatableCompany.setSize(company.getSize());
- updatableCompany.setWebsite(company.getWebsite());
- if (company.getCustomAttributes() != null) {
- updatableCompany.getCustomAttributes().putAll(company.getCustomAttributes());
- }
- if (company.getPlan() != null) {
- updatableCompany.setPlan(company.getPlan().getName());
- }
- return updatableCompany;
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java b/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java
deleted file mode 100644
index 8f1d8296..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.collect.Maps;
-
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-@JsonIgnoreProperties(ignoreUnknown = true)
-class CompanyWithStringPlan extends TypedData {
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("company_id")
- private String companyID;
-
- @JsonProperty("session_count")
- private int sessionCount;
-
- @JsonProperty("monthly_spend")
- private float monthlySpend;
-
- @JsonProperty("remote_created_at")
- private long remoteCreatedAt;
-
- @JsonProperty("plan")
- private String plan;
-
- @JsonProperty("size")
- private int size;
-
- @JsonProperty("website")
- private String website;
-
- @JsonProperty("industry")
- private String industry;
-
- @JsonIgnoreProperties(ignoreUnknown = false)
- @JsonProperty("custom_attributes")
- private Map customAttributes = Maps.newHashMap();
-
- @JsonProperty("remove")
- @JsonInclude(JsonInclude.Include.NON_NULL)
- private Boolean remove;
-
- public CompanyWithStringPlan() {
- }
-
- public String getType() {
- return "company";
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getCompanyID() {
- return companyID;
- }
-
- public void setCompanyID(String companyID) {
- this.companyID = companyID;
- }
-
- public Integer getSessionCount() {
- return sessionCount;
- }
-
- public void setSessionCount(Integer sessionCount) {
- this.sessionCount = sessionCount;
- }
-
- public float getMonthlySpend() {
- return monthlySpend;
- }
-
- public void setMonthlySpend(float monthlySpend) {
- this.monthlySpend = monthlySpend;
- }
-
- public long getRemoteCreatedAt() {
- return remoteCreatedAt;
- }
-
- public void setRemoteCreatedAt(long remoteCreatedAt) {
- this.remoteCreatedAt = remoteCreatedAt;
- }
-
- public int getSize() {
- return size;
- }
-
- public void setSize(int size) {
- this.size = size;
- }
-
- public String getWebsite() {
- return website;
- }
-
- public void setWebsite(String website) {
- this.website = website;
- }
-
- public String getIndustry() {
- return industry;
- }
-
- public void setIndustry(String industry) {
- this.industry = industry;
- }
-
- public String getPlan() {
- return plan;
- }
-
- public void setPlan(String plan) {
- this.plan = plan;
- }
-
- public Map getCustomAttributes() {
- return customAttributes;
- }
-
- public void setCustomAttributes(Map customAttributes) {
- this.customAttributes = customAttributes;
- }
-
- public Boolean getRemove() {
- return remove;
- }
-
- public CompanyWithStringPlan setRemove(Boolean remove) {
- this.remove = remove;
- return this;
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Conditions.java b/intercom-java/src/main/java/io/intercom/api/Conditions.java
deleted file mode 100644
index 6e92f32b..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Conditions.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package io.intercom.api;
-
-import com.google.common.collect.Lists;
-
-class Conditions {
-
- /**
- * Ensures that an object reference passed as a parameter to the calling
- * method is not null. Variant of Guava's Preconditions that returns an
- * InvalidException containing an ErrorCollection
- *
- * @param reference an object reference
- * @param errorMessage the exception message to use if the check fails
- * @return the non-null reference that was validated
- * @throws InvalidException if {@code reference} is null
- */
- public static T checkNotNull(T reference, String errorMessage) {
- if (reference == null) {
- throw new InvalidException(
- new ErrorCollection(
- Lists.newArrayList(
- new Error("invalid", "item method must be supplied"))));
- }
- return reference;
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Contact.java b/intercom-java/src/main/java/io/intercom/api/Contact.java
deleted file mode 100644
index 392e6488..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Contact.java
+++ /dev/null
@@ -1,678 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class Contact extends TypedData implements Replier {
-
- private static final Map SENTINEL = Maps.newHashMap();
-
- public static Contact findByID(String id)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return new HttpClient(contactURI(id)).get(Contact.class);
- }
-
- public static Contact findByUserID(String userID)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- final Map params = Maps.newHashMap();
- params.put("user_id", userID);
- return DataResource.find(params, "contacts", Contact.class);
- }
-
- public static ContactCollection listByEmail(String email)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- final Map params = Maps.newHashMap();
- params.put("email", email);
- return list(params);
- }
-
- public static ContactCollection list(Map params)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.list(params, "contacts", ContactCollection.class);
- }
-
- public static ContactCollection list()
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.list(SENTINEL, "contacts", ContactCollection.class);
- }
-
- public static ScrollableContactCollection scroll()
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.scroll(null, "contacts", ScrollableContactCollection.class);
- }
-
- public static Contact create(Contact c)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.create(ContactUpdate.buildFrom(c), "contacts", Contact.class);
- }
-
- public static Contact update(Contact c)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.update(ContactUpdate.buildFrom(c), "contacts", Contact.class);
- }
-
- public static Contact delete(Contact c)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- if(!Strings.isNullOrEmpty(c.getID())) {
- return delete(c.getID());
- }
- else if(!Strings.isNullOrEmpty(c.getUserID())) {
- return deleteByUserID(c.getUserID());
- }
- else {
- throw new InvalidException("to delete a contact you must provide a id or user_id value");
- }
- }
-
- public static Contact delete(String id)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.delete(id, "contacts", Contact.class);
- }
-
- public static Contact deleteByUserID(String user_id)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- Map params = new HashMap();
- params.put("user_id", user_id);
- return DataResource.delete(params, "contacts", Contact.class);
- }
-
- public static User convert(Contact c, User u)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.post(ContactConvertBuilder.buildConvert(c, u), convertURI(), User.class);
- }
-
- private static URI contactURI(String id) {
- return UriBuilder.newBuilder().path("contacts").path(id).build();
- }
-
- private static URI convertURI() {
- return UriBuilder.newBuilder().path("contacts").path("convert").build();
- }
-
- static class ContactConvertBuilder {
-
- static ContactConvert buildConvert(Contact c, User u) throws InvalidException {
- return new ContactConvertBuilder().build(c, u);
- }
-
- ContactConvert build(Contact c, User u) throws InvalidException {
- return new ContactConvert(buildConvertContact(c), buildConvertUser(u));
- }
-
- HashMap buildConvertUser(User u) {
- final HashMap convertUser = Maps.newHashMap();
-
- if (u.getId() != null) {
- convertUser.put("id", u.getId());
- }
-
- if (u.getUserId() != null) {
- convertUser.put("user_id", u.getUserId());
- }
-
- if (u.getEmail() != null) {
- convertUser.put("email", u.getEmail());
- }
-
- checkValidConvertContact(convertUser);
-
- return convertUser;
- }
-
- void checkValidConvertContact(HashMap convertUser) {
- if ((!convertUser.containsKey("id")) && (!convertUser.containsKey("user_id")) && (!convertUser.containsKey("email"))) {
- throw new InvalidException("a convert user must include at least one of, an id, user_id or email parameter");
- }
- }
-
- HashMap buildConvertContact(Contact c) {
- final HashMap convertContact = Maps.newHashMap();
-
- if (c.getID() != null) {
- convertContact.put("id", c.getID());
- }
-
- if (c.getUserID() != null) {
- convertContact.put("user_id", c.getUserID());
- }
-
- checkValidConvertUser(convertContact);
-
- return convertContact;
- }
-
- void checkValidConvertUser(HashMap convertContact) {
- if ((!convertContact.containsKey("id")) && (!convertContact.containsKey("user_id"))) {
- throw new InvalidException("a convert contact must include at least one of, an id or a user_id parameter");
- }
- }
- }
-
-
- @SuppressWarnings("UnusedDeclaration")
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- static class ContactConvert {
-
- @JsonProperty("contact")
- private Map contact;
-
- @JsonProperty("user")
- private Map user;
-
- public ContactConvert() {
- }
-
- public ContactConvert(Map contact, Map user) {
- this.contact = contact;
- this.user = user;
- }
-
- public Map getContact() {
- return contact;
- }
-
- public void setContact(Map contact) {
- this.contact = contact;
- }
-
- public Map getUser() {
- return user;
- }
-
- public void setUser(Map user) {
- this.user = user;
- }
- }
-
- @SuppressWarnings("UnusedDeclaration")
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- static class ContactUpdate extends TypedData {
-
- static ContactUpdate buildFrom(Contact c) {
- final ContactUpdate contactUpdate = new ContactUpdate();
- contactUpdate.id = c.getID(); // propagated, noset
- contactUpdate.userID = c.getUserID(); // propagated, noset
- contactUpdate.email = c.getEmail();
- contactUpdate.phone = c.getPhone();
- contactUpdate.name = c.getName();
- contactUpdate.lastSeenIP = c.getLastSeenIP();
- contactUpdate.customAttributes = c.getCustomAttributes();
- contactUpdate.avatar = c.getAvatar();
- contactUpdate.lastRequestAt = c.getLastRequestAt();
- contactUpdate.unsubscribedFromEmails = c.getUnsubscribedFromEmails();
- return contactUpdate;
- }
-
- @JsonProperty("type")
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private String type;
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("user_id")
- private String userID;
-
- @JsonProperty("email")
- private String email;
-
- @JsonProperty("phone")
- private String phone;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("last_seen_ip")
- private String lastSeenIP;
-
- @JsonProperty("avatar")
- private Avatar avatar;
-
- @JsonIgnoreProperties(ignoreUnknown = false)
- @JsonProperty("custom_attributes")
- private Map customAttributes = Maps.newHashMap();
-
- @JsonProperty("last_seen_user_agent")
- private String lastSeenUserAgent;
-
- @JsonProperty("companies")
- private List companyCollection;
-
- @JsonProperty("last_request_at")
- private long lastRequestAt;
-
- @JsonProperty("signed_up_at")
- private long signedUpAt;
-
- /*
- * Making these Booleans allows us to send true or false as set
- * values leaving null the ignored field for NON_DEFAULT. A
- * primitive would result in false not being sent
- */
-
- @JsonProperty("unsubscribed_from_emails")
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private Boolean unsubscribedFromEmails;
-
- @JsonProperty("update_last_request_at")
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private Boolean updateLastRequestAt;
-
- @JsonProperty("new_session")
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private Boolean newSession;
-
- public ContactUpdate() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getID() {
- return id;
- }
-
- public String getUserID() {
- return userID;
- }
-
- public String getEmail() {
- return email;
- }
-
- public String getPhone() {
- return phone;
- }
-
- public String getName() {
- return name;
- }
-
- public String getLastSeenIP() {
- return lastSeenIP;
- }
-
- public Map getCustomAttributes() {
- return customAttributes;
- }
-
- public String getLastSeenUserAgent() {
- return lastSeenUserAgent;
- }
-
- public List getCompanyCollection() {
- return companyCollection;
- }
-
- public long getLastRequestAt() {
- return lastRequestAt;
- }
-
- public Boolean getUnsubscribedFromEmails() {
- return unsubscribedFromEmails;
- }
-
- public Boolean isUpdateLastRequestAt() {
- return updateLastRequestAt;
- }
-
- public Boolean isNewSession() {
- return newSession;
- }
- }
-
- @JsonProperty("type")
- @JsonInclude(JsonInclude.Include.ALWAYS)
- private final String type = "contact";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("user_id")
- private String userID;
-
- @JsonProperty("email")
- private String email;
-
- @JsonProperty("phone")
- private String phone;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("pseudonym")
- private String pseudonym;
-
- @JsonProperty("avatar")
- private Avatar avatar;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("unsubscribed_from_emails")
- private Boolean unsubscribedFromEmails;
-
- @JsonProperty("session_count")
- private int sessionCount;
-
- @JsonProperty("last_request_at")
- private long lastRequestAt;
-
- @JsonProperty("last_seen_ip")
- private String lastSeenIP;
-
- @JsonIgnoreProperties(ignoreUnknown = false)
- @JsonProperty("custom_attributes")
- private Map customAttributes = Maps.newHashMap();
-
- @JsonProperty("user_agent_data")
- private String userAgentData;
-
- @JsonProperty("location_data")
- private LocationData locationData;
-
- @JsonIgnoreProperties(ignoreUnknown = false)
- @JsonProperty("companies")
- private CompanyCollection companyCollection = new CompanyCollection();
-
- @JsonProperty("social_profiles")
- private SocialProfileCollection socialProfileCollection = new SocialProfileCollection();
-
- @JsonProperty("segments")
- private SegmentCollection segmentCollection = new SegmentCollection();
-
- @JsonProperty("tags")
- private TagCollection tagCollection = new TagCollection();
-
- @JsonProperty("update_last_request_at")
- private Boolean updateLastRequestAt;
-
- @JsonProperty("new_session")
- private Boolean newSession;
-
- private Boolean untag;
-
- public Contact() {
- }
-
- public Contact untag() {
- untag = Boolean.TRUE;
- return this;
- }
-
- boolean isUntag() {
- return untag == null ? false : untag;
- }
-
- @JsonIgnore
- public String getReplyType() {
- return getType() + "_reply";
- }
-
- public String getType() {
- return type;
- }
-
- public String getID() {
- return id;
- }
-
- public Contact setID(String id) {
- this.id = id;
- return this;
- }
-
- public String getName() {
- return name;
- }
-
- public Contact setName(String name) {
- this.name = name;
- return this;
- }
-
- public String getPseudonym() {
- return pseudonym;
- }
-
- public String getEmail() {
- return email;
- }
-
- public Contact setEmail(String email) {
- this.email = email;
- return this;
- }
-
- public String getPhone() {
- return phone;
- }
-
- public Contact setPhone(String phone) {
- this.phone = phone;
- return this;
- }
-
- public String getUserID() {
- return userID;
- }
-
- public Contact setUserID(String userID) {
- this.userID = userID;
- return this;
- }
-
- public Avatar getAvatar() {
- return avatar;
- }
-
- public Contact setAvatar(Avatar avatar) {
- this.avatar = avatar;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public Boolean getUnsubscribedFromEmails() {
- return unsubscribedFromEmails;
- }
-
- public Contact setUnsubscribedFromEmails(boolean unsubscribedFromEmails) {
- this.unsubscribedFromEmails = unsubscribedFromEmails;
- return this;
- }
-
- public int getSessionCount() {
- return sessionCount;
- }
-
- public long getLastRequestAt() {
- return lastRequestAt;
- }
-
- public Contact setLastRequestAt(long lastRequestAt) {
- this.lastRequestAt = lastRequestAt;
- return this;
- }
-
- public String getLastSeenIP() {
- return lastSeenIP;
- }
-
- public Contact setLastSeenIP(String lastSeenIP) {
- this.lastSeenIP = lastSeenIP;
- return this;
- }
-
- public Map getCustomAttributes() {
- return customAttributes;
- }
-
- public Contact setCustomAttributes(Map customAttributes) {
- this.customAttributes = customAttributes;
- return this;
- }
-
- public Contact addCustomAttribute(CustomAttribute customAttribute) {
- this.customAttributes.put(customAttribute.getName(), customAttribute);
- return this;
- }
-
- public String getUserAgentData() {
- return userAgentData;
- }
-
- public LocationData getLocationData() {
- return locationData;
- }
-
- public CompanyCollection getCompanyCollection() {
- return companyCollection;
- }
-
- public SocialProfileCollection getSocialProfileCollection() {
- return socialProfileCollection;
- }
-
- public SegmentCollection getSegmentCollection() {
- return segmentCollection;
- }
-
- public TagCollection getTagCollection() {
- return tagCollection;
- }
-
- public Boolean isUpdateLastRequestAt() {
- return updateLastRequestAt;
- }
-
- public Boolean isNewSession() {
- return newSession;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Contact contact = (Contact) o;
-
- if (createdAt != contact.createdAt) return false;
- if (updatedAt != contact.updatedAt) return false;
- if (sessionCount != contact.sessionCount) return false;
- if (lastRequestAt != contact.lastRequestAt) return false;
- if (!type.equals(contact.type)) return false;
- if (id != null ? !id.equals(contact.id) : contact.id != null) return false;
- if (name != null ? !name.equals(contact.name) : contact.name != null) return false;
- if (email != null ? !email.equals(contact.email) : contact.email != null) return false;
- if (phone != null ? !phone.equals(contact.phone) : contact.phone != null) return false;
- if (userID != null ? !userID.equals(contact.userID) : contact.userID != null) return false;
- if (avatar != null ? !avatar.equals(contact.avatar) : contact.avatar != null) return false;
- if (unsubscribedFromEmails != null ? !unsubscribedFromEmails.equals(contact.unsubscribedFromEmails) : contact.unsubscribedFromEmails != null)
- return false;
- if (lastSeenIP != null ? !lastSeenIP.equals(contact.lastSeenIP) : contact.lastSeenIP != null) return false;
- if (customAttributes != null ? !customAttributes.equals(contact.customAttributes) : contact.customAttributes != null)
- return false;
- if (userAgentData != null ? !userAgentData.equals(contact.userAgentData) : contact.userAgentData != null)
- return false;
- if (locationData != null ? !locationData.equals(contact.locationData) : contact.locationData != null)
- return false;
- if (companyCollection != null ? !companyCollection.equals(contact.companyCollection) : contact.companyCollection != null)
- return false;
- if (socialProfileCollection != null ? !socialProfileCollection.equals(contact.socialProfileCollection) : contact.socialProfileCollection != null)
- return false;
- if (segmentCollection != null ? !segmentCollection.equals(contact.segmentCollection) : contact.segmentCollection != null)
- return false;
- if (tagCollection != null ? !tagCollection.equals(contact.tagCollection) : contact.tagCollection != null)
- return false;
- if (updateLastRequestAt != null ? !updateLastRequestAt.equals(contact.updateLastRequestAt) : contact.updateLastRequestAt != null)
- return false;
- //noinspection SimplifiableIfStatement
- if (newSession != null ? !newSession.equals(contact.newSession) : contact.newSession != null) return false;
- return !(untag != null ? !untag.equals(contact.untag) : contact.untag != null);
-
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (email != null ? email.hashCode() : 0);
- result = 31 * result + (phone != null ? phone.hashCode() : 0);
- result = 31 * result + (userID != null ? userID.hashCode() : 0);
- result = 31 * result + (avatar != null ? avatar.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (unsubscribedFromEmails != null ? unsubscribedFromEmails.hashCode() : 0);
- result = 31 * result + sessionCount;
- result = 31 * result + (int) (lastRequestAt ^ (lastRequestAt >>> 32));
- result = 31 * result + (lastSeenIP != null ? lastSeenIP.hashCode() : 0);
- result = 31 * result + (customAttributes != null ? customAttributes.hashCode() : 0);
- result = 31 * result + (userAgentData != null ? userAgentData.hashCode() : 0);
- result = 31 * result + (locationData != null ? locationData.hashCode() : 0);
- result = 31 * result + (companyCollection != null ? companyCollection.hashCode() : 0);
- result = 31 * result + (socialProfileCollection != null ? socialProfileCollection.hashCode() : 0);
- result = 31 * result + (segmentCollection != null ? segmentCollection.hashCode() : 0);
- result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0);
- result = 31 * result + (updateLastRequestAt != null ? updateLastRequestAt.hashCode() : 0);
- result = 31 * result + (newSession != null ? newSession.hashCode() : 0);
- result = 31 * result + (untag != null ? untag.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Contact{" +
- "type='" + type + '\'' +
- ", id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", email='" + email + '\'' +
- ", phone='" + phone + '\'' +
- ", userID='" + userID + '\'' +
- ", avatar=" + avatar +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", unsubscribedFromEmails=" + unsubscribedFromEmails +
- ", sessionCount=" + sessionCount +
- ", lastRequestAt=" + lastRequestAt +
- ", lastSeenIP='" + lastSeenIP + '\'' +
- ", customAttributes=" + customAttributes +
- ", userAgentData='" + userAgentData + '\'' +
- ", locationData=" + locationData +
- ", companyCollection=" + companyCollection +
- ", socialProfileCollection=" + socialProfileCollection +
- ", segmentCollection=" + segmentCollection +
- ", tagCollection=" + tagCollection +
- ", updateLastRequestAt=" + updateLastRequestAt +
- ", newSession=" + newSession +
- ", untag=" + untag +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ContactCollection.java b/intercom-java/src/main/java/io/intercom/api/ContactCollection.java
deleted file mode 100644
index dbd2de08..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ContactCollection.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.Iterator;
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ContactCollection extends TypedDataCollection {
-
-
- public ContactCollection() {
- }
-
- public ContactCollection(List contacts) {
- this();
- this.page = contacts;
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("contacts")
- @Override
- public List getPage() {
- return super.getPage();
- }
-
- @Override
- public ContactCollection nextPage() {
- return fetchNextPage(ContactCollection.class);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ContactMessage.java b/intercom-java/src/main/java/io/intercom/api/ContactMessage.java
deleted file mode 100644
index b79539b9..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ContactMessage.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class ContactMessage extends TypedMessage {
-
- public ContactMessage() {
- }
-
- @Override
- public String toString() {
- return "ContactMessage{} " + super.toString();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Conversation.java b/intercom-java/src/main/java/io/intercom/api/Conversation.java
deleted file mode 100644
index 1bf47a1a..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Conversation.java
+++ /dev/null
@@ -1,435 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class Conversation extends TypedData {
-
- @SuppressWarnings("UnusedDeclaration")
- @JsonIgnoreProperties(ignoreUnknown = true)
- private static class ConversationRead extends TypedData {
-
- @JsonProperty("read")
- private boolean read;
-
- public ConversationRead() {
- this.read = true;
- }
- }
-
- private static final HashMap SENTINEL = Maps.newHashMap();
- private static final List DISPLAY_AS_FORMATS = Lists.newArrayList("plaintext", "html");
- static final String MESSAGE_TYPE_ASSIGNMENT = "assignment";
- static final String MESSAGE_TYPE_COMMENT = "comment";
- static final String MESSAGE_TYPE_NOTE = "note";
- static final String MESSAGE_TYPE_CLOSE = "close";
- static final String MESSAGE_TYPE_OPEN = "open";
- static final String MESSAGE_TYPE_SNOOZED = "snoozed";
- static final List MESSAGE_TYPES = Lists.newArrayList(
- MESSAGE_TYPE_ASSIGNMENT,
- MESSAGE_TYPE_COMMENT,
- MESSAGE_TYPE_NOTE,
- MESSAGE_TYPE_CLOSE,
- MESSAGE_TYPE_OPEN,
- MESSAGE_TYPE_SNOOZED
- );
-
- public static Conversation find(String id) throws InvalidException, AuthorizationException {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("conversations").path(id).build());
- return resource.get(Conversation.class);
- }
-
- public static Conversation find(String id, Map params) throws InvalidException, AuthorizationException {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("conversations").path(id).query(params).build());
- return resource.get(Conversation.class);
- }
-
- public static ConversationCollection list() throws InvalidException, AuthorizationException {
- return DataResource.list(SENTINEL, "conversations", ConversationCollection.class);
- }
-
- public static ConversationCollection list(Map params) throws InvalidException, AuthorizationException {
- validateListRequest(params);
-
- return DataResource.list(params, "conversations", ConversationCollection.class);
- }
-
- public static Conversation reply(String id, UserReply reply) {
- validateUserReplyRequest(reply);
-
- final URI uri = UriBuilder.newBuilder()
- .path("conversations")
- .path(id)
- .path("reply")
- .build();
- return new HttpClient(uri)
- .post(Conversation.class, new UserReply.UserStringReply(reply));
- }
-
- public static Conversation reply(String id, AdminReply reply) {
- validateAdminReplyRequest(reply);
-
- final URI uri = UriBuilder.newBuilder()
- .path("conversations")
- .path(id)
- .path("reply")
- .build();
- return new HttpClient(uri)
- .post(Conversation.class, new AdminReply.AdminStringReply(reply));
- }
-
- public static Conversation markAsRead(String id) {
- final URI uri = UriBuilder.newBuilder()
- .path("conversations")
- .path(id)
- .build();
-
- return new HttpClient(uri)
- .put(Conversation.class, new ConversationRead());
- }
-
- public static UserMessage create(UserMessage message) {
- return DataResource.create(message, "messages", UserMessage.class);
- }
-
- public static ContactMessage create(ContactMessage message) {
- return DataResource.create(message, "messages", ContactMessage.class);
- }
-
- public static AdminMessage create(AdminMessage message) throws InvalidException {
- if ((!message.getTemplate().equals("plain")) && (!message.getTemplate().equals("personal"))) {
- throw new InvalidException("The template must be either personal or plain");
- }
- if ((!message.getMessageType().equals("email")) && (!message.getMessageType().equals("inapp"))) {
- throw new InvalidException("The message type must be either email or inapp");
- }
- /*
- the message api is asymmetric because reasons. this wraps the response
- type so we only expose AdminMessage in the client surface
- */
- final AdminMessageResponse adminMessageResponse =
- DataResource.create(message, "messages", AdminMessageResponse.class);
- AdminMessage response = new AdminMessage();
- response.setAdmin(adminMessageResponse.getAdmin());
- response.setBody(adminMessageResponse.getBody());
- response.setCreatedAt(adminMessageResponse.getCreatedAt());
- response.setId(adminMessageResponse.getId());
- response.setMessageType(adminMessageResponse.getMessageType());
- response.setSubject(adminMessageResponse.getSubject());
- response.setTemplate(adminMessageResponse.getTemplate());
- // user returns null
- // response.setUser(adminMessageResponse.getFrom());
- return response;
- }
-
- public static Conversation runAssignmentRules(String id) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("conversations").path(id).path("run_assignment_rules").build());
- return resource.post(Conversation.class, null);
- }
-
- static void validateAdminReplyRequest(AdminReply reply) {
-
- validateMessageType(reply);
-
- if (reply.getAssigneeID() != null
- && !"assignment".equals(reply.getMessageType())) {
- throw new InvalidException("an assignee id can be set only for a message type of assignment");
- }
-
- if (("note".equals(reply.getMessageType()) || "comment".equals(reply.getMessageType()))
- && (isNullOrBlank(reply.getBody()))
- ) {
- throw new InvalidException("a comment or note reply must have a body");
- }
- }
-
- static boolean isNullOrBlank(String s) {
- return s == null || s.trim().length() == 0;
-
- }
-
- static void validateUserReplyRequest(UserReply reply) {
- if (! "comment".equals(reply.getMessageType())) {
- throw new InvalidException("a user reply must have a message type of comment");
- }
- }
-
- static void validateMessageType(Reply reply) {
- if(! MESSAGE_TYPES.contains(reply.getMessageType())) {
- throw new InvalidException(
- "A reply message type must be one of "
- + Joiner.on(", ").join(MESSAGE_TYPES));
- }
- }
-
- static void validateListRequest(Map params) {
-
- if (isAdminQuery(params)
- && !(params.containsKey("admin_id"))) {
- throw new InvalidException("an admin_id must be supplied for an admin conversation query");
- }
-
- if (params.containsKey("display_as")) {
- if (!DISPLAY_AS_FORMATS.contains(params.get("display_as"))) {
- throw new InvalidException(
- "A display_as parameter must have one of the values "
- + Joiner.on(", ").join(DISPLAY_AS_FORMATS));
- }
- }
-
- if (isUserQuery(params)
- && (!params.containsKey("intercom_user_id")
- && !params.containsKey("user_id")
- && !params.containsKey("email"))) {
- throw new InvalidException(
- "One of intercom_user_id, user_id or email must be supplied for a user conversation query");
- }
- }
-
- private static boolean isUserQuery(Map params) {
- return params.containsKey("type") && params.get("type").equals("user");
- }
-
- private static boolean isAdminQuery(Map params) {
- return params.containsKey("type") && params.get("type").equals("admin");
- }
-
- @JsonProperty("type")
- private final String type = "conversation";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("conversation_message")
- private ConversationMessage conversationMessage;
-
- @JsonProperty("customer_first_reply")
- private CustomerFirstReply customerFirstReply;
-
- @JsonProperty("conversation_rating")
- private ConversationRating conversationRating;
-
- @JsonProperty("user")
- private User user;
-
- @JsonProperty("assignee")
- private Admin assignee;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("waiting_since")
- private long waitingSince;
-
- @JsonProperty("snoozed_until")
- private long snoozedUntil;
-
- @JsonProperty("conversation_parts")
- private ConversationPartCollection conversationPartCollection;
-
- @JsonProperty("tags")
- private TagCollection tagCollection;
-
- @JsonProperty("open")
- private boolean open;
-
- @JsonProperty("read")
- private boolean read;
-
- @JsonProperty("state")
- private String state;
-
- @JsonProperty("links")
- private Map links;
-
- public Conversation() {
- }
-
- public String getType() {
- return type;
- }
-
- public Admin getCurrentAssignee() {
- Admin assignee = null;
- if (getAssignee() != null) {
- assignee = getAssignee();
- } else if (getMostRecentConversationPart() != null && getMostRecentConversationPart().getAssignedTo() != null) {
- assignee = getMostRecentConversationPart().getAssignedTo();
- }
-
- return assignee;
- }
-
- public Optional getFirstConversationPart() {
- return Optional.fromNullable(getConversationPartCollection().getPage().get(0));
- }
-
- public ConversationPart getMostRecentConversationPart() {
- final ConversationPartCollection conversationParts = getConversationPartCollection();
- final List items = conversationParts.getPage();
- if (items.isEmpty()) {
- return null;
- } else {
- return items.get(items.size() - 1);
- }
- }
-
- public String getId() {
- return id;
- }
-
- public ConversationMessage getConversationMessage() {
- return conversationMessage;
- }
-
- public CustomerFirstReply getCustomerFirstReply() {
- return customerFirstReply;
- }
-
- public ConversationRating getConversationRating() {
- return conversationRating;
- }
-
- public User getUser() {
- return user;
- }
-
- public Admin getAssignee() {
- return assignee;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public long getWaitingSince() {
- return waitingSince;
- }
-
- public long getSnoozedUntil() {
- return snoozedUntil;
- }
-
- public ConversationPartCollection getConversationPartCollection() {
- if (conversationPartCollection == null) {
- conversationPartCollection = find(this.getId()).getConversationPartCollection();
- }
-
- return conversationPartCollection;
- }
-
- public TagCollection getTagCollection() {
- if (tagCollection == null) {
- tagCollection = find(this.getId()).getTagCollection();
- }
-
- return tagCollection;
- }
-
- public boolean getOpen() {
- return open;
- }
-
- public boolean getRead() {
- return read;
- }
-
- public String getState() {
- return state;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Conversation that = (Conversation) o;
-
- if (createdAt != that.createdAt) return false;
- if (open != that.open) return false;
- if (read != that.read) return false;
- if (updatedAt != that.updatedAt) return false;
- if (waitingSince != that.waitingSince) return false;
- if (snoozedUntil != that.snoozedUntil) return false;
- if (assignee != null ? !assignee.equals(that.assignee) : that.assignee != null) return false;
- if (conversationMessage != null ? !conversationMessage.equals(that.conversationMessage) : that.conversationMessage != null)
- return false;
- if (conversationRating != null ? !conversationRating.equals(that.conversationRating) : that.conversationRating != null)
- return false;
- if (conversationPartCollection != null ? !conversationPartCollection.equals(that.conversationPartCollection) : that.conversationPartCollection != null)
- return false;
- if (tagCollection != null ? !tagCollection.equals(that.tagCollection) : that.tagCollection != null)
- return false;
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
- if (links != null ? !links.equals(that.links) : that.links != null) return false;
- if (!state.equals(that.state)) return false;
- if (!type.equals(that.type)) return false;
- //noinspection RedundantIfStatement
- if (user != null ? !user.equals(that.user) : that.user != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (state != null ? state.hashCode() : 0);
- result = 31 * result + (conversationMessage != null ? conversationMessage.hashCode() : 0);
- result = 31 * result + (conversationRating != null ? conversationRating.hashCode() : 0);
- result = 31 * result + (user != null ? user.hashCode() : 0);
- result = 31 * result + (assignee != null ? assignee.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (int) (waitingSince ^ (waitingSince >>> 32));
- result = 31 * result + (int) (snoozedUntil ^ (snoozedUntil >>> 32));
- result = 31 * result + (conversationPartCollection != null ? conversationPartCollection.hashCode() : 0);
- result = 31 * result + (tagCollection != null ? tagCollection.hashCode() : 0);
- result = 31 * result + (open ? 1 : 0);
- result = 31 * result + (read ? 1 : 0);
- result = 31 * result + (links != null ? links.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Conversation{" +
- "type='" + type + '\'' +
- ", id='" + id + '\'' +
- ", conversationMessage=" + conversationMessage +
- ", user=" + user +
- ", assignee=" + assignee +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", waitingSince=" + waitingSince +
- ", snoozedUntil=" + snoozedUntil +
- ", conversationPartCollection=" + conversationPartCollection +
- ", tagCollection=" + tagCollection +
- ", open=" + open +
- ", state=" + state +
- ", read=" + read +
- ", links=" + links +
- ", conversationRating=" + conversationRating +
- "} " + super.toString();
- }
-}
-
diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java b/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java
deleted file mode 100644
index 33965186..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.Iterator;
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ConversationCollection extends TypedDataCollection {
-
-
- public ConversationCollection() {
- type = "conversation.list";
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("conversations")
- public List getPage() {
- return super.getPage();
- }
-
- @Override
- public ConversationCollection nextPage() {
- return fetchNextPage(ConversationCollection.class);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java b/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java
deleted file mode 100644
index c225ced3..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ConversationMessage extends TypedData {
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private final String type = "conversation_message";
-
- @JsonProperty
- private String id;
-
- @JsonProperty
- private String subject;
-
- @JsonProperty
- private String body;
-
- @JsonProperty
- private Author author;
-
- @JsonProperty
- private String url;
-
- @JsonProperty("delivered_as")
- private String deliveredAs;
-
- @JsonProperty("attachments")
- private List attachments;
-
- public ConversationMessage() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getId() {
- return id;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public String getBody() {
- return body;
- }
-
- public Author getAuthor() {
- return author;
- }
-
- public String getUrl() {
- return url;
- }
-
- public String getDeliveredAs() {
- return deliveredAs;
- }
-
- public List getAttachments() {
- return attachments;
- }
-
- @Override
- public int hashCode() {
- int result = subject != null ? subject.hashCode() : 0;
- result = 31 * result + (body != null ? body.hashCode() : 0);
- result = 31 * result + (author != null ? author.hashCode() : 0);
- result = 31 * result + (deliveredAs != null ? deliveredAs.hashCode() : 0);
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (url != null ? url.hashCode() : 0);
- result = 31 * result + (attachments != null ? attachments.hashCode() : 0);
-
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ConversationMessage that = (ConversationMessage) o;
-
- if (author != null ? !author.equals(that.author) : that.author != null) return false;
- if (body != null ? !body.equals(that.body) : that.body != null) return false;
- //noinspection RedundantIfStatement
- if (subject != null ? !subject.equals(that.subject) : that.subject != null) return false;
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
- if (url != null ? !url.equals(that.url) : that.url != null) return false;
- if (deliveredAs != null ? !deliveredAs.equals(that.deliveredAs) : that.deliveredAs != null) return false;
- if (attachments != null ? !attachments.equals(that.attachments) : that.attachments != null) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "ConversationMessage{" +
- "type='" + type + '\'' +
- ", id='" + id + '\'' +
- ", subject='" + subject + '\'' +
- ", body='" + body + '\'' +
- ", author=" + author +
- ", url=" + url +
- ", deliveredAs=" + deliveredAs +
- ", attachments=" + attachments +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationPart.java b/intercom-java/src/main/java/io/intercom/api/ConversationPart.java
deleted file mode 100644
index 74240721..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationPart.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ConversationPart extends TypedData {
-
- @JsonProperty("type")
- private final String type = "conversation_part";
-
- @JsonProperty
- private String id;
-
- @JsonProperty("part_type")
- private String partType;
-
- @JsonProperty
- private String body;
-
- @JsonProperty
- private Author author;
-
- @JsonProperty("assigned_to")
- private Admin assignedTo;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("notified_at")
- private long NotifiedAt;
-
- public ConversationPart() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getId() {
- return id;
- }
-
- public String getPartType() {
- return partType;
- }
-
- public String getBody() {
- return body;
- }
-
- public Author getAuthor() {
- return author;
- }
-
- public Admin getAssignedTo() {
- return assignedTo;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public long getNotifiedAt() {
- return NotifiedAt;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ConversationPart that = (ConversationPart) o;
-
- if (NotifiedAt != that.NotifiedAt) return false;
- if (createdAt != that.createdAt) return false;
- if (updatedAt != that.updatedAt) return false;
- if (assignedTo != null ? !assignedTo.equals(that.assignedTo) : that.assignedTo != null) return false;
- if (author != null ? !author.equals(that.author) : that.author != null) return false;
- if (body != null ? !body.equals(that.body) : that.body != null) return false;
- if (id != null ? !id.equals(that.id) : that.id != null) return false;
- if (partType != null ? !partType.equals(that.partType) : that.partType != null) return false;
- //noinspection RedundantIfStatement
- if (!type.equals(that.type)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (partType != null ? partType.hashCode() : 0);
- result = 31 * result + (body != null ? body.hashCode() : 0);
- result = 31 * result + (author != null ? author.hashCode() : 0);
- result = 31 * result + (assignedTo != null ? assignedTo.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (int) (NotifiedAt ^ (NotifiedAt >>> 32));
- return result;
- }
-
- @Override
- public String toString() {
- return "ConversationPart{" +
- "type='" + type + '\'' +
- ", id='" + id + '\'' +
- ", partType='" + partType + '\'' +
- ", body='" + body + '\'' +
- ", author=" + author +
- ", assignedTo=" + assignedTo +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", NotifiedAt=" + NotifiedAt +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java b/intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java
deleted file mode 100644
index 0a67e617..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationPartCollection.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ConversationPartCollection extends TypedDataCollection {
-
- public ConversationPartCollection() {
- type = "conversation_part.list";
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("conversation_parts")
- public List getPage() {
- return super.getPage();
- }
-
- @Override
- public ConversationPartCollection nextPage() {
- return new ConversationPartCollection();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ConversationRating.java b/intercom-java/src/main/java/io/intercom/api/ConversationRating.java
deleted file mode 100644
index c1a893cb..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationRating.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class ConversationRating extends TypedData {
-
- @JsonProperty
- private int rating;
-
- @JsonProperty
- private String remark;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty
- private Customer customer;
-
- @JsonProperty
- private Teammate teammate;
-
- public ConversationRating() {
- }
-
- public int getRating() {
- return rating;
- }
-
- public String getRemark() {
- return remark;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public Customer getCustomer() {
- return customer;
- }
-
- public Teammate getTeammate() {
- return teammate;
- }
-
- @Override
- public int hashCode() {
- int result = remark != null ? remark.hashCode() : 0;
- result = 31 * result + (customer != null ? customer.hashCode() : 0);
- result = 31 * result + (teammate != null ? teammate.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + rating;
-
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- ConversationRating that = (ConversationRating) o;
-
- if (customer != null ? !customer.equals(that.customer) : that.customer != null) return false;
- if (teammate != null ? !teammate.equals(that.teammate) : that.teammate != null) return false;
- if (remark != null ? !remark.equals(that.remark) : that.remark != null) return false;
- if (createdAt != that.createdAt) return false;
- if (rating != that.rating) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "ConversationRating{" +
- "rating='" + rating + '\'' +
- ", remark='" + remark + '\'' +
- ", created_at='" + createdAt + '\'' +
- ", customer=" + customer +
- ", teammate=" + teammate +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java b/intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java
deleted file mode 100644
index e991d642..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CountItemDeserializer.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.TreeNode;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-import java.io.IOException;
-import java.util.Map;
-
-class CountItemDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 8226175715446656115L;
-
- public CountItemDeserializer() {
- super(Counts.CountItem.class);
- }
-
- @Override
- public Counts.CountItem deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- final TreeNode treeNode = jp.getCodec().readTree(jp);
- final Map.Entry next = ((ObjectNode) treeNode).fields().next();
- return new Counts.CountItem(next.getKey(), next.getValue().asLong());
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java b/intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java
deleted file mode 100644
index bdd581b0..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CountItemSerializer.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-
-import java.io.IOException;
-
-class CountItemSerializer extends StdSerializer {
-
- public CountItemSerializer() {
- super(Counts.CountItem.class);
- }
-
- @Override
- public void serialize(Counts.CountItem value, JsonGenerator jgen, SerializerProvider provider)
- throws IOException {
- jgen.writeStartObject();
- jgen.writeNumberField(value.getName(), value.getValue());
- jgen.writeEndObject();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Counts.java b/intercom-java/src/main/java/io/intercom/api/Counts.java
deleted file mode 100644
index 170687de..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Counts.java
+++ /dev/null
@@ -1,340 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class Counts {
-
- static Counts countQuery(Map query) {
- final URI build = UriBuilder.newBuilder()
- .path("counts")
- .query(query)
- .build();
- final HttpClient resource = new HttpClient(build);
- return resource.get(Counts.class);
- }
-
- public static Counts.Totals appTotals() throws InvalidException, AuthorizationException {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path("counts").build());
- return resource.get(Totals.class);
- }
-
-// public static Long userCount() throws InvalidException, AuthorizationException{
-// final HashMap params = Maps.newHashMap();
-// params.put("type", "user");
-// return countQuery(params).getUser().getUser();
-// }
-
- public static List userTags() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "user");
- params.put("count", "tag");
- return countQuery(params).getUser().getTags();
- }
-
- public static List userSegments() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "user");
- params.put("count", "segment");
- return countQuery(params).getUser().getSegments();
- }
-
- public static Counts.Conversation conversationTotals() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "conversation");
- return countQuery(params).getConversation();
- }
-
- public static Counts.Conversation conversationAdmins() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "conversation");
- params.put("count", "admin");
- return countQuery(params).getConversation();
- }
-
-// public static Long companyCount() throws InvalidException, AuthorizationException{
-// final HashMap params = Maps.newHashMap();
-// params.put("type", "company");
-// return countQuery(params).getCompany().getCompanies();
-// }
-
- public static List companySegments() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "company");
- params.put("count", "segment");
- return countQuery(params).getCompany().getSegments();
- }
-
- public static List companyTags() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "company");
- params.put("count", "tag");
- return countQuery(params).getCompany().getTags();
- }
-
- public static List companyUsers() throws InvalidException, AuthorizationException {
- final HashMap params = Maps.newHashMap();
- params.put("type", "company");
- params.put("count", "user");
- return countQuery(params).getCompany().getUsers();
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public static class Totals {
-
- @JsonProperty("company")
- private CountItem company;
-
- @JsonProperty("segment")
- private CountItem segment;
-
- @JsonProperty("tag")
- private CountItem tag;
-
- @JsonProperty("user")
- private CountItem user;
-
- public CountItem getCompany() {
- return company;
- }
-
- public CountItem getSegment() {
- return segment;
- }
-
- public CountItem getTag() {
- return tag;
- }
-
- public CountItem getUser() {
- return user;
- }
-
- @Override
- public String toString() {
- return "Totals{" +
- "company=" + company +
- ", segment=" + segment +
- ", tag=" + tag +
- ", user=" + user +
- '}';
- }
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public static class CountItem {
-
- private String name;
-
- private long value;
-
- public CountItem(String name, long value) {
- this.name = name;
- this.value = value;
- }
-
- public String getName() {
- return name;
- }
-
- public long getValue() {
- return value;
- }
-
- @Override
- public String toString() {
- return "CountItem{" +
- "name='" + name + '\'' +
- ", value=" + value +
- '}';
- }
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public static class Conversation {
-
- @JsonProperty("admin")
- List admins;
-
- @JsonProperty("assigned")
- private long assigned;
-
- @JsonProperty("closed")
- private long closed;
-
- @JsonProperty("open")
- private long open;
-
- @JsonProperty("unassigned")
- private long unassigned;
-
- Conversation() {
- }
-
- public List getAdmins() {
- return admins;
- }
-
- public long getAssigned() {
- return assigned;
- }
-
- public long getClosed() {
- return closed;
- }
-
- public long getOpen() {
- return open;
- }
-
- public long getUnassigned() {
- return unassigned;
- }
-
- @Override
- public String toString() {
- return "Conversation{" +
- "assigned=" + assigned +
- ", closed=" + closed +
- ", open=" + open +
- ", unassigned=" + unassigned +
- ", admins=" + admins +
- '}';
- }
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public static class User {
-
- @JsonProperty("user")
- private long user;
-
- @JsonProperty("tag")
- private List tags;
-
- @JsonProperty("segment")
- private List segments;
-
- User() {
- }
-
- public long getUser() {
- return user;
- }
-
- public List getTags() {
- return tags;
- }
-
- public List getSegments() {
- return segments;
- }
-
- @Override
- public String toString() {
- return "User{" +
- "user=" + user +
- ", tags=" + tags +
- ", segments=" + segments +
- '}';
- }
- }
-
- @JsonIgnoreProperties(ignoreUnknown = true)
- @JsonInclude(JsonInclude.Include.NON_EMPTY)
- public static class Company {
-
- @JsonProperty("company")
- private long companies;
-
- @JsonProperty("tag")
- private List tags;
-
- @JsonProperty("user")
- private List users;
-
- @JsonProperty("segment")
- private List segments;
-
- Company() {
- }
-
- public long getCompanies() {
- return companies;
- }
-
- public List getTags() {
- return tags;
- }
-
- public List getUsers() {
- return users;
- }
-
- public List getSegments() {
- return segments;
- }
-
- @Override
- public String toString() {
- return "Company{" +
- "companies=" + companies +
- ", tags=" + tags +
- ", users=" + users +
- ", segments=" + segments +
- '}';
- }
- }
-
- @JsonProperty("type")
- private String type = "count";
-
- @JsonProperty("company")
- private Counts.Company company;
-
- @JsonProperty("user")
- private Counts.User user;
-
- @JsonProperty("conversation")
- private Counts.Conversation conversation;
-
- public String getType() {
- return type;
- }
-
- public Company getCompany() {
- return company;
- }
-
- public User getUser() {
- return user;
- }
-
- public Conversation getConversation() {
- return conversation;
- }
-
- @Override
- public String toString() {
- return "Counts{" +
- "type='" + type + '\'' +
- ", company=" + company +
- ", user=" + user +
- ", conversation=" + conversation +
- '}';
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CustomAttribute.java b/intercom-java/src/main/java/io/intercom/api/CustomAttribute.java
deleted file mode 100644
index 1415fa32..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CustomAttribute.java
+++ /dev/null
@@ -1,202 +0,0 @@
-package io.intercom.api;
-
-import com.google.common.collect.Lists;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-@SuppressWarnings("UnusedDeclaration")
-public class CustomAttribute {
-
- @SuppressWarnings("unchecked")
- private static final ArrayList extends Class extends Serializable>> CLASSES = Lists.newArrayList(String.class, Long.class, Float.class, Double.class, Boolean.class, Integer.class);
-
- public static StringAttribute newStringAttribute(String name, String value) {
- return new StringAttribute(name, value);
- }
-
- public static BooleanAttribute newBooleanAttribute(String name, boolean value) {
- return new BooleanAttribute(name, value);
- }
-
- public static DoubleAttribute newDoubleAttribute(String name, double value) {
- return new DoubleAttribute(name, value);
- }
-
- public static LongAttribute newLongAttribute(String name, long value) {
- return new LongAttribute(name, value);
- }
-
- public static IntegerAttribute newIntegerAttribute(String name, int value) {
- return new IntegerAttribute(name, value);
- }
-
- public static FloatAttribute newFloatAttribute(String name, float value) {
- return new FloatAttribute(name, value);
- }
-
- public static class StringAttribute extends CustomAttribute {
-
- private StringAttribute(String name, String value) {
- super(name, value, String.class);
- }
-
- private StringAttribute(String name, String value, Class clazz) {
- super(name, value, clazz);
- }
- }
-
- public static class BooleanAttribute extends CustomAttribute {
-
- private BooleanAttribute(String name, boolean value) {
- super(name, value, Boolean.class);
- }
-
- private BooleanAttribute(String name, boolean value, Class clazz) {
- super(name, value, clazz);
- }
- }
-
- public static class DoubleAttribute extends CustomAttribute {
-
- private DoubleAttribute(String name, double value, Class clazz) {
- super(name, value, clazz);
- }
-
- private DoubleAttribute(String name, double value) {
- super(name, value, Double.class);
- }
- }
-
- public static class FloatAttribute extends CustomAttribute {
-
- private FloatAttribute(String name, float value, Class clazz) {
- super(name, value, clazz);
- }
-
- private FloatAttribute(String name, float value) {
- super(name, value, Float.class);
- }
- }
-
- public static class IntegerAttribute extends CustomAttribute {
-
- private IntegerAttribute(String name, int value) {
- super(name, value, Integer.class);
- }
-
- private IntegerAttribute(String name, int value, Class clazz) {
- super(name, value, clazz);
- }
- }
-
- public static class LongAttribute extends CustomAttribute {
-
- public LongAttribute(String name, long value, Class clazz) {
- super(name, value, clazz);
- }
-
- public LongAttribute(String name, long value) {
- super(name, value, Long.class);
- }
-
- }
-
- private String name;
-
- private T value;
-
- private Class clazz;
-
- public CustomAttribute(String name, T value, Class clazz) {
- //noinspection SuspiciousMethodCalls
- if (!CLASSES.contains(clazz)) {
- throw new InvalidException(String.format("cannot accept class type [%s] for custom attribute", clazz.getName()));
- }
- this.name = name;
- this.value = value;
- this.clazz = clazz;
-
- }
-
- public Class getValueClass() {
- return clazz;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public T getValue() {
- return value;
- }
-
- public void setValue(T value) {
- this.value = value;
- }
-
- public C as(Class c) {
- //noinspection unchecked
- return (C) getValue();
- }
-
- public long longValue() {
- return as(Long.class);
- }
-
- public String textValue() {
- return as(String.class);
- }
-
- public boolean booleanValue() {
- return as(Boolean.class);
- }
-
- public float floatValue() {
- return as(Float.class);
- }
-
- public double doubleValue() {
- return as(Double.class);
- }
-
- public int integerValue() {
- return as(Integer.class);
- }
-
- @Override
- public int hashCode() {
- int result = name != null ? name.hashCode() : 0;
- result = 31 * result + (value != null ? value.hashCode() : 0);
- result = 31 * result + (clazz != null ? clazz.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- CustomAttribute that = (CustomAttribute) o;
-
- if (clazz != null ? !clazz.equals(that.clazz) : that.clazz != null) return false;
- if (name != null ? !name.equals(that.name) : that.name != null) return false;
- //noinspection RedundantIfStatement
- if (value != null ? !value.equals(that.value) : that.value != null) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "CustomAttribute{" +
- "name='" + name + '\'' +
- ", value=" + value +
- ", clazz=" + clazz +
- '}';
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java b/intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java
deleted file mode 100644
index 4756b257..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CustomAttributeDeserializer.java
+++ /dev/null
@@ -1,53 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.databind.DeserializationContext;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
-import com.fasterxml.jackson.databind.node.JsonNodeType;
-import com.fasterxml.jackson.databind.node.NumericNode;
-import com.fasterxml.jackson.databind.node.ValueNode;
-
-import java.io.IOException;
-
-class CustomAttributeDeserializer extends StdDeserializer {
-
- private static final long serialVersionUID = 5069924730975394938L;
-
- public CustomAttributeDeserializer() {
- super(CustomAttribute.class);
- }
-
- @Override
- public CustomAttribute deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
- CustomAttribute cda = null;
- final String currentName = jp.getParsingContext().getCurrentName();
- final ObjectMapper mapper = (ObjectMapper) jp.getCodec();
- final ValueNode vNode = mapper.readTree(jp);
- if (vNode.asToken().isScalarValue()) {
- if (vNode.getNodeType() == JsonNodeType.BOOLEAN) {
- cda = new CustomAttribute(currentName, vNode.asBoolean(), Boolean.class);
- } else if (vNode.getNodeType() == JsonNodeType.STRING) {
- cda = new CustomAttribute(currentName, vNode.asText(), String.class);
- } else if (vNode.getNodeType() == JsonNodeType.NUMBER) {
- final NumericNode nNode = (NumericNode) vNode;
- if (currentName.endsWith("_at")) {
- cda = new CustomAttribute(currentName, vNode.longValue(), Long.class);
- } else if (nNode.isInt()) {
- cda = new CustomAttribute(currentName, vNode.intValue(), Integer.class);
- } else if (nNode.isFloat()) {
- cda = new CustomAttribute(currentName, vNode.floatValue(), Float.class);
- } else if (nNode.isDouble()) {
- cda = new CustomAttribute(currentName, vNode.doubleValue(), Double.class);
- } else if (nNode.isLong()) {
- cda = new CustomAttribute(currentName, vNode.longValue(), Long.class);
- } else {
- cda = new CustomAttribute(currentName, vNode.asText(), String.class);
- }
- } else {
- cda = new CustomAttribute(currentName, vNode.asText(), String.class);
- }
- }
- return cda;
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java b/intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java
deleted file mode 100644
index 07c2cf08..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CustomAttributeSerializer.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.std.StdSerializer;
-
-import java.io.IOException;
-
-class CustomAttributeSerializer extends StdSerializer {
-
- public CustomAttributeSerializer() {
- super(CustomAttribute.class);
- }
-
- @Override
- public void serialize(CustomAttribute value, JsonGenerator jgen, SerializerProvider provider)
- throws IOException {
- // the field name has already been written
- jgen.writeObject(value.getValue());
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Customer.java b/intercom-java/src/main/java/io/intercom/api/Customer.java
deleted file mode 100644
index 8ac92b4e..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Customer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package io.intercom.api;
-
-
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class Customer extends TypedData {
-
- @JsonProperty("type")
- private String type;
-
- @JsonProperty("id")
- private String id;
-
- public Customer() {
- }
-
- public String getType() {
- return type;
- }
-
- public Customer setType(String type) {
- this.type = type;
- return this;
- }
-
- public String getId() {
- return id;
- }
-
- public Customer setId(String id) {
- this.id = id;
- return this;
- }
-
- @Override
- public int hashCode() {
- int result = id != null ? id.hashCode() : 0;
- result = 31 * result + (type != null ? type.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Customer customer = (Customer) o;
-
- if (id != null ? !id.equals(customer.id) : customer.id != null) return false;
- if (type != null ? !type.equals(customer.type) : customer.type != null) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "Customer{" +
- "type='" + type + '\'' +
- ", id='" + id+ '\'' +
- "} " + super.toString();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java b/intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java
deleted file mode 100644
index 7336259c..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CustomerFirstReply.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class CustomerFirstReply extends TypedData {
-
- @JsonProperty
- private String type;
-
- @JsonProperty
- private String url;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- public CustomerFirstReply() {
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public void setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (createdAt ^ (createdAt >>> 32));
- result = prime * result + ((type == null) ? 0 : type.hashCode());
- result = prime * result + ((url == null) ? 0 : url.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- CustomerFirstReply other = (CustomerFirstReply) obj;
- if (createdAt != other.createdAt)
- return false;
- if (type == null) {
- if (other.type != null)
- return false;
- } else if (!type.equals(other.type))
- return false;
- if (url == null) {
- if (other.url != null)
- return false;
- } else if (!url.equals(other.url))
- return false;
- return true;
- }
-
-
- @Override
- public String toString() {
- return "CustomerFirstReply{" + "type='" + type + '\'' + ", url='" + url + '\'' + ", created_at='" + createdAt + '\'' + "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/DataResource.java b/intercom-java/src/main/java/io/intercom/api/DataResource.java
deleted file mode 100644
index 88c49ef7..00000000
--- a/intercom-java/src/main/java/io/intercom/api/DataResource.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package io.intercom.api;
-
-import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.List;
-import java.util.Map;
-
-abstract class DataResource {
-
- @SuppressWarnings("SameParameterValue")
- public static T find(String id, String collectionPath, Class c) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build());
- return resource.get(c);
- }
-
- public static T find(Map params, String collectionPath, Class c) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build());
- return resource.get(c);
- }
-
- public static R create(T entity, String collectionPath, Class response) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).build());
- return resource.post(response, entity);
- }
-
- public static R create(T entity, List paths, Class response) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(paths).build());
- return resource.post(response, entity);
- }
-
- public static R update(T entity, String collectionPath, Class response) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).build());
- return resource.post(response, entity);
- }
-
- public static R post(T entity, URI path, Class response) {
- final HttpClient resource = new HttpClient(path);
- return resource.post(response, entity);
- }
-
- public static R updatePut(T entity, URI collectionPath, Class response) {
- final HttpClient resource = new HttpClient(collectionPath);
- return resource.put(response, entity);
- }
-
- @SuppressWarnings("SameParameterValue")
- public static R update(T entity, String collectionPath, String id, Class response) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build());
- return resource.post(response, entity);
- }
-
- public static T delete(String id, String collectionPath, Class c) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path(id).build());
- return resource.delete(c);
- }
-
- public static T delete(Map params, String collectionPath, Class c) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build());
- return resource.delete(c);
- }
-
- public static C list(Map params, String collectionPath, Class c) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).query(params).build());
- return resource.get(c);
- }
-
- public static C scroll(String scrollParam, String collectionPath, Class c) {
- Map params = Maps.newHashMap();
- if (!Strings.isNullOrEmpty(scrollParam)) {
- params.put("scroll_param", scrollParam);
- }
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).path("scroll").query(params).build());
- return resource.get(c);
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Error.java b/intercom-java/src/main/java/io/intercom/api/Error.java
deleted file mode 100644
index 10beabd2..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Error.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class Error extends TypedData {
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private final String type = "error";
-
- @JsonProperty("code")
- private String code;
-
- @JsonProperty("message")
- private String message;
-
- public Error() {
- }
-
- public Error(String code, String message) {
- this.code = code;
- this.message = message;
- }
-
- public String getType() {
- return type;
- }
-
- public String getCode() {
- return code;
- }
-
- public void setCode(String code) {
- this.code = code;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- @Override
- public int hashCode() {
- int result = code != null ? code.hashCode() : 0;
- result = 31 * result + (message != null ? message.hashCode() : 0);
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Error error = (Error) o;
-
- if (code != null ? !code.equals(error.code) : error.code != null) return false;
- //noinspection RedundantIfStatement
- if (message != null ? !message.equals(error.message) : error.message != null) return false;
-
- return true;
- }
-
- @Override
- public String toString() {
- return getType() + "{" +
- "code='" + code + '\'' +
- ", message='" + message + '\'' +
- "} " + super.toString();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/ErrorCollection.java b/intercom-java/src/main/java/io/intercom/api/ErrorCollection.java
deleted file mode 100644
index d9720516..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ErrorCollection.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.base.Preconditions;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public final class ErrorCollection {
-
- @JsonProperty("errors")
- private List errors;
-
- // for jackson
- ErrorCollection() {
- }
-
- public ErrorCollection(List errors) {
- Preconditions.checkNotNull(errors, "cannot create an error collection with a null error list");
- Preconditions.checkArgument(errors.size() > 0, "cannot create an error collection with an empty error list");
- this.errors = errors;
- }
-
- public List getErrors() {
- return errors;
- }
-
- public String getType() {
- return "error.list";
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Event.java b/intercom-java/src/main/java/io/intercom/api/Event.java
deleted file mode 100644
index 70227cb0..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Event.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Strings;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class Event extends TypedData {
-
- private static final List BULK_METHODS = Lists.newArrayList("post");
- private static final ArrayList BULK_PATHS = Lists.newArrayListWithExpectedSize(2);
-
- static {
- BULK_PATHS.add("bulk");
- BULK_PATHS.add("events");
- }
-
- public static void create(Event event) throws InvalidException, AuthorizationException {
-
- validateCreateEvent(event);
-
- if (event.getCreatedAt() == 0L) {
- event.setCreatedAt(System.currentTimeMillis() / 1000);
- }
- DataResource.create(event, "events", Void.class);
- }
-
- public static Job submit(List> items)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return submit(items, null);
- }
-
- public static Job submit(List> items, Job job)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return Job.submit(validateJobItems(items), job, BULK_PATHS);
- }
-
- public static JobItemCollection listJobErrorFeed(String jobID)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return Job.listJobErrorFeed(jobID, Event.class);
- }
-
- public static EventCollection list(Map params) throws InvalidException, AuthorizationException {
- if ((!params.containsKey("email")) && (!params.containsKey("user_id")) && (!params.containsKey("intercom_user_id"))) {
- throw new InvalidException("an event query must include an email, user_id or intercom_user_id parameter");
- }
- return DataResource.list(params, "events", EventCollection.class);
- }
-
- public static EventSummaryCollection listSummary(Map params) throws InvalidException, AuthorizationException {
- if ((!params.containsKey("email")) && (!params.containsKey("user_id")) && (!params.containsKey("intercom_user_id"))) {
- throw new InvalidException("an event query must include an email, user_id or intercom_user_id parameter");
- }
- params.put("summary", "true");
- return DataResource.list(params, "events", EventSummaryCollection.class);
- }
-
- @VisibleForTesting
- static List> validateJobItems(List> items) {
- final JobSupport jobSupport = new JobSupport();
- for (JobItem item : items) {
- jobSupport.validateJobItem(item, BULK_METHODS);
- validateCreateEvent(item.getData());
- }
-
- return items;
- }
-
- private static final ErrorCollection INVALID_NAME = new ErrorCollection(
- Lists.newArrayList(
- new Error("invalid", "an event must supply an event name")));
-
- private static final ErrorCollection INVALID_USER = new ErrorCollection(
- Lists.newArrayList(
- new Error("invalid", "an event must supply either an email or a user id")));
-
- @VisibleForTesting
- static void validateCreateEvent(Event event) {
- if (Strings.isNullOrEmpty(event.getEventName())) {
- throw new InvalidException(INVALID_NAME);
- }
-
- if (Strings.isNullOrEmpty(event.getUserID())
- && Strings.isNullOrEmpty(event.getId())
- && Strings.isNullOrEmpty(event.getEmail())) {
- throw new InvalidException(INVALID_USER);
- }
- }
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private final String type = "event";
-
- @JsonProperty("event_name")
- private String eventName;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("email")
- private String email;
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("user_id")
- private String userID;
-
- @JsonProperty("intercom_user_id")
- private String intercomUserID;
-
- @JsonProperty("metadata")
- private Map metadata = Maps.newHashMap();
-
- public Event() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getEventName() {
- return eventName;
- }
-
- public Event setEventName(String eventName) {
- this.eventName = eventName;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- @SuppressWarnings("UnusedReturnValue")
- public Event setCreatedAt(long createdAt) {
- this.createdAt = createdAt;
- return this;
- }
-
- public String getEmail() {
- return email;
- }
-
- public Event setEmail(String email) {
- this.email = email;
- return this;
- }
-
- public String getId() {
- return id;
- }
-
- public Event setId(String id) {
- this.id = id;
- return this;
- }
-
- public String getUserID() {
- return userID;
- }
-
- public Event setUserID(String userID) {
- this.userID = userID;
- return this;
- }
-
- public String getIntercomUserID() {
- return intercomUserID ;
- }
-
- public Event setIntercomUserID(String intercomUserID ) {
- this.intercomUserID = intercomUserID ;
- return this;
- }
-
- public Event putMetadata(String name, String value) {
- metadata.put(name, value);
- return this;
- }
-
- public Event putMetadata(String name, boolean value) {
- metadata.put(name, value);
- return this;
- }
-
- public Event putMetadata(String name, int value) {
- metadata.put(name, value);
- return this;
- }
-
- public Event putMetadata(String name, double value) {
- metadata.put(name, value);
- return this;
- }
-
- public Event putMetadata(String name, long value) {
- metadata.put(name, value);
- return this;
- }
-
- public Event putMetadata(String name, float value) {
- metadata.put(name, value);
- return this;
- }
-
- public Map getMetadata() {
- return metadata;
- }
-
- public Event setMetadata(Map metadata) {
- this.metadata = metadata;
- return this;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Event event = (Event) o;
-
- if (createdAt != event.createdAt) return false;
- if (email != null ? !email.equals(event.email) : event.email != null) return false;
- if (eventName != null ? !eventName.equals(event.eventName) : event.eventName != null) return false;
- if (metadata != null ? !metadata.equals(event.metadata) : event.metadata != null) return false;
- if (!type.equals(event.type)) return false;
- //noinspection RedundantIfStatement
- if (userID != null ? !userID.equals(event.userID) : event.userID != null) return false;
- if (id != null ? !id.equals(event.id) : event.id != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (eventName != null ? eventName.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (email != null ? email.hashCode() : 0);
- result = 31 * result + (userID != null ? userID.hashCode() : 0);
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (metadata != null ? metadata.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Event{" +
- "type='" + type + '\'' +
- ", eventName='" + eventName + '\'' +
- ", createdAt=" + createdAt +
- ", email='" + email + '\'' +
- ", id='" + id + '\'' +
- ", userID='" + userID + '\'' +
- ", metadata=" + metadata +
- "} " + super.toString();
- }
-}
-
-
diff --git a/intercom-java/src/main/java/io/intercom/api/EventCollection.java b/intercom-java/src/main/java/io/intercom/api/EventCollection.java
deleted file mode 100644
index 70a74fba..00000000
--- a/intercom-java/src/main/java/io/intercom/api/EventCollection.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package io.intercom.api;
-
-import java.util.Iterator;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class EventCollection extends TypedDataCollection {
-
- public EventCollection() {
- }
-
- public EventCollection(List events) {
- this();
- this.page = events;
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("events")
- @Override
- public List getPage() {
- return super.getPage();
- }
-
- @Override
- public EventCollection nextPage() {
- return fetchNextPage(EventCollection.class);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/EventSummary.java b/intercom-java/src/main/java/io/intercom/api/EventSummary.java
deleted file mode 100644
index 81892755..00000000
--- a/intercom-java/src/main/java/io/intercom/api/EventSummary.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class EventSummary {
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("first")
- private String first;
-
- @JsonProperty("last")
- private String last;
-
- @JsonProperty("count")
- private int count;
-
- @JsonProperty("description")
- private String description;
-
- public EventSummary() {
- }
-
- public String getName() {
- return name;
- }
-
- public String getFirstOccurredAtString() {
- return first;
- }
-
- public Date getFirstOccurredAt() throws ParseException {
- return stringToDate(first);
- }
-
- public String getLastOccurredAtString() {
- return last;
- }
-
- public Date getLastOccurredAt() throws ParseException {
- return stringToDate(last);
- }
-
- public int getCount() {
- return count;
- }
-
- public String getDescription() {
- return description;
- }
-
- private Date stringToDate(String dateString) throws ParseException {
- return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSX").parse(dateString);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- EventSummary eventSummary = (EventSummary) o;
-
- if (name != null ? !name.equals(eventSummary.name) : eventSummary.name != null) return false;
- if (first != null ? !first.equals(eventSummary.first) : eventSummary.first != null) return false;
- if (last != null ? !last.equals(eventSummary.last) : eventSummary.last != null) return false;
- if (count != eventSummary.count) return false;
- if (description != null ? !description.equals(eventSummary.description) : eventSummary.description != null) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = (name!= null ? name.hashCode() : 0);
- result = 31 * result + (description != null ? description.hashCode() : 0);
- result = 31 * result + (first != null ? first.hashCode() : 0);
- result = 31 * result + (last != null ? last.hashCode() : 0);
- result = 31 * result + count;
- return result;
- }
- @Override
- public String toString() {
- return "EventSummaryCollection{" +
- "name='" + name+ '\'' +
- ", count=" + count +
- ", description='" + description + '\'' +
- ", first='" + first + '\'' +
- ", last='" + last + '\'' +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java b/intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java
deleted file mode 100644
index 2e17903e..00000000
--- a/intercom-java/src/main/java/io/intercom/api/EventSummaryCollection.java
+++ /dev/null
@@ -1,88 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class EventSummaryCollection extends TypedData {
-
- @JsonProperty("type")
- private final String type = "event.summary";
-
- @JsonProperty("email")
- private String email;
-
- @JsonProperty("user_id")
- private String userID;
-
- @JsonProperty("intercom_user_id")
- private String intercomUserID;
-
- @JsonProperty("events")
- private List eventSummaries;
-
- public EventSummaryCollection() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getEmail() {
- return email;
- }
-
- public String getUserID() {
- return userID;
- }
-
- public String getIntercomUserID() {
- return intercomUserID ;
- }
-
- public List getEventSummaries() {
- return eventSummaries;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- EventSummaryCollection eventSummaryCollection = (EventSummaryCollection) o;
-
- if (email != null ? !email.equals(eventSummaryCollection.email) : eventSummaryCollection.email != null) return false;
- if (userID != null ? !userID.equals(eventSummaryCollection.userID) : eventSummaryCollection.userID != null) return false;
- if (intercomUserID!= null ? !intercomUserID.equals(eventSummaryCollection.intercomUserID) : eventSummaryCollection.intercomUserID != null) return false;
- if (eventSummaries!= null ? !eventSummaries.equals(eventSummaryCollection.eventSummaries) : eventSummaryCollection.eventSummaries != null) return false;
- if (!type.equals(eventSummaryCollection.type)) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = type.hashCode();
- result = 31 * result + (email != null ? email.hashCode() : 0);
- result = 31 * result + (userID != null ? userID.hashCode() : 0);
- result = 31 * result + (intercomUserID != null ? intercomUserID.hashCode() : 0);
- result = 31 * result + (eventSummaries != null ? eventSummaries.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Event{" +
- "type='" + type + '\'' +
- ", email='" + email + '\'' +
- ", userID='" + userID + '\'' +
- ", intercomUserID='" + intercomUserID + '\'' +
- ", eventSummaries=" + eventSummaries +
- "} " + super.toString();
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/HttpClient.java b/intercom-java/src/main/java/io/intercom/api/HttpClient.java
deleted file mode 100644
index 99056439..00000000
--- a/intercom-java/src/main/java/io/intercom/api/HttpClient.java
+++ /dev/null
@@ -1,268 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.CharStreams;
-import com.google.common.primitives.Ints;
-import com.google.common.primitives.Longs;
-
-import org.apache.commons.codec.binary.Base64;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-class HttpClient {
-
- private static final Logger logger = LoggerFactory.getLogger("intercom-java");
-
- private static final String CLIENT_AGENT_DETAILS = clientAgentDetails();
-
- private static final String USER_AGENT = Intercom.USER_AGENT;
-
- private static final String UTF_8 = "UTF-8";
-
- private static final String APPLICATION_JSON = "application/json";
-
- public static final String RATE_LIMIT_HEADER = "X-RateLimit-Limit";
- public static final String RATE_LIMIT_REMAINING_HEADER = "X-RateLimit-Remaining";
- public static final String RATE_LIMIT_RESET_HEADER = "X-RateLimit-Reset";
-
- private static String clientAgentDetails() {
- final HashMap map = Maps.newHashMap();
- final ArrayList propKeys = Lists.newArrayList(
- "os.arch", "os.name", "os.version",
- "user.language", "user.timezone",
- "java.class.version", "java.runtime.version", "java.version",
- "java.vm.name", "java.vm.vendor", "java.vm.version");
- for (String propKey : propKeys) {
- map.put(propKey, System.getProperty(propKey));
- }
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try {
- MapperSupport.objectMapper().disable(SerializationFeature.INDENT_OUTPUT).writeValue(baos, map);
- } catch (IOException e) {
- logger.warn(String.format("could not serialize client agent details [%s]", e.getMessage()), e);
- }
- return baos.toString();
- }
-
- private final ObjectMapper objectMapper;
-
- private final URI uri;
-
- private final Map headers;
-
- private final HttpConnectorSupplier connection = Intercom.getHttpConnectorSupplier();
-
- public HttpClient(URI uri) {
- this(uri, Maps.newHashMap());
- }
-
- private HttpClient(URI uri, Map headers) {
- this.uri = uri;
- this.headers = headers;
- this.objectMapper = MapperSupport.objectMapper();
- }
-
- public T get(Class reqres) throws IntercomException {
- return get(getJavaType(reqres));
- }
-
- T get(JavaType responseType) throws IntercomException {
- return executeHttpMethod("GET", null, responseType);
- }
-
- public T delete(Class reqres) {
- return executeHttpMethod("DELETE", null, getJavaType(reqres));
- }
-
- public T put(Class reqres, E entity) {
- headers.put("Content-Type", APPLICATION_JSON);
- return executeHttpMethod("PUT", (E) entity, getJavaType(reqres));
- }
-
- public T post(Class reqres, E entity) {
- headers.put("Content-Type", APPLICATION_JSON);
- return executeHttpMethod("POST", entity, getJavaType(reqres));
- }
-
- private T executeHttpMethod(String method, E entity, JavaType responseType) {
- HttpURLConnection conn = null;
- try {
- conn = initializeConnection(uri, method);
- if(entity != null) {
- prepareRequestEntity(entity, conn);
- }
- return runRequest(uri, responseType, conn);
- } catch (IOException e) {
- return throwLocalException(e);
- } finally {
- IOUtils.disconnectQuietly(conn);
- }
- }
-
- private JavaType getJavaType(Class reqres) {
- return objectMapper.getTypeFactory().constructType(reqres);
- }
-
- // trick java with a dummy return
- private T throwLocalException(IOException e) {
- throw new IntercomException(String.format("Local exception calling [%s]. Check connectivity and settings. [%s]", uri.toASCIIString(), e.getMessage()), e);
- }
-
- private void prepareRequestEntity(Object entity, HttpURLConnection conn) throws IOException {
- conn.setDoOutput(true);
- OutputStream stream = null;
- try {
- stream = conn.getOutputStream();
- if (logger.isDebugEnabled()) {
- logger.info(String.format("api server request --\n%s\n-- ", objectMapper.writeValueAsString(entity)));
- }
- objectMapper.writeValue(stream, entity);
- } finally {
- IOUtils.closeQuietly(stream);
- }
- }
-
- private HttpURLConnection initializeConnection(URI uri, String method) throws IOException {
- HttpURLConnection conn = connection.connect(uri);
- conn.setRequestMethod(method);
- conn = prepareConnection(conn);
- conn = applyHeaders(conn);
- return conn;
- }
-
- private T runRequest(URI uri, JavaType javaType, HttpURLConnection conn) throws IOException {
- conn.connect();
- final int responseCode = conn.getResponseCode();
- if (responseCode >= 200 && responseCode < 300) {
- return handleSuccess(javaType, conn, responseCode);
- } else {
- return handleError(uri, conn, responseCode);
- }
- }
-
- private T handleError(URI uri, HttpURLConnection conn, int responseCode) throws IOException {
- ErrorCollection errors;
- try {
- errors = objectMapper.readValue(conn.getErrorStream(), ErrorCollection.class);
- } catch (IOException e) {
- errors = createUnprocessableErrorResponse(e);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("error json follows --\n{}\n-- ", objectMapper.writeValueAsString(errors));
- }
- return throwException(responseCode, errors, conn);
- }
-
- private T handleSuccess(JavaType javaType, HttpURLConnection conn, int responseCode) throws IOException {
- if (shouldSkipResponseEntity(javaType, conn, responseCode)) {
- return null;
- } else {
- return readEntity(conn, responseCode, javaType);
- }
- }
-
- private boolean shouldSkipResponseEntity(JavaType javaType, HttpURLConnection conn, int responseCode) {
- return responseCode == 204 || Void.class.equals(javaType.getRawClass());
- }
-
- private T readEntity(HttpURLConnection conn, int responseCode, JavaType javaType) throws IOException {
- final InputStream entityStream = conn.getInputStream();
- try {
- final String text = CharStreams.toString(new InputStreamReader(entityStream));
- if (logger.isDebugEnabled()) {
- logger.debug("api server response status[{}] --\n{}\n-- ", responseCode, text);
- }
- if (text.isEmpty()) return null;
- return objectMapper.readValue(text, javaType);
- } finally {
- IOUtils.closeQuietly(entityStream);
- }
- }
-
- private T throwException(int responseCode, ErrorCollection errors, HttpURLConnection conn) {
- // bind some well known response codes to exceptions
- if (responseCode == 403 || responseCode == 401) {
- throw new AuthorizationException(errors);
- } else if (responseCode == 429) {
- throw new RateLimitException(errors, Ints.tryParse(conn.getHeaderField(RATE_LIMIT_HEADER)),
- Ints.tryParse(conn.getHeaderField(RATE_LIMIT_REMAINING_HEADER)),
- Longs.tryParse(conn.getHeaderField(RATE_LIMIT_RESET_HEADER)));
- } else if (responseCode == 404) {
- throw new NotFoundException(errors);
- } else if (responseCode == 422) {
- throw new InvalidException(errors);
- } else if (responseCode == 400 || responseCode == 405 || responseCode == 406) {
- throw new ClientException(errors);
- } else if (responseCode == 500 || responseCode == 503) {
- throw new ServerException(errors);
- } else {
- throw new IntercomException(errors);
- }
- }
-
- private HttpURLConnection applyHeaders(HttpURLConnection conn) {
- for (Map.Entry entry : createHeaders().entrySet()) {
- conn.setRequestProperty(entry.getKey(), entry.getValue());
- }
- for (Map.Entry entry : createAuthorizationHeaders().entrySet()) {
- conn.setRequestProperty(entry.getKey(), entry.getValue());
- }
- return conn;
- }
-
- // todo: expose this config
- private HttpURLConnection prepareConnection(HttpURLConnection conn) {
- conn.setConnectTimeout(Intercom.getConnectionTimeout());
- conn.setReadTimeout(Intercom.getRequestTimeout());
- conn.setUseCaches(Intercom.isRequestUsingCaches());
- return conn;
- }
-
- private Map createAuthorizationHeaders() {
- headers.put("Authorization", "Basic " + generateAuthString(Intercom.getToken(),""));
- return headers;
- }
-
- private String generateAuthString(String username, String password) {
- return Base64.encodeBase64String((username + ":" + password).getBytes());
- }
-
- private Map createHeaders() {
- headers.put("User-Agent", USER_AGENT);
- headers.put("X-Client-Platform-Details", CLIENT_AGENT_DETAILS);
- headers.put("Accept-Charset", UTF_8);
- headers.put("Accept", APPLICATION_JSON);
- return headers;
- }
-
- private ErrorCollection createUnprocessableErrorResponse(IOException e) {
- ErrorCollection errors;
- final long grepCode = getGrepCode();
- final String msg = String.format("could not parse error response: [%s]", e.getLocalizedMessage());
- logger.error(String.format("[%016x] %s", grepCode, msg), e);
- Error err = new Error("unprocessable_entity", String.format("%s logged with code [%016x]", msg, grepCode));
- errors = new ErrorCollection(Lists.newArrayList(err));
- return errors;
- }
-
- private long getGrepCode() {
- return ThreadLocalRandom.current().nextLong();
- }
-
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java b/intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java
deleted file mode 100644
index de02df36..00000000
--- a/intercom-java/src/main/java/io/intercom/api/HttpConnectorSupplier.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package io.intercom.api;
-
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URI;
-
-public interface HttpConnectorSupplier {
-
- HttpURLConnection connect(URI uri) throws IOException;
-
- HttpConnectorSupplier defaultSupplier = new HttpConnectorSupplier() {
- public HttpURLConnection connect(URI uri) throws IOException {
- return (HttpURLConnection) uri.toURL().openConnection();
- }
- };
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/IOUtils.java b/intercom-java/src/main/java/io/intercom/api/IOUtils.java
deleted file mode 100644
index b6f5966d..00000000
--- a/intercom-java/src/main/java/io/intercom/api/IOUtils.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package io.intercom.api;
-
-import org.slf4j.LoggerFactory;
-
-import java.io.Closeable;
-import java.net.HttpURLConnection;
-
-class IOUtils {
-
- private static final org.slf4j.Logger logger = LoggerFactory.getLogger("intercom-java");
-
- /**
- * Close a HttpURLConnection, ignores checked Exceptions and nulls,
- * but rethrows RuntimeExceptions.
- *
- * @param connection the connection to disconnect
- */
- public static void disconnectQuietly(HttpURLConnection connection) {
- if (connection != null) {
- try {
- connection.disconnect();
- } catch (RuntimeException rethrow) {
- throw rethrow;
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- }
- }
-
- /**
- * Close a stream, ignores checked Exceptions and nulls,
- * but rethrows RuntimeExceptions.
- *
- * @param stream the object to close
- */
- public static void closeQuietly(Closeable stream) {
- if (stream != null) {
- try {
- stream.close();
- } catch (RuntimeException rethrow) {
- throw rethrow;
- } catch (Exception e) {
- logger.warn(e.getMessage());
- }
- }
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Intercom.java b/intercom-java/src/main/java/io/intercom/api/Intercom.java
deleted file mode 100644
index 22b81c1a..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Intercom.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package io.intercom.api;
-
-import java.net.URI;
-
-public class Intercom {
-
- static class Context {
- private volatile String token;
- private volatile int connectionTimeout = 3 * 1000;
- private volatile int requestTimeout = 60 * 1000;
- private volatile boolean requestUsingCaches = false;
- }
-
- private static final URI API_BASE_URI = URI.create("https://api.intercom.io/");
-
- private static volatile boolean useThreadLocal = false;
-
- private static volatile URI apiBaseURI = API_BASE_URI;
-
- private static final String VERSION = "2.8.2";
-
- public static final String USER_AGENT = "intercom-java/" + Intercom.VERSION;
-
- private static ThreadLocal threadContext = newThreadLocalContext();
-
- private static final Context staticContext = new Context();
-
- private static Context getContext() {
- if (useThreadLocal) {
- return threadContext.get();
- }
- return staticContext;
- }
-
- private static volatile HttpConnectorSupplier httpConnectorSupplier = HttpConnectorSupplier.defaultSupplier;
-
- public static long currentTimestamp() {
- return System.currentTimeMillis()/1000;
- }
-
- public static int getConnectionTimeout() {
- return getContext().connectionTimeout;
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public static void setConnectionTimeout(int connectionTimeout) {
- getContext().connectionTimeout = connectionTimeout;
- }
-
- public static int getRequestTimeout() {
- return getContext().requestTimeout;
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public static void setRequestTimeout(int requestTimeout) {
- getContext().requestTimeout = requestTimeout;
- }
-
- public static boolean isRequestUsingCaches() {
- return getContext().requestUsingCaches;
- }
-
- public static void setRequestUsingCaches(boolean requestUsingCaches) {
- getContext().requestUsingCaches = requestUsingCaches;
- }
-
- public static HttpConnectorSupplier getHttpConnectorSupplier() {
- return httpConnectorSupplier;
- }
-
- public static void setHttpConnectorSupplier(HttpConnectorSupplier supplier) {
- Intercom.httpConnectorSupplier = supplier;
- }
-
- public static void setToken(String token) {
- Context context = getContext();
- context.token = token;
- }
-
- public static URI getApiBaseURI() {
- return Intercom.apiBaseURI;
- }
-
- public static void setApiBaseURI(URI apiBaseURI) {
- Intercom.apiBaseURI = apiBaseURI;
- }
-
- public static String getToken() {
- return getContext().token;
- }
-
- public static boolean usesThreadLocal() {
- return Intercom.useThreadLocal;
- }
-
- public static void setUseThreadLocal(boolean useThreadLocal) {
- Intercom.useThreadLocal = useThreadLocal;
- }
-
- public static void clearThreadLocalContext() {
- threadContext.remove();
- }
-
- public static void clearThreadLocalContexts() {
- threadContext = newThreadLocalContext();
- }
-
- private static ThreadLocal newThreadLocalContext() {
- return new ThreadLocal() {
- @Override protected Context initialValue() {
- return new Context();
- }
- };
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/IntercomException.java b/intercom-java/src/main/java/io/intercom/api/IntercomException.java
deleted file mode 100644
index b32441fc..00000000
--- a/intercom-java/src/main/java/io/intercom/api/IntercomException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package io.intercom.api;
-
-public class IntercomException extends RuntimeException {
-
- private static final long serialVersionUID = -2723350106062183796L;
-
- private ErrorCollection errorCollection;
-
- @SuppressWarnings("WeakerAccess")
- public IntercomException(String message) {
- super(message);
- }
-
- public IntercomException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IntercomException(ErrorCollection errorCollection) {
- this(getMessage(errorCollection));
- this.errorCollection = errorCollection;
- }
-
- public static String getMessage(ErrorCollection errorCollection) {
- String message = "Could not read error message from server";
- if(errorCollection!=null
- && errorCollection.getErrors() != null
- && errorCollection.getErrors().size() > 0
- && errorCollection.getErrors().get(0) != null
- && errorCollection.getErrors().get(0).getMessage() != null){
- message = errorCollection.getErrors().get(0).getMessage();
- }
- return message;
- }
-
- @SuppressWarnings("WeakerAccess")
- public IntercomException(ErrorCollection errorCollection, Throwable cause) {
- this(getMessage(errorCollection), cause);
- this.errorCollection = errorCollection;
- }
-
- public ErrorCollection getErrorCollection() {
- return errorCollection;
- }
-
- public Error getFirstError() {
- return errorCollection.getErrors().get(0);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/InvalidException.java b/intercom-java/src/main/java/io/intercom/api/InvalidException.java
deleted file mode 100644
index 6a4381bd..00000000
--- a/intercom-java/src/main/java/io/intercom/api/InvalidException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.intercom.api;
-
-public class InvalidException extends IntercomException {
-
- private static final long serialVersionUID = -2111295679006526646L;
-
- public InvalidException(String message) {
- super(message);
- }
-
- public InvalidException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public InvalidException(ErrorCollection errorCollection) {
- super(errorCollection);
- }
-
- public InvalidException(ErrorCollection errorCollection, Throwable cause) {
- super(errorCollection, cause);
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/Job.java b/intercom-java/src/main/java/io/intercom/api/Job.java
deleted file mode 100644
index ab7f1756..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Job.java
+++ /dev/null
@@ -1,216 +0,0 @@
-package io.intercom.api;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-import com.fasterxml.jackson.annotation.JsonInclude;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JavaType;
-import com.google.common.collect.Maps;
-
-import java.net.URI;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_DEFAULT)
-public class Job extends TypedData {
-
- private static final HashMap SENTINEL = Maps.newHashMap();
-
- public static Job find(String id)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return find(id, SENTINEL);
- }
-
- public static Job find(String id, Map params)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return new HttpClient(
- UriBuilder.newBuilder().path("jobs").path(id).query(params).build()
- ).get(Job.class);
- }
-
- public static Job update(Job job)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.post(
- job,
- UriBuilder.newBuilder().path("jobs").path(job.getID()).build(),
- Job.class);
- }
-
- static Job submit(List> items, List bulkPaths)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return submit(items, null, bulkPaths);
- }
-
- static Job submit(List> items, Job job, List bulkPaths)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- return DataResource.create(new JobItemRequest(items, job), bulkPaths, Job.class);
- }
-
- static JobItemCollection