Sha256: 6dc03ed3d0aeb404ac9bfdc03628ef7453a074f19a1c22d0b4bd10e6418e01e5
Contents?: true
Size: 915 Bytes
Versions: 3
Compression:
Stored size: 915 Bytes
Contents
module Conekta class APIResource < ConektaObject 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 "/#{CGI.escape(class_name.downcase)}s" end def url unless id = self['id'] raise ParameterValidationError.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 = Conekta.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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
conekta-0.3.3 | lib/conekta/api_resource.rb |
conekta-0.3.1 | lib/conekta/api_resource.rb |
conekta-0.3.0 | lib/conekta/api_resource.rb |