diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e4c88cc..2466f6f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/lib/docusign_rest/client.rb b/lib/docusign_rest/client.rb index b7fcc4d1..4b2d10fe 100644 --- a/lib/docusign_rest/client.rb +++ b/lib/docusign_rest/client.rb @@ -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. @@ -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 @@ -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