bravo 0.1.1 → 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.
@@ -0,0 +1,3 @@
1
+ *Bravo 0.2.0 (March 04, 2011)*
2
+
3
+ * Bill#response returns a complete hash from WSFE response [leanucci]
data/Rakefile CHANGED
@@ -13,7 +13,7 @@ require 'jeweler'
13
13
  Jeweler::Tasks.new do |gem|
14
14
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
15
  gem.name = "bravo"
16
- gem.homepage = "http://github.com/leanucci/bravo"
16
+ gem.homepage = "http://github.com/Vurbia/Bravo"
17
17
  gem.license = "MIT"
18
18
  gem.summary = "Adaptador AFIP wsfe."
19
19
  gem.description = "Adaptador para el Web Service de Facturacion Electronica de AFIP"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bravo}
8
- s.version = "0.1.1"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leandro Marcucci"]
12
- s.date = %q{2011-03-02}
12
+ s.date = %q{2011-03-04}
13
13
  s.description = %q{Adaptador para el Web Service de Facturacion Electronica de AFIP}
14
14
  s.email = %q{leanucci@vurbia.com}
15
15
  s.extra_rdoc_files = [
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
+ "CHANGELOG",
21
22
  "Gemfile",
22
23
  "Gemfile.lock",
23
24
  "LICENSE.txt",
@@ -32,6 +33,7 @@ Gem::Specification.new do |s|
32
33
  "lib/bravo/bill.rb",
33
34
  "lib/bravo/constants.rb",
34
35
  "lib/bravo/core_ext/float.rb",
36
+ "lib/bravo/core_ext/hash.rb",
35
37
  "lib/bravo/version.rb",
36
38
  "spec/bravo/auth_data_spec.rb",
37
39
  "spec/bravo/authorizer_spec.rb",
@@ -39,7 +41,7 @@ Gem::Specification.new do |s|
39
41
  "spec/spec_helper.rb",
40
42
  "wsaa-client.sh"
41
43
  ]
42
- s.homepage = %q{http://github.com/leanucci/bravo}
44
+ s.homepage = %q{http://github.com/Vurbia/Bravo}
43
45
  s.licenses = ["MIT"]
44
46
  s.require_paths = ["lib"]
45
47
  s.rubygems_version = %q{1.6.0}
@@ -3,6 +3,7 @@ require "bravo/version"
3
3
  require "bravo/constants"
4
4
  require "savon"
5
5
  require "bravo/core_ext/float"
6
+ require "bravo/core_ext/hash"
6
7
  module Bravo
7
8
 
8
9
  class NullOrInvalidAttribute < StandardError; end
@@ -46,9 +46,7 @@ module Bravo
46
46
  soap.body = body
47
47
  end
48
48
 
49
- response = response.to_hash
50
-
51
- setup_response(response)
49
+ setup_response(response.to_hash)
52
50
  self.authorized?
53
51
  end
54
52
 
@@ -112,11 +110,23 @@ module Bravo
112
110
  end
113
111
 
114
112
  def setup_response(response)
115
- detail_response = response[:fecae_solicitar_response][:fecae_solicitar_result][:fe_det_resp][:fecae_det_response]
116
- header_response = response[:fecae_solicitar_response][:fecae_solicitar_result][:fe_cab_resp]
113
+ header_response = response[:fecae_solicitar_response][:fecae_solicitar_result][:fe_cab_resp].symbolize_keys
114
+ detail_response = response[:fecae_solicitar_response][:fecae_solicitar_result][:fe_det_resp][:fecae_det_response].symbolize_keys
115
+
116
+ iva = self.body["FeCAEReq"]["FeDetReq"]["FECAEDetRequest"]["Iva"]["AlicIva"].underscore_keys!
117
+
118
+ detail_response.merge!(iva.symbolize_keys!)
119
+
120
+ response_hash = {:header_result => header_response.delete(:resultado),
121
+ :detail_result => detail_response.delete(:resultado),
122
+ :cae_due_date => detail_response.delete(:cae_fch_vto),
123
+ :authorized_on => header_response.delete(:fch_proceso),
124
+ :iva_id => detail_response.delete(:id),
125
+ :iva_importe => detail_response.delete(:importe)
126
+ }.merge!(header_response).merge!(detail_response)
117
127
 
118
- response_struct = Struct.new("Response", :header_result, :detail_result, :cae, :cae_due_date, :authorized_on)
119
- self.response = response_struct.new(header_response[:resultado], detail_response[:resultado], detail_response[:cae], detail_response[:cae_fch_vto], header_response[:fch_proceso])
128
+ keys, values = response_hash.to_a.transpose
129
+ self.response = Struct.new("Response", *keys).new(*values)
120
130
  end
121
131
  end
122
132
  end
@@ -0,0 +1,23 @@
1
+ class Hash
2
+ def symbolize_keys!
3
+ keys.each do |key|
4
+ self[(key.to_sym rescue key) || key] = delete(key)
5
+ end
6
+ self
7
+ end
8
+
9
+ def symbolize_keys
10
+ dup.symbolize_keys!
11
+ end
12
+
13
+ def underscore_keys!
14
+ keys.each do |key|
15
+ self[(key.downcase rescue key) || key] = delete(key)
16
+ end
17
+ self
18
+ end
19
+
20
+ def underscore_keys
21
+ dup.underscore_keys!
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module Bravo
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -96,7 +96,15 @@ describe "Bill" do
96
96
  @bill.authorize.should == true
97
97
 
98
98
  @bill.authorized?.should == true
99
- @bill.response.cae.length.should == 14
99
+
100
+ response = @bill.response
101
+
102
+ response.cae.length.should == 14
103
+
104
+ pp response
105
+
106
+ response.length.should == 19
107
+
100
108
  end
101
109
  end
102
110
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bravo
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 1
10
- version: 0.1.1
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Leandro Marcucci
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-02 00:00:00 -03:00
18
+ date: 2011-03-04 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -153,6 +153,7 @@ extra_rdoc_files:
153
153
  - README.textile
154
154
  files:
155
155
  - .document
156
+ - CHANGELOG
156
157
  - Gemfile
157
158
  - Gemfile.lock
158
159
  - LICENSE.txt
@@ -167,6 +168,7 @@ files:
167
168
  - lib/bravo/bill.rb
168
169
  - lib/bravo/constants.rb
169
170
  - lib/bravo/core_ext/float.rb
171
+ - lib/bravo/core_ext/hash.rb
170
172
  - lib/bravo/version.rb
171
173
  - spec/bravo/auth_data_spec.rb
172
174
  - spec/bravo/authorizer_spec.rb
@@ -174,7 +176,7 @@ files:
174
176
  - spec/spec_helper.rb
175
177
  - wsaa-client.sh
176
178
  has_rdoc: true
177
- homepage: http://github.com/leanucci/bravo
179
+ homepage: http://github.com/Vurbia/Bravo
178
180
  licenses:
179
181
  - MIT
180
182
  post_install_message: