Class: Stripe::Account
Constant Summary
collapse
- OBJECT_NAME =
"account".freeze
- ARGUMENT_NOT_PROVIDED =
Object.new
Instance Attribute Summary
Attributes inherited from APIResource
#save_with_parent
Class Method Summary
collapse
Instance Method Summary
collapse
create
list
nested_resource_class_methods
included, #save
#delete, included
Methods inherited from APIResource
class_name, custom_method, #refresh, resource_url, save_nested_resource
included
#==, #[], #[]=, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, #refresh_from, serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Stripe::StripeObject
Class Method Details
.protected_fields ⇒ Object
118
119
120
|
# File 'lib/stripe/resources/account.rb', line 118
def self.protected_fields
[:legal_entity]
end
|
.retrieve(id = ARGUMENT_NOT_PROVIDED, opts = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/stripe/resources/account.rb', line 47
def self.retrieve(id = ARGUMENT_NOT_PROVIDED, opts = {})
id = if id.equal?(ARGUMENT_NOT_PROVIDED)
nil
else
Util.check_string_argument!(id)
end
if opts == {} && id.is_a?(String) && id.start_with?("sk_")
opts = id
id = nil
end
super(id, opts)
end
|
Instance Method Details
#deauthorize(client_id = nil, opts = {}) ⇒ Object
133
134
135
136
137
138
139
|
# File 'lib/stripe/resources/account.rb', line 133
def deauthorize(client_id = nil, opts = {})
params = {
client_id: client_id,
stripe_user_id: id,
}
OAuth.deauthorize(params, opts)
end
|
#legal_entity ⇒ Object
122
123
124
|
# File 'lib/stripe/resources/account.rb', line 122
def legal_entity
self["legal_entity"]
end
|
#legal_entity=(_legal_entity) ⇒ Object
126
127
128
129
130
131
|
# File 'lib/stripe/resources/account.rb', line 126
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
66
67
68
69
|
# File 'lib/stripe/resources/account.rb', line 66
def persons(params = {}, opts = {})
resp, opts = request(:get, resource_url + "/persons", params, opts)
Util.convert_to_stripe_object(resp.data, opts)
end
|
#reject(params = {}, opts = {}) ⇒ Object
22
23
24
25
|
# File 'lib/stripe/resources/account.rb', line 22
def reject(params = {}, opts = {})
resp, opts = request(:post, resource_url + "/reject", params, opts)
initialize_from(resp.data, opts)
end
|
#resource_url ⇒ Object
38
39
40
41
42
43
44
|
# File 'lib/stripe/resources/account.rb', line 38
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.
98
99
100
|
# File 'lib/stripe/resources/account.rb', line 98
def serialize_params(options = {})
serialize_params_account(self, super, options)
end
|
#serialize_params_account(_obj, update_hash, options = {}) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/stripe/resources/account.rb', line 102
def serialize_params_account(_obj, update_hash, options = {})
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(options)
end
end
update_hash
end
|