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

Docs update after new package release #761

Merged
merged 6 commits into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ If you haven't already created an app in Box go to https://developer.box.com/ an

#### Using a Developer Token (generate one in your app admin console; they last for 60 minutes)
```c#
var config = new BoxConfig(<Client_Id>, <Client_Secret>, new Uri("http://localhost"));
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, new Uri("http://localhost")).Build();
var session = new OAuthSession(<Developer_Token>, "NOT_NEEDED", 3600, "bearer");
client = new BoxClient(config, session);
```
Expand All @@ -58,13 +58,13 @@ Allow Box Managed Users to share and collaboration with external users via Box a

##### Configure
```c#
var boxConfig = new BoxConfig(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>);
var boxConfig = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>). Build();
var boxJWT = new BoxJWTAuth(boxConfig);
```

##### Authenticate
```c#
var adminToken = boxJWT.AdminToken(); //valid for 60 minutes so should be cached and re-used
var adminToken = await boxJWT.AdminTokenAsync(); //valid for 60 minutes so should be cached and re-used
var adminClient = boxJWT.AdminClient(adminToken);
```

Expand All @@ -75,7 +75,7 @@ var userRequest = new BoxUserRequest() { Name = "test appuser", IsPlatformAccess
var appUser = await adminClient.UsersManager.CreateEnterpriseUserAsync(userRequest);

//get a user client
var userToken = boxJWT.UserToken(appUser.Id); //valid for 60 minutes so should be cached and re-used
var userToken = await boxJWT.UserTokenAsync(appUser.Id); //valid for 60 minutes so should be cached and re-used
var userClient = boxJWT.UserClient(userToken, appUser.Id);

//for example, look up the app user's details
Expand All @@ -91,7 +91,7 @@ This is a three-legged authentication process to allow managed user and external
##### Configure
Set your configuration parameters and initialize the client:
```c#
var config = new BoxConfig(<Client_Id>, <Client_Secret>, <Redirect_Uri>);
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Redirect_Uri>).Build();
var client = new BoxClient(config);
```

Expand Down Expand Up @@ -134,7 +134,7 @@ this method of aythentication, simply create a client with only the API key and
access token provided:

```c#
var config = new BoxConfig(<API_KEY>, "", new Uri("http://localhost"));
var config = new BoxConfigBuilder(<API_KEY>, "", new Uri("http://localhost")).Build();
var session = new OAuthSession(<PRIMARY OR SECONDARY TOKEN>, "NOT_NEEDED", 3600, "bearer");
client = new BoxClient(config, session);
```
Expand Down Expand Up @@ -276,7 +276,7 @@ var results = await client.SearchManager.SearchAsync(mdFilters: new List<BoxMeta
If you have an admin token with appropriate permissions, you can make API calls in the context of a managed user. In order to do this you must request Box.com to activate As-User functionality for your API key (see developer site for instructions).

```c#
var config = new BoxConfig(<Client_Id>, <Client_Secret>, <Redirect_Uri);
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Redirect_Uri).Build();
var auth = new OAuthSession(<Your_Access_Token>, <Your_Refresh_Token>, 3600, "bearer");

var userId = "12345678"
Expand All @@ -291,10 +291,10 @@ var items = await userClient.FoldersManager.GetFolderItemsAsync("0", 500);
Using the admin token we can make a call to retrieve all users or a specific user

```cs
var boxConfig = new BoxConfig(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>);
var boxConfig = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Enterprise_Id>, <Private_Key>, <JWT_Private_Key_Password>, <JWT_Public_Key_Id>). Build();
var boxJWT = new BoxJWTAuth(boxConfig);

var adminToken = boxJWT.AdminToken();
var adminToken = await boxJWT.AdminTokenAsync();
var adminClient = boxJWT.AdminClient(adminToken);

var boxUsers = await adminClient.UsersManager.GetEnterpriseUsersAsync();
Expand Down Expand Up @@ -326,7 +326,7 @@ foreach(BoxItem item in boxFolderItemsList)
#### Suppressing Notifications
If you are making administrative API calls (that is, your application has “Manage an Enterprise” scope, and the user making the API call is a co-admin with the correct "Edit settings for your company" permission) then you can suppress both email and webhook notifications.
```c#
var config = new BoxConfig(<Client_Id>, <Client_Secret>, <Redirect_Uri);
var config = new BoxConfigBuilder(<Client_Id>, <Client_Secret>, <Redirect_Uri).Build();
var auth = new OAuthSession(<Your_Access_Token>, <Your_Refresh_Token>, 3600, "bearer");

var adminClient = new BoxClient(config, auth, suppressNotifications: true);
Expand All @@ -350,8 +350,8 @@ public class BoxFolderHintsManager : BoxResourceManager
.Header(Constants.RequestParameters.XRepHints, xRepHints);

return await ToResponseAsync<MyCustomReturnObject>(request).ConfigureAwait(false);
}
}
}
```

You need to first register your custom `BoxResourceManager`, then you can use it as any other SDK manager.
Expand Down
22 changes: 11 additions & 11 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The following example creates an API client with a developer token:

<!-- sample x_auth init_with_dev_token -->
```c#
var config = new BoxConfig("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", new Uri("http://localhost"));
var config = new BoxConfigBuilder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", new Uri("http://localhost")).Build();
var session = new OAuthSession("YOUR_DEVELOPER_TOKEN", "N/A", 3600, "bearer");
var client = new BoxClient(config, session);
```
Expand All @@ -62,20 +62,20 @@ Service Account:

<!-- sample x_auth init_with_jwt_enterprise -->
```c#
var config = BoxConfig.CreateFromJsonString(jsonConfig);
var config = BoxConfigBuilder.CreateFromJsonString(jsonConfig).Build();
var session = new BoxJWTAuth(config);
var adminToken = session.AdminToken(); //valid for 60 minutes so should be cached and re-used
var adminToken = await session.AdminTokenAsync(); //valid for 60 minutes so should be cached and re-used
BoxClient adminClient = session.AdminClient(adminToken);
```

Otherwise, you'll need to provide the necessary configuration fields directly
to the `BoxConfig` constructor:
to the `BoxConfigBuilder` constructor:

<!-- sample x_auth init_with_jwt_enterprise_with_config -->
```c#
var boxConfig = new BoxConfig("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "YOUR_ENTERPRISE_ID", "ENCRYPTED_PRIVATE_KEY", "PRIVATE_KEY_PASSWORD", "PUBLIC_KEY_ID");
var boxConfig = new BoxConfigBuilder("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET", "YOUR_ENTERPRISE_ID", "ENCRYPTED_PRIVATE_KEY", "PRIVATE_KEY_PASSWORD", "PUBLIC_KEY_ID").Build();
var boxJWT = new BoxJWTAuth(boxConfig);
var adminToken = boxJWT.AdminToken(); //valid for 60 minutes so should be cached and re-used
var adminToken = await boxJWT.AdminTokenAsync(); //valid for 60 minutes so should be cached and re-used
BoxClient adminClient = boxJWT.AdminClient(adminToken);
adminClient.Auth.SessionAuthenticated += delegate(object o, SessionAuthenticatedEventArgs e)
{
Expand All @@ -99,7 +99,7 @@ instance as in the above examples, similarly to creating a Service Account clien
<!-- sample x_auth init_with_jwt_with_user_id -->
```c#
var appUserId = "12345";
var userToken = boxJWT.UserToken(appUserID); //valid for 60 minutes so should be cached and re-used
var userToken = await boxJWT.UserTokenAsync(appUserID); //valid for 60 minutes so should be cached and re-used
BoxClient appUserClient = boxJWT.UserClient(userToken, appUserId);
appUserClient.Auth.SessionAuthenticated += delegate(object o, SessionAuthenticatedEventArgs e)
{
Expand Down Expand Up @@ -128,7 +128,7 @@ client secret to establish an API connection. The `BoxClient` will
automatically refresh the access token as needed.

```c#
var config = new BoxConfig("CLIENT_ID", "CLIENT_SECRET", new System.Uri("YOUR_REDIRECT_URL"));
var config = new BoxConfigBuilder("CLIENT_ID", "CLIENT_SECRET", new System.Uri("YOUR_REDIRECT_URL")).Build();
var client = new BoxClient(config);
OAuthSession session = // Create session from custom implementation
var client = new BoxClient(config, session);
Expand All @@ -155,7 +155,7 @@ simply create a basic client with that token:

<!-- sample x_auth init_with_app_token -->
```c#
var config = new BoxConfig("YOUR_CLIENT_ID", "N/A", new Uri("http://localhost"));
var config = new BoxConfigBuilder("YOUR_CLIENT_ID", "N/A", new Uri("http://localhost")).Build();
var session = new OAuthSession("YOUR_APP_TOKEN", "N/A", 3600, "bearer");
var client = new BoxClient(config, session);
```
Expand Down Expand Up @@ -194,13 +194,13 @@ scope, restricted to a single file, suitable for the
```c#
var exchanger = new TokenExchange(client.Auth.Session.AccessToken, "item_preview");
exchanger.SetResource("https://api.box.com/2.0/files/123456789");
string downscopedToken = exchanger.Exchange();
string downscopedToken = await exchanger.ExchangeAsync();
```

To exchange the client's token for one with scopes to upload and delete items, but not to view their contents,
which would be suitable for an less-trusted server-side process;
```c#
var scopes = new List<string>() { "item_upload", "item_download" };
var exchanger = new TokenExchange(client.Auth.Session.AccessToken, scopes);
string downscopedToken = exchanger.Exchange();
string downscopedToken = await exchanger.ExchangeAsync();
```
103 changes: 103 additions & 0 deletions docs/sign-requests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
Sign Requests
==================

Sign Requests are used to request e-signatures on documents from signers.
A Sign Request can refer to one or more Box Files and can be sent to one or more Box Sign Request Signers.

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Create Sign Request](#create-sign-request)
- [Get all Sign Requests](#get-all-sign-requests)
- [Get Sign Request by ID](#get-sign-request-by-id)
- [Cancel Sign Request](#cancel-sign-request)
- [Resend Sign Request](#resend-sign-request)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Create Sign Request
------------------------

The `SignRequestsManager.CreateSignRequestAsync(BoxSignRequestCreateRequest signRequestCreateRequest)`
method will create a Sign Request. You need to provide at least one file (from which the signing document will be created) and at least one signer to receive the Sign Request.

<!-- sample post_sign_requests -->
```c#
var sourceFiles = new List<BoxSignRequestCreateSourceFile>
{
new BoxSignRequestCreateSourceFile()
{
Id = "12345"
}
};

var signers = new List<BoxSignRequestSignerCreate>
{
new BoxSignRequestSignerCreate()
{
Email = "[email protected]"
}
};

var parentFolder = new BoxRequestEntity()
{
Id = "12345",
Type = BoxType.folder
};

var request = new BoxSignRequestCreateRequest
{
SourceFiles = sourceFiles,
Signers = signers,
ParentFolder = parentFolder
};

BoxSignRequest signRequest = await client.SignRequestsManager.CreateSignRequestAsync(request);
```

If you set ```isDocumentPreparationNeeded``` flag to true, you need to visit ```prepareUrl``` before the Sign Request will be sent.
For more information on ```isDocumentPreparationNeeded``` and the other parameters available, please refer to the [developer documentation](https://developer.box.com/guides/sign-request/).

Get All Sign Requests
------------------------

Calling the `SignRequestsManager.GetSignRequestsAsync(int limit = 100, string nextMarker = null, bool autoPaginate = false)`
will return an iterable that will page through all the Sign Requests.

<!-- sample get_sign_requests -->
```c#
BoxCollectionMarkerBased<BoxSignRequest> signRequests = await client.SignRequestsManager.GetSignRequestsAsync();
```

Get Sign Request by ID
------------------------

Calling `SignRequestsManager.GetSignRequestByIdAsync(string signRequestId)` will return an object
containing information about the Sign Request.

<!-- sample get_sign_requests_id -->
```c#
BoxSignRequest signRequest = await client.SignRequestsManager.GetSignRequestByIdAsync("12345");
```

Cancel Sign Request
------------------------

Calling `SignRequestsManager.CancelSignRequestAsync(string signRequestId)` will cancel a created Sign Request.

<!-- sample post_sign_requests_id_cancel -->
```c#
BoxSignRequest cancelledSignRequest = await client.SignRequestsManager.CancelSignRequestAsync("12345");
```

Resend Sign Request
------------------------

Calling `SignRequestsManager.ResendSignRequestAsync(string signRequestId)` will resend a Sign Request to all signers that have not signed it yet.
There is an 10-minute cooling-off period between re-sending reminder emails.

<!-- sample post_sign_requests_id_resend -->
```c#
await client.SignRequestsManager.ResendSignRequestAsync("12345");
```
30 changes: 30 additions & 0 deletions docs/terms-of-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Box Platform.
- [Update a Terms of Service for an Enterprise](#update-a-terms-of-service-for-an-enterprise)
- [Get a Terms of Service By ID](#get-a-terms-of-service-by-id)
- [Get Terms of Service for an Enterprise](#get-terms-of-service-for-an-enterprise)
- [Create User Status on Terms of Service](#create-user-status-on-terms-of-service)
- [Update User Status on Terms of Service](#update-user-status-on-terms-of-service)
- [Get Terms of Service Status for User](#get-terms-of-service-status-for-user)

Expand Down Expand Up @@ -78,6 +79,35 @@ BoxTermsOfServiceCollection<BoxTermsOfService> termsOfService = await client.Ter
.GetTermsOfServicesAsync();
```

Create User Status on Terms of Service
--------------------------------------

For create user status on a terms of service call the
`TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(BoxTermsOfServiceUserStatusCreateRequest termsOfServiceUserStatusCreateRequest)`

You can only create a user status on a terms of service if the user has never accepted/declined a terms of service.
If they have then you will need to make the update call..

<!-- sample post_terms_of_service_user_statuses -->
```c#
var createStatusRequest = new BoxTermsOfServiceUserStatusCreateRequest()
{
TermsOfService = new BoxRequestEntity()
{
Id = "11111",
Type = BoxType.terms_of_service
},
User = new BoxRequestEntity()
{
Id = "22222",
Type = BoxType.user
},
IsAccepted = true
};
BoxTermsOfServiceUserStatuses termsOfServiceUserStatuses =
await client.TermsOfServiceManager.CreateBoxTermsOfServiceUserStatusesAsync(createStatusRequest);
```

Update User Status on Terms of Service
--------------------------------------

Expand Down