Skip to content

Commit

Permalink
Documentation updates (#29)
Browse files Browse the repository at this point in the history
* added readme

* added the readme

* corrected link

* using tabs

* Updating readme file

* updated

* updated the readme

* Took out the println
  • Loading branch information
g8rswimmer authored May 10, 2019
1 parent f3c89d0 commit b923c4a
Show file tree
Hide file tree
Showing 9 changed files with 418 additions and 379 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# go-sfdc
This is a `golang` library for interfacing with `Salesforce` APIs.

## Getting Started
### Installing
To start using GO-SFDC, install GO and run `go get`
```
go get -u github.com/g8rswimmer/go-sfdc
```
This will retrieve the library.

## Usage
To use this library, the following will need to be done.
* Create `Salesforce` [credentials](./credentials/README.md) to properly authenticate with the `Salesforce org`
Expand All @@ -11,6 +19,8 @@ To use this library, the following will need to be done.
- [SObject Collection APIs](./sobject/collections/README.md)
- [SObject Tree API](./sobject/tree/README.md)
- [SOQL APIs](./soql/README.md)
- [Composite](./composite/README.md)
- [Composite Batch](./composite/batch/README.md)

## Configuration
The configuration defines several parameters that can be used by the library. The configuration is used per [session](./session/README.md).
Expand All @@ -25,3 +35,6 @@ config := sfdc.Configuration{
Version: 44,
}
```

## License
GO-SFDC source code is available under the [MIT License](LICENSE.txt)
10 changes: 4 additions & 6 deletions composite/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Composite API
[back](../README.md)

The `sobject` package is an implementation of `Salesforce APIs` centered on `Composite` operations. These operations include:
The `composite` package is an implementation of `Salesforce APIs` centered on `Composite` operations. These operations include:
* SObject Resources
* Query Resource
* Query All Resource
Expand Down Expand Up @@ -81,16 +81,14 @@ func (c *compositeSubRequest) Body() map[string]interface{} {

resource, err := composite.NewResource(session)
if err != nil {
fmt.Printf("Composite Error %s", err.Error())
fmt.Println()
fmt.Printf("Composite Error %s\n", err.Error())
return
}
value, err := resource.Retrieve(false, subRequests)
if err != nil {
fmt.Printf("Composite Error %s", err.Error())
fmt.Println()
fmt.Printf("Composite Error %s\n", err.Error())
return
}

fmt.Printf("%+v", value)
fmt.Printf("%+v\n", value)
```
71 changes: 71 additions & 0 deletions composite/batch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Composite Batch API
[back](../../README.md)

The `batch` package is an implementation of `Salesforce APIs` centered on `Composite Batch` operations. These operations include:
* Limits Resources
* SObject Resources
* Query All
* Query
* Search
* Connect Resources
* Chatter Resources

As a reference, see `Salesforce API` [documentation](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/intro_what_is_rest_api.htm)

## Examples
The following are examples to access the `APIs`. It is assumed that a `sfdc` [session](../../session/README.md) has been created.
### Subrequest
```go
type batchSubrequester struct {
url string
method string
richInput map[string]interface{}
binaryPartName string
binaryPartAlais string
}

func (b *batchSubrequester) URL() string {
return b.url
}
func (b *batchSubrequester) Method() string {
return b.method
}
func (b *batchSubrequester) BinaryPartName() string {
return b.binaryPartName
}
func (b *batchSubrequester) BinaryPartNameAlias() string {
return b.binaryPartAlais
}
func (b *batchSubrequester) RichInput() map[string]interface{} {
return b.richInput
}
```
### Composite Batch
```go
subRequests := []batch.Subrequester{
&batchSubrequester{
url: "v44.0/sobjects/Account/0012E00001qLpKZQA0",
method: http.MethodPatch,
richInput: map[string]interface{}{
"Name": "NewName",
},
},
&batchSubrequester{
url: "v44.0/sobjects/Account/0012E00001qLpKZQA0",
method: http.MethodGet,
},
}

resource, err := batch.NewResource(session)
if err != nil {
fmt.Printf("Batch Composite Error %s\n", err.Error())
return
}
value, err := resource.Retrieve(false, subRequests)
if err != nil {
fmt.Printf("Batch Composite Error %s\n", err.Error())
return
}

fmt.Printf("%+v\n", value)
```
16 changes: 8 additions & 8 deletions credentials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ The following are some example(s) of creating credentials to be used when openin
### Password
```go
creds := credentials.PasswordCredentails{
URL: "https://login.salesforce.com",
Username: "my.user@name.com",
Password: "greatpassword",
ClientID: "asdfnapodfnavppe",
ClientSecret: "12312573857105",
URL: "https://login.salesforce.com",
Username: "my.user@name.com",
Password: "greatpassword",
ClientID: "asdfnapodfnavppe",
ClientSecret: "12312573857105",
}

config := sfdc.Configuration{
Credentials: credentials.NewPasswordCredentials(creds),
Client: salesforceHTTPClient,
Version: 44,
Credentials: credentials.NewPasswordCredentials(creds),
Client: salesforceHTTPClient,
Version: 44,
}
```
21 changes: 10 additions & 11 deletions session/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ The session is used to authenticate with `Salesforce` and retrieve the org's inf
The following example demonstrates how to create a session.
```go
creds := credentials.PasswordCredentails{
URL: "https://login.salesforce.com",
Username: "my.user@name.com",
Password: "greatpassword",
ClientID: "asdfnapodfnavppe",
ClientSecret: "12312573857105",
URL: "https://login.salesforce.com",
Username: "my.user@name.com",
Password: "greatpassword",
ClientID: "asdfnapodfnavppe",
ClientSecret: "12312573857105",
}

config := sfdc.Configuration{
Credentials: credentials.NewPasswordCredentials(creds),
Client: http.DefaultClient,
Version: 44,
Credentials: credentials.NewPasswordCredentials(creds),
Client: http.DefaultClient,
Version: 44,
}

session, err := session.Open(config)

if err != nil {
fmt.Printf("Error %s", err.Error())
fmt.Println()
return
fmt.Printf("Error %s\n", err.Error())
return
}

// access Salesforce APIs
Expand Down
Loading

0 comments on commit b923c4a

Please sign in to comment.