Skip to content

Commit

Permalink
Record base_url returned from successful login
Browse files Browse the repository at this point in the history
Per Docusign team: "In the demo environment all account URLs
start with demo.docusign.net, however in production there are
multiple sub-domains like www, na2, eu, etc.  To resolve all you need to
do is parse the baseUrl value that is returned from the login call."

This seems to also apply to the oauth token, but I'm not sure of the use
case there.

Thanks to Will Beattie for the report.
  • Loading branch information
tommotorefi committed May 1, 2017
1 parent 422eab2 commit 323c5f5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Changelog

## v0.2.1 April ?? 2017
## v0.2.1 May ?? 2017

### Features:
* Add certificate option to DocusignRest::Client#get_combined_document_from_envelope (Shane Stanford)
* Memoize base_url after successful login attempt. This prevents problems in production when Docusign returns a different subdomain on login as discussed in [here](https://github.com/jondkinney/docusign_rest/pull/102) (Tom Copeland)

### Misc:
* Replace monkeypatch with argument usage (Jean-Philippe Moal)
Expand Down
10 changes: 8 additions & 2 deletions lib/docusign_rest/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module DocusignRest
class Client
# Define the same set of accessors as the DocusignRest module
attr_accessor *Configuration::VALID_CONFIG_KEYS
attr_accessor :docusign_authentication_headers, :acct_id
attr_accessor :docusign_authentication_headers, :acct_id, :base_url

def initialize(options={})
# Merge the config values from the module and those passed to the client.
Expand Down Expand Up @@ -80,7 +80,12 @@ def headers(user_defined_headers={})
#
# Returns a parsed URI object
def build_uri(url)
URI.parse("#{endpoint}/#{api_version}#{url}")
uri_string = if base_url
"#{base_url}#{url}"
else
"#{endpoint}/#{api_version}#{url}"
end
URI.parse(uri_string)
end


Expand Down Expand Up @@ -190,6 +195,7 @@ def get_account_id
hashed_response = JSON.parse(response)
login_accounts = hashed_response['loginAccounts']
@acct_id ||= login_accounts.first['accountId']
@base_url = login_accounts.first['baseUrl']
end

acct_id
Expand Down

0 comments on commit 323c5f5

Please sign in to comment.