Skip to content

Commit

Permalink
Revert format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneZsng committed Apr 8, 2022
1 parent dbce722 commit a0808ee
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions force.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ type QueryResult struct {

// Expose sid to save in admin settings
func (client *Client) GetSid() (sid string) {
return client.sessionID
return client.sessionID
}

//Expose Loc to save in admin settings
Expand All @@ -60,8 +60,8 @@ func (client *Client) GetLoc() (loc string) {

// Set SID and Loc as a means to log in without LoginPassword
func (client *Client) SetSidLoc(sid string, loc string) {
client.sessionID = sid
client.instanceURL = loc
client.sessionID = sid
client.instanceURL = loc
}

// Query runs an SOQL query. q could either be the SOQL string or the nextRecordsURL.
Expand Down Expand Up @@ -283,31 +283,19 @@ func (client *Client) SetHttpClient(c *http.Client) {

// DownloadFile downloads a file based on the REST API path given. Saves to filePath.
func (client *Client) DownloadFile(contentVersionID string, filepath string) error {
apiPath := fmt.Sprintf(
"/services/data/v%s/sobjects/ContentVersion/%s/VersionData",
client.apiVersion,
contentVersionID,
)
apiPath := fmt.Sprintf("/services/data/v%s/sobjects/ContentVersion/%s/VersionData", client.apiVersion, contentVersionID)
return client.download(apiPath, filepath)
}

func (client *Client) DownloadAttachment(attachmentId string, filepath string) error {
apiPath := fmt.Sprintf(
"/services/data/v%s/sobjects/Attachment/%s/Body",
client.apiVersion,
attachmentId,
)
apiPath := fmt.Sprintf("/services/data/v%s/sobjects/Attachment/%s/Body", client.apiVersion, attachmentId)
return client.download(apiPath, filepath)
}

func (client *Client) download(apiPath string, filepath string) error {
// Get the data
httpClient := client.httpClient
req, err := http.NewRequest(
"GET",
fmt.Sprintf("%s%s", strings.TrimRight(client.instanceURL, "/"), apiPath),
nil,
)
req, err := http.NewRequest("GET", fmt.Sprintf("%s%s", strings.TrimRight(client.instanceURL, "/"), apiPath), nil)
req.Header.Add("Content-Type", "application/json; charset=UTF-8")
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer "+client.sessionID)
Expand Down

0 comments on commit a0808ee

Please sign in to comment.