Sha256: a9a6d7871dc9444c7f14d5ffb035f0baf4541d6e5ec562c4b71807af145dff54
Contents?: true
Size: 910 Bytes
Versions: 1
Compression:
Stored size: 910 Bytes
Contents
module Paysio class APIResource < PaysioObject def self.class_name self.name.split('::')[-1] end 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 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 def refresh response, api_key = Paysio.request(:get, url, @api_key, @retrieve_options) refresh_from(response, api_key) self end def self.retrieve(id, api_key=nil) instance = self.new(id, api_key) instance.refresh instance end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paysio-1.0.0 | lib/paysio/api_resource.rb |