Skip to content

fixed objectmapper serialization and updated Language enum class #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,6 @@ public <P> HttpURLConnection getConnection(final String serviceUrl, final P body
connection.setRequestProperty("Content-Type", "application/json");
ObjectMapper mapper = new ObjectMapper();
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
// Specifically set the date format for POST requests so scheduled
// messages and other things relying on specific date formats don't
// fail when sending.
Expand Down
14 changes: 12 additions & 2 deletions api/src/main/java/com/messagebird/objects/Language.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.messagebird.objects;

import com.fasterxml.jackson.annotation.JsonValue;

/**
* Created by faizan on 09/12/15.
*/
Expand All @@ -25,13 +27,21 @@ public enum Language {
PT_BR("pt-br"),
RO_RO("ro-ro");

private String code;
final String code;

Language(String code) {
this.code = code;
}

@JsonValue
public String getCode() {
return code;
}

@Override
public String toString() {
return this.code;
return "Language{" +
"code='" + code + '\'' +
'}';
}
}