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

🌿 Fern Regeneration -- February 20, 2024 #10

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repositories {
}

dependencies {
api 'com.squareup.okhttp3:okhttp:4.9.3'
api 'com.squareup.okhttp3:okhttp:4.12.0'
api 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.12.3'
api 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.12.3'
Expand Down Expand Up @@ -46,7 +46,7 @@ publishing {
maven(MavenPublication) {
groupId = 'com.cohere'
artifactId = 'cohere-java'
version = '1.0.3'
version = '1.0.6'
from components.java
}
}
Expand Down
134 changes: 76 additions & 58 deletions src/main/java/com/cohere/api/Cohere.java

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion src/main/java/com/cohere/api/CohereBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,25 @@
public final class CohereBuilder {
private ClientOptions.Builder clientOptionsBuilder = ClientOptions.builder();

private String token = null;

private String clientName = null;

private Environment environment = Environment.PRODUCTION;

/**
* Sets token
*/
public CohereBuilder token(String token) {
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + token);
this.token = token;
return this;
}

/**
* Sets clientName
*/
public CohereBuilder clientName(String clientName) {
this.clientName = clientName;
return this;
}

Expand All @@ -27,6 +42,14 @@ public CohereBuilder url(String url) {
}

public Cohere build() {
if (token == null) {
throw new RuntimeException("Please provide token");
}
this.clientOptionsBuilder.addHeader("Authorization", "Bearer " + this.token);
if (clientName == null) {
throw new RuntimeException("Please provide clientName");
}
this.clientOptionsBuilder.addHeader("X-Client-Name", this.clientName);
clientOptionsBuilder.environment(this.environment);
return new Cohere(clientOptionsBuilder.build());
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cohere/api/core/ApiError.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public Object body() {
return this.body;
}

@Override
@java.lang.Override
public String toString() {
return "ApiError{" + "statusCode: " + statusCode + ", body: " + body + "}";
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/cohere/api/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ private ClientOptions(
"X-Fern-SDK-Name",
"com.cohere.fern:api-sdk",
"X-Fern-SDK-Version",
"1.0.3",
"1.0.6",
"X-Fern-Language",
"JAVA"));
this.headerSuppliers = headerSuppliers;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/cohere/api/core/MediaTypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* This file was auto-generated by Fern from our API Definition.
*/
package com.cohere.api.core;

import okhttp3.MediaType;

public final class MediaTypes {

public static final MediaType APPLICATION_JSON = MediaType.parse("application/json");

private MediaTypes() {}
}
17 changes: 15 additions & 2 deletions src/main/java/com/cohere/api/core/RequestOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@
public final class RequestOptions {
private final String token;

private RequestOptions(String token) {
private final String clientName;

private RequestOptions(String token, String clientName) {
this.token = token;
this.clientName = clientName;
}

public Map<String, String> getHeaders() {
Map<String, String> headers = new HashMap<>();
if (this.token != null) {
headers.put("Authorization", "Bearer " + this.token);
}
if (this.clientName != null) {
headers.put("X-Client-Name", this.clientName);
}
return headers;
}

Expand All @@ -28,13 +34,20 @@ public static Builder builder() {
public static final class Builder {
private String token = null;

private String clientName = null;

public Builder token(String token) {
this.token = token;
return this;
}

public Builder clientName(String clientName) {
this.clientName = clientName;
return this;
}

public RequestOptions build() {
return new RequestOptions(token);
return new RequestOptions(token, clientName);
}
}
}
Loading
Loading