Sha256: 4d3e0e459977d193914891e50501284ccfbe3dc6f24a4868ea53fd3601846beb
Contents?: true
Size: 1.26 KB
Versions: 3
Compression:
Stored size: 1.26 KB
Contents
class Sendle::Api::Resource include Sendle::Api::Actions::Base def url raise "An API Resource must implement the url method." end def self.url self.new.url end def include_credentials? true end #Index action hook methods def validate_index_request!(params) end def process_index_response(response) return_json(response) end #Create action hook methods def validate_create_request!(params) end def process_create_response(response) return_json(response) end #Show action hook methods def process_show_response(response) return_json(response) end #Destroy action hook methods def process_destroy_response(response) return_json(response) end def method_missing(m, *args, &blk) if Sendle::Api::Utils.respond_to?(m) Sendle::Api::Utils.send(m, *args) else super(m, *args, blk) end end protected def return_json(response) Sendle::Api::Responses::Json.new(response) end def validate_presence_of!(required_params, hash) symbolize_strings(required_params).each do |required_param| if (!hash.key?(required_param) || nullish?(hash[required_param])) raise Sendle::Api::Errors::MissingParams.new(required_params) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sendle-api-0.0.13 | lib/sendle/api/resource.rb |
sendle-api-0.0.12 | lib/sendle/api/resource.rb |
sendle-api-0.0.11 | lib/sendle/api/resource.rb |