lib/imis/api.rb in usps-imis-api-0.1.1 vs lib/imis/api.rb in usps-imis-api-0.1.2
- old
+ new
@@ -23,9 +23,21 @@
def imis_id_for(certificate)
result = query(Imis.configuration.imis_id_query_name, { certificate: certificate })
@imis_id = result['Items']['$values'][0]['ID']
end
+ # Run requests as DSL, with specific iMIS ID only maintained for this scope
+ #
+ # This should be used with methods that do not change the value of `imis_id`
+ #
+ def with(id, &block)
+ old_id = imis_id
+ self.imis_id = id
+ instance_eval(&block)
+ ensure
+ self.imis_id = old_id
+ end
+
# Get a business object for the current member
#
def get(business_object_name)
uri = uri_for(business_object_name)
request = Net::HTTP::Get.new(uri)