caren-api 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.8
1
+ 0.5.9
data/caren-api.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "caren-api"
8
- s.version = "0.5.8"
8
+ s.version = "0.5.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andre Foeken"]
@@ -54,10 +54,23 @@ class Caren::Store::Invoice < Caren::Base
54
54
  session.delete self.class.resource_url(self.id)
55
55
  end
56
56
 
57
+ def mark_as_paid method, description, session
58
+ self.class.from_xml session.post(self.class.mark_as_paid_url(self.id), self.class.mark_as_paid_xml(method,description))
59
+ end
60
+
61
+ def mark_as_revoked session
62
+ self.class.from_xml session.post(self.class.mark_as_revoked_url(self.id), nil)
63
+ end
64
+
57
65
  def email session
58
66
  self.class.from_xml session.post(self.class.email_url(self.id), self.to_xml)
59
67
  end
60
68
 
69
+ def self.mark_as_paid_xml method=nil, description=nil
70
+ body = { :payment_method_description => description, :payment_method => method }
71
+ return body.to_xml( :root => (self.node_root || self.class.node_root) )
72
+ end
73
+
61
74
  def as_xml
62
75
  # make sure we have the correct address nodes here
63
76
  billing_address.purpose = 'billing' if billing_address
@@ -81,7 +94,7 @@ class Caren::Store::Invoice < Caren::Base
81
94
  :paid_at => self.paid_at
82
95
  }
83
96
  end
84
-
97
+
85
98
  def self.init_dependent_objects invoice
86
99
 
87
100
  if invoice.shipping_address.is_a?(Hash)
@@ -112,6 +125,14 @@ class Caren::Store::Invoice < Caren::Base
112
125
  def self.filter_url filter
113
126
  "#{self.resource_url}?filter=#{filter}"
114
127
  end
128
+
129
+ def self.mark_as_revoked_url id
130
+ "#{self.resource_url(id)}/mark_as_revoked"
131
+ end
132
+
133
+ def self.mark_as_paid_url id
134
+ "#{self.resource_url(id)}/mark_as_paid"
135
+ end
115
136
 
116
137
  def self.email_url id
117
138
  "#{self.resource_url(id)}/email"
@@ -29,6 +29,12 @@ describe "Store::Invoice", "converting to xml" do
29
29
 
30
30
  new_object.attributes.should == @invoice_a.attributes
31
31
  end
32
+
33
+ it "should generate correct mark as paid xml" do
34
+ hash = Hash.from_xml( Caren::Store::Invoice.mark_as_paid_xml("cash","test") )
35
+ hash["invoice"]["payment_method"].should == "cash"
36
+ hash["invoice"]["payment_method_description"].should == "test"
37
+ end
32
38
 
33
39
  end
34
40
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caren-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 5
9
- - 8
10
- version: 0.5.8
9
+ - 9
10
+ version: 0.5.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andre Foeken