Skip to content

Commit

Permalink
Revert "chore: cleanup docs dir"
Browse files Browse the repository at this point in the history
This reverts commit 2ca8ca3.
  • Loading branch information
Justintime50 committed May 1, 2023
1 parent 6c0bf38 commit aaee874
Show file tree
Hide file tree
Showing 10 changed files with 231 additions and 2 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ csx
AppPackages/

# Others
docs
sql/
*.Cache
ClientBin/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Using the `Parameters` classes is not required, but they can help in a number of

API documentation can be found at: <https://easypost.com/docs/api>.

Library documentation can be found on the web at: <https://easypost.github.io/easypost-csharp> or by building them locally via the `make docs` command.
Library documentation can be found on the web at: <https://easypost.github.io/easypost-csharp> or locally on the [`gh-pages` branch](https://github.com/EasyPost/easypost-csharp/tree/gh-pages).

Upgrading major versions of this project? Refer to the [Upgrade Guide](UPGRADE_GUIDE.md).

Expand Down
9 changes: 9 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
###############
# folder #
###############
/**/DROP/
/**/TEMP/
/**/packages/
/**/bin/
/**/obj/
_site
5 changes: 5 additions & 0 deletions docs/api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
###############
# temp file #
###############
*.yml
.manifest
2 changes: 2 additions & 0 deletions docs/api/index.md
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*!
60 changes: 60 additions & 0 deletions docs/articles/intro.md
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).
2 changes: 2 additions & 0 deletions docs/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Introduction
href: intro.md
65 changes: 65 additions & 0 deletions docs/docfx.json
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
}
}
82 changes: 82 additions & 0 deletions docs/index.md
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));
}
}
}
```
5 changes: 5 additions & 0 deletions docs/toc.yml
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

0 comments on commit aaee874

Please sign in to comment.