loopline-systems / closeio-api-wrapper

PHP Wrapper to use the Close.io API
MIT License
14 stars 15 forks source link

Unable to save opportunities #9

Closed wundo closed 9 years ago

wundo commented 9 years ago

Try:

  $opportunity = new Opportunity();
  $opportunity->setConfidence("50");

  $lead->setOpportunities(array($opportunity));
  $response = $leadsApi->addLead($lead);

Nothing happens :(

philfreo commented 9 years ago

did you print_r($response) to see what's happening?

wundo commented 9 years ago

Yes I did, $response->getData()['opportunities'] is empty

philfreo commented 9 years ago

Okay I'm not familiar with the details of how this library works, but the Close.io REST API doesn't support creating Opportunities by posting them inside of a Lead. To create an Opportunity via the API you have to send a POST to the Opportunity endpoint on its own, after the lead is created. @mickadoo will have to let you know how to do that in this library, if it's supported.

(Alternatively you could use a lightweight requests wrapper to do it)

wundo commented 9 years ago

requests wrappers seems too much like a "quick hack" for me, no offense intended.

philfreo commented 9 years ago

No offense intended - though it's not a hack, it's just simply using a REST API without a PHP code having to be written to wrap each API endpoint & method. I'm glad this library exists and I hope @mickadoo can help you :)

null9beta commented 9 years ago

@wundo - we just started out with implementing the lead api wanting to implement the others whenever needed. We will remove the opportunity from the lead api to clean things up and implement the opportunity api. Should be ready somewhat today.

Also it would be nice if could ask you to test the feature branch with the opportunity api once we are ready before we actually going to merge it back to the master and tag it.

Best Marco

mickadoo commented 9 years ago

@wundo I've added the OpportunityApi in the branch feature/9_add-opportunity-api

You can see how to use it in the updated README.md in that branch. Would you be able to test it to see if it satisfies your requirements?

Michael

mickadoo commented 9 years ago

@wundo New release (v0.1.0) should address your problem. If you have any issues just let me know.

Michael

wundo commented 9 years ago

Awesome! thanks :)