|
1 | | -*This project is currently in **Beta**. Please open up an issue [here](https://github.com/mxenabled/mx-platform-java/issues) to report issues using the MX Platform API Java Library.* |
| 1 | +*This project is currently in **Beta**. Please open up an issue [here](https://github.com/mxenabled/mx-platform-java/issues) to report issues using the MX Platform Java library.* |
2 | 2 |
|
3 | | -*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech).* |
| 3 | +# MX Platform Java |
4 | 4 |
|
5 | | -# MX Platform Java - v{{{artifactVersion}}} |
| 5 | +The [MX Platform API](https://www.mx.com/products/platform-api) is a powerful, fully-featured API designed to make aggregating and enhancing financial data easy and reliable. It can seamlessly connect your app or website to tens of thousands of financial institutions. |
6 | 6 |
|
7 | | -{{{appDescriptionWithNewLines}}} |
| 7 | +## Documentation |
8 | 8 |
|
9 | | -{{#infoUrl}} |
10 | | -Please [visit]({{{infoUrl}}}) for more information. |
11 | | -{{/infoUrl}} |
| 9 | +Examples for the API endpoints can be found [here.](https://docs.mx.com/api) |
12 | 10 |
|
13 | 11 | ## Requirements |
14 | 12 |
|
15 | 13 | Building the API client library requires: |
16 | 14 |
|
17 | | -1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+ |
18 | | -2. Maven |
19 | | - |
20 | | -### Documentation |
21 | | - |
22 | | -See the [documentation](https://docs.mx.com/api). |
| 15 | +- Java 1.7+ |
| 16 | +- Maven |
23 | 17 |
|
24 | 18 | ## Installation |
25 | 19 |
|
@@ -48,106 +42,66 @@ Add this dependency to your project's POM: |
48 | 42 |
|
49 | 43 | You can find the MX Platform Java Library in the [Maven Central Repository](https://search.maven.org/search?q=mx-platform-java). |
50 | 44 |
|
51 | | -{{#jersey2}} |
52 | | -## Usage |
53 | | - |
54 | | -To add a HTTP proxy for the API client, use `ClientConfig`: |
55 | | -```java |
56 | | -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} |
57 | | -import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; |
58 | | -import org.glassfish.jersey.client.ClientConfig; |
59 | | -import org.glassfish.jersey.client.ClientProperties; |
60 | | -import {{{invokerPackage}}}.*; |
61 | | -import {{{package}}}.{{{classname}}}; |
62 | | - |
63 | | -... |
64 | | - |
65 | | -ApiClient defaultClient = Configuration.getDefaultApiClient(); |
66 | | -ClientConfig clientConfig = defaultClient.getClientConfig(); |
67 | | -clientConfig.connectorProvider(new ApacheConnectorProvider()); |
68 | | -clientConfig.property(ClientProperties.PROXY_URI, "http://proxy_url_here"); |
69 | | -clientConfig.property(ClientProperties.PROXY_USERNAME, "proxy_username"); |
70 | | -clientConfig.property(ClientProperties.PROXY_PASSWORD, "proxy_password"); |
71 | | -defaultClient.setClientConfig(clientConfig); |
72 | | - |
73 | | -{{{classname}}} apiInstance = new {{{classname}}}(defaultClient); |
74 | | -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} |
75 | | -``` |
76 | | - |
77 | | -{{/jersey2}} |
78 | 45 | ## Getting Started |
79 | 46 |
|
80 | 47 | In order to make requests, you will need to [sign up](https://dashboard.mx.com/sign_up) for the MX Platform API and get a `Client ID` and `API Key`. |
81 | 48 |
|
82 | | -Please follow the [installation](#installation) instruction and execute the following Java code: |
| 49 | +Please follow the [installation](#installation) procedure and then run the following code to create your first User: |
83 | 50 |
|
84 | 51 | ```java |
85 | | -{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}} |
86 | | -import {{{invokerPackage}}}.*; |
87 | | -import {{{invokerPackage}}}.auth.*; |
88 | | -import {{{modelPackage}}}.*; |
89 | | -import {{{package}}}.{{{classname}}}; |
90 | | - |
91 | | -public class {{{classname}}}Example { |
92 | | -
|
| 52 | +import com.mx.client.ApiClient; |
| 53 | +import com.mx.client.ApiException; |
| 54 | +import com.mx.client.Configuration; |
| 55 | +import com.mx.client.auth.*; |
| 56 | +import com.mx.client.model.*; |
| 57 | +import com.mx.client.mx_platform_api.MxPlatformApi; |
| 58 | + |
| 59 | +public class Example { |
93 | 60 | public static void main(String[] args) { |
| 61 | + // Configure environment. https://int-api.mx.com for development, https://api.mx.com for production |
94 | 62 | ApiClient defaultClient = Configuration.getDefaultApiClient(); |
95 | | - defaultClient.setBasePath("{{{basePath}}}"); |
96 | | - {{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}{{#isBasicBasic}} |
97 | | - // Configure HTTP basic authorization: {{{name}}} |
98 | | - HttpBasicAuth {{{name}}} = (HttpBasicAuth) defaultClient.getAuthentication("{{{name}}}"); |
99 | | - {{{name}}}.setUsername("YOUR USERNAME"); |
100 | | - {{{name}}}.setPassword("YOUR PASSWORD");{{/isBasicBasic}}{{#isBasicBearer}} |
101 | | - // Configure HTTP bearer authorization: {{{name}}} |
102 | | - HttpBearerAuth {{{name}}} = (HttpBearerAuth) defaultClient.getAuthentication("{{{name}}}"); |
103 | | - {{{name}}}.setBearerToken("BEARER TOKEN");{{/isBasicBearer}}{{/isBasic}}{{#isApiKey}} |
104 | | - // Configure API key authorization: {{{name}}} |
105 | | - ApiKeyAuth {{{name}}} = (ApiKeyAuth) defaultClient.getAuthentication("{{{name}}}"); |
106 | | - {{{name}}}.setApiKey("YOUR API KEY"); |
107 | | - // Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null) |
108 | | - //{{{name}}}.setApiKeyPrefix("Token");{{/isApiKey}}{{#isOAuth}} |
109 | | - // Configure OAuth2 access token for authorization: {{{name}}} |
110 | | - OAuth {{{name}}} = (OAuth) defaultClient.getAuthentication("{{{name}}}"); |
111 | | - {{{name}}}.setAccessToken("YOUR ACCESS TOKEN");{{/isOAuth}}{{#isHttpSignature}} |
112 | | - // Configure HTTP signature authorization: {{{name}}} |
113 | | - HttpSignatureAuth {{{name}}} = (HttpSignatureAuth) defaultClient.getAuthentication("{{{name}}}"); |
114 | | - // All the HTTP signature parameters below should be customized to your environment. |
115 | | - // Configure the keyId |
116 | | - {{{name}}}.setKeyId("YOUR KEY ID"); |
117 | | - // Configure the signature algorithm |
118 | | - {{{name}}}.setSigningAlgorithm(SigningAlgorithm.HS2019); |
119 | | - // Configure the specific cryptographic algorithm |
120 | | - {{{name}}}.setAlgorithm(Algorithm.ECDSA_SHA256); |
121 | | - // Configure the cryptographic algorithm parameters, if applicable |
122 | | - {{{name}}}.setAlgorithmParameterSpec(null); |
123 | | - // Set the cryptographic digest algorithm. |
124 | | - {{{name}}}.setDigestAlgorithm("SHA-256"); |
125 | | - // Set the HTTP headers that should be included in the HTTP signature. |
126 | | - {{{name}}}.setHeaders(Arrays.asList("date", "host")); |
127 | | - // Set the private key used to sign the HTTP messages |
128 | | - {{{name}}}.setPrivateKey();{{/isHttpSignature}} |
129 | | - {{/authMethods}} |
130 | | - {{/hasAuthMethods}} |
131 | | - |
132 | | - {{{classname}}} apiInstance = new {{{classname}}}(defaultClient); |
133 | | - {{#allParams}} |
134 | | - {{{dataType}}} {{{paramName}}} = {{{example}}}; // {{{dataType}}} | {{{description}}} |
135 | | - {{/allParams}} |
| 63 | + defaultClient.setBasePath("https://int-api.mx.com"); |
| 64 | +
|
| 65 | + // Configure with your Client ID/API Key from https://dashboard.mx.com |
| 66 | + HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth"); |
| 67 | + basicAuth.setUsername("Your Client ID"); |
| 68 | + basicAuth.setPassword("Your API Key"); |
| 69 | +
|
| 70 | + MxPlatformApi apiInstance = new MxPlatformApi(defaultClient); |
| 71 | +
|
| 72 | + UserCreateRequest userCreateRequest = new UserCreateRequest(); |
| 73 | + userCreateRequest.setMetadata("Creating a user!"); |
| 74 | +
|
| 75 | + UserCreateRequestBody userCreateRequestBody = new UserCreateRequestBody(); |
| 76 | + userCreateRequestBody.setUser(userCreateRequest); |
| 77 | +
|
136 | 78 | try { |
137 | | - {{#returnType}}{{{.}}} response = {{/returnType}}apiInstance.{{{operationId}}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} |
138 | | - System.out.println(response);{{/returnType}} |
| 79 | + UserResponseBody response = apiInstance.createUser(userCreateRequestBody); |
| 80 | + System.out.println(response); |
139 | 81 | } catch (ApiException e) { |
140 | | - System.err.println("Exception when calling {{{classname}}}#{{{operationId}}}"); |
| 82 | + System.err.println("Exception when calling MxPlatformApi#createUser"); |
141 | 83 | System.err.println("Status code: " + e.getCode()); |
142 | 84 | System.err.println("Reason: " + e.getResponseBody()); |
143 | 85 | System.err.println("Response headers: " + e.getResponseHeaders()); |
144 | 86 | e.printStackTrace(); |
145 | 87 | } |
146 | 88 | } |
147 | 89 | } |
148 | | -{{/-first}}{{/operation}}{{/operations}}{{/-first}}{{/apis}}{{/apiInfo}} |
149 | 90 | ``` |
150 | 91 |
|
151 | | -## Recommendation |
| 92 | +## Development |
| 93 | + |
| 94 | +This project was generated by the [OpenAPI Generator](https://openapi-generator.tech). To generate this library, verify you have the latest version of the `openapi-generator-cli` found [here.](https://github.com/OpenAPITools/openapi-generator#17---npm) |
| 95 | + |
| 96 | +Running the following command in this repo's directory will generate this library using the [MX Platform API OpenAPI spec](https://github.com/mxenabled/openapi/blob/master/openapi/mx_platform_api_beta.yml) with our [configuration and templates.](https://github.com/mxenabled/mx-platform-ruby/tree/master/openapi) |
| 97 | +```shell |
| 98 | +openapi-generator-cli generate \ |
| 99 | +-i https://raw.githubusercontent.com/mxenabled/openapi/master/openapi/mx_platform_api_beta.yml \ |
| 100 | +-g java \ |
| 101 | +-c ./openapi/config.yml \ |
| 102 | +-t ./openapi/templates |
| 103 | +``` |
| 104 | + |
| 105 | +## Contributing |
152 | 106 |
|
153 | | -It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. |
| 107 | +Please [open an issue](https://github.com/mxenabled/mx-platform-java/issues) or [submit a pull request.](https://github.com/mxenabled/mx-platform-java/pulls) |
0 commit comments