snoopy_afip 2.1.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/snoopy_afip.rb CHANGED
@@ -1,23 +1,22 @@
1
+ # coding: utf-8
1
2
  require "bundler/setup"
2
3
  require "snoopy_afip/version"
3
4
  require "snoopy_afip/constants"
5
+ require "snoopy_afip/exceptions"
4
6
  require "savon"
5
7
  require "snoopy_afip/core_ext/float"
6
8
  require "snoopy_afip/core_ext/hash"
7
9
  require "snoopy_afip/core_ext/string"
8
- module Snoopy
9
-
10
- class NullOrInvalidAttribute < StandardError; end
11
-
12
- autoload :Authorizer, "snoopy_afip/authorizer"
13
- autoload :AuthData, "snoopy_afip/auth_data"
14
- autoload :Bill, "snoopy_afip/bill"
15
- autoload :Constants, "snoopy_afip/constants"
16
10
 
11
+ module Snoopy
12
+ autoload :Constants, 'snoopy_afip/constants'
13
+ autoload :Bill, 'snoopy_afip/bill'
14
+ autoload :Client, 'snoopy_afip/client'
15
+ autoload :AuthorizeAdapter, 'snoopy_afip/authorize_adapter'
16
+ autoload :AuthenticationAdapter, 'snoopy_afip/authentication_adapter'
17
17
 
18
18
  extend self
19
- attr_accessor :cuit, :sale_point, :service_url, :default_documento, :pkey, :cert,
20
- :default_concepto, :default_moneda, :own_iva_cond, :verbose, :auth_url
19
+ attr_accessor :cuit, :sale_point, :service_url, :default_document_type, :pkey, :cert, :default_concept, :default_currency, :own_iva_cond, :verbose, :auth_url
21
20
 
22
21
  def auth_hash
23
22
  {"Token" => Snoopy::TOKEN, "Sign" => Snoopy::SIGN, "Cuit" => Snoopy.cuit}
@@ -56,3 +55,4 @@ module Snoopy
56
55
  # end
57
56
 
58
57
  end
58
+
data/snoopy_afip.gemspec CHANGED
@@ -9,21 +9,21 @@ Gem::Specification.new do |s|
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["g.edera"]
12
- s.date = "2016-09-12"
12
+ s.date = "2017-06-29"
13
13
  s.description = "Adaptador para Web Service de Facturación Electrónica Argentina (AFIP)"
14
14
  s.email = ["gab.edera@gmail.com"]
15
15
  s.extra_rdoc_files = ["LICENSE.txt", "README.textile"]
16
- s.files = [".document", "CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE.txt", "README.textile", "Rakefile", "VERSION", "autotest/discover.rb", "snoopy_afip.gemspec", "lib/snoopy_afip.rb", "lib/snoopy_afip/auth_data.rb", "lib/snoopy_afip/authorizer.rb", "lib/snoopy_afip/bill.rb", "lib/snoopy_afip/constants.rb", "lib/snoopy_afip/core_ext/float.rb", "lib/snoopy_afip/core_ext/hash.rb", "lib/snoopy_afip/core_ext/string.rb", "lib/snoopy_afip/version.rb", "spec/snoopy_afip/auth_data_spec.rb", "spec/snoopy_afip/authorizer_spec.rb", "spec/snoopy_afip/bill_spec.rb", "spec/spec_helper.rb", "wsaa-client.sh"]
16
+ s.files = [".document", "CHANGELOG", "Gemfile", "Gemfile.lock", "LICENSE.txt", "README.textile", "Rakefile", "VERSION", "autotest/discover.rb", "snoopy_afip.gemspec", "lib/snoopy_afip.rb", "lib/snoopy_afip/authentication_adapter.rb", "lib/snoopy_afip/authorize_adapter.rb", "lib/snoopy_afip/bill.rb", "lib/snoopy_afip/client.rb", "lib/snoopy_afip/constants.rb", "lib/snoopy_afip/core_ext/float.rb", "lib/snoopy_afip/core_ext/hash.rb", "lib/snoopy_afip/core_ext/string.rb", "lib/snoopy_afip/exceptions.rb", "lib/snoopy_afip/version.rb", "spec/snoopy_afip/authorizer_spec.rb", "spec/snoopy_afip/bill_spec.rb", "spec/spec_helper.rb", "wsaa-client.sh"]
17
17
  s.homepage = "https://github.com/gedera/snoopy_afip"
18
18
  s.licenses = ["MIT"]
19
19
  s.require_paths = ["lib"]
20
- s.rubygems_version = "1.8.25"
20
+ # s.rubygems_version = "1.8.25"
21
21
  s.summary = "Adaptador AFIP wsfe."
22
- s.test_files = ["spec/snoopy_afip/auth_data_spec.rb", "spec/snoopy_afip/authorizer_spec.rb", "spec/snoopy_afip/bill_spec.rb", "spec/spec_helper.rb"]
22
+ s.test_files = ["spec/snoopy_afip/authorizer_spec.rb", "spec/snoopy_afip/bill_spec.rb", "spec/spec_helper.rb"]
23
23
 
24
- s.add_runtime_dependency('savon', ["~> 2.4.0"])
24
+ s.add_runtime_dependency('savon', ["~> 2.4"])
25
25
  s.add_runtime_dependency('nokogiri', ["~> 1.6"])
26
- s.add_runtime_dependency('wasabi', ["~> 3.2.3"])
26
+ s.add_runtime_dependency('wasabi', ["~> 3.2"])
27
27
  s.add_runtime_dependency('akami', ["~> 1.2"])
28
- s.add_runtime_dependency('nori', ["~> 2.3.0"])
28
+ s.add_runtime_dependency('nori', ["~> 2.3"])
29
29
  end
metadata CHANGED
@@ -1,95 +1,78 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: snoopy_afip
3
- version: !ruby/object:Gem::Version
4
- version: 2.1.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - g.edera
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-12 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
11
+
12
+ date: 2017-06-29 00:00:00 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
14
15
  name: savon
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 2.4.0
20
- type: :runtime
21
16
  prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 2.4.0
27
- - !ruby/object:Gem::Dependency
28
- name: nokogiri
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.6'
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: "2.4"
34
22
  type: :runtime
23
+ version_requirements: *id001
24
+ - !ruby/object:Gem::Dependency
25
+ name: nokogiri
35
26
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.6'
41
- - !ruby/object:Gem::Dependency
42
- name: wasabi
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.2.3
27
+ requirement: &id002 !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ~>
30
+ - !ruby/object:Gem::Version
31
+ version: "1.6"
48
32
  type: :runtime
33
+ version_requirements: *id002
34
+ - !ruby/object:Gem::Dependency
35
+ name: wasabi
49
36
  prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.2.3
55
- - !ruby/object:Gem::Dependency
56
- name: akami
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '1.2'
37
+ requirement: &id003 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ~>
40
+ - !ruby/object:Gem::Version
41
+ version: "3.2"
62
42
  type: :runtime
43
+ version_requirements: *id003
44
+ - !ruby/object:Gem::Dependency
45
+ name: akami
63
46
  prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.2'
69
- - !ruby/object:Gem::Dependency
70
- name: nori
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 2.3.0
47
+ requirement: &id004 !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ~>
50
+ - !ruby/object:Gem::Version
51
+ version: "1.2"
76
52
  type: :runtime
53
+ version_requirements: *id004
54
+ - !ruby/object:Gem::Dependency
55
+ name: nori
77
56
  prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 2.3.0
83
- description: Adaptador para Web Service de Facturación Electrónica Argentina (AFIP)
84
- email:
57
+ requirement: &id005 !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: "2.3"
62
+ type: :runtime
63
+ version_requirements: *id005
64
+ description: "Adaptador para Web Service de Facturaci\xC3\xB3n Electr\xC3\xB3nica Argentina (AFIP)"
65
+ email:
85
66
  - gab.edera@gmail.com
86
67
  executables: []
68
+
87
69
  extensions: []
88
- extra_rdoc_files:
70
+
71
+ extra_rdoc_files:
89
72
  - LICENSE.txt
90
73
  - README.textile
91
- files:
92
- - ".document"
74
+ files:
75
+ - .document
93
76
  - CHANGELOG
94
77
  - Gemfile
95
78
  - Gemfile.lock
@@ -99,46 +82,48 @@ files:
99
82
  - VERSION
100
83
  - autotest/discover.rb
101
84
  - lib/snoopy_afip.rb
102
- - lib/snoopy_afip/auth_data.rb
103
- - lib/snoopy_afip/authorizer.rb
85
+ - lib/snoopy_afip/authentication_adapter.rb
86
+ - lib/snoopy_afip/authorize_adapter.rb
104
87
  - lib/snoopy_afip/bill.rb
88
+ - lib/snoopy_afip/client.rb
105
89
  - lib/snoopy_afip/constants.rb
106
90
  - lib/snoopy_afip/core_ext/float.rb
107
91
  - lib/snoopy_afip/core_ext/hash.rb
108
92
  - lib/snoopy_afip/core_ext/string.rb
93
+ - lib/snoopy_afip/exceptions.rb
109
94
  - lib/snoopy_afip/version.rb
110
95
  - snoopy_afip.gemspec
111
- - spec/snoopy_afip/auth_data_spec.rb
112
96
  - spec/snoopy_afip/authorizer_spec.rb
113
97
  - spec/snoopy_afip/bill_spec.rb
114
98
  - spec/spec_helper.rb
115
99
  - wsaa-client.sh
116
100
  homepage: https://github.com/gedera/snoopy_afip
117
- licenses:
101
+ licenses:
118
102
  - MIT
119
103
  metadata: {}
104
+
120
105
  post_install_message:
121
106
  rdoc_options: []
122
- require_paths:
107
+
108
+ require_paths:
123
109
  - lib
124
- required_ruby_version: !ruby/object:Gem::Requirement
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: '0'
129
- required_rubygems_version: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: '0'
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - &id006
113
+ - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: "0"
116
+ required_rubygems_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - *id006
134
119
  requirements: []
120
+
135
121
  rubyforge_project:
136
- rubygems_version: 2.5.1
122
+ rubygems_version: 2.6.12
137
123
  signing_key:
138
124
  specification_version: 4
139
125
  summary: Adaptador AFIP wsfe.
140
- test_files:
141
- - spec/snoopy_afip/auth_data_spec.rb
126
+ test_files:
142
127
  - spec/snoopy_afip/authorizer_spec.rb
143
128
  - spec/snoopy_afip/bill_spec.rb
144
129
  - spec/spec_helper.rb
@@ -1,46 +0,0 @@
1
- # coding: utf-8
2
- module Snoopy
3
- module AuthData
4
- def generate_auth_file
5
- Snoopy::AuthData.generate_auth_file(:cuit => cuit, :pkey => pkey, :cert => cert)
6
-
7
- todays_datafile = "/tmp/snoopy_afip_#{cuit}_#{Time.new.strftime('%d_%m_%Y')}.yml"
8
- current_token_sign_file = YAML.load_file(todays_datafile)
9
-
10
- { "Token" => current_token_sign_file["token"], "Sign" => current_token_sign_file["sign"], "Cuit" => cuit }
11
- end
12
-
13
- def self.generate_auth_file invoicing_firm
14
- raise "Debe definir el cuit del emisor" unless invoicing_firm[:cuit]
15
- raise "Archivo certificado no encontrado en #{invoicing_firm[:cert]}" unless File.exists?(invoicing_firm[:cert])
16
- raise "Archivo de llave privada no encontrado en #{invoicing_firm[:pkey]}" unless File.exists?(invoicing_firm[:pkey])
17
-
18
- todays_datafile = "/tmp/snoopy_afip_#{invoicing_firm[:cuit]}_#{Time.new.strftime('%d_%m_%Y')}.yml"
19
- opts = "-u #{Snoopy.auth_url} -k #{invoicing_firm[:pkey]} -c #{invoicing_firm[:cert]} -i #{invoicing_firm[:cuit]}"
20
-
21
- %x(#{File.dirname(__FILE__)}/../../wsaa-client.sh #{opts}) unless File.exists?(todays_datafile)
22
- end
23
-
24
- def self.generate_pkey file
25
- begin
26
- %x(openssl genrsa -out #{file} 8192)
27
- rescue => e
28
- raise "command fail: 'openssl genrsa -out #{file} 8192' error al generar pkey: #{e.message}, error: #{e.message}"
29
- end
30
- end
31
-
32
- # pkey: clave privada generada por el metodo generate_pkey.
33
- # subj_o: Nombre de la empresa, registrado en AFIP.
34
- # subj_cn: hostname del servidor que realizara la comunicación con AFIP.
35
- # subj_cuit: Cuit registado en AFIP.
36
- # out_path: donde se almacenara el certificado generado.
37
- # Snoopy::AuthData.generate_certificate_request(generate_pkey, subj_o, subj_cn, subj_cuit, tmp_cert_req_path)
38
- def self.generate_certificate_request(pkey, subj_o, subj_cn, subj_cuit, out_path)
39
- begin
40
- %x(openssl req -new -key #{pkey} -subj "/C=AR/O=#{subj_o}/CN=#{subj_cn}/serialNumber=CUIT #{subj_cuit}" -out #{out_path})
41
- rescue => e
42
- raise "command fail: openssl req -new -key #{pkey} -subj /C=AR/O=#{subj_o}/CN=#{subj_cn}/serialNumber=CUIT #{subj_cuit} -out #{out_path}, error: #{e.message}"
43
- end
44
- end
45
- end
46
- end
@@ -1,10 +0,0 @@
1
- module Snoopy
2
- class Authorizer
3
- attr_reader :pkey, :cert
4
-
5
- def initialize
6
- @pkey = Snoopy.pkey
7
- @cert = Snoopy.cert
8
- end
9
- end
10
- end
@@ -1,12 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
-
3
- describe "AuthData" do
4
- it "should create constants for todays data" do
5
- Snoopy::AuthData.fetch
6
- if RUBY_VERSION >= "1.9"
7
- Snoopy.constants.should include(:TOKEN, :SIGN)
8
- else
9
- Snoopy.constants.should include("TOKEN", "SIGN")
10
- end
11
- end
12
- end