-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
10 changed files
with
231 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,7 +126,6 @@ csx | |
AppPackages/ | ||
|
||
# Others | ||
docs | ||
sql/ | ||
*.Cache | ||
ClientBin/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
############### | ||
# folder # | ||
############### | ||
/**/DROP/ | ||
/**/TEMP/ | ||
/**/packages/ | ||
/**/bin/ | ||
/**/obj/ | ||
_site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
############### | ||
# temp file # | ||
############### | ||
*.yml | ||
.manifest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# PLACEHOLDER | ||
TODO: Add .NET projects to the *src* folder and run `docfx` to generate **REAL** *API Documentation*! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
## Configuration | ||
|
||
A `Client` object is the entry point into the EasyPost API. It is instantiated with your API key: | ||
|
||
```csharp | ||
using EasyPost; | ||
|
||
Client myClient = new Client("EASYPOST_API_KEY"); | ||
``` | ||
|
||
An API key is required for all requests. You can find your API key in | ||
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. | ||
|
||
|
||
## Upgrading | ||
|
||
Upgrading major versions of this project? Refer to the [Upgrade Guide](https://github.com/EasyPost/easypost-csharp/blob/master/UPGRADE_GUIDE.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- name: Introduction | ||
href: intro.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ | ||
"metadata": [ | ||
{ | ||
"src": [ | ||
{ | ||
"files": [ | ||
"EasyPost/**.csproj" | ||
], | ||
"src": "../" | ||
} | ||
], | ||
"dest": "api", | ||
"disableGitFeatures": false, | ||
"disableDefaultFilter": false | ||
} | ||
], | ||
"build": { | ||
"content": [ | ||
{ | ||
"files": [ | ||
"api/**.yml", | ||
"api/index.md" | ||
] | ||
}, | ||
{ | ||
"files": [ | ||
"articles/**.md", | ||
"articles/**/toc.yml", | ||
"toc.yml", | ||
"*.md" | ||
] | ||
} | ||
], | ||
"resource": [ | ||
{ | ||
"files": [ | ||
"images/**" | ||
] | ||
} | ||
], | ||
"overwrite": [ | ||
{ | ||
"files": [ | ||
"apidoc/**.md" | ||
], | ||
"exclude": [ | ||
"obj/**", | ||
"_site/**" | ||
] | ||
} | ||
], | ||
"dest": "_site", | ||
"globalMetadataFiles": [], | ||
"fileMetadataFiles": [], | ||
"template": [ | ||
"default" | ||
], | ||
"postProcessors": [], | ||
"markdownEngineName": "markdig", | ||
"noLangKeyword": false, | ||
"keepFileLink": false, | ||
"cleanupCacheHistory": false, | ||
"disableGitFeatures": false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# EasyPost's .NET client library | ||
|
||
The [EasyPost .NET client library](https://github.com/EasyPost/easypost-csharp) provides convenient access to the EasyPost API from .NET applications written in the .NET language. | ||
|
||
## Installation | ||
|
||
Install the library with [NuGet](https://www.nuget.org/packages/EasyPost-Official): | ||
|
||
```powershell | ||
Install-Package EasyPost-Official | ||
``` | ||
|
||
See NuGet docs for additional instructions on installing via | ||
the [dialog](http://docs.nuget.org/docs/start-here/managing-nuget-packages-using-the-dialog) or | ||
the [console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console). | ||
|
||
## Usage | ||
|
||
A simple create & buy shipment example: | ||
|
||
```csharp | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using EasyPost; | ||
using Newtonsoft.Json; | ||
|
||
namespace example | ||
{ | ||
class exampleClass | ||
{ | ||
static async Task Main() | ||
{ | ||
Client client = new Client(Environment.GetEnvironmentVariable("EASYPOST_API_KEY")); | ||
|
||
Shipment shipment = await client.Shipment.Create(new Dictionary<string, object>() | ||
{ | ||
{ | ||
"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", "dr_steve_brule@gmail.com" } | ||
} | ||
}, | ||
{ | ||
"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", "support@easypost.com" } | ||
} | ||
}, | ||
{ | ||
"parcel", new Dictionary<string, object>() | ||
{ | ||
{ "length", 20.2 }, | ||
{ "width", 10.9 }, | ||
{ "height", 5 }, | ||
{ "weight", 65.9 } | ||
} | ||
} | ||
}); | ||
|
||
await shipment.Buy(shipment.LowestRate()); | ||
|
||
Console.WriteLine(JsonConvert.SerializeObject(shipment, Formatting.Indented)); | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- name: Articles | ||
href: articles/ | ||
- name: Api Documentation | ||
href: api/ | ||
homepage: api/index.md |