Sha256: 00362dc0f9d0f83c322c6780e6b4c580de5da9b1d7cfda2adda0c16daf3d089b

Contents?: true

Size: 1.12 KB

Versions: 9

Compression:

Stored size: 1.12 KB

Contents

module Cobrato
  module Resources
    class Charge < Base
      crud :all

      def receive(id, params)
        http.post("#{resource_base_path}/#{id}/receive", { body: params }) do |response|
          respond_with_entity(response)
        end
      end

      def undo_receive(id)
        http.post("#{resource_base_path}/#{id}/undo_receive") do |response|
          respond_with_entity(response)
        end
      end

      def deliver_billet(id, emails=nil)
        body = {to: emails}
        http.post("#{resource_base_path}/#{id}/deliver_billet", { body: body }) do |response|
          response.code == 200
        end
      end

      def billet(id)
        http.get("#{resource_base_path}/#{id}/billet") do |response|
          respond_with_openstruct response
        end
      end

      def cancel(id)
        http.post("#{resource_base_path}/#{id}/cancel") do |response|
          response.code == 204
        end
      end

      def retry(id)
        http.put("#{resource_base_path}/#{id}/retry") do |response|
          response.code == 204
        end
      end

      notify :receive, :undo_receive, :cancel
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
cobrato-client-0.9.1 lib/cobrato/resources/charge.rb
cobrato-client-0.9.0 lib/cobrato/resources/charge.rb
cobrato-client-0.8.0 lib/cobrato/resources/charge.rb
cobrato-client-0.7.0 lib/cobrato/resources/charge.rb
cobrato-client-0.6.0 lib/cobrato/resources/charge.rb
cobrato-client-0.5.0 lib/cobrato/resources/charge.rb
cobrato-client-0.4.2 lib/cobrato/resources/charge.rb
cobrato-client-0.4.1 lib/cobrato/resources/charge.rb
cobrato-client-0.4.0 lib/cobrato/resources/charge.rb