dineromail 0.1.4 → 0.2.0
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/lib/dineromail/notification.rb +18 -8
- data/lib/dineromail/operation.rb +11 -1
- data/lib/dineromail/status_report.rb +0 -2
- data/lib/dineromail/version.rb +1 -1
- data/spec/dineromail/notification_spec.rb +6 -0
- data/spec/dineromail/status_report_spec.rb +7 -0
- data/spec/fixtures/notification_alphanumeric_id.xml +10 -0
- data/spec/fixtures/status_report.xml +1 -1
- data/spec/fixtures/status_report_alphanumeric_id.xml +40 -0
- metadata +72 -109
@@ -2,15 +2,15 @@ require 'happymapper'
|
|
2
2
|
module Dineromail
|
3
3
|
class Notification
|
4
4
|
include HappyMapper
|
5
|
-
|
5
|
+
|
6
6
|
tag 'operacion'
|
7
|
-
element :transaction_id,
|
7
|
+
element :transaction_id, String, :tag => 'id'
|
8
8
|
element :type, String, :tag => 'tipo'
|
9
|
-
|
9
|
+
|
10
10
|
def initialize(options = {})
|
11
11
|
@options = options.symbolize_keys
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def status_report
|
15
15
|
unless @status_report
|
16
16
|
@status_report = StatusReport.get_report_for(transaction_id,@options)
|
@@ -18,21 +18,31 @@ module Dineromail
|
|
18
18
|
@status_report
|
19
19
|
end
|
20
20
|
|
21
|
+
def transaction_id
|
22
|
+
#If the transaction_id being used is the string representation
|
23
|
+
#of an integer return an integer for backward compatibility
|
24
|
+
if @transaction_id =~ /\A\d+\Z/
|
25
|
+
@transaction_id.to_i
|
26
|
+
else
|
27
|
+
@transaction_id
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
21
31
|
def valid_report?
|
22
32
|
status_report.valid_report?
|
23
33
|
end
|
24
|
-
|
34
|
+
|
25
35
|
def method_missing(symbol, *args)
|
26
36
|
unless status_report.operations.empty?
|
27
37
|
status_report.operations.first.send(symbol, *args)
|
28
38
|
end
|
29
39
|
end
|
30
|
-
|
40
|
+
|
31
41
|
def self.parse(xml)
|
32
42
|
#Convert tags to lowercase
|
33
43
|
xml = xml.gsub(/<(.*?)[> ]/){|tag| tag.downcase}
|
34
44
|
super(xml)
|
35
45
|
end
|
36
|
-
|
46
|
+
|
37
47
|
end
|
38
|
-
end
|
48
|
+
end
|
data/lib/dineromail/operation.rb
CHANGED
@@ -4,7 +4,7 @@ module Dineromail
|
|
4
4
|
include HappyMapper
|
5
5
|
|
6
6
|
tag 'operacion'
|
7
|
-
element :transaction_id,
|
7
|
+
element :transaction_id, String, :tag => 'id'
|
8
8
|
element :date, DateTime, :tag => 'fecha'
|
9
9
|
element :status, Integer, :tag => 'estado'
|
10
10
|
element :amount, Float, :tag => 'monto'
|
@@ -30,5 +30,15 @@ module Dineromail
|
|
30
30
|
status == CANCELLED_STATUS
|
31
31
|
end
|
32
32
|
|
33
|
+
def transaction_id
|
34
|
+
#If the transaction_id being used is the string representation
|
35
|
+
#of an integer return an integer for backward compatibility
|
36
|
+
if @transaction_id =~ /\A\d+\Z/
|
37
|
+
@transaction_id.to_i
|
38
|
+
else
|
39
|
+
@transaction_id
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
33
43
|
end
|
34
44
|
end
|
data/lib/dineromail/version.rb
CHANGED
@@ -9,6 +9,12 @@ describe Dineromail::Notification do
|
|
9
9
|
notifications.last.transaction_id.should == 5547
|
10
10
|
end
|
11
11
|
|
12
|
+
it 'should allow alphanumeric transaction ids' do
|
13
|
+
notification_xml = File.read( 'spec/fixtures/notification_alphanumeric_id.xml')
|
14
|
+
notifications = Dineromail::Notification.parse(notification_xml)
|
15
|
+
notifications.first.transaction_id.should == 'ABC123'
|
16
|
+
end
|
17
|
+
|
12
18
|
it 'should get automaticaly the status data associated with the notification' do
|
13
19
|
HTTParty.stub!(:get).and_return {
|
14
20
|
stub :body => File.read( 'spec/fixtures/status_report.xml')
|
@@ -36,6 +36,13 @@ describe Dineromail::StatusReport do
|
|
36
36
|
item.unit_price.should == 6.9
|
37
37
|
end
|
38
38
|
|
39
|
+
it 'should allow alphanumeric transaction ids' do
|
40
|
+
xml = File.read( 'spec/fixtures/status_report_alphanumeric_id.xml')
|
41
|
+
status_report = Dineromail::StatusReport.parse(xml)
|
42
|
+
operation = status_report.operations.first
|
43
|
+
operation.transaction_id.should == 'ABC123'
|
44
|
+
end
|
45
|
+
|
39
46
|
it 'should use the configuration to get the parameters for the request if no options are given' do
|
40
47
|
transaction_id = 42
|
41
48
|
Dineromail.configure do |c|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<REPORTE>
|
3
|
+
<ESTADOREPORTE>1</ESTADOREPORTE>
|
4
|
+
<DETALLE>
|
5
|
+
<OPERACIONES>
|
6
|
+
<OPERACION>
|
7
|
+
<ID>ABC123</ID>
|
8
|
+
<FECHA>28/01/2011 12:02:01 PM</FECHA>
|
9
|
+
<ESTADO>1</ESTADO>
|
10
|
+
<NUMTRANSACCION>67777</NUMTRANSACCION>
|
11
|
+
<COMPRADOR>
|
12
|
+
<EMAIL>comprador@email.com</EMAIL>
|
13
|
+
<DIRECCION>San Martin 10</DIRECCION>
|
14
|
+
<COMENTARIO>comentario</COMENTARIO>
|
15
|
+
<NOMBRE>Juan</NOMBRE>
|
16
|
+
<TELEFONO>4444444</TELEFONO>
|
17
|
+
<TIPODOC>DNI</TIPODOC>
|
18
|
+
<NUMERODOC>222222222</NUMERODOC>
|
19
|
+
</COMPRADOR>
|
20
|
+
<MONTO>60.2</MONTO>
|
21
|
+
<MONTONETO>50.3</MONTONETO>
|
22
|
+
<METODOPAGO>TARJETA DE CREDITO</METODOPAGO>
|
23
|
+
<MEDIOPAGO>VISA</MEDIOPAGO>
|
24
|
+
<CUOTAS>1</CUOTAS>
|
25
|
+
<ITEMS>
|
26
|
+
<ITEM>
|
27
|
+
<DESCRIPCION>Libro</DESCRIPCION>
|
28
|
+
<MONEDA>1</MONEDA>
|
29
|
+
<PRECIOUNITARIO>6.90</PRECIOUNITARIO>
|
30
|
+
<CANTIDAD>2</CANTIDAD>
|
31
|
+
</ITEM>
|
32
|
+
</ITEMS>
|
33
|
+
<VENDEDOR>
|
34
|
+
<TIPODOC></TIPODOC>
|
35
|
+
<NUMERODOC></NUMERODOC>
|
36
|
+
</VENDEDOR>
|
37
|
+
</OPERACION>
|
38
|
+
</OPERACIONES>
|
39
|
+
</DETALLE>
|
40
|
+
</REPORTE>
|
metadata
CHANGED
@@ -1,122 +1,93 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: dineromail
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 4
|
10
|
-
version: 0.1.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Nicolas Mosconi
|
14
9
|
- Shadi Calcagni
|
15
10
|
- Juan Pablo Gutierrez
|
16
11
|
autorequire:
|
17
12
|
bindir: bin
|
18
13
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dependencies:
|
23
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
24
17
|
name: happymapper
|
25
|
-
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &82024490 !ruby/object:Gem::Requirement
|
27
19
|
none: false
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
|
32
|
-
segments:
|
33
|
-
- 0
|
34
|
-
version: "0"
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
35
24
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: httparty
|
39
25
|
prerelease: false
|
40
|
-
|
26
|
+
version_requirements: *82024490
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: httparty
|
29
|
+
requirement: &82111890 !ruby/object:Gem::Requirement
|
41
30
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 0
|
48
|
-
version: "0"
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
49
35
|
type: :runtime
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: rails
|
53
36
|
prerelease: false
|
54
|
-
|
37
|
+
version_requirements: *82111890
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: rails
|
40
|
+
requirement: &82111490 !ruby/object:Gem::Requirement
|
55
41
|
none: false
|
56
|
-
requirements:
|
42
|
+
requirements:
|
57
43
|
- - ~>
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 3
|
62
|
-
- 0
|
63
|
-
version: "3.0"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
64
46
|
type: :runtime
|
65
|
-
version_requirements: *id003
|
66
|
-
- !ruby/object:Gem::Dependency
|
67
|
-
name: bundler
|
68
47
|
prerelease: false
|
69
|
-
|
48
|
+
version_requirements: *82111490
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: bundler
|
51
|
+
requirement: &82111210 !ruby/object:Gem::Requirement
|
70
52
|
none: false
|
71
|
-
requirements:
|
72
|
-
- -
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
|
75
|
-
segments:
|
76
|
-
- 0
|
77
|
-
version: "0"
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
78
57
|
type: :development
|
79
|
-
version_requirements: *id004
|
80
|
-
- !ruby/object:Gem::Dependency
|
81
|
-
name: rspec-rails
|
82
58
|
prerelease: false
|
83
|
-
|
59
|
+
version_requirements: *82111210
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: rspec-rails
|
62
|
+
requirement: &82110980 !ruby/object:Gem::Requirement
|
84
63
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
segments:
|
90
|
-
- 0
|
91
|
-
version: "0"
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
92
68
|
type: :development
|
93
|
-
version_requirements: *id005
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rspec2-rails-views-matchers
|
96
69
|
prerelease: false
|
97
|
-
|
70
|
+
version_requirements: *82110980
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: rspec2-rails-views-matchers
|
73
|
+
requirement: &82110760 !ruby/object:Gem::Requirement
|
98
74
|
none: false
|
99
|
-
requirements:
|
100
|
-
- -
|
101
|
-
- !ruby/object:Gem::Version
|
102
|
-
|
103
|
-
segments:
|
104
|
-
- 0
|
105
|
-
version: "0"
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
106
79
|
type: :development
|
107
|
-
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: *82110760
|
108
82
|
description: Integration with dineromail plataform for rails projects
|
109
|
-
email:
|
83
|
+
email:
|
110
84
|
- nicolas@soluciones-simplex.com.ar
|
111
85
|
- shadi@soluciones-simplex.com.ar
|
112
86
|
- juanpablo@soluciones-simplex.com.ar
|
113
87
|
executables: []
|
114
|
-
|
115
88
|
extensions: []
|
116
|
-
|
117
89
|
extra_rdoc_files: []
|
118
|
-
|
119
|
-
files:
|
90
|
+
files:
|
120
91
|
- .gitignore
|
121
92
|
- Gemfile
|
122
93
|
- LICENSE
|
@@ -135,42 +106,34 @@ files:
|
|
135
106
|
- spec/dineromail/notification_spec.rb
|
136
107
|
- spec/dineromail/status_report_spec.rb
|
137
108
|
- spec/fixtures/notification.xml
|
109
|
+
- spec/fixtures/notification_alphanumeric_id.xml
|
138
110
|
- spec/fixtures/status_report.xml
|
111
|
+
- spec/fixtures/status_report_alphanumeric_id.xml
|
139
112
|
- spec/helpers/dineromail_helper_spec.rb
|
140
113
|
- spec/spec_helper.rb
|
141
|
-
|
142
|
-
homepage: ""
|
114
|
+
homepage: ''
|
143
115
|
licenses: []
|
144
|
-
|
145
116
|
post_install_message:
|
146
117
|
rdoc_options: []
|
147
|
-
|
148
|
-
require_paths:
|
118
|
+
require_paths:
|
149
119
|
- lib
|
150
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
121
|
none: false
|
152
|
-
requirements:
|
153
|
-
- -
|
154
|
-
- !ruby/object:Gem::Version
|
155
|
-
|
156
|
-
|
157
|
-
- 0
|
158
|
-
version: "0"
|
159
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
127
|
none: false
|
161
|
-
requirements:
|
162
|
-
- -
|
163
|
-
- !ruby/object:Gem::Version
|
164
|
-
|
165
|
-
segments:
|
166
|
-
- 0
|
167
|
-
version: "0"
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
168
132
|
requirements: []
|
169
|
-
|
170
133
|
rubyforge_project:
|
171
|
-
rubygems_version: 1.
|
134
|
+
rubygems_version: 1.8.11
|
172
135
|
signing_key:
|
173
136
|
specification_version: 3
|
174
137
|
summary: Dineromail library for Rails
|
175
138
|
test_files: []
|
176
|
-
|
139
|
+
has_rdoc:
|