Coder Social home page Coder Social logo

go-sfdc's People

Contributors

ehtycuact avatar g8rswimmer avatar guitarbum722 avatar rmulley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

go-sfdc's Issues

Could Builder fields just be exported?

This is more of a question hoping to prompt discussion.

Using soql.Builder as an example, could most of its fields simply be exported? I say this because many of the builder's methods are simply doing a direct assignment.
For the fields that require additional logic/validation/etc. then those respective methods can remain in place for assignment.

At that point, maybe it isn't a "builder" per se, but maybe rather a soql.Opts struct.

I wonder if that would simplify your lib even further (and it is already very readable and well documented). It's that much fewer API components that the consumer would need to concern themselves with.

Unable to provide my own Session to the package

It seems the package is designed to obtain its own session. I'm working from the idea that a calling org will provide a session for me to use and I do not obtain my own.

To make this work I needed to override part of the Session package but still provide a set of fake Credentials just to get a session created.

I wanted to put this up for discussion before I tried to mangle the package via PR.

I changed session.sessionPasswordResponse to be exported then created an alternate session.Open function that would accept it in and create a Session without trying to login. Staying compatible with the current Session interface so I could pass my session to your systems.

I don't think this solution is very clean because it still requires a sfdc.Configuration object with all the OAuth properties.

// SessionPasswordResponse is the relevant connection details for Salesforce
type SessionPasswordResponse struct {
	AccessToken string `json:"access_token"`
	InstanceURL string `json:"instance_url"`
	TokenType   string
}

// Open is used to authenticate with Salesforce and open a session.  The user will need to
// supply the proper credentials and a HTTP client.
func Open(config sfdc.Configuration, resp *SessionPasswordResponse) (*Session, error) {
	if config.Credentials == nil {
		return nil, errors.New("session: configuration crendentials can not be nil")
	}
	if config.Client == nil {
		return nil, errors.New("session: configuration client can not be nil")
	}
	if config.Version <= 0 {
		return nil, errors.New("session: configuration version can not be less than zero")
	}
	session := &Session{
		response: resp,
		config:   config,
	}

	return session, nil
}

Upsert External ID Issue dml

I'm getting the issue below with upserting a External ID. Thoughts Thanks!

This
NOT_FOUND: Provided external ID field does not exist or is not accessible:

Code below

dml := &dml{
sobject: "Facebook_7FF__c",
fields: map[string]interface{}{
"Ad_Spent_Cents__c": "$10000",
"Clicks__c": "200",
"Entered_Date_Time__c": "12/4/2019, 5:10:20 PM",
"LMS_ID__c": "2324",
"LMS_Record_ID__c": "e4f5591f-ca42-4eb5-bd4b-3d6a1d1b2602",
"Leads__c": "5",
"Period_End_Date__c": "11/27/2019",
"Period_Start_Date__c": "11/27/2019",
"Sales_Cents__c": "$2000",
"Scheduled_ss__c": "2",
"Person_Account__c": "a293i0000009ErBAAU",
"clients__c": "1",
"ss__c": "1",
},
}
dml.id = "a293i0000009ErBAAU"
dml.externalField = "75bc21b7-201c-4a90-b716-506785a0c2a0"

Incorrect error messages

I noticed that there are some incorrect or out of context error messages when I was looking into #33 .

To reproduce, I called resource.Query(), revoked an access token, and got an error returned.

The error for the call to Query() was insert response err: INVALID_SESSION_ID: Session expired or invalid... (not in regards to a insert)

In fact, this might be an issue in multiple places in the codebase after doing a quick search.

Reflection mapping

Add some methods that will use reflection and tags to map salesforce fields to a struct and struct to a map of fields

Map[string]interface{}{

Hey g8rswimmer, thank for this repository. I am new to Go and I confused with the "map[string]interface{}" function, how does the system know why type of field it is? Also, do you know of examples of code that shows your code implemented. I appreciate it!

DD

Propagate context to Query

Hello,

Is there any estimation that you will implement the API requests using NewRequestWithContext instead of NewRequest so we will be able to pass our context?

Thanks in advanced.

Session expired or invalid

What is the desired behavior when an OAuth token is expired/invalid?

For example, I created a session, initialized a Resource and then called resource.Query() in a loop on a 5 second delay just to simulate some typical usage by an automated client.

I logged into my Org and removed the client's session.

SFDC returns INVALID_SESSION_ID: Session expired or invalid, obviously. Thus, an error is returned (I assumed via the call to queryResponse().

  • Is there anything besides the error string I could inspect if this occurs?
  • Am I missing functionality that you've already implemented?
  • Is there a benefit to re-auth and/or letting the caller know that they should authenticate and retry?

SOQL: Lookup fields cause error

Running a SOQL query like "SELECT Id, AccountId, Account.Name FROM Contact" causes an error because the processor sees a nested object and thinks it is a nested list of results caused by querying from a top-down lookup where this is a bottom-up lookup and errors with SOQL Query Error query response: done is not present

Remembering that these can actually be nested up to five levels.

I'm not familiar enough with the package yet to know if I'm doing something wrong. Problem appears to be generally located in the assumptions held that if it isn't an attributes key then it must be a nested query.

soql\record.go--newQueryRecord:19
if k != sfdc.RecordAttributes {

Returned data is in the form

{
    "totalSize": 1,
    "done": true,
    "records": [
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v45.0/sobjects/Contact/003XXXXXXXXXXXXXXX"
            },
            "Id": "003XXXXXXXXXXXXXXX",
            "AccountId": "001XXXXXXXXXXXXXXX",
            "Account": {
                "attributes": {
                    "type": "Account",
                    "url": "/services/data/v45.0/sobjects/Account/001XXXXXXXXXXXXXXX"
                },
                "Name": "Test Account"
            }
        }
    ]
}

I'll try and figure it out and get a PR submitted.

Bug: `payload` function in `composite.go` should set `httpHeaders` field to `map[string]string` instead of `map[string][]string`

I was using this for a project and noticed that Salesforce expects a map[string]string instead of map[string][]string for the httpHeaders field in composite subrequests.

https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_record_manipulation.htm

When I use

            "httpHeaders": {
                "Some-Header": ["defg"]
            }

I get the error

[
    {
        "message": "Invalid type provided for value in 'httpHeaders'",
        "errorCode": "JSON_PARSER_ERROR"
    }
]

and the request works when I use

            "httpHeaders": {
                "Some-Header": "defg"
            }

pwdcreds error

cannot use pwdCreds (type *"go-sfdc/credentials".Credentials) as type *"github.com/g8rswimmer/go-sfdc/credentials".Credentials in field value

Add a Makefile to the project

Prefer doing this before opening up to the community.

Targets for a lib would likely include

  1. test
  2. docs
  3. deps (if applicable; use Go Modules)

Happy to provide some samples if desired.

Discovery - library additions to support types provided by the caller

Look into adding functionality to the API to support the caller's own type being deserialized.

This would be similar to a GORM query. For example:

var c customStruct
if err := resource.NeatQuery(&c); err != nil {
    log.Println(err)
}

fmt.Println(c.Name)

Since the SFDC services return JSON, I think this would simply end up wrapping json.Unmarshal.

See what it would take to extend this client sdk and keep it backwards compatible.
Use this issue for conversation, suggestions, etc.

Not able to use the result.Next to paginate through more records

Hi g8rswimmer,

first off - love your repo. i'm experiementing trying to use the "Next" function of the query result and can't get past a nil pointer dereference.

Do you have any sample code that i could quickly look out that demonstrates how to paginate through a large query REsult?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.