Sha256: 7ac695c02e24ec1a7ce4a74355f8164bf729fea8940cf7b9d8adba5ccb7c3f41
Contents?: true
Size: 1.17 KB
Versions: 27
Compression:
Stored size: 1.17 KB
Contents
require "cobrato/resources/hooks" module Cobrato module Resources class RemittanceCnab < Base crud :show, :list, :destroy def create(params) deprecate(params, %w[charge_ids charge_config_ids]) http.post(resource_base_path, { body: params }) do |response| respond_with_collection(response) end end def file(id) http.get("#{resource_base_path}/#{id}/file") do |response| respond_with_openstruct(response) end end def charges(id) puts "Warning: The 'charges' endpoint is deprecated. Use 'items' endpoint instead." http.get("#{resource_base_path}/#{id}/charges") do |response| respond_with_collection(response, 'Charge') end end def items(id) http.get("#{resource_base_path}/#{id}/items") do |response| hash = parsed_body(response) collection_name = hash.keys.first class_name = collection_name.gsub(/(.)(.*)s/) { "#{$1.upcase}#{$2}" } naked_klass = entity_klass(class_name) hash[collection_name].map { |item| naked_klass.new(item) } end end end end end
Version data entries
27 entries across 27 versions & 1 rubygems