Skip to content
Browse files

0.1.3 changed some method calls

  • Loading branch information...
1 parent f849462 commit 2c87ad8eaf3c67cced5d76ffd7bc2abe26648eef @jeanmartin jeanmartin committed May 22, 2012
View
2 Gemfile.lock
@@ -46,7 +46,7 @@ GEM
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
- micropayment (0.1.1)
+ micropayment (0.1.3)
addressable
yajl-ruby
mime-types (1.18)
View
2 VERSION
@@ -1 +1 @@
-0.1.1
+0.1.3
View
32 lib/micropayment-rails/classes/customer.rb
@@ -21,6 +21,28 @@ def bank_account
end
+
+
+ def update!(params={})
+ params.symbolized_keys!
+ bank_account_params = params.delete(:bank_account)
+ address_params = params.delete(:address)
+ update_params = {}.tap do |hsh|
+ hsh[:customerId] = id
+ hsh[:freeParams] = params
+ end
+ result = Micropayment::Debit.customerSet( update_params )
+ if result["error"] == "0"
+ self.bank_account = bank_account_params if bank_account_params
+ self.customer.address = address_params if address_params
+ self
+ else
+ raise "Customer#update! - #{result["error"]}: #{result["errorMessage"]}"
+ end
+ end
+
+
+
def self.find(customerId)
result = Micropayment::Debit.customerGet( :customerId => customerId )
@@ -47,14 +69,20 @@ def self.create!(params={})
customer.address = address_params if address_params
customer
else
- raise "#{result["error"]}: #{result["errorMessage"]}"
+ raise "Customer#create! - #{result["error"]}: #{result["errorMessage"]}"
end
end
def self.find_or_create_by_id(id, params={})
params.symbolized_keys!
obj = (find(id) rescue nil)
- obj ? obj : create( params.merge(:customerId => id) )
+ obj ? obj : create!( params.merge(:customerId => id) )
+ end
+
+ def self.find_create_or_update_by_id(id, params={})
+ params.symbolized_keys!
+ obj = (find(id) rescue nil)
+ obj ? obj.update!(params) : create!( params.merge(:customerId => id) )
end
def self.session_list
View
2 lib/micropayment-rails/classes/session.rb
@@ -7,7 +7,7 @@ class Session < Micropayment::Base
CREATE_METHOD = :sessionCreate
- def create!(project, customer, params={})
+ def self.create!(project, customer, params={})
params.symbolize_keys!
params.merge!( :customerId => customer.id, :project => project )
result = Micropayment::Debit.sessionCreate( params )
View
4 micropayment-rails.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = "micropayment-rails"
- s.version = "0.1.1"
+ s.version = "0.1.3"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jan Schwenzien"]
- s.date = "2012-05-20"
+ s.date = "2012-05-22"
s.description = "Use the micropayment API in your Rails project."
s.email = "jan@general-scripting.com"
s.extra_rdoc_files = [

0 comments on commit 2c87ad8

Please sign in to comment.
Something went wrong with that request. Please try again.