lib/cts/mpx/registry.rb in cts-mpx-1.0.1 vs lib/cts/mpx/registry.rb in cts-mpx-1.0.2
- old
+ new
@@ -14,10 +14,11 @@
# @param [User] user user to make calls with
# @param [String] account_id long form account id (ownerId)
# @raise (see #fetch_domain)
# @return [Hash] hash of the newly fetched domain
def fetch_and_store_domain(user, account_id = 'urn:theplatform:auth:root')
+ account_id ||= 'urn:theplatform:auth:root'
result = fetch_domain user, account_id
store_domain result, account_id
domains[account_id]
end
@@ -27,12 +28,13 @@
# @raise [ArgumentError] if the user is not a user object
# @raise [ArgumentError] if the account_id is not valid
# @return [Hash] hash of the newly fetched domain
def fetch_domain(user, account_id = 'urn:theplatform:auth:root')
return domains['urn:theplatform:auth:root'] if account_id == 'urn:theplatform:auth:root'
- Driver::Exceptions.raise_unless_argument_error?(user, 'User') { user.is_a? User }
- Driver::Exceptions.raise_unless_argument_error?(account_id, 'account_id') { Validators.account_id? account_id }
+
+ Driver::Exceptions.raise_unless_argument_error?(user, 'User') { !user.is_a? User }
+ Driver::Exceptions.raise_unless_argument_error?(account_id, 'account_id') { !Validators.account_id? account_id }
user.token!
response = Services::Web.post user: user, service: 'Access Data Service', endpoint: 'Registry', method: 'resolveDomain', arguments: { 'accountId' => account_id }
response.data['resolveDomainResponse']
end
@@ -44,9 +46,10 @@
# @raise [ArgumentError] if the account_id is not valid
# @return [Void]
def store_domain(data, account_id = 'urn:theplatform:auth:root')
raise ArgumentError, "#{account_id} is not a valid account_id" unless Validators.account_id? account_id
raise ArgumentError, "#{data} is not a valid Hash" unless data.is_a? Hash
+
@domains.store account_id, data
nil
end
# find and store the root registry from the US