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

feat(docs): Updating Java Sdk Docs #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
83 changes: 52 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,51 @@ Add the dependency in your `pom.xml`:
## Usage
Both the Medical and Devices APIs are accessible from the SDK.

```typescript
```java
package com.metriport.test;

import io.github.cdimascio.dotenv.Dotenv;
import com.metriport.api.Metriport;
import com.metriport.api.resources.medical.facility.types.BaseFacility;
import com.metriport.api.resources.commons.types.UsState;
import com.metriport.api.resources.commons.types.Address;
import com.metriport.api.resources.medical.organization.types.BaseOrganization;

Metriport metriport = Metriport.builder()
.apiKey("YOUR_API_KEY")
.build();

var response = metriport.medical().organization().create(BaseOrganization.builder()
.name("Metriport Inc.")
.type(OrgType.PostAcuteCare)
.location(Address.builder()
.addressLine1("2261 Market Street")
.addressLine1("#4818")
.city("San Francisco")
.state(UsState.CA)
.zip("94114")
.country("USA")
.build())
.build());

System.out.printlin("Received response!" + response);
public class CreateFacility {
public static void main(String[] args) {
Dotenv dotenv = Dotenv.load();

Metriport metriport = Metriport.builder()
.apiKey(dotenv.get("API_KEY"))
.url(dotenv.get("BASE_URL"))
.build();

Address address = Address.builder()
.addressLine1("2261 Market Street")
.city("San Francisco")
.state(UsState.CA)
.zip("12345")
.country("USA")
.addressLine2("#4818")
.build();

BaseFacility newFacility = BaseFacility.builder()
.name("New Facility")
.npi("1234567893")
.address(address)
.build();

var response = metriport.medical().facility().create(newFacility);
System.out.println("Created new facility!" + response);
}
}
```

### Handling Errors
When the API returns a non-success status code (4xx or 5xx response),
a subclass of [ApiError](src/main/java/com/metriport/api/core/ApiError.java)
will be thrown:

```ts
```java
import com.metriport.api.core.ApiError;

try {
Expand All @@ -89,17 +103,24 @@ name, type and location.
import com.metriport.api.resources.medical.organization.types.BaseOrganization;

// Doesn't compile
BaseOrganization org = BaseOrganization.builder()
.name(...)
.type(...)
.build();
BaseOrganization org = Address.builder()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Address address = ? You'll also want to edit the text above that references BaseOrganization

.addressLine1("2261 Market Street")
.addressLine2("#4818")
.city("San Francisco")
.state(UsState.CA)
.zip("12345")
.country("USA")
.build();

// Compiles
BaseOrganization org = BaseOrganization.builder()
.name(...)
.type(...)
.location(...)
.build();
BaseOrganization org = Address.builder()
.addressLine1("2261 Market Street")
.city("San Francisco")
.state(UsState.CA)
.zip("12345")
.country("USA")
.addressLine2("#4818")
.build();
```

## Beta status
Expand All @@ -117,4 +138,4 @@ be overwritten upon the next generated release. Feel free to open a PR as a
proof of concept, but know that we will not be able to merge it as-is.
We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!
On the other hand, contributions to the README are always very welcome!