Skip to content

Commit

Permalink
Fix maven release / tv create / various (#3)
Browse files Browse the repository at this point in the history
* Fix maven release information

* Add tv type on create and various fixes
  • Loading branch information
odairay authored Oct 30, 2017
1 parent 00e7ee5 commit 858c129
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 13 deletions.
31 changes: 23 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,34 @@

- Java7 TefpsTvClient

### Java7 TefpsTvClient - Usage
### Java7 TefpsTvClient - Installation

Add maven dependency to your pom.xml

```xml
<dependency>
<groupId>fr.polyconseil.smartcity</groupId>
<artifactId>tefps-clients</artifactId>
<version>1.0.0</version>
</dependency>
```


### Java7 TefpsTvClient - Usage

```java
import fr.polyconseil.smartcity.tefpsclient.tv.TefpsTvClient;
import fr.polyconseil.smartcity.tefpsclients.auth.OAuth2HttpClient;
import fr.polyconseil.smartcity.tefpsclient.dto.tv.ParkingRightDTO;

TefpsTvClient client = new TefpsTvClient(new OAuth2HttpClient(
"http://tefps-directory-host:port",
"clientId",
"clientSecret"),
"http://tefps-tv-host:port"
);
//...

TefpsTvClient client = new TefpsTvClient(new OAuth2HttpClient(
"http://tefps-directory-host:port",
"clientId",
"clientSecret"),
"http://tefps-tv-host:port"
);

ParkingRightDTO parkingRight = client.fetchTv("cityId", "tvId");
ParkingRightDTO parkingRight = client.fetchTv("cityId", "tvId");
```
14 changes: 14 additions & 0 deletions java7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
<url>https://github.com/Polyconseil/tefps-clients.git</url>
</scm>

<developers>
<developer>
<name>Polyconseil</name>
<email>[email protected]</email>
<organization>Polyconseil</organization>
<organizationUrl>http://www.polyconseil.fr</organizationUrl>
</developer>
</developers>

<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
Expand Down Expand Up @@ -131,6 +140,11 @@
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--no-tty</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.apache.http.client.methods.*;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.message.BasicNameValuePair;

Expand Down Expand Up @@ -134,7 +133,7 @@ public void delete(URI uri) throws IOException {

public <T> T patch(URI uri, List<PatchObject> patchList, Class<T> valueType) throws IOException {
HttpPatch patchRequest = new HttpPatch(uri);
patchRequest.setEntity(new StringEntity(mapper.writeValueAsString(patchList)));
patchRequest.setEntity(new ByteArrayEntity(mapper.writeValueAsBytes(patchList)));

return this.executeAuthenticated(patchRequest, valueType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public TefpsTvClient (OAuth2HttpClient oAuth2Client, String tvUrl) {
public ParkingRightDTO createTv(
String cityId,
String tvId,
ParkingRightType type,
String source,
@Nullable String fineLegalId,
String zoneId,
Expand All @@ -46,7 +47,7 @@ public ParkingRightDTO createTv(
) throws IOException, URISyntaxException {
ParkingRightCreationDTO dto = new ParkingRightCreationDTO();

dto.setType(ParkingRightType.TICKET);
dto.setType(type);
dto.setFineLegalId(fineLegalId);
dto.setSource(source);
dto.setZoneId(zoneId);
Expand Down Expand Up @@ -123,7 +124,7 @@ public void deleteTv(String cityId, String tvId) throws IOException, URISyntaxEx
oAuth2Client.delete(buildURI(cityId, tvId));
}

private URI buildURI(String tvId, String cityId) throws IOException, URISyntaxException {
return OAuth2HttpClient.buildURI(tvUrl, TV_API, tvId, cityId);
private URI buildURI(String cityId, String tvId) throws IOException, URISyntaxException {
return OAuth2HttpClient.buildURI(tvUrl, TV_API, cityId, tvId);
}
}

0 comments on commit 858c129

Please sign in to comment.