Skip to content

Commit

Permalink
Update README for rewrite (#328)
Browse files Browse the repository at this point in the history
* - Update README.md to account for re-architecture

* - Add link to release notes in nuspec file
  • Loading branch information
nwithan8 authored Sep 17, 2022
1 parent b90d50b commit 6e3a086
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 81 deletions.
1 change: 1 addition & 0 deletions EasyPost.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<description>EasyPost Shipping API Client Library for .NET https://easypost.com/docs</description>
<tags>EasyPost ShippingAPI USPS UPS FedEx</tags>
<readme>docs\README.md</readme>
<releaseNotes>See Release Notes at https://github.com/EasyPost/easypost-csharp/releases</releaseNotes>
<icon>images\icon.png</icon>
<dependencies>
<group targetFramework="netstandard2.0">
Expand Down
166 changes: 85 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,89 +34,44 @@ namespace example
{
Client client = new Client("EASYPOST_API_KEY");

Dictionary<string, object> fromAddress = new Dictionary<string, object>()
Shipment shipment = await client.Shipment.Create(new Dictionary<string, object>()
{
{
"name", "Dr. Steve Brule"
},
{
"street1", "417 Montgomery Street"
},
{
"street2", "5th Floor"
},
{
"city", "San Francisco"
},
{
"state", "CA"
},
{
"country", "US"
},
{
"zip", "94104"
},
{
"phone", "4153334444"
"to_address", new Dictionary<string, object>()
{
{ "name", "Dr. Steve Brule" },
{ "street1", "179 N Harbor Dr" },
{ "city", "Redondo Beach" },
{ "state", "CA" },
{ "zip", "90277" },
{ "country", "US" },
{ "phone", "8573875756" },
{ "email", "[email protected]" }
}
},
{
"from_address", new Dictionary<string, object>()
{
{ "name", "EasyPost" },
{ "street1", "417 Montgomery Street" },
{ "street2", "5th Floor" },
{ "city", "San Francisco" },
{ "state", "CA" },
{ "zip", "94104" },
{ "country", "US" },
{ "phone", "4153334445" },
{ "email", "[email protected]" }
}
},
{
"parcel", new Dictionary<string, object>()
{
{ "length", 20.2 },
{ "width", 10.9 },
{ "height", 5 },
{ "weight", 65.9 }
}
}
};

Dictionary<string, object> toAddress = new Dictionary<string, object>()
{
{
"company", "EasyPost"
},
{
"street1", "417 Montgomery Street"
},
{
"street2", "Floor 5"
},
{
"city", "San Francisco"
},
{
"state", "CA"
},
{
"country", "US"
},
{
"zip", "94104"
},
{
"phone", "415-379-7678"
}
};

Dictionary<string, object> parcel = new Dictionary<string, object>()
{
{
"length", 8
},
{
"width", 6
},
{
"height", 5
},
{
"weight", 10
},
};

Shipment shipment = await client.Shipment.Create(new Dictionary<string, object>
{
{
"from_address", fromAddress
},
{
"to_address", toAddress
},
{
"parcel", parcel
},
});

await shipment.Buy(shipment.LowestRate());
Expand All @@ -143,6 +98,46 @@ your [EasyPost dashboard](https://easypost.com/account/api-keys).
Once declared, a client's API key cannot be changed. If you are using multiple API keys, you can create multiple client
objects.

### Services

All general API services can be accessed through the `Client` object. For example, to access the `Address` service:

```csharp
AddressService addressService = myClient.Address;
```

Beta services can be accessed via the `myClient.Beta` property.

```csharp
ExampleService betaService = myClient.Beta.Example;
```

### Resources

API objects cannot be created locally. All local objects are copies of server-side data, retrieved via an API call from
a service.

For example, to create a new shipment, you must use the client's Shipment service:

```csharp
Shipment myShipment = await myClient.Shipment.Create(new Dictionary<string, object>
{
{ "from_address", fromAddress },
{ "to_address", toAddress },
{ "parcel", parcel }
});
```

Functions involving a specific resource are then enacted on that resource. For example, to buy the shipment:

```csharp
await myShipment.Buy(myShipment.LowestRate());
```

Any generated local resource will have stored internally the same client used to create or retrieve them. Any API call
made against the resource will automatically use the same client. This will prevent potential issues of accidentally
using the wrong API key when interacting with a resource in a multi-client environment.

## Documentation

API Documentation can be found at: <https://easypost.com/docs/api>.
Expand Down Expand Up @@ -174,6 +169,15 @@ EASYPOST_TEST_API_KEY=123... EASYPOST_PROD_API_KEY=123... make coverage
make scan
```

#### NuGet Dependencies

The NuGet package dependencies for this project are listed in the `.csproj` files. This project
uses [NuGet package locks](https://docs.microsoft.com/en-us/nuget/consume-packages/package-references-in-project-files#locking-dependencies)
to keep specific versions of dependencies. The lock files will be used during NuGet `restore`, if present.

If you need to update or alter NuGet dependencies, delete the `package.lock.json` files first. They will be regenerated
during the next `restore`.

### Testing

The test suite in this project was specifically built to produce consistent results on every run, regardless of when
Expand All @@ -188,7 +192,7 @@ cassettes that prior to committing your changes, no PII or sensitive information
cassette.

**Making Changes:** If you make an addition to this project, the request/response will get recorded automatically for
you if a `_vcr.SetUpTest("testName");` is included on the test function. When making changes to this project, you'll
you if `UseVCR("testName");` is included on the test function. When making changes to this project, you'll
need to re-record the associated cassette to force a new live API call for that test which will then record the
request/response used on the next run.

Expand Down

0 comments on commit 6e3a086

Please sign in to comment.