Class: Stripe::Account
- Inherits:
-
APIResource
- Object
- StripeObject
- APIResource
- Stripe::Account
- Extended by:
- Gem::Deprecate, Stripe::APIOperations::Create, Stripe::APIOperations::List, Stripe::APIOperations::NestedResource
- Defined in:
- lib/stripe/resources/account.rb
Constant Summary collapse
- OBJECT_NAME =
"account"
Constants inherited from StripeObject
StripeObject::RESERVED_FIELD_NAMES
Instance Attribute Summary
Attributes inherited from APIResource
Class Method Summary collapse
Instance Method Summary collapse
- #deauthorize(client_id = nil, opts = {}) ⇒ Object
- #legal_entity ⇒ Object
- #legal_entity=(_legal_entity) ⇒ Object
- #persons(params = {}, opts = {}) ⇒ Object
- #reject(params = {}, opts = {}) ⇒ Object
- #resource_url ⇒ Object
-
#serialize_params(options = {}) ⇒ Object
Somewhat unfortunately, we attempt to do a special encoding trick when serializing ‘additional_owners` under an account: when updating a value, we actually send the update parameters up as an integer-indexed hash rather than an array.
- #serialize_params_account(_obj, update_hash, options = {}) ⇒ Object
Methods included from Stripe::APIOperations::Create
Methods included from Stripe::APIOperations::List
Methods included from Stripe::APIOperations::NestedResource
Methods included from Stripe::APIOperations::Save
Methods included from Stripe::APIOperations::Delete
Methods inherited from APIResource
class_name, custom_method, #refresh, resource_url, save_nested_resource
Methods included from Stripe::APIOperations::Request
Methods inherited from StripeObject
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, #to_hash, #to_json, #to_s, #update_attributes, #values
Constructor Details
This class inherits a constructor from Stripe::StripeObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject
Class Method Details
.protected_fields ⇒ Object
115 116 117 |
# File 'lib/stripe/resources/account.rb', line 115 def self.protected_fields [:legal_entity] end |
.retrieve(id = nil, opts = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/stripe/resources/account.rb', line 48 def self.retrieve(id = nil, opts = {}) Util.check_string_argument!(id) if 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_") # `super` properly assumes a String opts is the apiKey and normalizes # as expected. opts = id id = nil end super(id, opts) end |
Instance Method Details
#deauthorize(client_id = nil, opts = {}) ⇒ Object
130 131 132 133 134 135 136 137 |
# File 'lib/stripe/resources/account.rb', line 130 def (client_id = nil, opts = {}) params = { client_id: client_id, stripe_user_id: id, } opts = @opts.merge(Util.normalize_opts(opts)) OAuth.(params, opts) end |
#legal_entity ⇒ Object
119 120 121 |
# File 'lib/stripe/resources/account.rb', line 119 def legal_entity self["legal_entity"] end |
#legal_entity=(_legal_entity) ⇒ Object
123 124 125 126 127 128 |
# File 'lib/stripe/resources/account.rb', line 123 def legal_entity=(_legal_entity) raise NoMethodError, "Overriding legal_entity can cause serious issues. Instead, set " \ "the individual fields of legal_entity like " \ "`account.legal_entity.first_name = 'Blah'`" end |
#persons(params = {}, opts = {}) ⇒ Object
63 64 65 66 |
# File 'lib/stripe/resources/account.rb', line 63 def persons(params = {}, opts = {}) resp, opts = execute_resource_request(:get, resource_url + "/persons", params, opts) Util.convert_to_stripe_object(resp.data, opts) end |
#reject(params = {}, opts = {}) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/stripe/resources/account.rb', line 23 def reject(params = {}, opts = {}) request_stripe_object( method: :post, path: resource_url + "/reject", params: params, opts: opts ) end |
#resource_url ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/stripe/resources/account.rb', line 39 def resource_url if self["id"] super else "/v1/account" end end |
#serialize_params(options = {}) ⇒ Object
Somewhat unfortunately, we attempt to do a special encoding trick when serializing ‘additional_owners` under an account: when updating a value, we actually send the update parameters up as an integer-indexed hash rather than an array. So instead of this:
field[]=item1&field[]=item2&field[]=item3
We send this:
field[0]=item1&field[1]=item2&field[2]=item3
There are two major problems with this technique:
* Entities are addressed by array index, which is not stable and can
easily result in unexpected results between two different requests.
* A replacement of the array's contents is ambiguous with setting a
subset of the array. Because of this, the only way to shorten an
array is to unset it completely by making sure it goes into the
server as an empty string, then setting its contents again.
We’re trying to get this overturned on the server side, but for now, patch in a special allowance.
95 96 97 |
# File 'lib/stripe/resources/account.rb', line 95 def serialize_params( = {}) serialize_params_account(self, super, ) end |
#serialize_params_account(_obj, update_hash, options = {}) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/stripe/resources/account.rb', line 99 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 if (individual = @values[:individual]) if individual.is_a?(Person) && !update_hash.key?(:individual) update_hash[:individual] = individual.serialize_params() end end update_hash end |