Sha256: fd6fa9ceb0dc5ef2467fe8e45a63709f4c02afda69086529bf4f301b460ba0b7
Contents?: true
Size: 1.59 KB
Versions: 4
Compression:
Stored size: 1.59 KB
Contents
# # Charge feature # class Spike::Charge def initialize(client) @client = client end def create(params, products) require 'json' res = @client.post(request_path: '/charges', request_params: params.merge(products: JSON.generate(products))) Spike::Charge::Response.new(res) end def retrieve(charge_id) res = @client.get(request_path: "/charges/#{charge_id}") Response.new(res) end def list(params = {}) res = @client.get(request_path: '/charges', request_params: params) Spike::Charge::List.new(res) end # # List object # class List < Spike::Object def object @attributes['object'] end def url @attributes['url'] end def has_more? @attributes['has_more'] end def data @attributes['data'].collect { |d| Spike::Charge::Response.new(d) } end end # # Charge object # class Response def initialize(hash) @attributes = Hash[hash.map { |k, v| [k.to_s, v] }] end def id @attributes['id'] end def object @attributes['object'] end def created_at Time.at(@attributes['created']) end def live_mode? @attributes['livemode'] end def paid? @attributes['paid'] end def captured? @attributes['captured'] end def amount @attributes['amount'].to_f end def currency @attributes['currency'] end def refunded? @attributes['refunded'] end def amount_refunded @attributes['amount_refunded'] end def refunds @attributes['refunds'] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
spike-ruby-0.1.3 | lib/spike/charge.rb |
spike-ruby-0.1.2 | lib/spike/charge.rb |
spike-ruby-0.1.1 | lib/spike/charge.rb |
spike-ruby-0.1.0 | lib/spike/charge.rb |