Skip to content
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ dependencies {
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.17.1'

// networking
implementation 'com.squareup.okhttp3:okhttp:3.7.0'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'

// test
testImplementation 'junit:junit:4.12'
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/co/omise/Configurer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package co.omise;

import org.jetbrains.annotations.NotNull;

import okhttp3.Credentials;
import okhttp3.Interceptor;
import okhttp3.Request;
Expand Down Expand Up @@ -46,6 +48,7 @@ public static Request configure(Config config, Request request) {
return builder.build();
}

@NotNull
@Override
public Response intercept(Chain chain) throws IOException {
return chain.proceed(configure(config, chain.request()));
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/co/omise/models/Params.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public RequestBody body(Serializer serializer) throws IOException {

ByteArrayOutputStream stream = new ByteArrayOutputStream(4096);
serializer.serializeParams(stream, this);
return RequestBody.create(JSON_MEDIA_TYPE, stream.toByteArray());
return RequestBody.Companion.create(stream.toByteArray(), JSON_MEDIA_TYPE);
}
}
2 changes: 1 addition & 1 deletion src/main/java/co/omise/requests/RequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected RequestBody payload() throws IOException {
protected RequestBody serialize() throws IOException {
ByteArrayOutputStream stream = new ByteArrayOutputStream(4096);
serializer().serializeRequestBuilder(stream, this);
return RequestBody.create(JSON_MEDIA_TYPE, stream.toByteArray());
return RequestBody.Companion.create(stream.toByteArray(), JSON_MEDIA_TYPE);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/test/java/co/omise/testutils/TestInterceptor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package co.omise.testutils;

import org.jetbrains.annotations.NotNull;

import co.omise.OmiseTest;
import okhttp3.*;

Expand All @@ -16,6 +18,7 @@ public TestInterceptor(OmiseTest test) {
this.test = test;
}

@NotNull
@Override
public Response intercept(Chain chain) {
Request request = chain.request();
Expand All @@ -32,10 +35,12 @@ public Response intercept(Chain chain) {
Response.Builder builder = new Response.Builder()
.request(request)
.protocol(Protocol.HTTP_1_1)
// Message is not optional anymore and this is only for testing
.message("")
.code(code);

if (responseData != null) {
builder = builder.body(ResponseBody.create(jsonMediaType, responseData));
builder = builder.body(ResponseBody.Companion.create(responseData, jsonMediaType));
}

return lastResponse = builder.build();
Expand Down