Sha256: f199f5a364825b4fd4dcde640e3deb2e195bd32419633246eac54f776a5ab674

Contents?: true

Size: 848 Bytes

Versions: 4

Compression:

Stored size: 848 Bytes

Contents

module Cobrato
  module Resources
    class Charge < Base

      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|
          OpenStruct.new(MultiJson.load(response.body))
        end
      end

      notify :receive, :undo_receive

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cobrato-client-0.2.5 lib/cobrato/resources/charge.rb
cobrato-client-0.2.4 lib/cobrato/resources/charge.rb
cobrato-client-0.2.3 lib/cobrato/resources/charge.rb
cobrato-client-0.2.3.pre lib/cobrato/resources/charge.rb