Skip to content

Commit 68c9dfe

Browse files
authored
feat: auto generated code from open api specs (#764)
1 parent 907a89f commit 68c9dfe

File tree

1,146 files changed

+111811
-7
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,146 files changed

+111811
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Change Log
22
All notable changes to this project will be documented in this file.
33

4+
[2024-06-27] Version 5.0.0-rc.1
5+
--------------------------------
6+
- Generating Sendgrid Code using open api spec.
7+
48
[2024-06-27] Version 5.0.0-rc.0
59
--------------------------------
610
- Release Candidate prep

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ touch Example.java
6969
Add the example you want to test to Example.java, including the headers at the top of the file.
7070

7171
``` bash
72-
javac -classpath ../repo/com/sendgrid/4.10.2/sendgrid-4.10.2-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/4.10.2/sendgrid-4.10.2-jar.jar:. Example
72+
javac -classpath ../repo/com/sendgrid/5.0.0-rc.1/sendgrid-5.0.0-rc.1-jar.jar:. Example.java && java -classpath ../repo/com/sendgrid/5.0.0-rc.1/sendgrid-5.0.0-rc.1-jar.jar:. Example
7373
```
7474

7575
<a name="understanding-the-codebase"></a>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Add the following to your build.gradle file in the root of your project.
6262
...
6363
dependencies {
6464
...
65-
implementation 'com.sendgrid:sendgrid-java:4.10.2'
65+
implementation 'com.sendgrid:sendgrid-java:5.0.0-rc.1'
6666
}
6767
6868
repositories {
@@ -81,7 +81,7 @@ mvn install
8181

8282
You can just drop the jar file in. It's a fat jar - it has all the dependencies built in.
8383

84-
[sendgrid-java.jar](https://github.com/sendgrid/sendgrid-java/releases/download/4.10.2/sendgrid-java.jar)
84+
[sendgrid-java.jar](https://github.com/sendgrid/sendgrid-java/releases/download/5.0.0-rc.1/sendgrid-java.jar)
8585

8686
## Dependencies
8787

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<groupId>com.sendgrid</groupId>
1010
<artifactId>sendgrid-java</artifactId>
1111
<name>Twilio SendGrid Java helper library</name>
12-
<version>4.10.2</version>
12+
<version>5.0.0-rc.1</version>
1313
<description>This Java module allows you to quickly and easily send emails through Twilio SendGrid using Java.</description>
1414
<url>https://github.com/sendgrid/sendgrid-java</url>
1515
<licenses>
@@ -26,7 +26,7 @@
2626
<url>https://github.com/sendgrid/sendgrid-java</url>
2727
<connection>scm:git:[email protected]:sendgrid/sendgrid-java.git</connection>
2828
<developerConnection>scm:git:[email protected]:sendgrid/sendgrid-java.git</developerConnection>
29-
<tag>4.10.2</tag>
29+
<tag>5.0.0-rc.1</tag>
3030
</scm>
3131
<profiles>
3232
<profile>

src/main/java/com/sendgrid/constant/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
@UtilityClass
66
public class Config {
7-
public static final String VERSION = "5.0.0-rc.0";
7+
public static final String VERSION = "5.0.0-rc.1";
88
public static final String JAVA_VERSION = System.getProperty("java.version");
99
public static final String OS_NAME = System.getProperty("os.name");
1010
public static final String OS_ARCH = System.getProperty("os.arch");
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* This code was generated by
3+
*
4+
* SENDGRID-OAI-GENERATOR
5+
*
6+
* Twilio SendGrid Account Provisioning API
7+
* The Twilio SendGrid Account Provisioning API provides a platform for Twilio SendGrid resellers to manage their customer accounts. This API is for companies that have a formal reseller partnership with Twilio SendGrid. You can access Twilio SendGrid sub-account functionality without becoming a reseller. If you require sub-account functionality, see the Twilio [SendGrid Subusers](https://docs.sendgrid.com/ui/account-and-settings/subusers) feature, which is available with [Pro and Premier plans](https://sendgrid.com/pricing/).
8+
*
9+
* NOTE: This class is auto generated by OpenAPI Generator.
10+
* https://openapi-generator.tech
11+
* Do not edit the class manually.
12+
*/
13+
14+
package com.sendgrid.rest.api.v3.accountprovisioning;
15+
16+
import com.sendgrid.base.apikey.ApiKeyBase;
17+
import com.sendgrid.constant.ApplicationConstants;
18+
import com.sendgrid.constant.Domains;
19+
import com.sendgrid.exception.ApiConnectionException;
20+
import com.sendgrid.exception.ApiErrorResponse;
21+
import com.sendgrid.exception.GenericApiError;
22+
import com.sendgrid.http.ApiKeyRestClient;
23+
import com.sendgrid.http.ApiResponse;
24+
import com.sendgrid.http.HttpMethod;
25+
import com.sendgrid.http.Request;
26+
import com.sendgrid.http.Response;
27+
import com.sendgrid.util.JsonUtil;
28+
import com.sendgrid.util.Matcher;
29+
import lombok.RequiredArgsConstructor;
30+
31+
@RequiredArgsConstructor
32+
public class AuthenticateAccount extends ApiKeyBase {
33+
34+
private final String accountID;
35+
36+
public ApiResponse<Void> send(final ApiKeyRestClient client) {
37+
String path = "/v3/partners/accounts/{accountID}/sso";
38+
Request request = new Request(
39+
HttpMethod.POST,
40+
path,
41+
Domains.API.toString()
42+
);
43+
addPathParams(request);
44+
Response response = client.request(request);
45+
46+
if (response == null) {
47+
throw new ApiConnectionException(
48+
"AuthenticateAccount creation failed: Unable to connect to server"
49+
);
50+
} else if (
51+
!ApplicationConstants.SUCCESS.test(response.getStatusCode())
52+
) {
53+
int statusCode = response.getStatusCode();
54+
if (Matcher.matches(Integer.toString(statusCode), "401")) {
55+
Object error = JsonUtil.fromJson(
56+
response.getStream(),
57+
Object.class
58+
);
59+
throw new ApiErrorResponse(
60+
statusCode,
61+
null,
62+
error,
63+
response.getHeaders()
64+
);
65+
}
66+
67+
if (Matcher.matches(Integer.toString(statusCode), "403")) {
68+
Object error = JsonUtil.fromJson(
69+
response.getStream(),
70+
Object.class
71+
);
72+
throw new ApiErrorResponse(
73+
statusCode,
74+
null,
75+
error,
76+
response.getHeaders()
77+
);
78+
}
79+
80+
if (Matcher.matches(Integer.toString(statusCode), "404")) {
81+
Object error = JsonUtil.fromJson(
82+
response.getStream(),
83+
Object.class
84+
);
85+
throw new ApiErrorResponse(
86+
statusCode,
87+
null,
88+
error,
89+
response.getHeaders()
90+
);
91+
}
92+
93+
GenericApiError error = JsonUtil.fromJson(
94+
response.getStream(),
95+
GenericApiError.class
96+
);
97+
throw new ApiErrorResponse(
98+
statusCode,
99+
null,
100+
error,
101+
response.getHeaders()
102+
);
103+
}
104+
int statusCode = response.getStatusCode();
105+
return new ApiResponse(statusCode, response.getHeaders());
106+
}
107+
108+
private void addPathParams(Request request) {
109+
if (accountID != null) {
110+
request.addPathParam("accountID", accountID.toString());
111+
}
112+
}
113+
}
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* This code was generated by
3+
*
4+
* SENDGRID-OAI-GENERATOR
5+
*
6+
* Twilio SendGrid Account Provisioning API
7+
* The Twilio SendGrid Account Provisioning API provides a platform for Twilio SendGrid resellers to manage their customer accounts. This API is for companies that have a formal reseller partnership with Twilio SendGrid. You can access Twilio SendGrid sub-account functionality without becoming a reseller. If you require sub-account functionality, see the Twilio [SendGrid Subusers](https://docs.sendgrid.com/ui/account-and-settings/subusers) feature, which is available with [Pro and Premier plans](https://sendgrid.com/pricing/).
8+
*
9+
* NOTE: This class is auto generated by OpenAPI Generator.
10+
* https://openapi-generator.tech
11+
* Do not edit the class manually.
12+
*/
13+
14+
package com.sendgrid.rest.api.v3.accountprovisioning;
15+
16+
import com.sendgrid.base.apikey.ApiKeyBase;
17+
import com.sendgrid.constant.ApplicationConstants;
18+
import com.sendgrid.constant.Domains;
19+
import com.sendgrid.exception.ApiConnectionException;
20+
import com.sendgrid.exception.ApiErrorResponse;
21+
import com.sendgrid.exception.GenericApiError;
22+
import com.sendgrid.http.ApiKeyRestClient;
23+
import com.sendgrid.http.ApiResponse;
24+
import com.sendgrid.http.HttpMethod;
25+
import com.sendgrid.http.Request;
26+
import com.sendgrid.http.Response;
27+
import com.sendgrid.rest.api.v3.accountprovisioning.models.AccountProvisioningAccountId;
28+
import com.sendgrid.rest.api.v3.accountprovisioning.models.CreateAccountParams;
29+
import com.sendgrid.util.JsonUtil;
30+
import com.sendgrid.util.Matcher;
31+
import lombok.RequiredArgsConstructor;
32+
import lombok.Setter;
33+
34+
@RequiredArgsConstructor
35+
public class CreateAccount extends ApiKeyBase {
36+
37+
@Setter
38+
private String tTestAccount;
39+
40+
@Setter
41+
private CreateAccountParams createAccountParams;
42+
43+
public ApiResponse<AccountProvisioningAccountId> send(
44+
final ApiKeyRestClient client
45+
) {
46+
String path = "/v3/partners/accounts";
47+
Request request = new Request(
48+
HttpMethod.POST,
49+
path,
50+
Domains.API.toString()
51+
);
52+
addHeaderParams(request);
53+
addBody(request);
54+
Response response = client.request(request);
55+
56+
if (response == null) {
57+
throw new ApiConnectionException(
58+
"CreateAccount creation failed: Unable to connect to server"
59+
);
60+
} else if (
61+
!ApplicationConstants.SUCCESS.test(response.getStatusCode())
62+
) {
63+
int statusCode = response.getStatusCode();
64+
if (Matcher.matches(Integer.toString(statusCode), "400")) {
65+
Object error = JsonUtil.fromJson(
66+
response.getStream(),
67+
Object.class
68+
);
69+
throw new ApiErrorResponse(
70+
statusCode,
71+
null,
72+
error,
73+
response.getHeaders()
74+
);
75+
}
76+
77+
if (Matcher.matches(Integer.toString(statusCode), "401")) {
78+
Object error = JsonUtil.fromJson(
79+
response.getStream(),
80+
Object.class
81+
);
82+
throw new ApiErrorResponse(
83+
statusCode,
84+
null,
85+
error,
86+
response.getHeaders()
87+
);
88+
}
89+
90+
if (Matcher.matches(Integer.toString(statusCode), "403")) {
91+
Object error = JsonUtil.fromJson(
92+
response.getStream(),
93+
Object.class
94+
);
95+
throw new ApiErrorResponse(
96+
statusCode,
97+
null,
98+
error,
99+
response.getHeaders()
100+
);
101+
}
102+
103+
GenericApiError error = JsonUtil.fromJson(
104+
response.getStream(),
105+
GenericApiError.class
106+
);
107+
throw new ApiErrorResponse(
108+
statusCode,
109+
null,
110+
error,
111+
response.getHeaders()
112+
);
113+
}
114+
int statusCode = response.getStatusCode();
115+
return new ApiResponse(
116+
statusCode,
117+
JsonUtil.fromJson(
118+
response.getStream(),
119+
AccountProvisioningAccountId.class
120+
),
121+
response.getHeaders()
122+
);
123+
}
124+
125+
private void addHeaderParams(Request request) {
126+
if (tTestAccount != null) {
127+
request.addHeaderParam("T-Test-Account", tTestAccount.toString());
128+
}
129+
}
130+
131+
private void addBody(final Request request) {
132+
if (createAccountParams != null) {
133+
request.addBody(JsonUtil.toJson(createAccountParams));
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)