afip.rb 1.1.0 → 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: 0e42c189eaf440590f00483ea1ad2c50c71d5a2d76657dcd65c34f4d38f119df
4
- data.tar.gz: 58ddb08555df0fdeb8afe73e462a8e557e1aa51caa72afbb4adc61dc7c79e05c
3
+ metadata.gz: 1e52833f2bb77d968e24c4bb4ccb1c98775fd194064ec3889bb3e32b434f394b
4
+ data.tar.gz: '097220873e56b5bc52c1449a9a2bf711fd16266ed8fe6f3ec338ea4accbddd9e'
5
5
  SHA512:
6
- metadata.gz: 5b81f1e1dbb0a8e2593cfad75d143eecff148ab7bc9b1058b52d232ee42ad8fa8dfd47c3db7d05a3e489111b5d0754411793ec135edd286b316edbad558b58e0
7
- data.tar.gz: d3ffb935950a08e1b363206f70849bbc523c8137495942d78929dba68966fd5186afb1b5f172cd2984891b09ba430be2d1ce40a402cbbbd4c01f1bf02e3c314c
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 60k descargas, 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.1.0"
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]
@@ -214,5 +212,79 @@ module Afip
214
212
 
215
213
  raise "Error: Waiting for too long"
216
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
217
289
  end
218
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.1.0
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-27 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: []