Skip to content
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

Added missing metadata to scheduled charge #153

Merged
merged 12 commits into from
Jul 17, 2023
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ build/
# Ignore Gradle GUI config
gradle-app.setting

# Ignore locale.properties file
local.properties

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

Expand Down
Binary file added file.ser
danfowler marked this conversation as resolved.
Show resolved Hide resolved
Binary file not shown.
7 changes: 7 additions & 0 deletions src/main/java/co/omise/models/schedules/ChargeSchedule.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public static class Params extends co.omise.models.Params {
@JsonProperty
private String description;

@JsonProperty
private Map<String, Object> metadata;

public Params amount(long amount) {
this.amount = amount;
return this;
Expand All @@ -116,5 +119,9 @@ public Params description(String description) {
this.description = description;
return this;
}
public Params metadata(Map<String, Object> metadata) {
this.metadata = metadata;
return this;
}
}
}
12 changes: 8 additions & 4 deletions src/test/java/co/omise/live/LiveScheduleRequestTest.java
danfowler marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.junit.Test;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import static org.junit.Assert.*;

Expand All @@ -24,7 +26,7 @@ public void setup() throws Exception {
}

@Test
@Ignore("only hit the network when we need to.")
//@Ignore("only hit the network when we need to.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Live tests supposed to be run on local only (at least for now).

Copy link
Contributor Author

@AnasNaouchi AnasNaouchi Jul 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah forgot to uncomment. Fixed now

public void testLiveScheduleListGet() throws IOException, OmiseException {
Request<ScopedList<Schedule>> request =
new Schedule.ListRequestBuilder()
Expand Down Expand Up @@ -75,7 +77,8 @@ public void testLiveScheduleGet() throws IOException, OmiseException {
.build();

Customer customer = client.sendRequest(customerRequest);

Map<String, Object> metadata = new HashMap<>();
metadata.put("testKey","testData");
Request<Schedule> scheduleRequest = new Schedule.CreateRequestBuilder()
.every(1)
.period(SchedulePeriod.Week)
Expand All @@ -85,8 +88,9 @@ public void testLiveScheduleGet() throws IOException, OmiseException {
.customer(customer.getId())
.amount(2000)
.currency("THB")
.description("Monthly membership fee"))
.build();
.description("Monthly membership fee")
.metadata(metadata)
).build();

Schedule createdSchedule = client.sendRequest(scheduleRequest);

Expand Down
Loading