diff --git a/.fern/metadata.json b/.fern/metadata.json
new file mode 100644
index 00000000..757181e8
--- /dev/null
+++ b/.fern/metadata.json
@@ -0,0 +1,12 @@
+{
+ "cliVersion": "3.0.2",
+ "generatorName": "fernapi/fern-java-sdk",
+ "generatorVersion": "3.21.0",
+ "generatorConfig": {
+ "enable-inline-types": true,
+ "client-class-name": "Intercom",
+ "inline-path-parameters": true,
+ "enable-forward-compatible-enums": true,
+ "enable-wire-tests": false
+ }
+}
\ No newline at end of file
diff --git a/.fernignore b/.fernignore
new file mode 100644
index 00000000..88a7de55
--- /dev/null
+++ b/.fernignore
@@ -0,0 +1,6 @@
+# Specify files that shouldn't be modified by Fern
+
+src/test/java/com/intercom/api/integration
+src/test/java/com/intercom/api/utils
+
+.github/workflows/ci.yml
diff --git a/.github/workflows-disabled/ci.yml b/.github/workflows-disabled/ci.yml
new file mode 100644
index 00000000..923e5103
--- /dev/null
+++ b/.github/workflows-disabled/ci.yml
@@ -0,0 +1,67 @@
+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
+ env:
+ INTERCOM_API_KEY: ${{ secrets.INTERCOM_API_KEY }}
+
+ publish:
+ needs: [ compile ]
+ if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
+ 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: Publish to maven
+ run: |
+ ./gradlew sonatypeCentralUpload -x test
+ env:
+ MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
+ MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
+ MAVEN_PUBLISH_REGISTRY_URL: "https://s01.oss.sonatype.org/content/repositories/releases/"
+ MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }}
+ MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }}
+ MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }}
diff --git a/.gitignore b/.gitignore
index c9e7d8ec..d4199abc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,14 +1,24 @@
-*/**/Spike*.java
-.gradle
*.class
-out/*
+.project
+.gradle
+?
+.classpath
+.checkstyle
+.settings
+.node
+build
+
+# IntelliJ
*.iml
*.ipr
*.iws
-build
-*/build/*
-*/build/**/*.jar
-*.war
-*.ear
-hs_err_pid*
-.idea
+.idea/
+out/
+
+# Eclipse/IntelliJ APT
+generated_src/
+generated_testSrc/
+generated/
+
+bin
+build
\ No newline at end of file
diff --git a/.publish/prepare.sh b/.publish/prepare.sh
new file mode 100755
index 00000000..df3948e3
--- /dev/null
+++ b/.publish/prepare.sh
@@ -0,0 +1,8 @@
+# Write key ring file
+echo "$MAVEN_SIGNATURE_SECRET_KEY" > armored_key.asc
+gpg -o publish_key.gpg --dearmor armored_key.asc
+
+# Generate gradle.properties file
+echo "signing.keyId=$MAVEN_SIGNATURE_KID" > gradle.properties
+echo "signing.secretKeyRingFile=publish_key.gpg" >> gradle.properties
+echo "signing.password=$MAVEN_SIGNATURE_PASSWORD" >> gradle.properties
diff --git a/CHANGES.md b/CHANGES.md
deleted file mode 100644
index 155d14da..00000000
--- a/CHANGES.md
+++ /dev/null
@@ -1,127 +0,0 @@
-### Changes
-
-#### 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
index fe8ed46f..8ba7df9c 100644
--- a/README.md
+++ b/README.md
@@ -1,647 +1,318 @@
-[](https://circleci.com/gh/intercom/intercom-java)
+# Intercom Java Library
-# intercom-java
+[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fintercom%2Fintercom-java)
+[](https://central.sonatype.com/artifact/io.intercom/intercom-java)
-Java bindings for the [Intercom API](https://api.intercom.io/docs)
+The Intercom Java library provides convenient access to the Intercom APIs from Java.
- - [Installation](#installation)
- - [Resources](#resources)
- - [Authorization](#authorization)
- - [Usage](#usage)
- - [Idioms](#idioms)
- - [Configuration](#configuration)
+## Table of Contents
+- [Installation](#installation)
+- [Reference](#reference)
+- [Usage](#usage)
+- [Environments](#environments)
+- [Base Url](#base-url)
+- [Exception Handling](#exception-handling)
+- [Advanced](#advanced)
+ - [Custom Client](#custom-client)
+ - [Retries](#retries)
+ - [Timeouts](#timeouts)
+ - [Custom Headers](#custom-headers)
+ - [Access Raw Response Data](#access-raw-response-data)
+- [Contributing](#contributing)
-## Add a dependency
+## Installation
-[  ](https://bintray.com/intercom/intercom-maven/intercom-java/_latestVersion)
+### Gradle
-The distribution is hosted on [bintray](https://bintray.com/intercom/intercom-maven/intercom-java/view).
-To use the client, you can add the jcenter repository to your dependencies.
+Add the dependency in your `build.gradle` file:
-### maven
-
-Add jcenter to your repositories in `pom.xml` or `settings.xml`:
+```groovy
+dependencies {
+ implementation 'io.intercom:intercom-java'
+}
+```
-```xml
-
-
- jcenter
- http://jcenter.bintray.com
-
-
-```
+### Maven
-and add the project declaration to your `pom.xml`:
+Add the dependency in your `pom.xml` file:
```xml
io.intercom
intercom-java
- 1.3.0
+ 4.0.4
```
-### gradle
-
-Add jcenter to your `repositories` block:
-
-```groovy
-repositories {
- jcenter()
-}
-```
-
-and add the project to the `dependencies` block in your `build.gradle`:
-
-```groovy
-dependencies {
- compile 'io.intercom:intercom-java:1.3.0'
-}
-```
-
-### sbt
-
-Add jcenter to your `resolvers` in your `build.sbt`:
-
-```scala
-resolvers += "jcenter" at "http://jcenter.bintray.com"
-```
-
-and add the project to your `libraryDependencies` in your `build.sbt`:
-
-```scala
-libraryDependencies += "io.intercom" % "intercom-java" % "1.3.0"
-```
-
-## Resources
-
-Resources this API supports:
-
-- [Users](#users)
-- [Contacts](#contacts)
-- [Companies](#companies)
-- [Admins](#admins)
-- [Events](#events)
-- [Tags](#tags)
-- [Segments](#segments)
-- [Notes](#notes)
-- [Conversations](#conversations)
-- [Messages](#messages)
-- [Counts](#counts)
-- [Webhooks](#webhooks)
-
-
-
-## Authorization
-
-You can set the app's id and api key via the `Intercom` object -
-
-```java
-Intercom.setAppID("pi3243fa");
-Intercom.setApiKey("da39a3ee5e6b4b0d3255bfef95601890afd80709");
-```
+## Reference
+A full reference for this library is available [here](https://github.com/intercom/intercom-java/blob/HEAD/./reference.md).
## Usage
-### Users
+Instantiate and use the client with the following:
```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
-UserCollection users = User.list();
-while(users.hasNext()) {
- System.out.println(users.next().getUserId());
+package com.example.usage;
+
+import com.intercom.api.Intercom;
+import com.intercom.api.resources.aicontent.requests.CreateContentImportSourceRequest;
+
+public class Example {
+ public static void main(String[] args) {
+ Intercom client = Intercom
+ .builder()
+ .token("")
+ .build();
+
+ client.aiContent().createContentImportSource(
+ CreateContentImportSourceRequest
+ .builder()
+ .url("https://www.example.com")
+ .build()
+ );
+ }
}
-
-// Bulk submit users
-final List> items = Lists.newArrayList();
-items.add(new JobItem("post", user1));
-items.add(new JobItem("post", user2));
-items.add(new JobItem("delete", user3));
-final Job job = User.submit(items);
-System.out.println(job.getID());
-
-// Bulk submit, add to an existing job
-final List> moreItems = Lists.newArrayList();
-items.add(new JobItem("post", user4));
-items.add(new JobItem("delete", user5));
-User.submit(moreItems, job);
-
-//View a bulk job error feed
-User.listJobErrorFeed(jobId)
```
-### Contacts
+## Environments
-_Contacts were added in version 1.1 of the client._
+This SDK allows you to configure different environments for API requests.
```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);
-
-// 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
-ContactCollection allContacts = Contact.list();
-while(allContacts.hasNext()) {
- System.out.println(allContacts.next());
-}
-
-// Remove a contact
-Contact.delete(contact);
+import com.intercom.api.Intercom;
+import com.intercom.api.core.Environment;
-// Convert a contact
-User converted = Contact.convert(contact, user);
+Intercom client = Intercom
+ .builder()
+ .environment(Environment.USProduction)
+ .build();
```
-### Companies
+## Base Url
-```java
-// Create a company
-Company company = new Company();
- company.setName("Blue Sun");
- company.setCompanyID("1");
- 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());
-}
+You can set a custom base URL when constructing the client.
-// Get a list of users in a company
-map = Maps.newHashMap();
-map.put("company_id", "6");
-UserCollection users = Company.listUsers(map);
+```java
+import com.intercom.api.Intercom;
-// Add a user to one or more companies
-User user = User.find("541a144b201ebf2ec5000001");
-user.addCompany(company);
-User.update(user);
+Intercom client = Intercom
+ .builder()
+ .url("https://example.com")
+ .build();
```
-### Admins
+## Exception Handling
+
+When the API returns a non-success status code (4xx or 5xx response), an API exception will be thrown.
```java
-// Iterate over all admins
-AdminCollection admins = Admin.list();
-while(admins.hasNext()) {
- System.out.println(admins.next().getName());
+import com.intercom.api.core.IntercomApiApiException;
+
+try{
+ client.aiContent().createContentImportSource(...);
+} catch (IntercomApiApiException e){
+ // Do something with the API exception...
}
```
+## Advanced
-### Events
-
-```java
-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);
-
-// Bulk submit events
-final List> items = Lists.newArrayList();
-items.add(new JobItem("post", event1));
-items.add(new JobItem("post", event2));
-items.add(new JobItem("post", event3));
-final Job job = Event.submit(items);
-System.out.println(job.getID());
-
-// Bulk submit, add to an existing job
-final List> moreItems = Lists.newArrayList();
-items.add(new JobItem("post", event4));
-items.add(new JobItem("delete", event5));
-Event.submit(moreItems, job);
-
-//View a bulk job error feed
-Event.listJobErrorFeed(jobId)
-```
+### Custom Client
-
-### Tags
+This SDK is built to work with any instance of `OkHttpClient`. By default, if no client is provided, the SDK will construct one.
+However, you can pass your own client like so:
```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);
-
-// iterate over all tags
-final TagCollection tags = Tag.list();
-while (tags.hasNext()) {
- System.out.println(tags.next().getId());
-}
+import com.intercom.api.Intercom;
+import okhttp3.OkHttpClient;
-// 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);
+OkHttpClient customClient = ...;
-// delete a tag
-Tag.delete(tag);
+Intercom client = Intercom
+ .builder()
+ .httpClient(customClient)
+ .build();
```
-### Segments
+### Retries
-```java
-// Find a segment
-Segment segment = Segment.find("1");
+The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
+as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
+retry limit (default: 2). Before defaulting to exponential backoff, the SDK will first attempt to respect
+the `Retry-After` header (as either in seconds or as an HTTP date), and then the `X-RateLimit-Reset` header
+(as a Unix timestamp in epoch seconds); failing both of those, it will fall back to exponential backoff.
-// Update a segment
-segment.setName("new name");
-Segment.update(segment);
+A request is deemed retryable when any of the following HTTP status codes is returned:
-// Iterate over all segments
-SegmentCollection segments = Segment.list();
-while(segments.hasNext()) {
- System.out.println(segments.next().getId());
-}
-```
+- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
+- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
+- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
-### Notes
+Use the `maxRetries` client option to configure this behavior.
```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());
-}
+import com.intercom.api.Intercom;
-// 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());
-}
+Intercom client = Intercom
+ .builder()
+ .maxRetries(1)
+ .build();
```
-### 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?")
- .setUser(user);
-Conversation.create(userMessage);
-
-// send a message from a contact
-ContactMessage contactMessage = new ContactMessage()
- .setBody("Hey! Is there, is there a reward?")
- .setUser(contact);
-Conversation.create(contactMessage);
-
-// 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();
-}
+### Timeouts
-// find a conversation by id
-final Conversation conversation = Conversation.find("66");
-ConversationMessage conversationMessage = conversation.getConversationMessage();
-ConversationPartCollection parts = conversation.getConversationPartCollection();
-List partList = parts.getPageItems();
-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");
-Conversation.reply("66", adminReply);
-
-// admin close
-Admin admin = new Admin().setId("1");
-AdminReply adminReply = new AdminReply(admin);
-adminReply.setMessageType("close");
-Conversation.reply("66", adminReply);
-
-// user reply
-User user1 = new User().setId("5310d8e8598c9a0b24000005");
-UserReply userReply = new UserReply(user1);
-userReply.setBody("Mighty fine shindig");
-System.out.println(MapperSupport.objectMapper().writeValueAsString(userReply));
-Conversation.reply("66", userReply);
-```
-
-### Webhooks
+The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
```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.addTopic(Subscription.Topic.COMPANY);
-subscription.setAppID("pi3243fa");
-Subscription.create(subscription);
-
-// find a subscription
-subscription = Subscription.find("nsub_60ca7690-4020-11e4-b789-4961958e51bd");
-
-// 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);
+import com.intercom.api.Intercom;
+import com.intercom.api.core.RequestOptions;
+
+// Client level
+Intercom client = Intercom
+ .builder()
+ .timeout(10)
+ .build();
+
+// Request level
+client.aiContent().createContentImportSource(
+ ...,
+ RequestOptions
+ .builder()
+ .timeout(10)
+ .build()
+);
```
-### Counts
+### Custom Headers
+
+The SDK allows you to add custom headers to requests. You can configure headers at the client level or at the request level.
```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());
-}
+import com.intercom.api.Intercom;
+import com.intercom.api.core.RequestOptions;
+
+// Client level
+Intercom client = Intercom
+ .builder()
+ .addHeader("X-Custom-Header", "custom-value")
+ .addHeader("X-Request-Id", "abc-123")
+ .build();
+;
+
+// Request level
+client.aiContent().createContentImportSource(
+ ...,
+ RequestOptions
+ .builder()
+ .addHeader("X-Request-Header", "request-value")
+ .build()
+);
+```
-// 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());
-}
+### Access Raw Response Data
-// segment user counts
-List segments = Counts.userSegments();
-for (Counts.CountItem segment : segments) {
- System.out.println(segment.getName()+": " +segment.getValue());
-}
+The SDK provides access to raw response data, including headers, through the `withRawResponse()` method.
+The `withRawResponse()` method returns a raw client that wraps all responses with `body()` and `headers()` methods.
+(A normal client's `response` is identical to a raw client's `response.body()`.)
-// company user counts
-List companyUsers = Counts.companyUsers();
-for (Counts.CountItem company : companyUsers) {
- System.out.println(company.getName()+": " +company.getValue());
-}
+```java
+CreateContentImportSourceHttpResponse response = client.aiContent().withRawResponse().createContentImportSource(...);
-// company tag counts
-List companyTags = Counts.companyTags();
-for (Counts.CountItem tag : companyTags) {
- System.out.println(tag.getName()+": " +tag.getValue());
-}
+System.out.println(response.body());
+System.out.println(response.headers().get("X-My-Header"));
```
-## Idioms
+## Contributing
-### HTTP requests
+While we value open-source contributions to this SDK, this library is generated programmatically.
+Additions made directly to this library would have to be moved over to our generation code,
+otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
+a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
+an issue first to discuss with us!
-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.
+On the other hand, contributions to the README are always very welcome!
-### Pagination
+## For Maintainers
-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
+### Regenerating the SDK
-- The collection's `getPageItems()`, `hasNextPage()` and `nextPage()` methods - these are useful when you want to fetch one or just a few pages directly.
+This SDK is generated using [Fern](https://buildwithfern.com). To regenerate the SDK after API changes:
-- Java's inbuilt iterator methods `next()` and `hasNext()` - these are useful when you want to fetch data without manually handling pagination.
+#### Prerequisites
-### Error handling
+- Ensure you have Fern CLI installed
+- Navigate to the `fern/` directory of the Fern config repo
+- If you only need regeneration without publishing, you can empty credentials in `generators.yml` to skip the publish step:
+ ```yaml
+ # Example: Clear Maven credentials to skip publish
+ username: ""
+ password: ""
+ signing-key-id: ""
+ ```
-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.
+#### Regeneration Command
-The API throws the following runtime exceptions -
+```bash
+fern generate --group java-sdk
+```
- - 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
+#### Common Issues
+- **Integration tests failing**: Fix the tests locally and push updates to the PR branch
+- **Spotless formatting errors**: Run the Spotless formatter locally to fix formatting issues
+- **Maven signing errors**: If publishing is enabled, ensure these environment variables are set:
+ - `MAVEN_SIGNING_KEY_ID`
+ - `MAVEN_SIGNING_KEY`
+ - `MAVEN_SIGNING_PASSWORD`
+- **GitHub Actions delays**: If CI is degraded, pipelines may need retries
-## Configuration
+### Publishing to Maven Central
-### HTTP
+After regenerating the SDK and merging the PR:
-The client can be configured to accept any http stack that implements
-`java.net.HttpURLConnection` by implementing the `HttpConnectorSupplier`
- interface.
+#### 1. Create a Release Tag
-For example, to use [OkHttp](http://square.github.io/okhttp/) as a connection
-supplier, create a supplier class -
+Manually create and push a Git tag for the release:
-```java
-public class OkHttpSupplier implements HttpConnectorSupplier {
- private final OkUrlFactory urlFactory;
+```bash
+git tag v4.0.x
+git push origin v4.0.x
+```
- public OkHttpSupplier(OkUrlFactory urlFactory) {
- this.urlFactory = urlFactory;
- }
+#### 2. Trigger Publish Workflow
- @Override
- public HttpURLConnection connect(URI uri) throws IOException {
- return urlFactory.open(uri.toURL());
- }
-}
-```
+The tag push triggers the publish workflow automatically. Ensure the version in the repo config aligns with the intended release.
-and hand a supplier to the Intercom object -
+#### 3. Verify Publication
-```
-final OkHttpClient client = new OkHttpClient();
-final OkUrlFactory factory = new OkUrlFactory(client);
-final OkHttpSupplier supplier = new OkHttpSupplier(factory);
-Intercom.setHttpConnectorSupplier(supplier);
-```
+- Check [Maven Central](https://central.sonatype.com/artifact/io.intercom/intercom-java/overview) for the new version
+- Note: Maven Central indexing can take some time to appear
-#### Timeouts
+#### Required Credentials
-The default connection and request timeouts can be set in milliseconds using the
-`Intercom.setConnectionTimeout` and `Intercom.setRequestTimeout` methods.
+Publishing requires:
+- Maven Central credentials (username/password)
+- GPG signing key configuration:
+ - `MAVEN_SIGNING_KEY_ID`
+ - `MAVEN_SIGNING_KEY`
+ - `MAVEN_SIGNING_PASSWORD`
+Contributors without publish credentials can open regeneration PRs. Team members with credentials can complete the publish steps.
-### Target API Server
+### Example Workflow
-The base URI to target can be changed for testing purposes
+1. **Update OpenAPI spec** (if needed): Add overrides in `openapi-overrides.yml` in the Intercom-OpenAPI repo
+2. **Regenerate SDK**: Run `fern generate --group java-sdk`
+3. **Fix any issues**: Address integration test failures or formatting issues
+4. **Create PR**: Open a pull request with the regenerated code
+5. **Merge PR**: After review and approval
+6. **Tag release**: Create and push a Git tag
+7. **Verify publish**: Check Maven Central for the new version
-```java
-URI baseURI = new URI("https://example.org/server");
-Intercom.setApiBaseURI(baseURI);
-```
+### Related Resources
+
+- [Fern Documentation](https://buildwithfern.com)
+- [Maven Central Repository](https://central.sonatype.com/artifact/io.intercom/intercom-java)
+- [Intercom OpenAPI Spec](https://github.com/intercom/Intercom-OpenAPI)
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index f58b503d..2c41feb7 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,59 +1,132 @@
-buildscript {
- repositories {
- jcenter()
+plugins {
+ id 'java-library'
+ id 'maven-publish'
+ id 'com.diffplug.spotless' version '6.11.0'
+ id 'signing'
+ id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
+}
+
+repositories {
mavenCentral()
- }
- //noinspection GroovyAssignabilityCheck
- dependencies {
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
- classpath 'org.ajoberstar:gradle-git:0.10.0'
- }
+ maven {
+ url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
+ }
}
-allprojects {
- apply plugin: 'idea'
+dependencies {
+ api 'com.squareup.okhttp3:okhttp:5.2.1'
+ api 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
+ api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2'
+ api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
+ testImplementation 'org.junit.jupiter:junit-jupiter-params:5.8.2'
}
-subprojects {
- buildscript {
- repositories {
- jcenter()
- mavenCentral()
- }
- //noinspection GroovyAssignabilityCheck
- dependencies {
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
- classpath 'org.ajoberstar:gradle-git:0.10.0'
+sourceCompatibility = 1.8
+targetCompatibility = 1.8
+
+tasks.withType(Javadoc) {
+ failOnError false
+ options.addStringOption('Xdoclint:none', '-quiet')
+}
+
+spotless {
+ java {
+ palantirJavaFormat()
}
- }
+}
- repositories {
- jcenter()
- mavenCentral()
- }
- apply plugin: 'maven'
- apply plugin: 'maven-publish'
- apply plugin: 'java'
- apply plugin: 'com.jfrog.bintray'
+java {
+ withSourcesJar()
+ withJavadocJar()
+}
+
+
+group = 'io.intercom'
+
+version = '4.0.4'
+
+jar {
+ dependsOn(":generatePomFileForMavenPublication")
+ archiveBaseName = "intercom-java"
+}
+
+sourcesJar {
+ archiveBaseName = "intercom-java"
+}
+
+javadocJar {
+ archiveBaseName = "intercom-java"
+}
+
+signing {
+ sign(publishing.publications)
+}
- sourceCompatibility = 1.7
- targetCompatibility = 1.7
+test {
+ useJUnitPlatform()
+ testLogging {
+ showStandardStreams = true
+ }
+}
- //noinspection GroovyAssignabilityCheck
- dependencies {
- compile 'com.fasterxml.jackson.core:jackson-core:2.4.2'
- compile 'com.fasterxml.jackson.core:jackson-annotations:2.4.2'
- compile 'com.fasterxml.jackson.core:jackson-databind:2.4.2'
- compile 'com.google.guava:guava:17.0'
- compile 'org.slf4j:slf4j-api:1.7.7'
- compile 'commons-codec:commons-codec:1.9'
- testCompile 'junit:junit:4.11'
- }
+publishing {
+ publications {
+ maven(MavenPublication) {
+ groupId = 'io.intercom'
+ artifactId = 'intercom-java'
+ version = '4.0.4'
+ from components.java
+ pom {
+ name = 'intercom'
+ description = 'The official SDK of intercom'
+ url = 'https://buildwithfern.com'
+ licenses {
+ license {
+ name = 'The MIT License (MIT)'
+ url = 'https://mit-license.org/'
+ }
+ }
+ developers {
+ developer {
+ name = 'intercom'
+ email = 'developers@intercom.com'
+ }
+ }
+ scm {
+ connection = 'scm:git:git://github.com/intercom/intercom-java.git'
+ developerConnection = 'scm:git:git://github.com/intercom/intercom-java.git'
+ url = 'https://github.com/intercom/intercom-java'
+ }
+ }
+ }
+ }
}
+sonatypeCentralUpload {
+ username = "$System.env.MAVEN_USERNAME"
+ password = "$System.env.MAVEN_PASSWORD"
+
+ archives = files(
+ "$buildDir/libs/intercom-java-" + version + ".jar",
+ "$buildDir/libs/intercom-java-" + version + "-sources.jar",
+ "$buildDir/libs/intercom-java-" + version + "-javadoc.jar"
+ )
-task wrapper(type: Wrapper) {
- gradleVersion = '2.0'
+ pom = file("$buildDir/publications/maven/pom-default.xml")
+ signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY"
+ signingKeyPassphrase = "$System.env.MAVEN_SIGNATURE_PASSWORD"
}
+
+signing {
+ def signingKeyId = "$System.env.MAVEN_SIGNATURE_KID"
+ def signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY"
+ def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD"
+ useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
+ sign publishing.publications.maven
+}
+
+sonatypeCentralUpload.dependsOn build
diff --git a/gradle.properties b/gradle.properties
index 52f44700..e69de29b 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,8 +0,0 @@
-version: 1.3.0
-
-groupId: io.intercom
-
-modules: \
- intercom-java
-
-org.gradle.daemon: true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index b7612167..1b33c55b 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 09495e50..d4081da4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,7 @@
-#Wed Sep 24 10:57:43 IST 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
+networkTimeout=10000
+validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.0-bin.zip
diff --git a/gradlew b/gradlew
index 91a7e269..23d15a93 100755
--- a/gradlew
+++ b/gradlew
@@ -1,79 +1,129 @@
-#!/usr/bin/env bash
+#!/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/.
+#
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+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
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+# 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 ( ) {
+warn () {
echo "$*"
-}
+} >&2
-die ( ) {
+die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
+CLASSPATH="\\\"\\\""
-# 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
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-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
@@ -82,83 +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" ] ; 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"`
-
- # 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
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+# 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" \
+ -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
+ "$@"
+
+# 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 aec99730..5eed7ee8 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
@@ -8,26 +26,30 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@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 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="-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,54 +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 Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_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=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
:execute
@rem Setup the command line
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+set CLASSPATH=
+
@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%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
: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/init.gradle b/init.gradle
deleted file mode 100644
index ce7f86da..00000000
--- a/init.gradle
+++ /dev/null
@@ -1,14 +0,0 @@
-gradle.projectsLoaded {
- rootProject.allprojects {
- buildscript {
- repositories {
- maven{
- url "http://repo.jfrog.org/artifactory/gradle"
- }
- dependencies {
- classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.12')
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/intercom-java/build.gradle b/intercom-java/build.gradle
deleted file mode 100644
index 47243735..00000000
--- a/intercom-java/build.gradle
+++ /dev/null
@@ -1,130 +0,0 @@
-import org.ajoberstar.grgit.Grgit
-import java.text.SimpleDateFormat
-
-final publicationVersion = new Version(version)
-def rawVersion = version
-
-group = 'io.intercom'
-version = publicationVersion
-status = version.status
-ext.publish = true
-
-
-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"
- }
- }
- }
-}
-
-
-bintray {
- // gradle apslodes if the bintray* props aren't found and we never run this task in circle
- if (System.getenv('release') != null) {
- user = bintrayUser
- key = bintrayKey
- }
- publications = ['mavenJava']
- dryRun = false
- publish = project.publish
- pkg {
- repo = 'intercom-maven'
- userOrg = 'intercom'
- name = 'intercom-java'
- desc = 'Java bindings for the Intercom API'
- websiteUrl = 'https://github.com/intercom/intercom-java'
- issueTrackerUrl = 'https://github.com/intercom/intercom-java/issues'
- vcsUrl = 'https://github.com/intercom/intercom-java.git'
- licenses = ['Apache-2.0']
- labels = ['intercom', 'java', 'api']
- publicDownloadNumbers = true
- //noinspection GroovyAssignabilityCheck
- version {
- name = publicationVersion
- vcsTag = publicationVersion
- }
- }
-}
-
-ext.repo = Grgit.open(project.file('..'))
-
-task printVersion << {
- println "publication version: ${publicationVersion}"
- println "raw version: ${rawVersion}"
-}
-
-task tagRelease << {
- repo.tag.add {
- name = publicationVersion
- message = "Release of ${rawVersion}"
- }
- repo.push(tags: true)
-}
-
-/*
- export release=1 && gradle publishRelease
-*/
-task publishRelease(dependsOn: ['clean', 'tagRelease', 'bintrayUpload'])
-tagRelease.mustRunAfter clean
-bintrayUpload.mustRunAfter tagRelease
-
-
-/**
- * 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 a0630719..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Admin.java
+++ /dev/null
@@ -1,157 +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.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);
- }
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private final 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;
-
- 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;
- }
-
- @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;
- //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));
- return result;
- }
-
- @Override
- public String toString() {
- return "Admin{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", email='" + email + '\'' +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- "} " + 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 7f37a2a5..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminCollection.java
+++ /dev/null
@@ -1,45 +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.Iterator;
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-@JsonInclude(JsonInclude.Include.NON_EMPTY)
-public class AdminCollection extends TypedDataCollection implements Iterator {
- protected TypedDataCollectionIterator iterator;
-
- public AdminCollection() {
- type = "company.list";
- iterator = new TypedDataCollectionIterator(this);
- }
-
- @Override
- public AdminCollection nextPage() {
- return fetchNextPage(AdminCollection.class);
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("admins")
- @Override
- public List getPage() {
- return super.getPage();
- }
-
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- public Admin next() {
- return iterator.next();
- }
-
- public void remove() {
- iterator.remove();
- }
-
-}
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 24f253ab..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;
-
- @JsonProperty("body")
- private String body;
-
- @JsonProperty("template")
- private String template;
-
- @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 3014c88d..00000000
--- a/intercom-java/src/main/java/io/intercom/api/AdminReply.java
+++ /dev/null
@@ -1,76 +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("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("assignee_id")
- private String assigneeID;
-
- 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;
- }
-
- @Override
- public String toString() {
- return "AdminReply{} " + 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 7cfd9897..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Avatar.java
+++ /dev/null
@@ -1,60 +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;
-
- Avatar() {
- }
-
- public String getType() {
- return type;
- }
-
- public URI getImageURL() {
- return imageURL;
- }
-
- @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 773097eb..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Company.java
+++ /dev/null
@@ -1,394 +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.setSessionCount(company.getSessionCount());
- entity.setMonthlySpend(company.getMonthlySpend());
- entity.setRemoteCreatedAt(company.getRemoteCreatedAt());
- 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 Company delete(String id) throws InvalidException, AuthorizationException {
- return DataResource.delete(id, "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 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("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("plan")
- private Plan plan;
-
- @JsonProperty("user_count")
- private Integer userCount;
-
- @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 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;
- }
-
- /**
- * Deprecated. The Intercom API does not support changing the
- * session value for a company. Calling this method has no
- * effect.
- *
- * @param sessionCount this value is ignored
- * @return the company object
- */
- @Deprecated
- public Company setSessionCount(int sessionCount) {
- return this;
- }
-
- public long getRemoteCreatedAt() {
- return remoteCreatedAt;
- }
-
- public Company setRemoteCreatedAt(long remoteCreatedAt) {
- this.remoteCreatedAt = remoteCreatedAt;
- 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 (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;
-
- 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 + (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);
- return result;
- }
-
- @Override
- public String toString() {
- return "Company{" +
- "id='" + id + '\'' +
- ", name='" + name + '\'' +
- ", companyID='" + companyID + '\'' +
- ", sessionCount=" + sessionCount +
- ", monthlySpend=" + monthlySpend +
- ", remoteCreatedAt=" + remoteCreatedAt +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", plan=" + plan +
- ", customAttributes=" + customAttributes +
- ", segmentCollection=" + segmentCollection +
- ", tagCollection=" + tagCollection +
- "} " + 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 37f8019e..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CompanyCollection.java
+++ /dev/null
@@ -1,66 +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 CompanyCollection extends TypedDataCollection implements Iterator {
-
- protected TypedDataCollectionIterator iterator;
-
- @JsonProperty("total_count")
- private long totalCount;
-
- public CompanyCollection() {
- type = "company.list";
- iterator = new TypedDataCollectionIterator(this);
- }
-
- 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);
- }
-
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- public Company next() {
- return iterator.next();
- }
-
- public void remove() {
- iterator.remove();
- }
-
- @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 fd27df4a..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CompanyUpdateBuilder.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package io.intercom.api;
-
-
-import com.google.common.collect.Lists;
-
-import java.util.ArrayList;
-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 ArrayList updatableCompanies = Lists.newArrayList();
- if (add != null) {
- final List companies = add.getPage();
- for (Company company : companies) {
- 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 CompanyWithStringPlan prepareUpdatableCompany(Company company) {
- final CompanyWithStringPlan updatableCompany = new CompanyWithStringPlan();
- updatableCompany.setCompanyID(company.getCompanyID());
- updatableCompany.setName(company.getName());
- updatableCompany.setSessionCount(company.getSessionCount());
- updatableCompany.setMonthlySpend(company.getMonthlySpend());
- updatableCompany.setRemoteCreatedAt(company.getRemoteCreatedAt());
- 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 ec9175e6..00000000
--- a/intercom-java/src/main/java/io/intercom/api/CompanyWithStringPlan.java
+++ /dev/null
@@ -1,123 +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;
-
- @JsonIgnoreProperties(ignoreUnknown = false)
- @JsonProperty("custom_attributes")
- private Map customAttributes = Maps.newHashMap();
-
- @JsonProperty("remove")
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- 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 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 0b769a44..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Contact.java
+++ /dev/null
@@ -1,616 +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.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 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 {
- return DataResource.delete(c.getID(), "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.name = c.getName();
- contactUpdate.lastSeenIP = c.getLastSeenIP();
- contactUpdate.customAttributes = c.getCustomAttributes();
- 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("name")
- private String name;
-
- @JsonProperty("last_seen_ip")
- private String lastSeenIP;
-
- @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 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("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;
- }
-
- @VisibleForTesting
- 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 getUserID() {
- return userID;
- }
-
- public Avatar getAvatar() {
- return avatar;
- }
-
- 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 (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 + (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 + '\'' +
- ", 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 2dbfd123..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ContactCollection.java
+++ /dev/null
@@ -1,48 +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 implements Iterator {
-
- protected TypedDataCollectionIterator iterator;
-
- public ContactCollection() {
- iterator = new TypedDataCollectionIterator(this);
- }
-
- 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);
- }
-
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- public Contact next() {
- return iterator.next();
- }
-
- public void remove() {
- iterator.remove();
- }
-
-}
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 2fccd559..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Conversation.java
+++ /dev/null
@@ -1,337 +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 {
-
- 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 List MESSAGE_TYPES = Lists.newArrayList(
- MESSAGE_TYPE_ASSIGNMENT,
- MESSAGE_TYPE_COMMENT,
- MESSAGE_TYPE_NOTE,
- MESSAGE_TYPE_CLOSE,
- MESSAGE_TYPE_OPEN
- );
-
- 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 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 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;
- }
-
- 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 (!params.containsKey("type")) {
- throw new InvalidException("a user or admin type must be supplied for a conversation query");
- }
-
- 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("user")
- private User user;
-
- @JsonProperty("assignee")
- private Admin assignee;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("conversation_parts")
- private ConversationPartCollection conversationPartCollection;
-
- @JsonProperty("open")
- private boolean open;
-
- @JsonProperty("read")
- private boolean read;
-
- @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 User getUser() {
- return user;
- }
-
- public Admin getAssignee() {
- return assignee;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public ConversationPartCollection getConversationPartCollection() {
- return conversationPartCollection;
- }
-
- public boolean getOpen() {
- return open;
- }
-
- public boolean getRead() {
- return read;
- }
-
- @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 (assignee != null ? !assignee.equals(that.assignee) : that.assignee != null) return false;
- if (conversationMessage != null ? !conversationMessage.equals(that.conversationMessage) : that.conversationMessage != null)
- return false;
- if (conversationPartCollection != null ? !conversationPartCollection.equals(that.conversationPartCollection) : that.conversationPartCollection != 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 (!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 + (conversationMessage != null ? conversationMessage.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 + (conversationPartCollection != null ? conversationPartCollection.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 +
- ", conversationPartCollection=" + conversationPartCollection +
- ", open=" + open +
- ", read=" + read +
- ", links=" + links +
- "} " + 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 68251f0c..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationCollection.java
+++ /dev/null
@@ -1,44 +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 implements Iterator {
-
- protected TypedDataCollectionIterator iterator;
-
- public ConversationCollection() {
- type = "conversation.list";
- iterator = new TypedDataCollectionIterator(this);
- }
-
- @SuppressWarnings("EmptyMethod")
- @JsonProperty("conversations")
- public List getPage() {
- return super.getPage();
- }
-
- @Override
- public ConversationCollection nextPage() {
- return fetchNextPage(ConversationCollection.class);
- }
-
-
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- public Conversation next() {
- return iterator.next();
- }
-
- public void remove() {
- iterator.remove();
- }
-
-}
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 328a7b3b..00000000
--- a/intercom-java/src/main/java/io/intercom/api/ConversationMessage.java
+++ /dev/null
@@ -1,74 +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 ConversationMessage extends TypedData {
-
- @SuppressWarnings("FieldCanBeLocal")
- @JsonProperty("type")
- private final String type = "conversation_message";
-
- @JsonProperty
- private String subject;
-
- @JsonProperty
- private String body;
-
- @JsonProperty
- private Author author;
-
- public ConversationMessage() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public String getBody() {
- return body;
- }
-
- public Author getAuthor() {
- return author;
- }
-
- @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);
- 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;
-
- return true;
- }
-
- @Override
- public String toString() {
- return "ConversationMessage{" +
- "type='" + type + '\'' +
- ", subject='" + subject + '\'' +
- ", body='" + body + '\'' +
- ", author=" + author +
- "} " + 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/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/DataResource.java b/intercom-java/src/main/java/io/intercom/api/DataResource.java
deleted file mode 100644
index 9343069f..00000000
--- a/intercom-java/src/main/java/io/intercom/api/DataResource.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package io.intercom.api;
-
-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 C list(Map params, String collectionPath, Class c) {
- final HttpClient resource = new HttpClient(UriBuilder.newBuilder().path(collectionPath).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 41c6e250..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Event.java
+++ /dev/null
@@ -1,228 +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);
- }
-
- @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.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("user_id")
- private String userID;
-
- @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 getUserID() {
- return userID;
- }
-
- public Event setUserID(String userID) {
- this.userID = userID;
- 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;
-
- 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 + (metadata != null ? metadata.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "Event{" +
- "type='" + type + '\'' +
- ", eventName='" + eventName + '\'' +
- ", createdAt=" + createdAt +
- ", email='" + email + '\'' +
- ", userID='" + userID + '\'' +
- ", metadata=" + metadata +
- "} " + 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 e6b52bb6..00000000
--- a/intercom-java/src/main/java/io/intercom/api/HttpClient.java
+++ /dev/null
@@ -1,263 +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 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";
-
- 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 String apiKey = Intercom.getApiKey();
-
- 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);
- }
-
- 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 == 202 || responseCode == 204 || Void.class.equals(javaType.getRawClass()) || "DELETE".equals(conn.getRequestMethod());
- }
-
- private T readEntity(HttpURLConnection conn, int responseCode, JavaType javaType) throws IOException {
- final InputStream entityStream = conn.getInputStream();
- try {
- if (logger.isDebugEnabled()) {
- final String text = CharStreams.toString(new InputStreamReader(entityStream));
- logger.debug("api server response status[{}] --\n{}\n-- ", responseCode, text);
- return objectMapper.readValue(text, javaType);
- } else {
- return objectMapper.readValue(entityStream, javaType);
- }
- } finally {
- IOUtils.closeQuietly(entityStream);
- }
- }
-
- private T throwException(int responseCode, ErrorCollection errors) {
- // 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);
- } 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() {
- if (Intercom.getAuthScheme().equals(Intercom.AUTH_BEARER)) {
- headers.put("Authorization", "Bearer " + apiKey);
- } else if (Intercom.getAuthScheme().equals(Intercom.AUTH_BASIC)) {
- final String authString = Intercom.getAppID() + ":" + Intercom.getApiKey();
- headers.put("Authorization", "Basic " + Base64.encodeBase64String(authString.getBytes()));
- }
- return headers;
- }
-
- 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 75fbcc42..00000000
--- a/intercom-java/src/main/java/io/intercom/api/Intercom.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package io.intercom.api;
-
-import java.net.URI;
-
-public class Intercom {
-
- private static final URI API_BASE_URI = URI.create("https://api.intercom.io/");
-
- private static volatile URI apiBaseURI = API_BASE_URI;
-
- static final String AUTH_BASIC = "Basic";
-
- private static final String AUTH_SCHEME = AUTH_BASIC;
-
- static final String AUTH_BEARER = "Bearer";
-
- private static final String VERSION = "1.3.0";
-
- public static final String USER_AGENT = "intercom-java/" + Intercom.VERSION;
-
- private static volatile String apiKey;
-
- private static volatile String appID;
-
- private static volatile int connectionTimeout = 3 * 1000;
-
- private static volatile int requestTimeout = 60 * 1000;
-
- private static volatile boolean requestUsingCaches = false;
-
- private static volatile HttpConnectorSupplier httpConnectorSupplier = HttpConnectorSupplier.defaultSupplier;
-
- public static long currentTimestamp() {
- return System.currentTimeMillis()/1000;
- }
-
- public static int getConnectionTimeout() {
- return connectionTimeout;
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public static void setConnectionTimeout(int connectionTimeout) {
- Intercom.connectionTimeout = connectionTimeout;
- }
-
- public static int getRequestTimeout() {
- return requestTimeout;
- }
-
- @SuppressWarnings("UnusedDeclaration")
- public static void setRequestTimeout(int requestTimeout) {
- Intercom.requestTimeout = requestTimeout;
- }
-
- public static boolean isRequestUsingCaches() {
- return requestUsingCaches;
- }
-
- public static void setRequestUsingCaches(boolean requestUsingCaches) {
- Intercom.requestUsingCaches = requestUsingCaches;
- }
-
- public static HttpConnectorSupplier getHttpConnectorSupplier() {
- return httpConnectorSupplier;
- }
-
- public static void setHttpConnectorSupplier(HttpConnectorSupplier supplier) {
- Intercom.httpConnectorSupplier = supplier;
- }
-
- public static String getAppID() {
- return appID;
- }
-
- public static void setAppID(String appID) {
- Intercom.appID = appID;
- }
-
- public static String getApiKey() {
- return Intercom.apiKey;
- }
-
- public static void setApiKey(String apiKey) {
- Intercom.apiKey = apiKey;
- }
-
- public static URI getApiBaseURI() {
- return Intercom.apiBaseURI;
- }
-
- public static void setApiBaseURI(URI apiBaseURI) {
- Intercom.apiBaseURI = apiBaseURI;
- }
-
- static String getAuthScheme() {
- return AUTH_SCHEME;
- }
-
-}
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 listJobErrorFeed(String jobID, Class c)
- throws AuthorizationException, ClientException, ServerException, InvalidException, RateLimitException {
- final URI feedURI = UriBuilder.newBuilder()
- .path("jobs")
- .path(jobID)
- .path("error")
- .build();
- final HttpClient resource = new HttpClient(feedURI);
- final TypeReference> typeReference =
- new TypeReference>() {
- };
-
- final JavaType type = MapperSupport
- .objectMapper()
- .getTypeFactory()
- .constructParametricType(JobItemCollection.class, c);
- return resource.get(type);
- }
-
-
- @JsonProperty("type")
- private final String type = "job";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("app_id")
- private String appID;
-
- @JsonProperty("created_at")
- private long createdAt;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("completed_at")
- private long completedAt;
-
- @JsonProperty("closing_at")
- private long closingAt;
-
- @JsonProperty("name")
- private String name;
-
- @JsonProperty("state")
- private String state;
-
- @JsonProperty("tasks")
- private List tasks;
-
- @JsonProperty("links")
- private Map links;
-
- public Job() {
- }
-
- public String getType() {
- return type;
- }
-
- public String getID() {
- return id;
- }
-
- public Job setID(String id) {
- this.id = id;
- return this;
- }
-
- public long getCreatedAt() {
- return createdAt;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public long getCompletedAt() {
- return completedAt;
- }
-
- public String getName() {
- return name;
- }
-
- public Job setName(String name) {
- this.name = name;
- return this;
- }
-
- public String getState() {
- return state;
- }
-
- public String getAppID() {
- return appID;
- }
-
- public Map getLinks() {
- return links;
- }
-
- public long getClosingAt() {
- return closingAt;
- }
-
- public Job setClosingAt(long closingAt) {
- this.closingAt = closingAt;
- return this;
- }
-
- public List getTasks() {
- return tasks;
- }
-
- @Override
- public String toString() {
- return "Job{" +
- "type='" + type + '\'' +
- ", id='" + id + '\'' +
- ", appID='" + appID + '\'' +
- ", createdAt=" + createdAt +
- ", updatedAt=" + updatedAt +
- ", completedAt=" + completedAt +
- ", name='" + name + '\'' +
- ", state='" + state + '\'' +
- ", links=" + links +
- "} " + super.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- Job job = (Job) o;
-
- if (createdAt != job.createdAt) return false;
- if (updatedAt != job.updatedAt) return false;
- if (completedAt != job.completedAt) return false;
- //noinspection ConstantConditions
- if (type != null ? !type.equals(job.type) : job.type != null) return false;
- if (id != null ? !id.equals(job.id) : job.id != null) return false;
- if (appID != null ? !appID.equals(job.appID) : job.appID != null) return false;
- if (name != null ? !name.equals(job.name) : job.name != null) return false;
- //noinspection SimplifiableIfStatement
- if (state != null ? !state.equals(job.state) : job.state != null) return false;
- return !(links != null ? !links.equals(job.links) : job.links != null);
-
- }
-
- @Override
- public int hashCode() {
- @SuppressWarnings("ConstantConditions") int result = type != null ? type.hashCode() : 0;
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (appID != null ? appID.hashCode() : 0);
- result = 31 * result + (int) (createdAt ^ (createdAt >>> 32));
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (int) (completedAt ^ (completedAt >>> 32));
- result = 31 * result + (name != null ? name.hashCode() : 0);
- result = 31 * result + (state != null ? state.hashCode() : 0);
- result = 31 * result + (links != null ? links.hashCode() : 0);
- return result;
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/JobItem.java b/intercom-java/src/main/java/io/intercom/api/JobItem.java
deleted file mode 100644
index 7afdf955..00000000
--- a/intercom-java/src/main/java/io/intercom/api/JobItem.java
+++ /dev/null
@@ -1,130 +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 JobItem extends TypedData {
-
- @JsonProperty("type")
- private final String type = "job_item";
-
- @JsonProperty("id")
- private String id;
-
- @JsonProperty("updated_at")
- private long updatedAt;
-
- @JsonProperty("method")
- private String method;
-
- @JsonProperty("data_type")
- private String dataType;
-
- @JsonProperty("error")
- private Error error;
-
- @JsonProperty("data")
- private T data;
-
- public JobItem() {
- }
-
- public JobItem(String method, T data) {
- checkNotNull(method, data);
- this.method = method;
- this.data = data;
- this.dataType = data.getType();
- }
-
- private void checkNotNull(String method, T data) {
- Conditions.checkNotNull(method, "item method must be supplied");
- Conditions.checkNotNull(data, "item data must be supplied");
- }
-
- public String getType() {
- return type;
- }
-
- public String getID() {
- return id;
- }
-
- public long getUpdatedAt() {
- return updatedAt;
- }
-
- public String getMethod() {
- return method;
- }
-
- public JobItem setMethod(String method) {
- this.method = method;
- return this;
- }
-
- public Error getError() {
- return error;
- }
-
- public T getData() {
- return data;
- }
-
- public JobItem setData(T data) {
- this.data = data;
- return this;
- }
-
- public String getDataType() {
- return dataType;
- }
-
- @Override
- public String toString() {
- return "JobItem{" +
- "type='" + type + '\'' +
- ", id='" + id + '\'' +
- ", updatedAt=" + updatedAt +
- ", method='" + method + '\'' +
- ", dataType='" + dataType + '\'' +
- ", error=" + error +
- ", data=" + data +
- "} " + super.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- JobItem> jobItem = (JobItem>) o;
-
- if (updatedAt != jobItem.updatedAt) return false;
- //noinspection ConstantConditions
- if (type != null ? !type.equals(jobItem.type) : jobItem.type != null) return false;
- if (id != null ? !id.equals(jobItem.id) : jobItem.id != null) return false;
- if (method != null ? !method.equals(jobItem.method) : jobItem.method != null) return false;
- if (dataType != null ? !dataType.equals(jobItem.dataType) : jobItem.dataType != null) return false;
- //noinspection SimplifiableIfStatement
- if (error != null ? !error.equals(jobItem.error) : jobItem.error != null) return false;
- return !(data != null ? !data.equals(jobItem.data) : jobItem.data != null);
-
- }
-
- @Override
- public int hashCode() {
- @SuppressWarnings("ConstantConditions") int result = type != null ? type.hashCode() : 0;
- result = 31 * result + (id != null ? id.hashCode() : 0);
- result = 31 * result + (int) (updatedAt ^ (updatedAt >>> 32));
- result = 31 * result + (method != null ? method.hashCode() : 0);
- result = 31 * result + (dataType != null ? dataType.hashCode() : 0);
- result = 31 * result + (error != null ? error.hashCode() : 0);
- result = 31 * result + (data != null ? data.hashCode() : 0);
- return result;
- }
-}
diff --git a/intercom-java/src/main/java/io/intercom/api/JobItemCollection.java b/intercom-java/src/main/java/io/intercom/api/JobItemCollection.java
deleted file mode 100644
index 52d841b2..00000000
--- a/intercom-java/src/main/java/io/intercom/api/JobItemCollection.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.Iterator;
-import java.util.List;
-
-@SuppressWarnings("UnusedDeclaration")
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class JobItemCollection
- extends TypedDataCollection>
- implements Iterator> {
-
- protected TypedDataCollectionIterator