Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
ClientConverter updated
  • Loading branch information
agafox committed Aug 8, 2017
1 parent 10e68a7 commit a1e4f93
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
Expand Up @@ -439,6 +439,23 @@ protected void writeVoiceApplicationSid(final Sid voiceApplicationSid, final Jso
}
}


protected void writePushClientIdentity(final String pushClientIdentity, final HierarchicalStreamWriter writer) {
if (pushClientIdentity != null) {
writer.startNode("PushClientIdentity");
writer.setValue(pushClientIdentity);
writer.endNode();
}
}

protected void writePushClientIdentity(final String pushClientIdentity, final JsonObject object) {
if (pushClientIdentity != null) {
object.addProperty("push_client_identity", pushClientIdentity);
} else {
object.add("voice_application_sid", JsonNull.INSTANCE);
}
}

protected void writeVoiceCallerIdLookup(final boolean voiceCallerIdLookup, final HierarchicalStreamWriter writer) {
writer.startNode("VoiceCallerIdLookup");
writer.setValue(Boolean.toString(voiceCallerIdLookup));
Expand Down
Expand Up @@ -66,6 +66,7 @@ public void marshal(final Object object, final HierarchicalStreamWriter writer,
writeVoiceFallbackMethod(client.getVoiceFallbackMethod(), writer);
writeVoiceApplicationSid(client.getVoiceApplicationSid(), writer);
writeUri(client.getUri(), writer);
writePushClientIdentity(client.getPushClientIdentity(), writer);
writer.endNode();
}

Expand All @@ -87,6 +88,7 @@ public JsonElement serialize(final Client client, final Type type, final JsonSer
writeVoiceFallbackMethod(client.getVoiceFallbackMethod(), object);
writeVoiceApplicationSid(client.getVoiceApplicationSid(), object);
writeUri(client.getUri(), object);
writePushClientIdentity(client.getPushClientIdentity(), object);
return object;
}

Expand Down
Expand Up @@ -187,6 +187,20 @@ public void createClientTestWithInvalidCharacters() throws ClientProtocolExcepti
Assert.assertTrue("Response should contain 'invalid' term", response.getEntity(String.class).toLowerCase().contains("invalid"));
}

@Test
public void createClientTestWithIsPushEnabled() throws IOException, ParseException, InterruptedException {
Client jersey = getClient(developerUsername, developeerAuthToken);
WebResource resource = jersey.resource( getResourceUrl("/2012-04-24/Accounts/" + developerAccountSid + "/Clients.json" ) );
MultivaluedMap<String, String> params = new MultivaluedMapImpl();
params.add("Login","bob"); // login contains @ sign
params.add("Password","RestComm1234!");
params.add("IsPushEnabled", "true");
ClientResponse response = resource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, params);
Assert.assertEquals(200, response.getStatus());
Assert.assertTrue("Response should contain 'push_client_identity'", response.getEntity(String.class).contains("push_client_identity"));
}


protected String getResourceUrl(String suffix) {
String urlString = deploymentUrl.toString();
if ( urlString.endsWith("/") )
Expand Down

0 comments on commit a1e4f93

Please sign in to comment.