Skip to content
This repository was archived by the owner on Oct 17, 2023. It is now read-only.

Comments

add method to query for signature requests#119

Merged
jspaetzel merged 1 commit intohellosign:masterfrom
codylerum:request_search
Feb 4, 2021
Merged

add method to query for signature requests#119
jspaetzel merged 1 commit intohellosign:masterfrom
codylerum:request_search

Conversation

@codylerum
Copy link
Contributor

@codylerum codylerum commented Jul 31, 2020

The API offers an option to query for signature requests that match a certain criteria

https://app.hellosign.com/api/reference#list_signature_requests

So you could create a request like https://api.hellosign.com/v3//signature_request/list?query=complete:false&page_size=100

However the Java API does not have an option to include the query parameter. I've added that here, but it begs another question if there should either be a SignatureRequestsRequestobject that you pass in

getSignatureRequests(SignatureRequestsRequest requst)

Where SignatureRequestsRequest contains page_size,page,query,account_id and adds them to the URL as query params if they are set, or

getSignatureRequests(Map<String,Object> params)

Where you just iterate through the entries and add them as key and value.toString

I'm not seeing any established conventions for this currently.

Stripe for instance uses something like

  Map<String, Object> params = new HashMap<String, Object>();
        params.put("expand", Lists.newArrayList("data.balance_transaction"));
        params.put("created", createdParams);
        params.put("limit", 100);
Charge.list(params)

Probably makes the most sense to do something like the below since .withGetParams(params) already exists on the HttpClient

public SignatureRequestList getSignatureRequests(Map<String, String> params) throws HelloSignException {       
        return new SignatureRequestList(httpClient.withAuth(auth).withGetParams(params).asJson());
    }

And then convert the existing methods to use it.

    public SignatureRequestList getSignatureRequests(int page) throws HelloSignException {
        HashMap<String,String> params = new HashMap<>();
        params.put(AbstractResourceList.PAGE, Integer.toString(page));
        return getSignatureRequests(params);
    }

 public SignatureRequestList getSignatureRequests(int page, int pageSize)
        throws HelloSignException {
        HashMap<String,String> params = new HashMap<>();
        params.put(AbstractResourceList.PAGE, Integer.toString(page));
        params.put(AbstractResourceList.PAGE_SIZE, Integer.toString(pageSize));
        return getSignatureRequests(params);
    }

If you think that is a good path I can update the PR

@codylerum
Copy link
Contributor Author

codylerum commented Aug 24, 2020

@jspaetzel can you take a look at this when you have a moment?

@jspaetzel jspaetzel self-requested a review August 25, 2020 17:30
@codylerum
Copy link
Contributor Author

@jspaetzel Any thoughts here?

@jspaetzel
Copy link
Member

jspaetzel commented Feb 4, 2021

Sorry for the wait! This change looks nice, thanks for the contribution!

For the SDK I prefer simple to use function signatures with escape hatches for when we're slow to implement new features here. If we were generating more code I'd prefer getSignatureRequests(SignatureRequestsRequest request) but since we're not it's a little saner to use getSignatureRequests(Map<String,Object> params) which is the more flexible choice. I'd welcome a PR with the changes you've described.

@jspaetzel jspaetzel merged commit 2450902 into hellosign:master Feb 4, 2021
@jspaetzel
Copy link
Member

jspaetzel commented Feb 4, 2021

I'll include this change with the next sdk release within the week, likely as 5.2.0

@jspaetzel jspaetzel added this to the 5.2.0 milestone Feb 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants