afip.rb 1.0.2 → 1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4c0c0cd1161e15cd97f4d01312a678fe5a8bc3f9935a182a58205e53cc6adad
4
- data.tar.gz: d6ca090bf60908eed7eb66b0e538a2016302501e6c043f0696ca25d4a8e19663
3
+ metadata.gz: 1e52833f2bb77d968e24c4bb4ccb1c98775fd194064ec3889bb3e32b434f394b
4
+ data.tar.gz: '097220873e56b5bc52c1449a9a2bf711fd16266ed8fe6f3ec338ea4accbddd9e'
5
5
  SHA512:
6
- metadata.gz: 56aa5eed6e8e9728c29594e56097c3e016c8ec842db726568276432cce0ac9a63dad47fa9df380fc499ee50f7f78c6c30b18d5cebd342d77fab7f46cca6a3dc3
7
- data.tar.gz: c8376dd90ed01696dc665fbf8f7be6eef9afdb3aa55f6fea93c3fec2867eb5d03480530ae13034f15cbb6becd1b9d1a1cfa4866ee8f579f471e5e601070f69e5
6
+ metadata.gz: d63faddfbb11748f96cba5655ac54aea0795e546fef935ed9faa06cd75862c555735f3b93c1306a1bfdd21d4efec975e53ce9949e1c920e07eef11231d36aae2
7
+ data.tar.gz: 15995e5b7caec214603ab7c67e2b180bd127eb305854a57cd71e876ba9657fdda0a4bb43cef74f38cd591a6d8f62d18e7f71188c3594e44c8a86de28013cfa0b
data/README.md CHANGED
@@ -20,6 +20,9 @@
20
20
  <a href="https://docs.afipsdk.com"><strong>Explorar documentación »</strong></a>
21
21
  <br />
22
22
  <br />
23
+ <a href="https://discord.gg/A6TuHEyAZm"><strong>Comunidad Afip SDK</strong></a>
24
+ <br />
25
+ <br />
23
26
  <a href="https://github.com/afipsdk/afip.rb/issues">Reportar un bug</a>
24
27
  </p>
25
28
  </p>
@@ -29,15 +32,18 @@
29
32
  ## Documentación
30
33
  [Explorar documentación](https://docs.afipsdk.com)
31
34
 
35
+ <!-- COMUNITY -->
36
+ ## Comunidad
37
+ [Comunidad Afip SDK](https://discord.gg/A6TuHEyAZm)
38
+
39
+
32
40
  <!-- ABOUT THE PROJECT -->
33
41
  ## Acerca del proyecto
34
- Con más de 60.000 descargas en sus versiones de PHP, Node y Ruby desde el 2017 Afip SDK es la librería elegida por los desarrolladores para integrar sus plataformas con AFIP.
35
-
36
- Esta librería fue creada con la intención de ayudar a los programadores a usar los Web Services de AFIP sin romperse la cabeza ni perder tiempo tratando de entender la complicada documentación que AFIP provee.
42
+ Con más de 100k descargas, desde el 2017, Afip SDK es la plataforma preferida entre los desarrolladores para conectarse a los web services de ARCA.
37
43
 
38
44
  <!-- CONTACT -->
39
45
  ### Contacto
40
- Afip SDK - afipsdk@gmail.com
46
+ Soporte de Afip SDK - ayuda@afipsdk.com
41
47
 
42
48
  Link del proyecto: [https://github.com/afipsdk/afip.rb](https://github.com/afipsdk/afip.rb)
43
49
 
data/afip.gemspec CHANGED
@@ -6,10 +6,10 @@ Gem::Specification.new do |spec|
6
6
  spec.name = "afip.rb"
7
7
  spec.version = Afip::VERSION
8
8
  spec.authors = ["Afip SDK"]
9
- spec.email = ["afipsdk@gmail.com"]
9
+ spec.email = ["ayuda@afipsdk.com"]
10
10
 
11
11
  spec.summary = "Library to connect with AFIP"
12
- spec.description = "AfipSDK is the easyest way to connect with AFIP"
12
+ spec.description = "Software Development Kit for ARCA web services"
13
13
  spec.homepage = "https://afipsdk.com"
14
14
  spec.license = "MIT"
15
15
  spec.required_ruby_version = ">= 2.3.0"
data/lib/afip/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Afip
4
- VERSION = "1.0.2"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/afip.rb CHANGED
@@ -12,7 +12,7 @@ require_relative "afip/register_inscription_proof"
12
12
  require_relative "afip/register_scope_ten"
13
13
  require_relative "afip/register_scope_thirteen"
14
14
 
15
- # AfipSDK is the easyest way to connect with AFIP
15
+ # Software Development Kit for AFIP web services
16
16
  module Afip
17
17
  def self.new(options)
18
18
  Afip::Instance.new(options)
@@ -30,9 +30,7 @@ module Afip
30
30
  :RegisterScopeThirteen
31
31
 
32
32
  def initialize(options)
33
- raise "CUIT field is required in options" unless options.key?(:CUIT)
34
-
35
- self.CUIT = options[:CUIT]
33
+ self.CUIT = options.key?(:CUIT) ? options[:CUIT] : nil
36
34
  self.production = options.key?(:production) ? options[:production] : false
37
35
  self.cert = options[:cert]
38
36
  self.key = options[:key]
@@ -117,5 +115,176 @@ module Afip
117
115
 
118
116
  Afip::WebService.new(self, options)
119
117
  end
118
+
119
+ # Create AFIP cert
120
+ def createCert(username, password, cert_alias)
121
+ url = URI("https://app.afipsdk.com/api/v1/afip/certs")
122
+
123
+ https = Net::HTTP.new(url.host, url.port)
124
+ https.use_ssl = true
125
+
126
+ request = Net::HTTP::Post.new(url)
127
+ request["Content-Type"] = "application/json"
128
+ request["sdk-version-number"] = Afip::VERSION
129
+ request["sdk-library"] = "ruby"
130
+ request["sdk-environment"] = production == true ? "prod" : "dev"
131
+ request["Authorization"] = "Bearer #{access_token}" if access_token
132
+
133
+ data = {
134
+ "environment": production == true ? "prod" : "dev",
135
+ "tax_id": self.CUIT,
136
+ "username": username,
137
+ "password": password,
138
+ "alias": cert_alias
139
+ }
140
+
141
+ retry_request = 24
142
+
143
+ while (retry_request -= 1) >= 0
144
+ request.body = JSON.dump(data)
145
+ response = https.request(request)
146
+
147
+ unless response.is_a? Net::HTTPSuccess
148
+ begin
149
+ raise JSON.parse(response.read_body)
150
+ rescue
151
+ raise response.read_body
152
+ end
153
+ end
154
+
155
+ decoded_res = JSON.parse(response.read_body)
156
+
157
+ return decoded_res["data"] if decoded_res["status"] == "complete"
158
+
159
+ data["long_job_id"] = decoded_res["long_job_id"] if decoded_res["long_job_id"]
160
+
161
+ sleep(5)
162
+ end
163
+
164
+ raise "Error: Waiting for too long"
165
+ end
166
+
167
+ # Create authorization to use a web service
168
+ def createWSAuth(username, password, cert_alias, wsid)
169
+ url = URI("https://app.afipsdk.com/api/v1/afip/ws-auths")
170
+
171
+ https = Net::HTTP.new(url.host, url.port)
172
+ https.use_ssl = true
173
+
174
+ request = Net::HTTP::Post.new(url)
175
+ request["Content-Type"] = "application/json"
176
+ request["sdk-version-number"] = Afip::VERSION
177
+ request["sdk-library"] = "ruby"
178
+ request["sdk-environment"] = production == true ? "prod" : "dev"
179
+ request["Authorization"] = "Bearer #{access_token}" if access_token
180
+
181
+ data = {
182
+ "environment": production == true ? "prod" : "dev",
183
+ "tax_id": self.CUIT,
184
+ "username": username,
185
+ "password": password,
186
+ "alias": cert_alias,
187
+ "wsid": wsid
188
+ }
189
+
190
+ retry_request = 24
191
+
192
+ while (retry_request -= 1) >= 0
193
+ request.body = JSON.dump(data)
194
+ response = https.request(request)
195
+
196
+ unless response.is_a? Net::HTTPSuccess
197
+ begin
198
+ raise JSON.parse(response.read_body)
199
+ rescue
200
+ raise response.read_body
201
+ end
202
+ end
203
+
204
+ decoded_res = JSON.parse(response.read_body)
205
+
206
+ return decoded_res["data"] if decoded_res["status"] == "complete"
207
+
208
+ data["long_job_id"] = decoded_res["long_job_id"] if decoded_res["long_job_id"]
209
+
210
+ sleep(5)
211
+ end
212
+
213
+ raise "Error: Waiting for too long"
214
+ end
215
+
216
+ # Create automation
217
+ def createAutomation(automation, params, wait = true)
218
+ url = URI("https://app.afipsdk.com/api/v1/automations")
219
+
220
+ https = Net::HTTP.new(url.host, url.port)
221
+ https.use_ssl = true
222
+
223
+ request = Net::HTTP::Post.new(url)
224
+ request["Content-Type"] = "application/json"
225
+ request["sdk-version-number"] = Afip::VERSION
226
+ request["sdk-library"] = "ruby"
227
+ request["sdk-environment"] = production == true ? "prod" : "dev"
228
+ request["Authorization"] = "Bearer #{access_token}" if access_token
229
+
230
+ data = {
231
+ "automation": automation,
232
+ "params": params
233
+ }
234
+
235
+ request.body = JSON.dump(data)
236
+ response = https.request(request)
237
+
238
+ unless response.is_a? Net::HTTPSuccess
239
+ begin
240
+ raise JSON.parse(response.read_body)
241
+ rescue
242
+ raise response.read_body
243
+ end
244
+ end
245
+
246
+ decoded_res = JSON.parse(response.read_body)
247
+
248
+ return decoded_res if !wait || decoded_res["status"] == "complete"
249
+
250
+ return self.getAutomationDetails(decoded_res["id"], wait)
251
+ end
252
+
253
+ # Get automation details
254
+ def getAutomationDetails(id, wait = true)
255
+ url = URI("https://app.afipsdk.com/api/v1/automations/#{id}")
256
+
257
+ https = Net::HTTP.new(url.host, url.port)
258
+ https.use_ssl = true
259
+
260
+ request = Net::HTTP::Get.new(url)
261
+ request["Content-Type"] = "application/json"
262
+ request["sdk-version-number"] = Afip::VERSION
263
+ request["sdk-library"] = "ruby"
264
+ request["sdk-environment"] = production == true ? "prod" : "dev"
265
+ request["Authorization"] = "Bearer #{access_token}" if access_token
266
+
267
+ retry_request = 24
268
+
269
+ while (retry_request -= 1) >= 0
270
+ response = https.request(request)
271
+
272
+ unless response.is_a? Net::HTTPSuccess
273
+ begin
274
+ raise JSON.parse(response.read_body)
275
+ rescue
276
+ raise response.read_body
277
+ end
278
+ end
279
+
280
+ decoded_res = JSON.parse(response.read_body)
281
+
282
+ return decoded_res if !wait || decoded_res["status"] == "complete"
283
+
284
+ sleep(5)
285
+ end
286
+
287
+ raise "Error: Waiting for too long"
288
+ end
120
289
  end
121
290
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: afip.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Afip SDK
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-02 00:00:00.000000000 Z
11
+ date: 2025-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: AfipSDK is the easyest way to connect with AFIP
13
+ description: Software Development Kit for ARCA web services
14
14
  email:
15
- - afipsdk@gmail.com
15
+ - ayuda@afipsdk.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
@@ -36,7 +36,7 @@ licenses:
36
36
  metadata:
37
37
  homepage_uri: https://afipsdk.com
38
38
  source_code_uri: https://github.com/AfipSDK/afip.rb
39
- post_install_message:
39
+ post_install_message:
40
40
  rdoc_options: []
41
41
  require_paths:
42
42
  - lib
@@ -51,8 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  requirements: []
54
- rubygems_version: 3.1.2
55
- signing_key:
54
+ rubygems_version: 3.0.3.1
55
+ signing_key:
56
56
  specification_version: 4
57
57
  summary: Library to connect with AFIP
58
58
  test_files: []