lib/stripe/account.rb in stripe-3.3.2 vs lib/stripe/account.rb in stripe-3.4.1

- old
+ new

@@ -4,44 +4,44 @@ extend Stripe::APIOperations::Create extend Stripe::APIOperations::List include Stripe::APIOperations::Delete include Stripe::APIOperations::Save - OBJECT_NAME = 'account' + OBJECT_NAME = "account".freeze save_nested_resource :external_account # This method is deprecated. Please use `#external_account=` instead. save_nested_resource :bank_account deprecate :bank_account=, "#external_account=", 2017, 8 def resource_url - if self['id'] + if self["id"] super else "/v1/account" end end # @override To make id optional - def self.retrieve(id=ARGUMENT_NOT_PROVIDED, opts={}) + def self.retrieve(id = ARGUMENT_NOT_PROVIDED, opts = {}) id = id.equal?(ARGUMENT_NOT_PROVIDED) ? nil : Util.check_string_argument!(id) # Account used to be a singleton, where this method's signature was # `(opts={})`. For the sake of not breaking folks who pass in an OAuth # key in opts, let's lurkily string match for it. - if opts == {} && id.is_a?(String) && id.start_with?('sk_') + if opts == {} && id.is_a?(String) && id.start_with?("sk_") # `super` properly assumes a String opts is the apiKey and normalizes as expected. opts = id id = nil end super(id, opts) end - def reject(params={}, opts={}) + def reject(params = {}, opts = {}) opts = Util.normalize_opts(opts) - resp, opts = request(:post, resource_url + '/reject', params, opts) + resp, opts = request(:post, resource_url + "/reject", params, opts) initialize_from(resp.data, opts) end # Somewhat unfortunately, we attempt to do a special encoding trick when # serializing `additional_owners` under an account: when updating a value, @@ -68,13 +68,13 @@ # patch in a special allowance. def serialize_params(options = {}) serialize_params_account(self, super) end - def serialize_params_account(obj, update_hash) - if entity = @values[:legal_entity] - if owners = entity[:additional_owners] + def serialize_params_account(_obj, update_hash) + if (entity = @values[:legal_entity]) + if (owners = entity[:additional_owners]) entity_update = update_hash[:legal_entity] ||= {} entity_update[:additional_owners] = serialize_additional_owners(entity, owners) end end @@ -84,21 +84,21 @@ def self.protected_fields [:legal_entity] end def legal_entity - self['legal_entity'] + self["legal_entity"] end def legal_entity=(_) - raise NoMethodError.new('Overridding legal_entity can cause serious issues. Instead, set the individual fields of legal_entity like blah.legal_entity.first_name = \'Blah\'') + raise NoMethodError, 'Overridding legal_entity can cause serious issues. Instead, set the individual fields of legal_entity like blah.legal_entity.first_name = \'Blah\'' end - def deauthorize(client_id=nil, opts={}) + def deauthorize(client_id = nil, opts = {}) params = { client_id: client_id, - stripe_user_id: self.id, + stripe_user_id: id, } OAuth.deauthorize(params, opts) end ARGUMENT_NOT_PROVIDED = Object.new @@ -109,13 +109,11 @@ original_value = legal_entity.instance_variable_get(:@original_values)[:additional_owners] if original_value && original_value.length > additional_owners.length # url params provide no mechanism for deleting an item in an array, # just overwriting the whole array or adding new items. So let's not # allow deleting without a full overwrite until we have a solution. - raise ArgumentError.new( - "You cannot delete an item from an array, you must instead set a new array" - ) + raise ArgumentError, "You cannot delete an item from an array, you must instead set a new array" end update_hash = {} additional_owners.each_with_index do |v, i| # We will almost always see a StripeObject except in the case of a Hash @@ -125,10 +123,10 @@ # StripeObject. update = v.is_a?(StripeObject) ? v.serialize_params : v if update != {} && (!original_value || update != legal_entity.serialize_params_value(original_value[i], nil, false, true)) - update_hash[i.to_s] = update + update_hash[i.to_s] = update end end update_hash end end