Skip to content

Commit

Permalink
SDK regeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-api[bot] committed Feb 20, 2024
1 parent 7fc98e8 commit 09e8605
Show file tree
Hide file tree
Showing 125 changed files with 7,892 additions and 1,627 deletions.
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

0 comments on commit 09e8605

Please sign in to comment.