diff --git a/.codeclimate.yml b/.codeclimate.yml
deleted file mode 100644
index c84b2ee..0000000
--- a/.codeclimate.yml
+++ /dev/null
@@ -1,88 +0,0 @@
-# This is a sample .codeclimate.yml configured for Engine analysis on Code
-# Climate Platform. For an overview of the Code Climate Platform, see here:
-# http://docs.codeclimate.com/article/300-the-codeclimate-platform
-
-# Under the engines key, you can configure which engines will analyze your repo.
-# Each key is an engine name. For each value, you need to specify enabled: true
-# to enable the engine as well as any other engines-specific configuration.
-
-# For more details, see here:
-# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
-
-# For a list of all available engines, see here:
-# http://docs.codeclimate.com/article/296-engines-available-engines
-
-#engines:
-# to turn on an engine, add it here and set enabled to `true`
-# to turn off an engine, set enabled to `false` or remove it
-# rubocop:
-# enabled: true
-# golint:
-# enabled: true
-# gofmt:
-# enabled: true
-# eslint:
-# enabled: true
-# csslint:
-# enabled: true
-
-# Engines can analyze files and report issues on them, but you can separately
-# decide which files will receive ratings based on those issues. This is
-# specified by path patterns under the ratings key.
-
-# For more details see here:
-# http://docs.codeclimate.com/article/289-configuring-your-repository-via-codeclimate-yml#platform
-
-# ratings:
-# paths:
-# - app/**
-# - lib/**
-# - "**.rb"
-# - "**.go"
-
-# You can globally exclude files from being analyzed by any engine using the
-# exclude_paths key.
-
-#All maintainability checks are enabled by default with the following configurations.
-#checks,
-# argument-count:
-# config:
-# threshold: 4
-# complex-logic:
-# config:
-# threshold: 4
-# file-lines:
-# config:
-# threshold: 250
-# method-complexity:
-# config:
-# threshold: 5
-# method-count:
-# config:
-# threshold: 20
-# method-lines:
-# config:
-# threshold: 25
-# nested-control-flow:
-# config:
-# threshold: 4
-# return-statements:
-# config:
-# threshold: 4
-# similar-code:
-# config:
-# threshold: # language-specific defaults. an override will affect all languages.
-# identical-code:
-# config:
-# threshold: # language-specific defaults. an override will affect all languages.
-
-engines:
- sonar-java:
- enabled: true
- channel: beta
-
-exclude_paths:
-- "scripts/"
-- ".github/"
-- "gradle/"
-- "**/test/"
\ No newline at end of file
diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE
deleted file mode 100644
index 5588c7f..0000000
--- a/.github/ISSUE_TEMPLATE
+++ /dev/null
@@ -1,17 +0,0 @@
-#### Issue Summary
-
-A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, code examples.
-
-
-#### Steps to Reproduce
-
-1. This is the first step
-2. This is the second step
-3. Further steps, etc.
-
-Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?
-
-#### Technical details:
-
-* java-http-client Version: master (latest commit: [commit number])
-* Java Version: X.X
diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE
deleted file mode 100644
index 7ad590b..0000000
--- a/.github/PULL_REQUEST_TEMPLATE
+++ /dev/null
@@ -1,24 +0,0 @@
-
-# Fixes #
-
-### Checklist
-- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
-- [ ] I have read the [Contribution Guide] and my PR follows them.
-- [ ] I updated my branch with the master branch.
-- [ ] I have added tests that prove my fix is effective or that my feature works
-- [ ] I have added necessary documentation about the functionality in the appropriate .md file
-- [ ] I have added in line documentation to the code I modified
-
-### Short description of what this PR does:
--
--
-
-If you have questions, please send an email to [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository.
diff --git a/.github/workflows/pr-lint.yml b/.github/workflows/pr-lint.yml
new file mode 100644
index 0000000..2f5232b
--- /dev/null
+++ b/.github/workflows/pr-lint.yml
@@ -0,0 +1,15 @@
+name: Lint PR
+on:
+ pull_request_target:
+ types: [ opened, edited, synchronize, reopened ]
+
+jobs:
+ validate:
+ name: Validate title
+ runs-on: ubuntu-latest
+ steps:
+ - uses: amannn/action-semantic-pull-request@v4
+ with:
+ types: chore docs fix feat test misc
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml
new file mode 100644
index 0000000..9abc8c2
--- /dev/null
+++ b/.github/workflows/test-and-deploy.yml
@@ -0,0 +1,93 @@
+name: Test and Deploy
+on:
+ push:
+ branches: [ '*' ]
+ tags: [ '*' ]
+ pull_request:
+ branches: [ main ]
+ schedule:
+ # Run automatically at 8AM PST Monday-Friday
+ - cron: '0 15 * * 1-5'
+ workflow_dispatch:
+
+jobs:
+ test:
+ name: Test
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ strategy:
+ matrix:
+ java: [ 8, 11, 17 ]
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Java
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'temurin'
+ java-version: ${{ matrix.java }}
+ cache: 'maven'
+
+ - run: mvn install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
+ - name: Run Unit Tests
+ run: mvn test -B
+
+ deploy:
+ name: Deploy
+ if: success() && github.ref_type == 'tag'
+ needs: [ test ]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+
+ - name: Set up Sonatype Maven
+ uses: actions/setup-java@v2
+ with:
+ java-version: 8
+ distribution: temurin
+ server-id: ossrh
+ server-username: MAVEN_USERNAME
+ server-password: MAVEN_PASSWORD
+ gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
+ gpg-passphrase: GPG_PASSPHRASE
+
+ - name: Install Dependencies
+ run: make install
+
+ - name: Create GitHub Release
+ uses: sendgrid/dx-automator/actions/release@main
+ with:
+ assets: java-http-client.jar
+ footer: '**[Maven](https://mvnrepository.com/artifact/com.sendgrid/java-http-client/${version})**'
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Publish to Maven
+ env:
+ MAVEN_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
+ MAVEN_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
+ GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
+ run: mvn clean deploy -DskipTests=true -B -U -Prelease
+
+ - name: Submit metric to Datadog
+ uses: sendgrid/dx-automator/actions/datadog-release-metric@main
+ env:
+ DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
+
+ notify-on-failure:
+ name: Slack notify on failure
+ if: failure() && github.event_name != 'pull_request' && (github.ref == 'refs/heads/main' || github.ref_type == 'tag')
+ needs: [ test, deploy ]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: rtCamp/action-slack-notify@v2
+ env:
+ SLACK_COLOR: failure
+ SLACK_ICON_EMOJI: ':github:'
+ SLACK_MESSAGE: ${{ format('Test *{0}*, Deploy *{1}*, {2}/{3}/actions/runs/{4}', needs.test.result, needs.deploy.result, github.server_url, github.repository, github.run_id) }}
+ SLACK_TITLE: Action Failure - ${{ github.repository }}
+ SLACK_USERNAME: GitHub Actions
+ SLACK_MSG_AUTHOR: twilio-dx
+ SLACK_FOOTER: Posted automatically using GitHub Actions
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
+ MSG_MINIMAL: true
diff --git a/.github/workflows/update-dependencies.yml b/.github/workflows/update-dependencies.yml
new file mode 100644
index 0000000..35ec8ed
--- /dev/null
+++ b/.github/workflows/update-dependencies.yml
@@ -0,0 +1,60 @@
+name: Update dependencies
+on:
+ schedule:
+ # Run automatically at 7AM PST Tuesday
+ - cron: '0 14 * * 2'
+ workflow_dispatch:
+
+jobs:
+ update-dependencies-and-test:
+ name: Update Dependencies & Test
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ strategy:
+ max-parallel: 1
+ matrix:
+ java: [ 8, 11, 17 ]
+
+ steps:
+ - name: Checkout java-http-client
+ uses: actions/checkout@v2
+
+ - name: Set up Java
+ uses: actions/setup-java@v2
+ with:
+ distribution: 'temurin'
+ java-version: ${{ matrix.java }}
+ cache: 'maven'
+
+ - name: Updating semver dependencies
+ run: make update-deps
+
+ - run: mvn install -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
+
+ - name: Add & Commit
+ if: matrix.java == '17'
+ uses: EndBug/add-and-commit@v8.0.2
+ env:
+ GITHUB_TOKEN: ${{ secrets.SG_JAVA_GITHUB_TOKEN }}
+ with:
+ add: 'pom.xml'
+ default_author: 'github_actions'
+ message: 'chore: update java-http-client dependencies'
+
+ notify-on-failure:
+ name: Slack notify on failure
+ if: failure()
+ needs: [ update-dependencies-and-test ]
+ runs-on: ubuntu-latest
+ steps:
+ - uses: rtCamp/action-slack-notify@v2
+ env:
+ SLACK_COLOR: failure
+ SLACK_ICON_EMOJI: ':github:'
+ SLACK_MESSAGE: ${{ format('Update dependencies *{0}*, {1}/{2}/actions/runs/{3}', needs.update-dependencies-and-test.result, github.server_url, github.repository, github.run_id) }}
+ SLACK_TITLE: Action Failure - ${{ github.repository }}
+ SLACK_USERNAME: GitHub Actions
+ SLACK_MSG_AUTHOR: twilio-dx
+ SLACK_FOOTER: Posted automatically using GitHub Actions
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
+ MSG_MINIMAL: true
diff --git a/.gitignore b/.gitignore
index d7feea8..4268a51 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,9 +16,18 @@ gradle.properties
.gradle
repo/
+# VSCode IDE
+.vscode
+
# JetBrains IDEs
*.iml
**/.idea/
/.settings/
/.classpath
/.project
+/bin
+
+# Environment files
+.env/*.*
+
+java-http-client.jar
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d0c473e..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,26 +0,0 @@
-language: java
-jdk:
-- oraclejdk8
-- openjdk8
-before_script:
-- chmod a+x gradlew
-script:
-- ./gradlew build check
-after_script:
-- "./scripts/s3upload.sh"
-env:
- global:
- - S3_POLICY: ewogICJleHBpcmF0aW9uIjogIjIxMDAtMDEtMDFUMTI6MDA6MDAuMDAwWiIsCiAgImNvbmRpdGlvbnMiOiBbCiAgICB7ImFjbCI6ICJwdWJsaWMtcmVhZCIgfSwKICAgIHsiYnVja2V0IjogInNlbmRncmlkLW9wZW4tc291cmNlIiB9LAogICAgWyJzdGFydHMtd2l0aCIsICIka2V5IiwgInNlbmRncmlkLWphdmEvIl0sCiAgICBbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwgMjA0OCwgMjY4NDM1NDU2XSwKICAgIFsiZXEiLCAiJENvbnRlbnQtVHlwZSIsICJhcHBsaWNhdGlvbi96aXAiXQogIF0KfQo=
- - secure: Iki1btwhG1nlyjnEMu90Oh/hoatFpPiiKkqpj7siLnlLp2xbBQ2003jRsn30I3Vujes2ugvzdlHqBJ9lDwRvfGrKXcLlRvYuDQ24N2YKquEiKHUxs+iMOzTQj6Sf64KL5O0aSZd1l5rjWgsQ0qqjHW9u3l5bUjqxzrhAI2Js37U=
- - secure: Khi6a4z1lfZmDEDV738MOiWznRcTv5ILZUM+igEw2txX7PGX+B5909WridpAijTGiurJ6eda7jvsUgci8DTPQCXB18LD6N870hnPcSQkuI6zDAhKTx+w/ZsfPLWh28sP2CVzbqGdxaitZDKxRWaVmKnBZpyi8XI9UKjmyK2sjwE=
- - secure: wKXAjjBgCLM4h++nP1xDQQtYU10JbwwynY0XB920SoQjI2Uu82cMPtkEXFWTpzyIS2hE5B3qvu75VHNdLqDUtek3e3lBg5k3SpYgGin20dg3SDEJrvA4vlvcApdQ132pMEWdDOVwzbXhm9+JTjALYbc3fX+VAQX1u5daPyeDGC4=
-notifications:
- hipchat:
- rooms:
- secure: j/23RY7nDWHMrpIcZiiwH3ORsWnmkZrMWKfv761RnJviYBQJy1cDEmvsyZy5w2AlE1w+CLNm+G7SI35N2eKZqtked+pWcx3nBN+bVmt7uRXmj16Oc5x2ztX6QWs3xFtUfGiA8t17q/LGRZlw9SiNI+SbP2wBHDJl66+KZWTppjbcmz/Rdax2OKj843Zx92bqsdAOjsdfwFm3B4isHQjE6hoS9u0MtIQ4KpkX4xOTJSF/r0RpIYWI37E41dDmdjLWIsYnj01P9dI+IQLN5OIfsaVQGWLVV9YkHjsEzOspJHBz8Mf40ADY76Exm/V+phRS2Q4tmAsAPXQ9lchS3uooat9z3RlfSxfIhVbjxTDLN7E/PMXCYAMKRU2FUqDYQoX3qSZBT9717Agz84T15S7l4g009bzzTgoHVpJjHVhNCRR1hWfaWFj7oRi8s0BDhQCclZ0ug+s//29LQWViSOvK7/prhJJwqDOD+GciVE4VDe1NFj7vhDTuIoWYU87D8zuZadLMz2jz1w67Oa1jJ1Ok64iFTqBS9AKQAfPKeQq9dZQ4SKMlS1Zyr8Y013ebp8CG01I8TZYQiBdbyhzYkAVSaz4x+Qh3n6WPJLJA0FUuQFcn3p1UQS/I16U2253F7w5t+7wU2DMj8k8k7ZN373FZc1ZWngX5ljR6nMoJNR73opg=
- template:
- - '%{repository}
- Build %{build_number} on branch %{branch} by %{author}: %{message}
- View on GitHub'
- format: html
- notify: true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfd40b5..e4a94c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,7 +3,130 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
-## [4.2.0] - 2017-10-30
+[2022-05-18] Version 4.5.1
+--------------------------
+**Library - Docs**
+- [PR #144](https://github.com/sendgrid/java-http-client/pull/144): Update to align with SendGrid Support. Thanks to [@garethpaul](https://github.com/garethpaul)!
+
+**Library - Fix**
+- [PR #143](https://github.com/sendgrid/java-http-client/pull/143): override default gh token. Thanks to [@beebzz](https://github.com/beebzz)!
+
+
+[2022-03-09] Version 4.5.0
+--------------------------
+**Library - Chore**
+- [PR #142](https://github.com/sendgrid/java-http-client/pull/142): push Datadog Release Metric upon deploy success. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
+
+**Library - Feature**
+- [PR #141](https://github.com/sendgrid/java-http-client/pull/141): add GH action to update dependencies. Thanks to [@JenniferMah](https://github.com/JenniferMah)!
+
+
+[2022-02-09] Version 4.4.0
+--------------------------
+**Library - Chore**
+- [PR #139](https://github.com/sendgrid/java-http-client/pull/139): upgrade supported language versions. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
+- [PR #138](https://github.com/sendgrid/java-http-client/pull/138): add gh release to workflow. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
+- [PR #137](https://github.com/sendgrid/java-http-client/pull/137): merge test and deploy workflows. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
+
+**Library - Feature**
+- [PR #134](https://github.com/sendgrid/java-http-client/pull/134): Support multiple duplicate queryparams. Thanks to [@mjjs](https://github.com/mjjs)!
+
+
+[2022-01-12] Version 4.3.9
+--------------------------
+**Library - Chore**
+- [PR #136](https://github.com/sendgrid/java-http-client/pull/136): update license year. Thanks to [@JenniferMah](https://github.com/JenniferMah)!
+
+
+[2021-12-01] Version 4.3.8
+--------------------------
+**Library - Chore**
+- [PR #135](https://github.com/sendgrid/java-http-client/pull/135): fix pom for release. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
+- [PR #133](https://github.com/sendgrid/java-http-client/pull/133): migrate to github actions. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
+
+
+[2021-05-19] Version 4.3.7
+--------------------------
+**Library - Chore**
+- [PR #131](https://github.com/sendgrid/java-http-client/pull/131): Bump org.apache.httpcomponents.httpclient from 4.5.12 to 4.5.13. Thanks to [@akunzai](https://github.com/akunzai)!
+
+
+[2020-08-19] Version 4.3.6
+--------------------------
+**Library - Chore**
+- [PR #128](https://github.com/sendgrid/java-http-client/pull/128): update GitHub branch references to use HEAD. Thanks to [@thinkingserious](https://github.com/thinkingserious)!
+
+**Library - Docs**
+- [PR #97](https://github.com/sendgrid/java-http-client/pull/97): Correcting *.md files using Grammarly. Thanks to [@pushkyn](https://github.com/pushkyn)!
+- [PR #101](https://github.com/sendgrid/java-http-client/pull/101): Add first timers file. Thanks to [@Varpie](https://github.com/Varpie)!
+
+
+[2020-08-05] Version 4.3.5
+--------------------------
+**Library - Docs**
+- [PR #86](https://github.com/sendgrid/java-http-client/pull/86): Moved usage and enviorment variables to USAGE.md. Thanks to [@rareinator](https://github.com/rareinator)!
+
+
+[2020-07-22] Version 4.3.4
+--------------------------
+**Library - Fix**
+- [PR #109](https://github.com/sendgrid/java-http-client/pull/109): correct the LICENSE.md link in pom.xml. Thanks to [@crweiner](https://github.com/crweiner)!
+
+**Library - Docs**
+- [PR #108](https://github.com/sendgrid/java-http-client/pull/108): Create a Use Cases Directory. Thanks to [@ajloria](https://github.com/ajloria)!
+
+
+[2020-03-04] Version 4.3.3
+--------------------------
+**Library - Chore**
+- [PR #127](https://github.com/sendgrid/java-http-client/pull/127): fix JDK Travis failures. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
+
+
+[2020-02-19] Version 4.3.2
+--------------------------
+**Library - Chore**
+- [PR #111](https://github.com/sendgrid/java-http-client/pull/111): Update the Client file documentation. Thanks to [@vinifarias](https://github.com/vinifarias)!
+
+
+[2020-02-05] Version 4.3.1
+--------------------------
+**Library - Docs**
+- [PR #126](https://github.com/sendgrid/java-http-client/pull/126): baseline all the templated markdown docs. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
+
+
+[2020-02-01] Version 4.3.0
+--------------------------
+**Library - Feature**
+- [PR #25](https://github.com/sendgrid/java-http-client/pull/25): do not close or manage lifecycle of http-client passed in. Thanks to [@maxxedev](https://github.com/maxxedev)!
+- [PR #34](https://github.com/sendgrid/java-http-client/pull/34): Add close method to Client. Thanks to [@tsuyoshizawa](https://github.com/tsuyoshizawa)!
+- [PR #67](https://github.com/sendgrid/java-http-client/pull/67): Adding Docker support. Thanks to [@mithunsasidharan](https://github.com/mithunsasidharan)!
+
+**Library - Fix**
+- [PR #26](https://github.com/sendgrid/java-http-client/pull/26): use .equals to compare strings. Thanks to [@maxxedev](https://github.com/maxxedev)!
+- [PR #36](https://github.com/sendgrid/java-http-client/pull/36): No longer throwing IOExceptions on non 2xx response codes. Thanks to [@andy-trimble](https://github.com/andy-trimble)!
+- [PR #77](https://github.com/sendgrid/java-http-client/pull/77): Closes #72 Update Example.java. Thanks to [@AbdulDroid](https://github.com/AbdulDroid)!
+
+**Library - Chore**
+- [PR #54](https://github.com/sendgrid/java-http-client/pull/54): Added example file, updated .gitignore and README. Thanks to [@dhsrocha](https://github.com/dhsrocha)!
+- [PR #58](https://github.com/sendgrid/java-http-client/pull/58): added .codeclimate,yml for codeclimate run. Thanks to [@skshelar](https://github.com/skshelar)!
+- [PR #73](https://github.com/sendgrid/java-http-client/pull/73): Fixes #71. Thanks to [@huytranrjc](https://github.com/huytranrjc)!
+- [PR #76](https://github.com/sendgrid/java-http-client/pull/76): Update travis - add codecov. Thanks to [@pushkyn](https://github.com/pushkyn)!
+- [PR #92](https://github.com/sendgrid/java-http-client/pull/92): update LICENSE - bump year. Thanks to [@pushkyn](https://github.com/pushkyn)!
+- [PR #115](https://github.com/sendgrid/java-http-client/pull/115): add [openjdk11] to Travis build. Thanks to [@sullis](https://github.com/sullis)!
+- [PR #117](https://github.com/sendgrid/java-http-client/pull/117): Update transitive dependencies. Thanks to [@kebeda](https://github.com/kebeda)!
+- [PR #123](https://github.com/sendgrid/java-http-client/pull/123): prep the repo for automated releases. Thanks to [@eshanholtz](https://github.com/eshanholtz)!
+
+**Library - Docs**
+- [PR #59](https://github.com/sendgrid/java-http-client/pull/59): Typos in CONTRIBUTING.md. Thanks to [@rkaranam](https://github.com/rkaranam)!
+- [PR #113](https://github.com/sendgrid/java-http-client/pull/113): Add our Developer Experience Engineer career opportunity to the READM…. Thanks to [@mptap](https://github.com/mptap)!
+
+**Library - Test**
+- [PR #66](https://github.com/sendgrid/java-http-client/pull/66): Test to check year in license file. Thanks to [@pushkyn](https://github.com/pushkyn)!
+- [PR #93](https://github.com/sendgrid/java-http-client/pull/93): removed tests that were testing for files that didnt exist, bumped gradle version to 4.10.2. Thanks to [@Strum355](https://github.com/Strum355)!
+
+
+[2017-10-30] Version 4.2.0
+---------------------------
### Added
- [Pull #22](https://github.com/sendgrid/java-http-client/pull/22): Allow setting both `apache http client` and `test` parameters
- BIG thanks to [Maxim Novak](https://github.com/maximn) for the pull request!
@@ -22,14 +145,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### BREAKING Change
- [Pull #14](https://github.com/sendgrid/java-http-client/pull/14): Make response have private variables
- Fixed [Issue #12](https://github.com/sendgrid/java-http-client/issues/12): The public Response variables should be private
-- The breaking change is that variables that were public are now private and accessable only via getters and setters
+- The breaking change is that variables that were public are now private and accessible only via getters and setters
- BIG thanks to [Diego Camargo](https://github.com/belfazt) for the pull request!
## [3.0.0] - 2016-10-06
### BREAKING Change
- [Pull #15](https://github.com/sendgrid/java-http-client/pull/15): Update the request object with sensible defaults and access methods
- Fixes [Issue #13](https://github.com/sendgrid/java-http-client/issues/13): Update the Request object with sensible defaults and access methods
-- The breaking change is that variables that were public are now private and accessable only via getters and setters
+- The breaking change is that variables that were public are now private and accessible only via getters and setters
- BIG thanks to [Diego Camargo](https://github.com/belfazt) for the pull request!
## [2.3.4] - 2016-08-09
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index e3ce656..2f0727e 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,41 +1,73 @@
-# SendGrid Community Code of Conduct
+# Contributor Covenant Code of Conduct
-The SendGrid open source community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences successes and continued growth. When you're working with members of the community, we encourage you to follow these guidelines, which help steer our interactions and strive to maintain a positive, successful and growing community.
+## Our Pledge
-### Be Open
-Members of the community are open to collaboration, whether it's on pull requests, code reviews, approvals, issues or otherwise. We're receptive to constructive comments and criticism, as the experiences and skill sets of all members contribute to the whole of our efforts. We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate, and everyone can make a difference.
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, sex characteristics, gender identity and expression,
+level of experience, education, socio-economic status, nationality, personal
+appearance, race, religion, or sexual identity and orientation.
-### Be Considerate
-Members of the community are considerate of their peers, which include other contributors and users of SendGrid. We're thoughtful when addressing the efforts of others, keeping in mind that often the labor was completed with the intent of the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.
+## Our Standards
-### Be Respectful
-Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments and their efforts. We're respectful of the volunteer efforts that permeate the SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.
+Examples of behavior that contributes to creating a positive environment
+include:
-## Additional Guidance
+- Using welcoming and inclusive language
+- Being respectful of differing viewpoints and experiences
+- Gracefully accepting constructive criticism
+- Focusing on what is best for the community
+- Showing empathy towards other community members
-### Disclose Potential Conflicts of Interest
-Community discussions often involve interested parties. We expect participants to be aware when they are conflicted due to employment or other projects they are involved in and disclose those interests to other project members. When in doubt, over-disclose. Perceived conflicts of interest are important to address so that the community’s decisions are credible even when unpopular, difficult or favorable to the interests of one group over another.
+Examples of unacceptable behavior by participants include:
-### Interpretation
-This Code is not exhaustive or complete. It is not a rulebook; it serves to distill our common understanding of a collaborative, shared environment and goals. We expect it to be followed in spirit as much as in the letter. When in doubt, try to abide by [SendGrid’s cultural values](https://sendgrid.com/blog/employee-engagement-the-4h-way) defined by our “4H’s”: Happy, Hungry, Humble and Honest.
+- The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+- Trolling, insulting/derogatory comments, and personal or political attacks
+- Public or private harassment
+- Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+- Other conduct which could reasonably be considered inappropriate in a
+ professional setting
-### Enforcement
-Most members of the SendGrid community always comply with this Code, not because of the existence of this Code, but because they have long experience participating in open source communities where the conduct described above is normal and expected. However, failure to observe this Code may be grounds for suspension, reporting the user for abuse or changing permissions for outside contributors.
+## Our Responsibilities
-## If you have concerns about someone’s conduct
-**Initiate Direct Contact** - It is always appropriate to email a community member (if contact information is available), mention that you think their behavior was out of line, and (if necessary) point them to this Code.
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
-**Discuss Publicly** - Discussing publicly is always acceptable. Note, though, that approaching the person directly may be better, as it tends to make them less defensive, and it respects the time of other community members, so you probably want to try direct contact first.
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
-**Contact the Moderators** - You can reach the SendGrid moderators by emailing dx@sendgrid.com.
+## Scope
-## Submission to SendGrid Repositories
-Finally, just a reminder, changes to the SendGrid repositories will only be accepted upon completion of the [SendGrid Contributor Agreement](https://cla.sendgrid.com).
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+## Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at open-source@twilio.com. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
## Attribution
-SendGrid thanks the following, on which it draws for content and inspiration:
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
-* [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/)
-* [Open Source Initiative General Code of Conduct](https://opensource.org/codeofconduct)
-* [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html)
\ No newline at end of file
+[homepage]: https://www.contributor-covenant.org
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f082369..ff28f44 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,57 +1,11 @@
-Hello! Thank you for choosing to help contribute to one of the SendGrid open source projects. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies.
+Hello! Thank you for choosing to help contribute to one of the SendGrid open source projects. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies.
-- [CLAs and CCLAs](#cla)
-- [Roadmap & Milestones](#roadmap)
-- [Feature Request](#feature-request)
-- [Submit a Bug Report](#submit-a-bug-report)
- [Improvements to the Codebase](#improvements-to-the-codebase)
- [Understanding the Code Base](#understanding-the-codebase)
- [Testing](#testing)
- [Style Guidelines & Naming Conventions](#style-guidelines-and-naming-conventions)
- [Creating a Pull Request](#creating-a-pull-request)
-
-
-We use [Milestones](https://github.com/sendgrid/java-http-client/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
-
-
-## CLAs and CCLAs
-
-Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) be filled out by every contributor to a SendGrid open source project.
-
-Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution.
-
-SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA. Copies of the CLA are available [here](https://gist.github.com/SendGridDX/98b42c0a5d500058357b80278fde3be8#file-sendgrid_cla).
-
-When you create a Pull Request, after a few seconds, a comment will appear with a link to the CLA. Click the link and fill out the brief form and then click the "I agree" button and you are all set. You will not be asked to re-sign the CLA unless we make a change.
-
-There are a few ways to contribute, which we'll enumerate below:
-
-
-## Feature Request
-
-If you'd like to make a feature request, please read this section.
-
-The GitHub issue tracker is the preferred channel for library feature requests, but please respect the following restrictions:
-
-- Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests.
-- Please be respectful and considerate of others when commenting on issues
-
-
-## Submit a Bug Report
-
-Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
-
-A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report.
-
-Before you decide to create a new issue, please try the following:
-
-1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post.
-2. Update to the latest version of this code and check if issue has already been fixed
-3. Copy and fill in the Bug Report Template we have provided below
-
-### Please use our Bug Report Template
-
-In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/java-http-client/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
+- [Code Reviews](#code-reviews)
## Improvements to the Codebase
@@ -64,8 +18,8 @@ We welcome direct contributions to the java-http-client code base. Thank you!
##### Prerequisites #####
-- Java version Oracle JDK 8 or OpenJDK 7
-- Please see [build.gradle](https://github.com/sendgrid/java-http-client/blob/master/build.gradle)
+- Java 8 or 11
+- Please see [pom.xml](pom.xml)
##### Initial setup: #####
@@ -76,7 +30,7 @@ cd java-http-client
##### Execute: #####
-See the [examples folder](https://github.com/sendgrid/java-http-client/tree/master/examples) to get started quickly.
+See the [examples folder](examples) to get started quickly.
You will need to setup the following environment to use the SendGrid example:
@@ -120,9 +74,9 @@ Provides a standard interface to an API's response.
All PRs require passing tests before the PR will be reviewed.
-All test files are in [`http/src/test/java/com/sendgrid`](https://github.com/sendgrid/java-http-client/blob/master/src/test/java/com/sendgrid/ClientTest.java).
+All test files are in [`java-http-client/src/test/java/com/sendgrid`](src/test/java/com/sendgrid).
-For the purposes of contributing to this repo, please update the [`ClientTest.java`](https://github.com/sendgrid/java-http-client/blob/master/src/test/java/com/sendgrid/ClientTest.java) file with unit tests as you modify the code.
+For the purposes of contributing to this repo, please update the [`ClientTest.java`](src/test/java/com/sendgrid/ClientTest.java) file with unit tests as you modify the code.
Run the tests:
@@ -172,7 +126,7 @@ Please run your code through:
4. Commit your changes in logical chunks. Please adhere to these [git commit
message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
- or your code is unlikely be merged into the main project. Use Git's
+ or your code is unlikely to be merged into the main project. Use Git's
[interactive rebase](https://help.github.com/articles/interactive-rebase)
feature to tidy up your commits before making them public.
@@ -183,7 +137,7 @@ Please run your code through:
5. Locally merge (or rebase) the upstream development branch into your topic branch:
```bash
- git pull [--rebase] upstream master
+ git pull [--rebase] upstream main
```
6. Push your topic branch up to your fork:
@@ -193,6 +147,7 @@ Please run your code through:
```
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
- with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.
+ with a clear title and description against the `main` branch. All tests must be passing before we will review the PR.
-If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo.
+## Code Reviews
+If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, GitHub has some great [information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/).
diff --git a/FIRST_TIMERS.md b/FIRST_TIMERS.md
new file mode 100644
index 0000000..ab29f04
--- /dev/null
+++ b/FIRST_TIMERS.md
@@ -0,0 +1,53 @@
+# How To Contribute to Twilio SendGrid Repositories via GitHub
+Contributing to the Twilio SendGrid repositories is easy! All you need to do is find an open issue (see the bottom of this page for a list of repositories containing open issues), fix it and submit a pull request. Once you have submitted your pull request, the team can easily review it before it is merged into the repository.
+
+To make a pull request, follow these steps:
+
+1. Log into GitHub. If you do not already have a GitHub account, you will have to create one in order to submit a change. Click the Sign up link in the upper right-hand corner to create an account. Enter your username, password, and email address. If you are an employee of Twilio SendGrid, please use your full name with your GitHub account and enter Twilio SendGrid as your company so we can easily identify you.
+
+
+
+2. __[Fork](https://help.github.com/fork-a-repo/)__ the [java-http-client](https://github.com/sendgrid/java-http-client) repository:
+
+
+
+3. __Clone__ your fork via the following commands:
+
+```bash
+# Clone your fork of the repo into the current directory
+git clone https://github.com/your_username/java-http-client
+# Navigate to the newly cloned directory
+cd java-http-client
+# Assign the original repo to a remote called "upstream"
+git remote add upstream https://github.com/sendgrid/java-http-client
+```
+
+> Don't forget to replace *your_username* in the URL by your real GitHub username.
+
+4. __Create a new topic branch__ (off the main project development branch) to contain your feature, change, or fix:
+
+```bash
+git checkout -b
+```
+
+5. __Commit your changes__ in logical chunks.
+
+Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your code is unlikely be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. Probably you will also have to create tests (if needed) or create or update the example code that demonstrates the functionality of this change to the code.
+
+6. __Locally merge (or rebase)__ the upstream development branch into your topic branch:
+
+```bash
+git pull [--rebase] upstream main
+```
+
+7. __Push__ your topic branch up to your fork:
+
+```bash
+git push origin
+```
+
+8. __[Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#changing-the-branch-range-and-destination-repository/)__ with a clear title and description against the `main` branch. All tests must be passing before we will review the PR.
+
+## Important notice
+
+Before creating a pull request, make sure that you respect the repository's constraints regarding contributions. You can find them in the [CONTRIBUTING.md](CONTRIBUTING.md) file.
diff --git a/LICENSE.md b/LICENSE
similarity index 59%
rename from LICENSE.md
rename to LICENSE
index dd2444e..3154774 100644
--- a/LICENSE.md
+++ b/LICENSE
@@ -1,13 +1,13 @@
-The MIT License (MIT)
+MIT License
-Copyright (c) 2016-2017 SendGrid, Inc.
+Copyright (C) 2023, Twilio SendGrid, Inc.
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..851986a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,20 @@
+.PHONY: install package test update-deps test-integration clean
+
+VERSION := $(shell mvn help:evaluate -Dexpression=project.version --batch-mode | grep -e '^[^\[]')
+install:
+ @java -version || (echo "Java is not installed, please install Java >= 7"; exit 1);
+ mvn clean install -DskipTests=true -Dgpg.skip -B
+ cp target/java-http-client-$(VERSION).jar java-http-client.jar
+
+package:
+ mvn package -DskipTests=true -Dgpg.skip -B
+ cp target/java-http-client-$(VERSION).jar java-http-client.jar
+
+test:
+ mvn test
+
+update-deps:
+ mvn versions:use-latest-releases versions:commit -DallowMajorUpdates=false
+
+clean:
+ mvn clean
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000..bc85492
--- /dev/null
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,31 @@
+
+
+# Fixes #
+
+A short description of what this PR does.
+
+### Checklist
+- [x] I acknowledge that all my contributions will be made under the project's license
+- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
+- [ ] I have read the [Contribution Guidelines](https://github.com/sendgrid/java-http-client/blob/main/CONTRIBUTING.md) and my PR follows them
+- [ ] I have titled the PR appropriately
+- [ ] I have updated my branch with the main branch
+- [ ] I have added tests that prove my fix is effective or that my feature works
+- [ ] I have added the necessary documentation about the functionality in the appropriate .md file
+- [ ] I have added inline documentation to the code I modified
+
+If you have questions, please file a [support ticket](https://support.sendgrid.com), or create a GitHub Issue in this repository.
diff --git a/README.md b/README.md
index 9b5ced6..0f646b8 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
-
+
-[](https://travis-ci.org/sendgrid/java-http-client)
+[](https://github.com/sendgrid/java-http-client/actions/workflows/test-and-deploy.yml)
[](http://mvnrepository.com/artifact/com.sendgrid/java-http-client)
-[](./LICENSE.md)
+[](LICENSE)
[](https://twitter.com/sendgrid)
[](https://github.com/sendgrid/java-http-client/graphs/contributors)
@@ -15,23 +15,23 @@ If you are looking for the SendGrid API client library, please see [this repo](h
* [Announcements](#announcements)
* [Installation](#installation)
* [Quick Start](#quick-start)
-* [Usage](#usage)
-* [Roadmap](#roadmap)
+* [Usage](./USAGE.md)
* [How to Contribute](#contribute)
* [About](#about)
+* [Support](#support)
* [License](#license)
# Announcements
-All updates to this project is documented in our [CHANGELOG](https://github.com/sendgrid/java-http-client/blob/master/CHANGELOG.md).
+All updates to this project are documented in our [CHANGELOG](CHANGELOG.md).
# Installation
## Prerequisites
-- Java version Oracle JDK 8 or OpenJDK 7
+- Java 8, 11, or 17
## Install via Maven w/ Gradle
@@ -39,7 +39,7 @@ All updates to this project is documented in our [CHANGELOG](https://github.com/
...
dependencies {
...
- compile 'com.sendgrid:java-http-client:4.2.0'
+ compile 'com.sendgrid:java-http-client:4.5.1'
}
repositories {
@@ -54,19 +54,15 @@ repositories {
com.sendgridjava-http-client
- 4.2.0
+ 4.5.1
```
`mvn install`
-## Install via Fat Jar
-
-[sendgrid-java-latest.jar](http://dx.sendgrid.com/downloads/java-http-client/java-http-client-latest.jar)
-
## Dependencies
-- Please see the [build.gradle file](https://github.com/sendgrid/java-http-client/blob/master/build.gradle)
+- Please see the [pom.xml file](pom.xml)
# Quick Start
@@ -100,6 +96,8 @@ try {
request.addHeader("Authorization", "Bearer YOUR_API_KEY");
request.addQueryParam("limit", "100");
request.addQueryParam("offset", "0");
+// Will be parsed to categories=cake&categories=pie&categories=baking
+request.addQueryParam("categories", "cake&pie&baking");
request.setBody("{\"name\": \"My Request Body\"}");
request.setMethod(Method.POST);
String param = "param";
@@ -115,33 +113,29 @@ try {
}
```
-
-# Usage
-[Library Usage Documentation](USAGE.md)
-
-
-# Roadmap
-
-If you are interested in the future direction of this project, please take a look at our [milestones](https://github.com/sendgrid/java-http-client/milestones). We would love to hear your feedback.
-
# How to Contribute
-We encourage contribution to our projects please see our [CONTRIBUTING](https://github.com/sendgrid/java-http-client/blob/master/CONTRIBUTING.md) guide for details.
+We encourage contribution to our projects please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.
Quick links:
-- [Feature Request](https://github.com/sendgrid/java-http-client/blob/master/CONTRIBUTING.md#feature-request)
-- [Bug Reports](https://github.com/sendgrid/java-http-client/blob/master/CONTRIBUTING.md#submit-a-bug-report)
-- [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/java-http-client/blob/master/CONTRIBUTING.md#cla)
-- [Improvements to the Codebase](https://github.com/sendgrid/java-http-client/blob/master/CONTRIBUTING.md#improvements-to-the-codebase)
+- [Feature Request](CONTRIBUTING.md#feature-request)
+- [Bug Reports](CONTRIBUTING.md#submit-a-bug-report)
+- [Improvements to the Codebase](CONTRIBUTING.md#improvements-to-the-codebase)
+- [Review Pull Requests](CONTRIBUTING.md#Code-Reviews)
# About
-java-http-client is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
+java-http-client is maintained and funded by Twilio SendGrid, Inc. The names and logos for java-http-client are trademarks of Twilio SendGrid, Inc.
+
+
+# Support
+
+If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).
-java-http-client is maintained and funded by SendGrid, Inc. The names and logos for java-http-client are trademarks of SendGrid, Inc.
+If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
# License
-[The MIT License (MIT)](LICENSE.md)
+[The MIT License (MIT)](LICENSE)
diff --git a/USAGE.md b/USAGE.md
index 40c3f83..4a01093 100644
--- a/USAGE.md
+++ b/USAGE.md
@@ -1,6 +1,6 @@
# Usage
-- [Example Code](https://github.com/sendgrid/java-http-client/tree/master/examples)
+- [Example Code](examples)
The example uses SendGrid, you can get your free account [here](https://sendgrid.com/free?source=java-http-client).
@@ -16,4 +16,12 @@ source ./sendgrid.env
mvn package
cd examples
javac -classpath {path_to}/sendgrid-java-http-client-4.0.0-jar.jar:. Example.java && java -classpath {path_to}/sendgrid-java-http-client-4.0.0-jar.jar:. Example
-```
\ No newline at end of file
+```
+
+## Environment Variables
+
+You can do the following to create a .env file:
+
+```cp .env_example .env```
+
+Then, just add your API Key into your .env file.
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
deleted file mode 100644
index 3a4d715..0000000
--- a/build.gradle
+++ /dev/null
@@ -1,155 +0,0 @@
-/**
- * Commands:
- * - gradle build
- * - gradle test
- * - gradle assemble
- * - gradle uploadArchives
- *
- * To execute the 'uploadArchives' task, the following properties must be specified
- * in an external 'gradle.properties' file:
- * - sonatypeUsername
- * - sonatypePassword
- */
-
-apply plugin: 'java'
-apply plugin: 'maven'
-apply plugin: 'signing'
-apply plugin: 'com.github.johnrengelman.shadow'
-
-group = 'com.sendgrid'
-version = '4.2.0'
-ext.packaging = 'jar'
-
-allprojects {
- apply plugin: 'java'
- sourceCompatibility = 1.7
- targetCompatibility = 1.7
-}
-
-if (!hasProperty("sonatypeUsername")) {
- ext.sonatypeUsername = null
- ext.sonatypePassword = null
-}
-
-buildscript {
- dependencies {
- classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
- }
- repositories {
- jcenter()
- }
-}
-
-dependencies {
- compile 'org.apache.httpcomponents:httpcore:4.4.4'
- compile 'org.apache.httpcomponents:httpclient:4.5.2'
- testCompile 'org.mockito:mockito-core:1.10.19'
- testCompile group: 'junit', name: 'junit-dep', version: '4.10'
-
-}
-
-repositories {
- mavenCentral()
-}
-
-allprojects {
- gradle.projectsEvaluated {
- tasks.withType(JavaCompile) {
- options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
- }
- }
-}
-
-// adds 'with-dependencies' to the shadowJar name
-shadowJar {
- classifier 'jar'
- baseName "sendgrid-java-http-client"
- version version
-}
-jar {
- manifest {
- attributes("Implementation-Title": "http", "Implementation-Version": version)
- }
-}
-
-// copy shadowJar to base project directory so they will be in git (and on github for download)
-build << {
- copy {
- println "Copying ${shadowJar.archiveName} to $projectDir/repo/com/sendgrid/$version"
- from("$buildDir/libs/${shadowJar.archiveName}")
- into("$projectDir/repo/com/sendgrid/$version")
- }
- copy {
- println "Copying ${shadowJar.archiveName} to $projectDir/repo/com/sendgrid"
- from("$buildDir/libs/${shadowJar.archiveName}")
- into("$projectDir/repo/com/sendgrid")
- }
- tasks.renameSendGridVersionJarToSendGridJar.execute()
-}
-
-task renameSendGridVersionJarToSendGridJar {
- doLast {
- file("$projectDir/repo/com/sendgrid/${shadowJar.archiveName}").renameTo(file("$projectDir/repo/com/sendgrid/http-jar.jar"))
- }
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from 'build/docs/javadoc'
-}
-
-task sourcesJar(type: Jar) {
- from sourceSets.main.allSource
- classifier = 'sources'
-}
-
-signing {
- required { gradle.taskGraph.hasTask("uploadArchives") }
- sign configurations.archives
-}
-
-uploadArchives {
- repositories {
- mavenDeployer {
- beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
- repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
- authentication(userName: sonatypeUsername, password: sonatypePassword)
- }
-
- pom.project {
- name 'http'
- packaging 'jar'
- description 'A simple HTTP client'
- url 'https://github.com/sendgrid/java-http-client'
-
- scm {
- url 'scm:git@github.com:sendgrid/java-http-client.git'
- connection 'scm:git@github.com:sendgrid/java-http-client.git'
- developerConnection 'scm:git@github.com:sendgrid/java-http-client.git'
- }
-
- licenses {
- license {
- name 'MIT License'
- url 'http://opensource.org/licenses/MIT'
- distribution 'repo'
- }
- }
-
- developers {
- developer {
- id 'thinkingserious'
- name 'Elmer Thomas'
- }
- }
- }
- }
- }
-}
-
-artifacts {
- archives shadowJar
- archives jar
- archives javadocJar
- archives sourcesJar
-}
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..5e2749f
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,27 @@
+FROM store/oracle/serverjre:8
+
+ENV OAI_SPEC_URL="https://raw.githubusercontent.com/sendgrid/sendgrid-oai/HEAD/oai_stoplight.json"
+
+RUN yum install -y git
+
+WORKDIR /root
+
+# install Prism
+ADD https://raw.githubusercontent.com/stoplightio/prism/HEAD/install.sh install.sh
+RUN chmod +x ./install.sh && sync && \
+ ./install.sh && \
+ rm ./install.sh
+
+# set up default sendgrid env
+WORKDIR /root/sources
+RUN git clone https://github.com/sendgrid/java-http-client.git
+
+WORKDIR /root
+RUN ln -s /root/sources/java-http-client/sendgrid
+
+COPY entrypoint.sh entrypoint.sh
+RUN chmod +x entrypoint.sh
+
+# Set entrypoint
+ENTRYPOINT ["./entrypoint.sh"]
+CMD ["--mock"]
\ No newline at end of file
diff --git a/docker/README.md b/docker/README.md
new file mode 100644
index 0000000..fabe4c0
--- /dev/null
+++ b/docker/README.md
@@ -0,0 +1,31 @@
+# Supported tags and respective `Dockerfile` links
+ - `v1.0.0`, `latest` [(Dockerfile)](Dockerfile)
+
+# Quick reference
+Due to Oracle's JDK license, you must build this Docker image using the official Oracle image located in the Docker Store. You will need a Docker store account. Once you have an account, you must accept the Oracle license [here](https://store.docker.com/images/oracle-serverjre-8). On the command line, type `docker login` and provide your credentials. You may then build the image using this command `docker build -t sendgrid/java-http-client -f Dockerfile .`
+
+ - **Where to get help:**
+ [Contact SendGrid Support](https://support.sendgrid.com/hc/en-us)
+
+ - **Where to file issues:**
+ https://github.com/sendgrid/java-http-client/issues
+
+ - **Where to get more info:**
+ [USAGE.md](USAGE.md)
+
+ - **Maintained by:**
+ [SendGrid Inc.](https://sendgrid.com)
+
+# Usage examples
+ - Most recent version: `docker run -it sendgrid/java-http-client`.
+ - Your own fork:
+ ```sh-session
+ $ git clone https://github.com/you/cool-java-http-client.git
+ $ realpath cool-java-http-client
+ /path/to/cool-java-http-client
+ $ docker run -it -v /path/to/cool-java-http-client:/mnt/java-http-client sendgrid/java-http-client
+ ```
+
+For more detailed information, see [USAGE.md](USAGE.md).
+
+
diff --git a/docker/USAGE.md b/docker/USAGE.md
new file mode 100644
index 0000000..9fbfb81
--- /dev/null
+++ b/docker/USAGE.md
@@ -0,0 +1,28 @@
+You can use Docker to easily try out or test java-http-client.
+
+
+# Quickstart
+
+1. Install Docker on your machine.
+2. If you have not done so, create a Docker Store account [here](https://store.docker.com/signup?next=%2F)
+3. Navigate [here](https://store.docker.com/images/oracle-serverjre-8) and click the "Proceed to Checkout" link (don't worry, it's free).
+4. On the command line, execute `docker login` and provide your credentials.
+5. Build the Docker image using the command `docker build -t sendgrid/java-http-client -f Dockerfile .`
+6. Run `docker run -it sendgrid/java-http-client`.
+
+
+# Info
+
+This Docker image contains
+ - `java-http-client`
+ - Stoplight's Prism, which lets you try out the API without actually sending email
+
+Run it in interactive mode with `-it`.
+
+You can mount repositories in the `/mnt/java-http-client` and `/mnt/java-http-client` directories to use them instead of the default SendGrid libraries. Read on for more info.
+
+
+# Testing
+Testing is easy! Run the container, `cd sendgrid`, and run `./gradlew test`.
+
+
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
new file mode 100644
index 0000000..b785be6
--- /dev/null
+++ b/docker/entrypoint.sh
@@ -0,0 +1,31 @@
+#! /bin/bash
+clear
+
+# check for + link mounted libraries:
+if [ -d /mnt/java-http-client ]
+then
+ rm /root/sendgrid
+ ln -s /mnt/java-http-client/sendgrid
+ echo "Linked mounted java-http-client's code to /root/sendgrid"
+fi
+
+SENDGRID_JAVA_VERSION="1.0.0"
+echo "Welcome to java-http-client docker v${SENDGRID_JAVA_VERSION}."
+echo
+
+if [ "$1" != "--no-mock" ]
+then
+ echo "Starting Prism in mock mode. Calls made to Prism will not actually send emails."
+ echo "Disable this by running this container with --no-mock."
+ prism run --mock --spec $OAI_SPEC_URL 2> /dev/null &
+else
+ echo "Starting Prism in live (--no-mock) mode. Calls made to Prism will send emails."
+ prism run --spec $OAI_SPEC_URL 2> /dev/null &
+fi
+echo "To use Prism, make API calls to localhost:4010. For example,"
+echo " sg = sendgrid.SendGridAPIClient("
+echo " host='http://localhost:4010/',"
+echo " api_key=os.environ.get('SENDGRID_API_KEY_CAMPAIGNS'))"
+echo "To stop Prism, run \"kill $!\" from the shell."
+
+bash
\ No newline at end of file
diff --git a/examples/.env_sample b/examples/.env_sample
new file mode 100644
index 0000000..30857f4
--- /dev/null
+++ b/examples/.env_sample
@@ -0,0 +1 @@
+export SENDGRID_API_KEY=''
\ No newline at end of file
diff --git a/examples/Example.java b/examples/Example.java
index a986d89..8320e81 100644
--- a/examples/Example.java
+++ b/examples/Example.java
@@ -13,40 +13,29 @@
import java.util.Map;
public class Example {
- public static void main(String[] args) throws IOException {
- Client client = new Client();
-
- Request request = new Request();
- request.setBaseUri("api.sendgrid.com");
- request.addHeader("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY"));
-
- Response response = new Response();
-
- // GET Collection
+
+ private static String apiKeyId = "";
+
+ private static void getCollection(Client client, Request request) throws IOException {
request.setMethod(Method.GET);
request.setEndpoint("/v3/api_keys");
request.addQueryParam("limit", "100");
request.addQueryParam("offset", "0");
try {
- response = client.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
+ processResponse();
} catch (IOException ex) {
throw ex;
}
request.clearQueryParams();
-
- // POST
+ }
+
+ private static void post(Client client, Request request) throws IOException {
request.setMethod(Method.POST);
request.setEndpoint("/v3/api_keys");
request.setBody("{\"name\": \"My api Key\",\"scopes\": [\"mail.send\",\"alerts.create\",\"alerts.read\"]}");
try {
- response = client.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
+ processResponse();
} catch (IOException ex) {
throw ex;
}
@@ -58,54 +47,83 @@ public static void main(String[] args) throws IOException {
} catch (IOException ex) {
throw ex;
}
- request.clearBody();
-
- // GET Single
+ request.clearBody();
+ }
+
+ private static void getSingle(Client client, Request request) throws IOException {
request.setMethod(Method.GET);
request.setEndpoint("/v3/api_keys/" + apiKeyId);
try {
- response = client.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
+ processResponse();
} catch (IOException ex) {
throw ex;
- }
-
- // PATCH
+ }
+ }
+
+ private static void patch(Client client, Request request) throws IOException {
request.setMethod(Method.PATCH);
request.setBody("{\"name\": \"A New Ho}");
try {
- response = client.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
+ processResponse();
} catch (IOException ex) {
throw ex;
}
- request.clearBody();
-
- // PUT
+ request.clearBody();
+ }
+
+ private static void put(Client client, Request request) throws IOException {
request.setMethod(Method.PUT);
request.setBody("{\"name\": \"A New Hope\",\"scopes\": [\"user.profile.read\",\"user.profile.update\"]}");
try {
- response = client.api(request);
- System.out.println(response.getStatusCode());
- System.out.println(response.getBody());
- System.out.println(response.getHeaders());
+ processResponse();
} catch (IOException ex) {
throw ex;
}
- request.clearBody();
-
- // DELETE
+ request.clearBody();
+ }
+
+ private static void delete(Client client, Request request) throws IOException {
request.setMethod(Method.DELETE);
try {
- response = client.api(request);
+ Response response = client.api(request);
System.out.println(response.getStatusCode());
System.out.println(response.getHeaders());
} catch (IOException ex) {
throw ex;
- }
+ }
+ }
+
+ public static void main(String[] args) throws IOException {
+ Client client = new Client();
+
+ Request request = new Request();
+ request.setBaseUri("api.sendgrid.com");
+ request.addHeader("Authorization", "Bearer " + System.getenv("SENDGRID_API_KEY"));
+
+ // GET Collection
+ getCollection(client, request);
+
+ // POST
+ post(client, request);
+
+ // GET Single
+ getSingle(client, request);
+
+ // PATCH
+ patch(client, request);
+
+ // PUT
+ put(client, request);
+
+ // DELETE
+ delete(client, request);
+ }
+
+ //Refactor method
+ private void processResponse(){
+ response = client.api(request);
+ System.out.println(response.getStatusCode());
+ System.out.println(response.getBody());
+ System.out.println(response.getHeaders());
}
-}
\ No newline at end of file
+}
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 0087cd3..0000000
Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 2310768..0000000
--- a/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Mon May 26 17:38:02 PDT 2014
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
\ No newline at end of file
diff --git a/gradlew b/gradlew
deleted file mode 100755
index e659319..0000000
--- a/gradlew
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# 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
- ;;
-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
-
-# 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"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-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.
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-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
-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
-
-# 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\""
- fi
- i=$((i+1))
- 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 "$@"
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8bfcede..efcc8d7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,5 +1,5 @@
-
+
+4.0.0org.sonatype.oss
@@ -7,16 +7,16 @@
7com.sendgrid
- http
+ java-http-clientjarA simple HTTP clientHTTP REST client, simplified for Java
- 4.2.0
+ 4.5.1https://github.com/sendgrid/java-http-clientThe MIT License (MIT)
- https://github.com/sendgrid/java-http-client/blob/master/LICENSE
+ https://github.com/sendgrid/java-http-client/blob/HEAD/LICENSErepo
@@ -24,8 +24,81 @@
https://github.com/sendgrid/java-http-clientscm:git:git@github.com:sendgrid/java-http-client.gitscm:git:git@github.com:sendgrid/java-http-client.git
- HEAD
+ 4.5.1
+
+
+ release
+
+
+ release
+
+
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.8
+ true
+
+ ossrh
+ https://oss.sonatype.org/
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 3.0.1
+
+
+ attach-sources
+
+ jar-no-fork
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.10.4
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+ ${gpg.keyname}
+ ${gpg.passphrase}
+
+ --pinentry-mode
+ loopback
+
+
+
+
+
+
+
+
+ 1.81.8
@@ -34,7 +107,7 @@
junitjunit-dep
- 4.10
+ 4.11test
@@ -46,12 +119,101 @@
org.apache.httpcomponentshttpcore
- 4.4.4
+ 4.4.15org.apache.httpcomponentshttpclient
- 4.5.2
+ 4.5.13
-
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.5
+
+
+
+ prepare-agent
+
+
+
+ report
+ test
+
+ report
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.1
+
+ 1.8
+ 1.8
+
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.4.2
+
+
+ org.apache.maven.scm
+ maven-scm-provider-gitexe
+ 1.8.1
+
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+ 2.2.1
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.9.1
+
+
+ attach-javadocs
+
+ jar
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-assembly-plugin
+ 3.1.1
+
+
+ jar-with-dependencies
+
+
+
+
+ make-assembly
+ package
+
+ single
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scripts/generate_upload_policy.php b/scripts/generate_upload_policy.php
deleted file mode 100644
index 18fdf82..0000000
--- a/scripts/generate_upload_policy.php
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/env php
-$blocksize)
- $key=pack('H*', $hashfunc($key));
- $key=str_pad($key,$blocksize,chr(0x00));
- $ipad=str_repeat(chr(0x36),$blocksize);
- $opad=str_repeat(chr(0x5c),$blocksize);
- $hmac = pack(
- 'H*',$hashfunc(
- ($key^$opad).pack(
- 'H*',$hashfunc(
- ($key^$ipad).$data
- )
- )
- )
- );
- return bin2hex($hmac);
-}
-
-/*
- * Used to encode a field for Amazon Auth
- * (taken from the Amazon S3 PHP example library)
- */
-function hex2b64($str)
-{
- $raw = '';
- for ($i=0; $i < strlen($str); $i+=2)
- {
- $raw .= chr(hexdec(substr($str, $i, 2)));
- }
- return base64_encode($raw);
-}
-
-if (count($argv) != 3) {
- echo "Usage: " . $argv[0] . " \n";
- exit(1);
-}
-
-$policy = file_get_contents($argv[1]);
-$secret = $argv[2];
-
-/*
- * Base64 encode the Policy Document and then
- * create HMAC SHA-1 signature of the base64 encoded policy
- * using the secret key. Finally, encode it for Amazon Authentication.
- */
-$base64_policy = base64_encode($policy);
-$signature = hex2b64(hmacsha1($secret, $base64_policy));
-echo "S3_POLICY=\"" . $base64_policy . "\"\nS3_SIGNATURE=\"" . $signature . "\"\n"
-?>
diff --git a/scripts/s3policy.json b/scripts/s3policy.json
deleted file mode 100644
index 487f00c..0000000
--- a/scripts/s3policy.json
+++ /dev/null
@@ -1,10 +0,0 @@
-{
- "expiration": "2100-01-01T12:00:00.000Z",
- "conditions": [
- {"acl": "public-read" },
- {"bucket": "sendgrid-open-source" },
- ["starts-with", "$key", "http/"],
- ["content-length-range", 2048, 268435456],
- ["eq", "$Content-Type", "application/zip"]
- ]
-}
\ No newline at end of file
diff --git a/scripts/s3upload.sh b/scripts/s3upload.sh
deleted file mode 100644
index b9bd916..0000000
--- a/scripts/s3upload.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-# From:
-# http://raamdev.com/2008/using-curl-to-upload-files-via-post-to-amazon-s3/
-
-GIT_VERSION=`git rev-parse --short HEAD`
-
-curl -X POST \
- -F "key=http/versions/http-$GIT_VERSION.jar" \
- -F "acl=public-read" \
- -F "AWSAccessKeyId=$S3_ACCESS_KEY" \
- -F "Policy=$S3_POLICY" \
- -F "Signature=$S3_SIGNATURE" \
- -F "Content-Type=application/zip" \
- -F "file=@./repo/com/sendgrid/http-jar.jar" \
- https://s3.amazonaws.com/$S3_BUCKET
-
-if [ "$TRAVIS_BRANCH" = "master" ]
-then
- curl -X POST \
- -F "key=http/http.jar" \
- -F "acl=public-read" \
- -F "AWSAccessKeyId=$S3_ACCESS_KEY" \
- -F "Policy=$S3_POLICY" \
- -F "Signature=$S3_SIGNATURE" \
- -F "Content-Type=application/zip" \
- -F "file=@./repo/com/sendgrid/http-jar.jar" \
- https://s3.amazonaws.com/$S3_BUCKET
-fi
-
-exit 0
\ No newline at end of file
diff --git a/src/main/java/com/sendgrid/Client.java b/src/main/java/com/sendgrid/Client.java
index 7360ab2..d0865fd 100644
--- a/src/main/java/com/sendgrid/Client.java
+++ b/src/main/java/com/sendgrid/Client.java
@@ -1,5 +1,6 @@
package com.sendgrid;
+import java.io.Closeable;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
@@ -8,10 +9,11 @@
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
+import java.util.Arrays;
+import java.util.List;
import org.apache.http.Header;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.NotThreadSafe;
+import org.apache.http.HttpMessage;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.CloseableHttpResponse;
@@ -26,11 +28,14 @@
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-// Hack to get DELETE to accept a request body
-@NotThreadSafe
+
+/**
+ * Hack to get DELETE to accept a request body.
+ */
class HttpDeleteWithBody extends HttpEntityEnclosingRequestBase {
public static final String METHOD_NAME = "DELETE";
+ @Override
public String getMethod() {
return METHOD_NAME;
}
@@ -41,23 +46,30 @@ public HttpDeleteWithBody(final String uri) {
}
}
+
/**
* Class Client allows for quick and easy access any REST or REST-like API.
*/
-public class Client {
+public class Client implements Closeable {
private CloseableHttpClient httpClient;
private Boolean test;
+ private boolean createdHttpClient;
+
/**
* Constructor for using the default CloseableHttpClient.
*/
public Client() {
- this(false);
+ this.httpClient = HttpClients.createDefault();
+ this.test = false;
+ this.createdHttpClient = true;
}
+
/**
- * Constructor for passing in an httpClient.
+ * Constructor for passing in an httpClient, typically for mocking. Passed-in httpClient will not be closed
+ * by this Client.
*
* @param httpClient
* an Apache CloseableHttpClient
@@ -66,8 +78,9 @@ public Client(CloseableHttpClient httpClient) {
this(httpClient, false);
}
+
/**
- * Constructor for passing in a test parameter to allow for http calls
+ * Constructor for passing in a test parameter to allow for http calls.
*
* @param test
* is a Bool
@@ -76,8 +89,9 @@ public Client(Boolean test) {
this(HttpClients.createDefault(), test);
}
+
/**
- * Constructor for passing in a an httpClient and test parameter to allow for http calls
+ * Constructor for passing in an httpClient and test parameter to allow for http calls.
*
* @param httpClient
* an Apache CloseableHttpClient
@@ -87,6 +101,7 @@ public Client(Boolean test) {
public Client(CloseableHttpClient httpClient, Boolean test) {
this.httpClient = httpClient;
this.test = test;
+ this.createdHttpClient = true;
}
@@ -99,10 +114,12 @@ public Client(CloseableHttpClient httpClient, Boolean test) {
* (e.g. "/your/endpoint/path")
* @param queryParams
* map of key, values representing the query parameters
+ * @throws URISyntaxException
+ * in of a URI syntax error
*/
public URI buildUri(String baseUri, String endpoint, Map queryParams) throws URISyntaxException {
URIBuilder builder = new URIBuilder();
- URI uri;
+ URI uri = null;
if (this.test == true) {
builder.setScheme("http");
@@ -114,8 +131,19 @@ public URI buildUri(String baseUri, String endpoint, Map queryPa
builder.setPath(endpoint);
if (queryParams != null) {
+ String multiValueDelimiter = "&";
+
for (Map.Entry entry : queryParams.entrySet()) {
- builder.setParameter(entry.getKey(), entry.getValue());
+ String value = entry.getValue();
+
+ if (value.indexOf(multiValueDelimiter) != -1) {
+ List values = Arrays.asList(value.split(multiValueDelimiter));
+ for (String val : values) {
+ builder.addParameter(entry.getKey(), val);
+ }
+ } else {
+ builder.setParameter(entry.getKey(), entry.getValue());
+ }
}
}
@@ -128,20 +156,22 @@ public URI buildUri(String baseUri, String endpoint, Map queryPa
return uri;
}
+
/**
* Prepare a Response object from an API call via Apache's HTTP client.
*
* @param response
* from a call to a CloseableHttpClient
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response getResponse(CloseableHttpResponse response) throws IOException {
ResponseHandler handler = new SendGridResponseHandler();
- String responseBody = "";
+ String responseBody = handler.handleResponse(response);
int statusCode = response.getStatusLine().getStatusCode();
- responseBody = handler.handleResponse(response);
-
Header[] headers = response.getAllHeaders();
Map responseHeaders = new HashMap();
for (Header h : headers) {
@@ -151,9 +181,18 @@ public Response getResponse(CloseableHttpResponse response) throws IOException {
return new Response(statusCode, responseBody, responseHeaders);
}
+
/**
* Make a GET request and provide the status code, response body and
* response headers.
+ *
+ * @param request
+ * the request object
+ * @throws URISyntaxException
+ * in case of a URI syntax error
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response get(Request request) throws URISyntaxException, IOException {
URI uri = null;
@@ -174,9 +213,18 @@ public Response get(Request request) throws URISyntaxException, IOException {
return executeApiCall(httpGet);
}
+
/**
* Make a POST request and provide the status code, response body and
* response headers.
+ *
+ * @param request
+ * the request object
+ * @throws URISyntaxException
+ * in case of a URI syntax error
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response post(Request request) throws URISyntaxException, IOException {
URI uri = null;
@@ -196,16 +244,23 @@ public Response post(Request request) throws URISyntaxException, IOException {
}
httpPost.setEntity(new StringEntity(request.getBody(), Charset.forName("UTF-8")));
- if (request.getBody() != "") {
- httpPost.setHeader("Content-Type", "application/json");
- }
+ writeContentTypeIfNeeded(request, httpPost);
return executeApiCall(httpPost);
}
+
/**
* Make a PATCH request and provide the status code, response body and
* response headers.
+ *
+ * @param request
+ * the request object
+ * @throws URISyntaxException
+ * in case of a URI syntax error
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response patch(Request request) throws URISyntaxException, IOException {
URI uri = null;
@@ -225,15 +280,23 @@ public Response patch(Request request) throws URISyntaxException, IOException {
}
httpPatch.setEntity(new StringEntity(request.getBody(), Charset.forName("UTF-8")));
- if (request.getBody() != "") {
- httpPatch.setHeader("Content-Type", "application/json");
- }
+ writeContentTypeIfNeeded(request, httpPatch);
+
return executeApiCall(httpPatch);
}
+
/**
* Make a PUT request and provide the status code, response body and
* response headers.
+ *
+ * @param request
+ * the request object
+ * @throws URISyntaxException
+ * in case of a URI syntax error
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response put(Request request) throws URISyntaxException, IOException {
URI uri = null;
@@ -253,15 +316,22 @@ public Response put(Request request) throws URISyntaxException, IOException {
}
httpPut.setEntity(new StringEntity(request.getBody(), Charset.forName("UTF-8")));
- if (request.getBody() != "") {
- httpPut.setHeader("Content-Type", "application/json");
- }
+ writeContentTypeIfNeeded(request, httpPut);
return executeApiCall(httpPut);
}
+
/**
* Make a DELETE request and provide the status code and response headers.
+ *
+ * @param request
+ * the request object
+ * @throws URISyntaxException
+ * in case of a URI syntax error
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response delete(Request request) throws URISyntaxException, IOException {
URI uri = null;
@@ -281,23 +351,32 @@ public Response delete(Request request) throws URISyntaxException, IOException {
}
httpDelete.setEntity(new StringEntity(request.getBody(), Charset.forName("UTF-8")));
- if (request.getBody() != "") {
- httpDelete.setHeader("Content-Type", "application/json");
- }
+ writeContentTypeIfNeeded(request, httpDelete);
return executeApiCall(httpDelete);
}
+ private void writeContentTypeIfNeeded(Request request, HttpMessage httpMessage) {
+ if (!"".equals(request.getBody())) {
+ httpMessage.setHeader("Content-Type", "application/json");
+ }
+ }
+
+
+ /**
+ * Makes a call to the client API.
+ *
+ * @param httpPost
+ * the request method object
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
+ */
private Response executeApiCall(HttpRequestBase httpPost) throws IOException {
try {
CloseableHttpResponse serverResponse = httpClient.execute(httpPost);
try {
- Response response = getResponse(serverResponse);
- if(response.getStatusCode() >= 300) {
- //throwing IOException here to not break API behavior.
- throw new IOException("Request returned status Code "+response.getStatusCode()+"Body:"+response.getBody());
- }
- return response;
+ return getResponse(serverResponse);
} finally {
serverResponse.close();
}
@@ -306,8 +385,15 @@ private Response executeApiCall(HttpRequestBase httpPost) throws IOException {
}
}
+
/**
* A thin wrapper around the HTTP methods.
+ *
+ * @param request
+ * the request object
+ * @throws IOException
+ * in case of a network error
+ * @return the response object
*/
public Response api(Request request) throws IOException {
try {
@@ -337,10 +423,29 @@ public Response api(Request request) throws IOException {
}
}
+
+ /**
+ * Closes the http client.
+ *
+ * @throws IOException
+ * in case of a network error
+ */
+ @Override
+ public void close() throws IOException {
+ this.httpClient.close();
+ }
+
+
+ /**
+ * Closes and finalizes the http client.
+ *
+ * @throws Throwable
+ * in case of an error
+ */
@Override
public void finalize() throws Throwable {
try {
- this.httpClient.close();
+ close();
} catch(IOException e) {
throw new Throwable(e.getMessage());
} finally {
diff --git a/src/main/java/com/sendgrid/SendGridResponseHandler.java b/src/main/java/com/sendgrid/SendGridResponseHandler.java
index 66ed893..109b704 100644
--- a/src/main/java/com/sendgrid/SendGridResponseHandler.java
+++ b/src/main/java/com/sendgrid/SendGridResponseHandler.java
@@ -39,5 +39,4 @@ public String handleResponse(final HttpResponse response)
public String handleEntity(HttpEntity entity) throws IOException {
return EntityUtils.toString(entity, StandardCharsets.UTF_8);
}
-
}
diff --git a/src/test/java/com/sendgrid/ClientTest.java b/src/test/java/com/sendgrid/ClientTest.java
index 9367379..0425199 100644
--- a/src/test/java/com/sendgrid/ClientTest.java
+++ b/src/test/java/com/sendgrid/ClientTest.java
@@ -33,8 +33,10 @@
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
+import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@@ -62,6 +64,7 @@ public void testbuildUri() {
Map queryParams = new HashMap();
queryParams.put("test1", "1");
queryParams.put("test2", "2");
+ queryParams.put("test3", "3&4&5");
try {
uri = client.buildUri(baseUri, endpoint, queryParams);
} catch (URISyntaxException ex) {
@@ -70,10 +73,23 @@ public void testbuildUri() {
Assert.assertTrue(errors.toString(), false);
}
- String url = uri.toString();
- System.out.println(url);
- Assert.assertTrue(url.equals("https://api.test.com/endpoint?test2=2&test1=1") ||
- url.equals("https://api.test.com/endpoint?test1=1&test2=2"));
+ URL url = null;
+ try {
+ url = uri.toURL();
+ } catch (MalformedURLException ex) {
+ StringWriter errors = new StringWriter();
+ ex.printStackTrace(new PrintWriter(errors));
+ Assert.assertTrue(errors.toString(), false);
+ }
+
+ Assert.assertTrue(url.getProtocol().equals("https"));
+ Assert.assertTrue(url.getHost().equals("api.test.com"));
+ Assert.assertTrue(url.getPath().equals("/endpoint"));
+ Assert.assertTrue(this.queryParamHasCorrectValue(url, "test1", "1"));
+ Assert.assertTrue(this.queryParamHasCorrectValue(url, "test2", "2"));
+ Assert.assertTrue(this.queryParamHasCorrectValue(url, "test3", "3"));
+ Assert.assertTrue(this.queryParamHasCorrectValue(url, "test3", "4"));
+ Assert.assertTrue(this.queryParamHasCorrectValue(url, "test3", "5"));
}
@Test
@@ -174,4 +190,8 @@ public void testPut() {
public void testDelete() {
testMethod(Method.DELETE, 204);
}
+
+ private boolean queryParamHasCorrectValue(URL url, String key, String value) {
+ return url.getQuery().indexOf(key + "=" + value) != -1;
+ }
}
diff --git a/src/test/java/com/sendgrid/LicenseTest.java b/src/test/java/com/sendgrid/LicenseTest.java
index 057060b..04e4849 100644
--- a/src/test/java/com/sendgrid/LicenseTest.java
+++ b/src/test/java/com/sendgrid/LicenseTest.java
@@ -13,7 +13,7 @@ public class LicenseTest {
@Test
public void testLicenseShouldHaveCorrectYear() throws IOException {
String copyrightText = null;
- try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE.md"))) {
+ try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE"))) {
for (String line; (line = br.readLine()) != null; ) {
if (line.startsWith("Copyright")) {
copyrightText = line;
@@ -21,7 +21,7 @@ public void testLicenseShouldHaveCorrectYear() throws IOException {
}
}
}
- String expectedCopyright = String.format("Copyright (c) 2016-%d SendGrid, Inc.", Calendar.getInstance().get(Calendar.YEAR));
+ String expectedCopyright = String.format("Copyright (C) %d, Twilio SendGrid, Inc. ", Calendar.getInstance().get(Calendar.YEAR));
Assert.assertEquals("License has incorrect year", copyrightText, expectedCopyright);
}
}
diff --git a/src/test/java/com/sendgrid/TestRequiredFilesExist.java b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
index eb04494..02e3d35 100644
--- a/src/test/java/com/sendgrid/TestRequiredFilesExist.java
+++ b/src/test/java/com/sendgrid/TestRequiredFilesExist.java
@@ -8,37 +8,27 @@ public class TestRequiredFilesExist {
// ./Docker or docker/Docker
@Test public void checkDockerExists() {
- boolean dockerExists = new File("./Docker").exists() ||
+ boolean dockerExists = new File("./docker/Dockerfile").exists() ||
new File("./docker/Docker").exists();
assertTrue(dockerExists);
}
- // ./docker-compose.yml or ./docker/docker-compose.yml
+ /* // ./docker-compose.yml or ./docker/docker-compose.yml
@Test public void checkDockerComposeExists() {
boolean dockerComposeExists = new File("./docker-compose.yml").exists() ||
new File("./docker/docker-compose.yml").exists();
assertTrue(dockerComposeExists);
}
-
- // ./.env_sample
+ // ./.env_sample
@Test public void checkEnvSampleExists() {
assertTrue(new File("./.env_sample").exists());
- }
+ } */
// ./.gitignore
@Test public void checkGitIgnoreExists() {
assertTrue(new File("./.gitignore").exists());
}
- // ./.travis.yml
- @Test public void checkTravisExists() {
- assertTrue(new File("./.travis.yml").exists());
- }
-
- // ./.codeclimate.yml
- @Test public void checkCodeClimateExists() {
- assertTrue(new File("./.codeclimate.yml").exists());
- }
// ./CHANGELOG.md
@Test public void checkChangelogExists() {
@@ -55,19 +45,14 @@ public class TestRequiredFilesExist {
assertTrue(new File("./CONTRIBUTING.md").exists());
}
- // ./.github/ISSUE_TEMPLATE
- @Test public void checkIssuesTemplateExists() {
- assertTrue(new File("./.github/ISSUE_TEMPLATE").exists());
- }
-
- // ./LICENSE.md
+ // ./LICENSE
@Test public void checkLicenseExists() {
- assertTrue(new File("./LICENSE.md").exists());
+ assertTrue(new File("./LICENSE").exists());
}
- // ./.github/PULL_REQUEST_TEMPLATE
+ // ./PULL_REQUEST_TEMPLATE.md
@Test public void checkPullRequestExists() {
- assertTrue(new File("./.github/PULL_REQUEST_TEMPLATE").exists());
+ assertTrue(new File("./PULL_REQUEST_TEMPLATE.md").exists());
}
// ./README.md
@@ -85,8 +70,8 @@ public class TestRequiredFilesExist {
assertTrue(new File("./USAGE.md").exists());
}
- // ./USE_CASES.md
+ /* // ./USE_CASES.md
@Test public void checkUseCases() {
assertTrue(new File("./USE_CASES.md").exists());
- }
+ } */
}
diff --git a/static/img/github-fork.png b/static/img/github-fork.png
new file mode 100644
index 0000000..6503be3
Binary files /dev/null and b/static/img/github-fork.png differ
diff --git a/static/img/github-sign-up.png b/static/img/github-sign-up.png
new file mode 100644
index 0000000..491392b
Binary files /dev/null and b/static/img/github-sign-up.png differ
diff --git a/twilio_sendgrid_logo.png b/twilio_sendgrid_logo.png
new file mode 100644
index 0000000..a4c2223
Binary files /dev/null and b/twilio_sendgrid_logo.png differ
diff --git a/use_cases/README.md b/use_cases/README.md
new file mode 100644
index 0000000..657a022
--- /dev/null
+++ b/use_cases/README.md
@@ -0,0 +1,5 @@
+This documentation provides examples for specific SendGrid v3 API use cases. Please [open an issue](https://github.com/sendgrid/java-http-client/issues) or make a pull request for any email use cases you would like us to document here. Thank you!
+
+# Email Use Cases
+
+# Non-mail Use Cases