Skip to content

Commit 403ffd6

Browse files
authored
Merge pull request #33 from messagebird/v2_staging
V2 staging
2 parents 33c8f21 + ab474c3 commit 403ffd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+3418
-224
lines changed

.travis.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
language: java
2-
dist: precise
2+
dist: trusty
33
before_script: cd api/
4-
script: mvn test -Ptest -DmessageBirdAccessKey=test_iQpAp0KCs5GCsMpDhIx2leuNB -DmessageBirdMSISDN=31612345678
4+
script: mvn test -Ptest -DskipTests=false -Dhttps.protocols=TLSv1.2 -DmessageBirdAccessKey=test_iQpAp0KCs5GCsMpDhIx2leuNB -DmessageBirdMSISDN=31612345678
55
jdk:
66
- oraclejdk8
7-
- oraclejdk7
8-
- openjdk6
7+
- oraclejdk9
98
- openjdk7
9+
- openjdk8
10+
matrix:
11+
include:
12+
- jdk: oraclejdk7
13+
dist: precise

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,19 @@ If you are using maven simply add the messagebird API to your dependencies like
2929
<dependency>
3030
<groupId>com.messagebird</groupId>
3131
<artifactId>messagebird-api</artifactId>
32-
<version>1.3.2</version>
32+
<version>2.0.0</version>
3333
</dependency>
3434
```
3535

3636
In case you are building without maven you still need maven to build the libraries but
3737
then simply copy the following jar's over to your project
3838

3939
```
40-
messagebird-api-1.3.2.jar
41-
jackson-core-2.1.1.jar
42-
jackson-databind-2.1.1.jar
43-
jackson-mapper-asl-1.9.13.jar
44-
jackson-core-asl-1.9.13.jar
40+
messagebird-api-2.0.0.jar
41+
jackson-core-2.9.0.jar
42+
jackson-databind-2.9.0.jar
43+
jackson-dataformat-csv-2.9.0.jar
4544
jackson-annotations-2.1.1.jar
46-
jackson-dataformat-csv-2.1.1.jar
4745
```
4846

4947

api/pom.xml

Lines changed: 50 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
<groupId>com.messagebird</groupId>
88
<artifactId>messagebird-api</artifactId>
9-
<version>1.3.2</version>
9+
<version>2.0.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>${project.groupId}:${project.artifactId}</name>
13-
<description>The MessageBird API provides a API to the MessageBird SMS and voicemail services located at https://www.messagebird.com.</description>
13+
<description>The MessageBird API provides an API to the MessageBird SMS, Chat and Voice services located at https://www.messagebird.com.</description>
1414

1515
<url>https://www.messagebird.com/</url>
1616

@@ -43,7 +43,6 @@
4343
<url>[email protected]:messagebird/java-rest-api.git</url>
4444
</scm>
4545

46-
4746
<profiles>
4847
<profile>
4948
<id>default</id>
@@ -54,24 +53,8 @@
5453
<skipTests>true</skipTests>
5554
<messageBirdAccessKey></messageBirdAccessKey>
5655
<messageBirdMSISDN></messageBirdMSISDN>
56+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5757
</properties>
58-
<build>
59-
<plugins>
60-
<plugin>
61-
<groupId>org.apache.maven.plugins</groupId>
62-
<artifactId>maven-javadoc-plugin</artifactId>
63-
<version>2.10.3</version>
64-
<executions>
65-
<execution>
66-
<phase>package</phase>
67-
<goals>
68-
<goal>jar</goal>
69-
</goals>
70-
</execution>
71-
</executions>
72-
</plugin>
73-
</plugins>
74-
</build>
7558
</profile>
7659
<profile>
7760
<id>test</id>
@@ -80,60 +63,47 @@
8063
</properties>
8164
</profile>
8265
<profile>
83-
<id>java8</id>
66+
<id>disable-doclint</id>
8467
<activation>
85-
<jdk>1.8</jdk>
68+
<jdk>[1.8,)</jdk>
8669
</activation>
8770
<properties>
71+
<doclint>none</doclint>
8872
<skipTests>true</skipTests>
8973
<messageBirdAccessKey></messageBirdAccessKey>
9074
<messageBirdMSISDN></messageBirdMSISDN>
75+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
9176
</properties>
92-
<build>
93-
<plugins>
94-
<plugin>
95-
<groupId>org.apache.maven.plugins</groupId>
96-
<artifactId>maven-javadoc-plugin</artifactId>
97-
<version>2.10.3</version>
98-
<executions>
99-
<execution>
100-
<phase>package</phase>
101-
<goals>
102-
<goal>jar</goal>
103-
</goals>
104-
<configuration>
105-
<additionalparam>-Xdoclint:none</additionalparam>
106-
</configuration>
107-
</execution>
108-
</executions>
109-
</plugin>
110-
</plugins>
111-
</build>
11277
</profile>
11378
</profiles>
11479

11580
<dependencies>
11681
<dependency>
117-
<groupId>com.fasterxml.jackson.dataformat</groupId>
118-
<artifactId>jackson-dataformat-csv</artifactId>
119-
<version>2.1.1</version>
82+
<groupId>com.fasterxml.jackson.core</groupId>
83+
<artifactId>jackson-annotations</artifactId>
84+
<version>2.9.0</version>
12085
</dependency>
12186
<dependency>
122-
<groupId>org.codehaus.jackson</groupId>
123-
<artifactId>jackson-mapper-asl</artifactId>
124-
<version>1.9.13</version>
87+
<groupId>com.fasterxml.jackson.core</groupId>
88+
<artifactId>jackson-databind</artifactId>
89+
<version>2.9.0</version>
12590
</dependency>
12691
<dependency>
127-
<groupId>org.codehaus.jackson</groupId>
128-
<artifactId>jackson-core-asl</artifactId>
129-
<version>1.9.13</version>
92+
<groupId>com.fasterxml.jackson.dataformat</groupId>
93+
<artifactId>jackson-dataformat-csv</artifactId>
94+
<version>2.9.0</version>
13095
</dependency>
13196
<dependency>
13297
<groupId>junit</groupId>
13398
<artifactId>junit</artifactId>
13499
<version>4.11</version>
135100
<scope>test</scope>
136101
</dependency>
102+
<dependency>
103+
<groupId>org.mockito</groupId>
104+
<artifactId>mockito-core</artifactId>
105+
<version>2.21.0</version>
106+
</dependency>
137107
</dependencies>
138108

139109
<distributionManagement>
@@ -148,7 +118,7 @@
148118
<plugin>
149119
<groupId>org.apache.maven.plugins</groupId>
150120
<artifactId>maven-source-plugin</artifactId>
151-
<version>2.4</version>
121+
<version>3.0.1</version>
152122
<executions>
153123
<execution>
154124
<id>attach-sources</id>
@@ -158,6 +128,27 @@
158128
</execution>
159129
</executions>
160130
</plugin>
131+
<plugin>
132+
<groupId>org.apache.maven.plugins</groupId>
133+
<artifactId>maven-javadoc-plugin</artifactId>
134+
<version>3.0.0</version>
135+
<executions>
136+
<execution>
137+
<phase>package</phase>
138+
<goals>
139+
<goal>jar</goal>
140+
</goals>
141+
</execution>
142+
</executions>
143+
<dependencies>
144+
<!-- https://issues.apache.org/jira/browse/MJAVADOC-517 -->
145+
<dependency>
146+
<groupId>org.apache.commons</groupId>
147+
<artifactId>commons-lang3</artifactId>
148+
<version>3.7</version>
149+
</dependency>
150+
</dependencies>
151+
</plugin>
161152
<plugin>
162153
<groupId>org.apache.maven.plugins</groupId>
163154
<artifactId>maven-gpg-plugin</artifactId>
@@ -175,13 +166,15 @@
175166
<plugin>
176167
<groupId>org.apache.maven.plugins</groupId>
177168
<artifactId>maven-compiler-plugin</artifactId>
178-
<version>3.1</version>
169+
<version>3.7.0</version>
179170
<configuration>
180-
<source>1.6</source>
181-
<target>1.6</target>
171+
<source>1.7</source>
172+
<target>1.7</target>
182173
</configuration>
183174
</plugin>
184175
<plugin>
176+
<groupId>org.apache.maven.plugins</groupId>
177+
<version>3.1.0</version>
185178
<artifactId>maven-assembly-plugin</artifactId>
186179
<configuration>
187180
<descriptorRefs>
@@ -201,7 +194,7 @@
201194
<plugin>
202195
<groupId>org.apache.maven.plugins</groupId>
203196
<artifactId>maven-surefire-plugin</artifactId>
204-
<version>2.18.1</version>
197+
<version>2.21.0</version>
205198
<configuration>
206199
<skipTests>${skipTests}</skipTests>
207200
<systemPropertyVariables>
@@ -213,7 +206,7 @@
213206
<plugin>
214207
<groupId>org.sonatype.plugins</groupId>
215208
<artifactId>nexus-staging-maven-plugin</artifactId>
216-
<version>1.6.3</version>
209+
<version>1.6.7</version>
217210
<extensions>true</extensions>
218211
<configuration>
219212
<serverId>ossrh</serverId>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.messagebird;
2+
3+
/**
4+
* Represents a raw response received from the API.
5+
*/
6+
public class APIResponse {
7+
8+
/**
9+
* Status indicates a successful request.
10+
*/
11+
private static final int STATUS_OK = 200;
12+
13+
private static final int STATUS_NO_CONTENT = 204;
14+
15+
private static final int STATUS_RANGE_SUCCESS_START = 200;
16+
private static final int STATUS_RANGE_SUCCESS_END = 299;
17+
18+
private final String body;
19+
private final int status;
20+
21+
APIResponse(final String body, final int status) {
22+
this.body = body;
23+
this.status = status;
24+
}
25+
26+
/**
27+
* Initializes an APIResponse object and sets the HTTP status code to 200.
28+
* @param body
29+
*/
30+
APIResponse(final String body) {
31+
this(body, STATUS_OK);
32+
}
33+
34+
/**
35+
* Determines whether the provided HTTP status code indicates success.
36+
*
37+
* @param status
38+
*
39+
* @return True if the status indicates success.
40+
*/
41+
public static boolean isSuccessStatus(final int status) {
42+
return status >= STATUS_RANGE_SUCCESS_START
43+
&& status <= STATUS_RANGE_SUCCESS_END;
44+
}
45+
46+
/**
47+
* Determines whether this request is successful based on its HTTP status
48+
* code.
49+
*
50+
* @return True if the request is successful.
51+
*/
52+
public boolean isSuccess() {
53+
return isSuccessStatus(status);
54+
}
55+
56+
/**
57+
* Determines whether this request has content, based on its HTTP status
58+
* code and otherwise by inspecting the response body.
59+
*
60+
* @return True if the request has content.
61+
*/
62+
public boolean hasContent() {
63+
return status == STATUS_NO_CONTENT
64+
|| body == null
65+
|| body.isEmpty();
66+
}
67+
68+
public String getBody() {
69+
return body;
70+
}
71+
72+
public int getStatus() {
73+
return status;
74+
}
75+
}

0 commit comments

Comments
 (0)