PHP sdk example problems


(1st Source It, Llc) #1

I’m trying to just get started. The arguments in the README.md for the _list() method of the customer object is incorrect. According to the class, all 3 arguments are required (though I don’t think the 2nd two should be). I.e. _list(10, 0, ‘’). (side queestion, where is the ‘search’ parameter documented?).

However, when I make the call it dies with a fatal error with a serialized result. Very hard to parse this into something that makes sense.

Fatal error: Uncaught DwollaSwagger\ApiException: API call to https::/api-uat.dwolla.com//customers?limit=10&offset=0&search= timed out: a:26:{s:3:"url";s:70:"HTTP://https::/api-uat.dwolla.com//customers?limit=10&offset=0&search=";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:0;s:14:"redirect_count";i:0;s:10:"total_time";d:0.000271999999999999997855881783692666431306861340999603271484375;s:15:"namelookup_time";d:0;s:12:"connect_time";d:0;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:0:"";s:8:"certinfo";a:0:{}s:12:"primary_port";i:0;s:8:"local_ip";s:0:"";s:10:"local_port";i:0;} in /home/ezms/public_html_subs/mve4/app/addons/vendor_pay/provider_classes/dwolla/lib/ApiClient.php:298 Stack t in/home/ezms/public_html_subs/mve4/app/addons/vendor_pay/provider_classes/dwolla/lib/ApiClient.php on line 298

Not a very friendly return upon any kind of failure. I didn’t want to use the SDK but wanted to use the REST API itself. But I can’t find any documentation on the basic REST API. The docs just seem to launch into the SDK versions of the endpoints.

The $this-apiClient is obtained via this code in the constructor where ‘oauth_token’ is the 60 day token.:

            $this->accessToken = $credentials['oauth_token'];
            DwollaSwagger\Configuration::$access_token = $this->accessToken;
            $this->apiClient = new DwollaSwagger\ApiClient($this->url);

My class method is (the uncommented die() is never reached):

    Public function createCustomer($customer_data) {
        $c_data = array();
        $c_data['firstName'] = empty($customer_data['first_name']) ? '' : $customer_data['first_name'];
        $c_data['lastName'] = empty($customer_data['last_name']) ? '' : $customer_data['last_name'];
        $c_data['email'] = empty($customer_data['email']) ? '' : $customer_data['email'];
        $c_data['phone'] = empty($customer_data['phone']) ? '' : $customer_data['phone'];
        
        $cApi = new DwollaSwagger\CustomersApi($this->apiClient);
//die("<pre>cApi:".print_r($cApi,true) );
$customers = $cApi->_list(10, 0, '');
die("<pre>customers:".print_r($customers,true) );
die("<pre>cApi:".print_r($cApi,true) );
        $location = $cApi->create($c_data);
        return $location;
    }

Any help/pointers greatly appreciated.


(1st Source It, Llc) #2

Gotta love typos. The url being attempted was https::/uat-… instead of https://uat-…

But the docs are still wrong!


(Spencer Hunter) #3

Thanks for pointing this out @1st_Source_IT_LLC! You’re correct, all three arguments should not be required instead they should be optional.

You can find the API reference docs for search here: https://docsv2.dwolla.com/#list-customers

Sorry for the inconvenience. We are working on making updates to this SDK and hope to have something released later this week. That being said, you can definitely use a third party HTTP client like Guzzle for making calls to the API. When looking in the docs be sure to select Raw which will show what a raw HTTP request looks like. We’ll post back as we progress toward updating this SDK.


(1st Source It, Llc) #4

This doesn’t tell the format of the search string. I.e. is it mysql style, shell style, exact match only? I.e. Frank%, Frank* or only Franklin?


(Andrew Toivonen) #5

The format of the search parameter does not include extra search parameters at this time. It doesn’t have to be an exact match but does at least have to match part of the start of the string (ex: searching for “andre” should return results including “andrew”) but it currently does not support fuzzy searches. Also it will match on different parts of email addresses - searching for gmail.com will return your customers with emails matching that domain.