Class: Payjp::APIResource
Direct Known Subclasses
Account, Balance, Card, Charge, Customer, Event, Plan, Statement, Subscription, Tenant, Term, ThreeDSecureRequest, Token, Transfer
Class Method Summary
collapse
Instance Method Summary
collapse
included
Methods inherited from PayjpObject
#[], #[]=, #_dump, _load, #as_json, construct_from, #each, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #serialize_nested_object, serialize_params, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Payjp::PayjpObject
Class Method Details
.class_name ⇒ Object
5
6
7
|
# File 'lib/payjp/api_resource.rb', line 5
def self.class_name
name.split('::')[-1]
end
|
.retrieve(id, opts = {}) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/payjp/api_resource.rb', line 28
def self.retrieve(id, opts = {})
opts = Util.normalize_opts(opts)
instance = new(id, opts)
instance.refresh
instance
end
|
.url ⇒ Object
9
10
11
12
13
14
|
# File 'lib/payjp/api_resource.rb', line 9
def self.url
if self == APIResource
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)')
end
"/v1/#{CGI.escape(class_name.downcase)}s"
end
|
Instance Method Details
#refresh ⇒ Object
23
24
25
26
|
# File 'lib/payjp/api_resource.rb', line 23
def refresh
response, opts = request(:get, url, @retrieve_params)
refresh_from(response, opts)
end
|
#url ⇒ Object
16
17
18
19
20
21
|
# File 'lib/payjp/api_resource.rb', line 16
def url
unless id = self['id']
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
end
"#{self.class.url}/#{CGI.escape(id)}"
end
|