diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE
new file mode 100644
index 0000000..7ad590b
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE
@@ -0,0 +1,24 @@
+
+# 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/.travis.yml b/.travis.yml
index fc8d67d..d0c473e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,12 @@
language: java
-sudo: false
jdk:
- oraclejdk8
-- oraclejdk7
-- openjdk7
+- openjdk8
+before_script:
+- chmod a+x gradlew
+script:
+- ./gradlew build check
after_script:
-- "./gradlew build"
- "./scripts/s3upload.sh"
env:
global:
@@ -22,4 +23,4 @@ notifications:
Build %{build_number} on branch %{branch} by %{author}: %{message}
View on GitHub'
format: html
- notify: true
\ No newline at end of file
+ notify: true
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5669281..c3530e4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
+## [4.1.1] - 2016-10-11
+### Added
+- [Pull #23](https://github.com/sendgrid/java-http-client/pull/23): Moved Mockito to test dependency.
+- BIG thanks to [Joseph Lust](https://github.com/twistedpair) for the pull request!
+
## [4.1.0] - 2016-10-11
### Added
- [Pull #17](https://github.com/sendgrid/java-http-client/pull/17): Assign server response outside try block
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..e3ce656
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,41 @@
+# SendGrid Community 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.
+
+### 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.
+
+### 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.
+
+### 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.
+
+## Additional Guidance
+
+### 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.
+
+### 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.
+
+### 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.
+
+## 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.
+
+**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.
+
+**Contact the Moderators** - You can reach the SendGrid moderators by emailing dx@sendgrid.com.
+
+## 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).
+
+## Attribution
+
+SendGrid thanks the following, on which it draws for content and inspiration:
+
+* [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
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 64ed06b..82c11e2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,13 +2,13 @@ Hello! Thank you for choosing to help contribute to one of the SendGrid open sou
- [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)
+- [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)
+- [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.
@@ -26,7 +26,7 @@ When you create a Pull Request, after a few seconds, a comment will appear with
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.
@@ -36,7 +36,7 @@ The GitHub issue tracker is the preferred channel for library feature requests,
- 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.
@@ -53,7 +53,7 @@ Before you decide to create a new issue, please try the following:
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.
-
+
## Improvements to the Codebase
We welcome direct contributions to the java-http-client code base. Thank you!
@@ -64,7 +64,7 @@ We welcome direct contributions to the java-http-client code base. Thank you!
##### Prerequisites #####
-- Java version Oracle JDK 7, 8 or OpenJDK 7
+- Java version Oracle JDK 8 or OpenJDK 7
- Please see [build.gradle](https://github.com/sendgrid/java-http-client/blob/master/build.gradle)
##### Initial setup: #####
@@ -89,10 +89,10 @@ source ./sendgrid.env
```bash
./gradlew build
cd examples
-javac -classpath {path_to}/sendgrid-java-http-client-4.1.0-jar.jar:. Example.java && java -classpath {path_to}/sendgrid-java-http-client-4.1.0-jar.jar:. Example
+javac -classpath {path_to}/sendgrid-java-http-client-4.1.1-jar.jar:. Example.java && java -classpath {path_to}/sendgrid-java-http-client-4.1.1-jar.jar:. Example
```
-
+
## Understanding the Code Base
**/examples**
@@ -131,7 +131,7 @@ Run the tests:
./gradlew test -i
```
-
+
## Style Guidelines & Naming Conventions
Generally, we follow the style guidelines as suggested by the official language. However, we ask that you conform to the styles that already exist in the library. If you wish to deviate, please explain your reasoning.
@@ -141,8 +141,8 @@ Please run your code through:
- [FindBugs](http://findbugs.sourceforge.net/)
- [CheckStyle](http://checkstyle.sourceforge.net/) with [Google's Java Style Guide](http://checkstyle.sourceforge.net/reports/google-java-style.html).
-
-## Creating a Pull Request
+
+## Creating a Pull Request
1. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork,
and configure the remotes:
@@ -151,7 +151,7 @@ Please run your code through:
# Clone your fork of the repo into the current directory
git clone https://github.com/sendgrid/java-http-client
# Navigate to the newly cloned directory
- cd sendgrid-python
+ cd java-http-client
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/sendgrid/java-http-client
```
diff --git a/LICENSE.txt b/LICENSE.txt
index 9b2cba2..dd2444e 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2016 SendGrid, Inc.
+Copyright (c) 2016-2017 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
diff --git a/README.md b/README.md
index 96245bd..1dd1203 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,37 @@
-[![Build Status](https://travis-ci.org/sendgrid/java-http-client.svg?branch=master)](https://travis-ci.org/sendgrid/java-http-client) [![Maven](https://maven-badges.herokuapp.com/maven-central/com.sendgrid/java-http-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.sendgrid/java-http-client)
+![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)
+
+[![Build Status](https://travis-ci.org/sendgrid/java-http-client.svg?branch=master)](https://travis-ci.org/sendgrid/java-http-client)
+[![Maven Central](https://img.shields.io/maven-central/v/com.sendgrid/java-http-client.svg)](http://mvnrepository.com/artifact/com.sendgrid/java-http-client)
+[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)
+[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
+[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/java-http-client.svg)](https://github.com/sendgrid/java-http-client/graphs/contributors)
**Quickly and easily access any RESTful or RESTful-like API.**
If you are looking for the SendGrid API client library, please see [this repo](https://github.com/sendgrid/sendgrid-java).
+# Table of Contents
+
+* [Announcements](#announcements)
+* [Installation](#installation)
+* [Quick Start](#quick-start)
+* [Usage](#usage)
+* [Roadmap](#roadmap)
+* [How to Contribute](#contribute)
+* [About](#about)
+* [License](#license)
+
+
# Announcements
All updates to this project is documented in our [CHANGELOG](https://github.com/sendgrid/java-http-client/blob/master/CHANGELOG.md).
+
# Installation
## Prerequisites
-- Java version Oracle JDK 7, 8 or OpenJDK 7
+- Java version Oracle JDK 8 or OpenJDK 7
## Install via Maven w/ Gradle
@@ -20,7 +39,7 @@ All updates to this project is documented in our [CHANGELOG](https://github.com/
...
dependencies {
...
- compile 'com.sendgrid:java-http-client:4.1.0'
+ compile 'com.sendgrid:java-http-client:4.1.1'
}
repositories {
@@ -35,7 +54,7 @@ repositories {
com.sendgrid
java-http-client
- 3.0.0
+ 4.1.1
```
@@ -43,12 +62,13 @@ repositories {
## Install via Fat Jar
-[Download](http://repo1.maven.org/maven2/com/sendgrid/java-http-client/4.1.0/java-http-client-4.1.0-jar.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)
+
# Quick Start
Here is a quick example:
@@ -95,46 +115,33 @@ try {
}
```
+
# Usage
+[Library Usage Documentation](USAGE.md)
-- [Example Code](https://github.com/sendgrid/java-http-client/tree/master/examples)
-
-The example uses SendGrid, you can get your free account [here](https://sendgrid.com/free?source=java-http-client).
-
-First, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).
-
-```bash
-echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
-echo "sendgrid.env" >> .gitignore
-source ./sendgrid.env
-```
-
-```bash
-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
-```
-
-## Roadmap
+
+# Roadmap
-If you are intersted 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.
+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
+
+# 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.
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)
+- [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)
+- [Improvements to the Codebase](https://github.com/sendgrid/java-http-client/blob/master/CONTRIBUTING.md#improvements-to-the-codebase)
+
# 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 SendGrid, Inc. The names and logos for java-http-client are trademarks of SendGrid, Inc.
-![SendGrid Logo]
-(https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.png)
+# License
+[The MIT License (MIT)](LICENSE.txt)
\ No newline at end of file
diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md
new file mode 100644
index 0000000..ef5b2a5
--- /dev/null
+++ b/TROUBLESHOOTING.md
@@ -0,0 +1,18 @@
+If you have a non-library SendGrid issue, please contact our [support team](https://support.sendgrid.com).
+
+If you can't find a solution below, please open an [issue](https://github.com/sendgrid/java-http-client/issues).
+
+## Table of Contents
+
+* [Viewing the Request Body](#request-body)
+
+
+## Viewing the Request Body
+
+When debugging or testing, it may be useful to examine the raw request body to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html).
+
+You can do this right before you call `request.setBody(mail.build())` like so:
+
+```java
+System.out.println(mail.build());
+```
diff --git a/USAGE.md b/USAGE.md
new file mode 100644
index 0000000..40c3f83
--- /dev/null
+++ b/USAGE.md
@@ -0,0 +1,19 @@
+# Usage
+
+- [Example Code](https://github.com/sendgrid/java-http-client/tree/master/examples)
+
+The example uses SendGrid, you can get your free account [here](https://sendgrid.com/free?source=java-http-client).
+
+First, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).
+
+```bash
+echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
+echo "sendgrid.env" >> .gitignore
+source ./sendgrid.env
+```
+
+```bash
+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
diff --git a/build.gradle b/build.gradle
index 342ac8f..c572c17 100644
--- a/build.gradle
+++ b/build.gradle
@@ -17,7 +17,7 @@ apply plugin: 'signing'
apply plugin: 'com.github.johnrengelman.shadow'
group = 'com.sendgrid'
-version = '4.1.0'
+version = '4.1.1'
ext.packaging = 'jar'
allprojects {
@@ -31,10 +31,6 @@ if (!hasProperty("sonatypeUsername")) {
ext.sonatypePassword = null
}
-task wrapper(type: Wrapper) {
- gradleVersion = '1.8'
-}
-
buildscript {
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
@@ -47,7 +43,7 @@ buildscript {
dependencies {
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile 'org.apache.httpcomponents:httpclient:4.5.2'
- compile 'org.mockito:mockito-core:1.10.19'
+ testCompile 'org.mockito:mockito-core:1.10.19'
testCompile group: 'junit', name: 'junit-dep', version: '4.10'
}
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 42b1604..2310768 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-1.8-bin.zip
\ No newline at end of file
+distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 8f9ca8d..bf5caff 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,7 +11,7 @@
jar
A simple HTTP client
HTTP REST client, simplified for Java
- 4.1.0
+ 4.1.1
https://github.com/sendgrid/java-http-client
diff --git a/src/main/java/com/sendgrid/Client.java b/src/main/java/com/sendgrid/Client.java
index 789855c..7360ab2 100644
--- a/src/main/java/com/sendgrid/Client.java
+++ b/src/main/java/com/sendgrid/Client.java
@@ -53,19 +53,17 @@ public class Client {
* Constructor for using the default CloseableHttpClient.
*/
public Client() {
- this.httpClient = HttpClients.createDefault();
- this.test = false;
+ this(false);
}
/**
- * Constructor for passing in an httpClient for mocking.
+ * Constructor for passing in an httpClient.
*
* @param httpClient
* an Apache CloseableHttpClient
*/
public Client(CloseableHttpClient httpClient) {
- this.httpClient = httpClient;
- this.test = false;
+ this(httpClient, false);
}
/**
@@ -75,10 +73,23 @@ public Client(CloseableHttpClient httpClient) {
* is a Bool
*/
public Client(Boolean test) {
- this.httpClient = HttpClients.createDefault();
+ this(HttpClients.createDefault(), test);
+ }
+
+ /**
+ * Constructor for passing in a an httpClient and test parameter to allow for http calls
+ *
+ * @param httpClient
+ * an Apache CloseableHttpClient
+ * @param test
+ * is a Bool
+ */
+ public Client(CloseableHttpClient httpClient, Boolean test) {
+ this.httpClient = httpClient;
this.test = test;
}
+
/**
* Add query parameters to a URL.
*