Permalink
Browse files

servicedaccountservice requires instantiation without customer_id

  • Loading branch information...
1 parent e6a96d6 commit ddbc68d38574911e7c738f9f0d2f28f48b449c05 @Kequc Kequc committed May 24, 2012
Showing with 10 additions and 6 deletions.
  1. +3 −4 lib/adapi/api.rb
  2. +6 −1 lib/adapi/service_api.rb
  3. +1 −1 lib/adapi/serviced_account.rb
View
7 lib/adapi/api.rb
@@ -33,10 +33,9 @@ def initialize(params={})
end
def customer_id=(customer_id)
- if customer_id.present?
- @customer_id = customer_id.to_i
- Adapi::Config.set(:client_customer_id => @customer_id)
- end
+ @customer_id = customer_id.to_i
+ @customer_id = nil if @customer_id < 1
+ Adapi::Config.set(:client_customer_id => @customer_id)
end
def add_error(error_string)
View
7 lib/adapi/service_api.rb
@@ -110,10 +110,15 @@ def mutate_explicit(operator, operand)
self.mutate(operation)
end
+ def needs_customer_id?
+ return false if params[:service_name] == :ServicedAccountService
+ !@customer_id.present?
+ end
+
def execute!(operation, method=:mutate)
response = nil
@attempts = 0
- raise "Service api request attempt without customer_id; #{operation.inspect}" unless @customer_id.present?
+ raise "Service api request attempt without customer_id; #{operation.inspect}" if needs_customer_id?
begin
@perform_retry = false
View
2 lib/adapi/serviced_account.rb
@@ -15,7 +15,7 @@ def self.find(amount=:all, params={})
end
params.symbolize_keys!
- response = self.get(nil, 0)
+ response = self.get(nil)
response = (response and response[:accounts]) ? response[:accounts] : []
found = nil

0 comments on commit ddbc68d

Please sign in to comment.