Class: EcfDgii::Client
- Inherits:
-
Object
- Object
- EcfDgii::Client
- Defined in:
- lib/ecf_dgii/client.rb
Constant Summary collapse
- ENVIRONMENT_URLS =
{ test: "https://api.test.ecfx.ssd.com.do", cert: "https://api.cert.ecfx.ssd.com.do", prod: "https://api.prod.ecfx.ssd.com.do" }.freeze
- ECF_TYPE_ROUTE_MAP =
Dynamic send_ecf routing (similar to TS sendEcf)
{ "FacturaDeCreditoFiscalElectronica" => "31", "FacturaDeConsumoElectronica" => "32", "NotaDeDebitoElectronica" => "33", "NotaDeCreditoElectronica" => "34", "ComprasElectronico" => "41", "GastosMenoresElectronico" => "43", "RegimenesEspecialesElectronico" => "44", "GubernamentalElectronico" => "45", "ComprobanteDeExportacionesElectronico" => "46", "ComprobanteParaPagosAlExteriorElectronico" => "47" }.freeze
Instance Attribute Summary collapse
-
#api_client ⇒ Object
readonly
Returns the value of attribute api_client.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
Instance Method Summary collapse
- #anulacion_rangos(body) ⇒ Object
- #api_key_api ⇒ Object
- #aprobacion_comercial_api ⇒ Object
- #company_api ⇒ Object
- #consulta_directorio(rnc) ⇒ Object
- #consulta_directorio_por_rnc(rnc, target_rnc) ⇒ Object
-
#consulta_estado(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad) ⇒ Object
—————————————————————— DGII operations ——————————————————————.
- #consulta_resultado(rnc, track_id) ⇒ Object
- #consulta_rfce(rnc, rnc_emisor, ncf_electronico) ⇒ Object
- #consulta_timbre(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad, fecha_emision, monto_total, uid_timbre) ⇒ Object
- #consulta_timbre_fc(rnc, rnc_emisor, ncf_electronico, rnc_comprador, fecha_emision, monto_total) ⇒ Object
- #consulta_track_id(rnc, rnc_emisor, encf) ⇒ Object
- #delete_company(rnc) ⇒ Object
- #dgii_api ⇒ Object
-
#ecf_api ⇒ Object
—————————————————————— Base API Clients ——————————————————————.
- #estatus_servicio(rnc) ⇒ Object
- #firmar_semilla(body) ⇒ Object
-
#get_acecf_reception_request(message_id) ⇒ Object
—————————————————————— Aprobacion Comercial operations ——————————————————————.
-
#get_companies(opts = {}) ⇒ Object
—————————————————————— Company operations ——————————————————————.
- #get_company_by_rnc(rnc) ⇒ Object
- #get_current_certificate(rnc) ⇒ Object
- #get_ecf_by_id(id) ⇒ Object
-
#get_ecf_reception_request(message_id) ⇒ Object
—————————————————————— Reception operations ——————————————————————.
- #get_ecf_receptor_by_message_id(message_id) ⇒ Object
-
#initialize(api_key: nil, base_url: nil, environment: :test, timeout: 30) ⇒ Client
constructor
A new instance of Client.
- #list_anulaciones(opts = {}) ⇒ Object
-
#new_company_api_key(body) ⇒ Object
—————————————————————— Api Key operations ——————————————————————.
-
#query_ecf(rnc, encf, opts = {}) ⇒ Object
—————————————————————— ECF query & search operations ——————————————————————.
- #recepcion_api ⇒ Object
- #search_acecf_reception_requests(opts = {}) ⇒ Object
- #search_all_ecfs(opts = {}) ⇒ Object
- #search_ecf_reception_requests(opts = {}) ⇒ Object
- #search_ecf_reception_requests_by_rnc(rnc, opts = {}) ⇒ Object
- #search_ecfs(rnc, opts = {}) ⇒ Object
- #send_aprobacion_comercial(body) ⇒ Object
- #send_ecf(ecf) ⇒ Object
-
#send_ecf31(ecf) ⇒ Object
—————————————————————— ECF send operations (per-type) ——————————————————————.
-
#send_ecf31_and_poll(ecf, options = nil) ⇒ Object
—————————————————————— Polling send operations ——————————————————————.
- #send_ecf32(ecf) ⇒ Object
- #send_ecf32_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf33(ecf) ⇒ Object
- #send_ecf33_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf34(ecf) ⇒ Object
- #send_ecf34_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf41(ecf) ⇒ Object
- #send_ecf41_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf43(ecf) ⇒ Object
- #send_ecf43_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf44(ecf) ⇒ Object
- #send_ecf44_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf45(ecf) ⇒ Object
- #send_ecf45_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf46(ecf) ⇒ Object
- #send_ecf46_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf47(ecf) ⇒ Object
- #send_ecf47_and_poll(ecf, options = nil) ⇒ Object
- #send_ecf_and_poll(ecf, options = nil) ⇒ Object
- #update_certificate_company(rnc, opts = {}) ⇒ Object
- #upsert_company(body) ⇒ Object
- #ventanas_mantenimiento(rnc) ⇒ Object
Constructor Details
#initialize(api_key: nil, base_url: nil, environment: :test, timeout: 30) ⇒ Client
Returns a new instance of Client.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ecf_dgii/client.rb', line 13 def initialize(api_key: nil, base_url: nil, environment: :test, timeout: 30) token = api_key || ENV["ECF_API_KEY"] resolved_url = base_url || ENV["ECF_API_URL"] || ENVIRONMENT_URLS[environment.to_sym] raise ArgumentError, "Se requiere un api_key o la variable de entorno ECF_API_KEY" if token.nil? || token.empty? raise ArgumentError, "El entorno especificado o la URL base no son válidos" if resolved_url.nil? || resolved_url.empty? config = EcfDgii::Generated::Configuration.new uri = URI.parse(resolved_url) config.scheme = uri.scheme config.host = uri.host config.base_path = uri.path.empty? ? "" : uri.path config.access_token = token config.timeout = timeout @api_client = EcfDgii::Generated::ApiClient.new(config) @environment = environment.to_sym end |
Instance Attribute Details
#api_client ⇒ Object (readonly)
Returns the value of attribute api_client.
11 12 13 |
# File 'lib/ecf_dgii/client.rb', line 11 def api_client @api_client end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
11 12 13 |
# File 'lib/ecf_dgii/client.rb', line 11 def environment @environment end |
Instance Method Details
#anulacion_rangos(body) ⇒ Object
206 207 208 |
# File 'lib/ecf_dgii/client.rb', line 206 def anulacion_rangos(body) ecf_api.anulacion_rangos(body) end |
#api_key_api ⇒ Object
57 58 59 |
# File 'lib/ecf_dgii/client.rb', line 57 def api_key_api @api_key_api ||= EcfDgii::Generated::ApiKeyApi.new(api_client) end |
#aprobacion_comercial_api ⇒ Object
53 54 55 |
# File 'lib/ecf_dgii/client.rb', line 53 def aprobacion_comercial_api @aprobacion_comercial_api ||= EcfDgii::Generated::AprobacionComercialApi.new(api_client) end |
#company_api ⇒ Object
49 50 51 |
# File 'lib/ecf_dgii/client.rb', line 49 def company_api @company_api ||= EcfDgii::Generated::CompanyApi.new(api_client) end |
#consulta_directorio(rnc) ⇒ Object
286 287 288 |
# File 'lib/ecf_dgii/client.rb', line 286 def consulta_directorio(rnc) dgii_api.consulta_directorio_listado(rnc) end |
#consulta_directorio_por_rnc(rnc, target_rnc) ⇒ Object
290 291 292 |
# File 'lib/ecf_dgii/client.rb', line 290 def consulta_directorio_por_rnc(rnc, target_rnc) dgii_api.consulta_directorio_obtener_directorio_por_rnc(rnc, target_rnc) end |
#consulta_estado(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad) ⇒ Object
DGII operations
262 263 264 |
# File 'lib/ecf_dgii/client.rb', line 262 def consulta_estado(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad) dgii_api.consulta_estado(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad) end |
#consulta_resultado(rnc, track_id) ⇒ Object
278 279 280 |
# File 'lib/ecf_dgii/client.rb', line 278 def consulta_resultado(rnc, track_id) dgii_api.consulta_resultado(rnc, track_id) end |
#consulta_rfce(rnc, rnc_emisor, ncf_electronico) ⇒ Object
282 283 284 |
# File 'lib/ecf_dgii/client.rb', line 282 def consulta_rfce(rnc, rnc_emisor, ncf_electronico) dgii_api.consulta_rfce(rnc, rnc_emisor, ncf_electronico) end |
#consulta_timbre(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad, fecha_emision, monto_total, uid_timbre) ⇒ Object
270 271 272 |
# File 'lib/ecf_dgii/client.rb', line 270 def consulta_timbre(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad, fecha_emision, monto_total, uid_timbre) dgii_api.consulta_timbre(rnc, rnc_emisor, ncf_electronico, rnc_comprador, codigo_seguridad, fecha_emision, monto_total, uid_timbre) end |
#consulta_timbre_fc(rnc, rnc_emisor, ncf_electronico, rnc_comprador, fecha_emision, monto_total) ⇒ Object
274 275 276 |
# File 'lib/ecf_dgii/client.rb', line 274 def consulta_timbre_fc(rnc, rnc_emisor, ncf_electronico, rnc_comprador, fecha_emision, monto_total) dgii_api.consulta_timbre_fc(rnc, rnc_emisor, ncf_electronico, rnc_comprador, fecha_emision, monto_total) end |
#consulta_track_id(rnc, rnc_emisor, encf) ⇒ Object
266 267 268 |
# File 'lib/ecf_dgii/client.rb', line 266 def consulta_track_id(rnc, rnc_emisor, encf) dgii_api.consulta_track_id(rnc, rnc_emisor, encf) end |
#delete_company(rnc) ⇒ Object
238 239 240 |
# File 'lib/ecf_dgii/client.rb', line 238 def delete_company(rnc) company_api.delete_company(rnc) end |
#dgii_api ⇒ Object
41 42 43 |
# File 'lib/ecf_dgii/client.rb', line 41 def dgii_api @dgii_api ||= EcfDgii::Generated::DgiiApi.new(api_client) end |
#ecf_api ⇒ Object
Base API Clients
37 38 39 |
# File 'lib/ecf_dgii/client.rb', line 37 def ecf_api @ecf_api ||= EcfDgii::Generated::EcfApi.new(api_client) end |
#estatus_servicio(rnc) ⇒ Object
294 295 296 |
# File 'lib/ecf_dgii/client.rb', line 294 def estatus_servicio(rnc) dgii_api.estatus_servicios_obtener_estatus(rnc) end |
#firmar_semilla(body) ⇒ Object
218 219 220 |
# File 'lib/ecf_dgii/client.rb', line 218 def firmar_semilla(body) ecf_api.firmar_semilla(body) end |
#get_acecf_reception_request(message_id) ⇒ Object
Aprobacion Comercial operations
326 327 328 |
# File 'lib/ecf_dgii/client.rb', line 326 def get_acecf_reception_request() aprobacion_comercial_api.get_acecf_reception_request() end |
#get_companies(opts = {}) ⇒ Object
Company operations
226 227 228 |
# File 'lib/ecf_dgii/client.rb', line 226 def get_companies(opts = {}) company_api.get_companies(opts) end |
#get_company_by_rnc(rnc) ⇒ Object
230 231 232 |
# File 'lib/ecf_dgii/client.rb', line 230 def get_company_by_rnc(rnc) company_api.get_company_by_rnc(rnc) end |
#get_current_certificate(rnc) ⇒ Object
242 243 244 |
# File 'lib/ecf_dgii/client.rb', line 242 def get_current_certificate(rnc) company_api.get_current_certificate(rnc) end |
#get_ecf_by_id(id) ⇒ Object
202 203 204 |
# File 'lib/ecf_dgii/client.rb', line 202 def get_ecf_by_id(id) ecf_api.get_ecf_by_id(id) end |
#get_ecf_reception_request(message_id) ⇒ Object
Reception operations
306 307 308 |
# File 'lib/ecf_dgii/client.rb', line 306 def get_ecf_reception_request() recepcion_api.get_ecf_reception_request() end |
#get_ecf_receptor_by_message_id(message_id) ⇒ Object
310 311 312 |
# File 'lib/ecf_dgii/client.rb', line 310 def () recepcion_api.() end |
#list_anulaciones(opts = {}) ⇒ Object
210 211 212 |
# File 'lib/ecf_dgii/client.rb', line 210 def list_anulaciones(opts = {}) ecf_api.list_anulaciones(opts) end |
#new_company_api_key(body) ⇒ Object
Api Key operations
254 255 256 |
# File 'lib/ecf_dgii/client.rb', line 254 def new_company_api_key(body) api_key_api.new_company_api_key(body) end |
#query_ecf(rnc, encf, opts = {}) ⇒ Object
ECF query & search operations
190 191 192 |
# File 'lib/ecf_dgii/client.rb', line 190 def query_ecf(rnc, encf, opts = {}) ecf_api.query_ecf(rnc, encf, opts) end |
#recepcion_api ⇒ Object
45 46 47 |
# File 'lib/ecf_dgii/client.rb', line 45 def recepcion_api @recepcion_api ||= EcfDgii::Generated::RecepcionApi.new(api_client) end |
#search_acecf_reception_requests(opts = {}) ⇒ Object
330 331 332 |
# File 'lib/ecf_dgii/client.rb', line 330 def search_acecf_reception_requests(opts = {}) aprobacion_comercial_api.search_acecf_reception_requests(opts) end |
#search_all_ecfs(opts = {}) ⇒ Object
198 199 200 |
# File 'lib/ecf_dgii/client.rb', line 198 def search_all_ecfs(opts = {}) ecf_api.search_all_ecfs(opts) end |
#search_ecf_reception_requests(opts = {}) ⇒ Object
314 315 316 |
# File 'lib/ecf_dgii/client.rb', line 314 def search_ecf_reception_requests(opts = {}) recepcion_api.search_ecf_reception_requests(opts) end |
#search_ecf_reception_requests_by_rnc(rnc, opts = {}) ⇒ Object
318 319 320 |
# File 'lib/ecf_dgii/client.rb', line 318 def search_ecf_reception_requests_by_rnc(rnc, opts = {}) recepcion_api.search_ecf_reception_requests_by_rnc(rnc, opts) end |
#search_ecfs(rnc, opts = {}) ⇒ Object
194 195 196 |
# File 'lib/ecf_dgii/client.rb', line 194 def search_ecfs(rnc, opts = {}) ecf_api.search_ecfs(rnc, opts) end |
#send_aprobacion_comercial(body) ⇒ Object
214 215 216 |
# File 'lib/ecf_dgii/client.rb', line 214 def send_aprobacion_comercial(body) recepcion_api.send_aprobacion_comercial(body) end |
#send_ecf(ecf) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/ecf_dgii/client.rb', line 166 def send_ecf(ecf) tipoe_cf = nil if ecf.respond_to?(:encabezado) && ecf.encabezado.respond_to?(:id_doc) tipoe_cf = ecf.encabezado.id_doc.tipoe_cf elsif ecf.is_a?(Hash) tipoe_cf = ecf.dig(:encabezado, :id_doc, :tipoe_cf) || ecf.dig("encabezado", "idDoc", "tipoeCF") end raise ArgumentError, "El objeto ECF debe contener encabezado.id_doc.tipoe_cf" if tipoe_cf.nil? || tipoe_cf.to_s.empty? route = ECF_TYPE_ROUTE_MAP[tipoe_cf.to_s] raise ArgumentError, "Tipo de eCF desconocido: #{tipoe_cf}" if route.nil? send("send_ecf#{route}", ecf) end |
#send_ecf31(ecf) ⇒ Object
ECF send operations (per-type)
65 66 67 |
# File 'lib/ecf_dgii/client.rb', line 65 def send_ecf31(ecf) ecf_api.recepcion_ecf_31(ecf) end |
#send_ecf31_and_poll(ecf, options = nil) ⇒ Object
Polling send operations
109 110 111 |
# File 'lib/ecf_dgii/client.rb', line 109 def send_ecf31_and_poll(ecf, = nil) _send_and_poll(send_ecf31(ecf), ) end |
#send_ecf32(ecf) ⇒ Object
69 70 71 |
# File 'lib/ecf_dgii/client.rb', line 69 def send_ecf32(ecf) ecf_api.recepcion_ecf_32(ecf) end |
#send_ecf32_and_poll(ecf, options = nil) ⇒ Object
113 114 115 |
# File 'lib/ecf_dgii/client.rb', line 113 def send_ecf32_and_poll(ecf, = nil) _send_and_poll(send_ecf32(ecf), ) end |
#send_ecf33(ecf) ⇒ Object
73 74 75 |
# File 'lib/ecf_dgii/client.rb', line 73 def send_ecf33(ecf) ecf_api.recepcion_ecf_33(ecf) end |
#send_ecf33_and_poll(ecf, options = nil) ⇒ Object
117 118 119 |
# File 'lib/ecf_dgii/client.rb', line 117 def send_ecf33_and_poll(ecf, = nil) _send_and_poll(send_ecf33(ecf), ) end |
#send_ecf34(ecf) ⇒ Object
77 78 79 |
# File 'lib/ecf_dgii/client.rb', line 77 def send_ecf34(ecf) ecf_api.recepcion_ecf_34(ecf) end |
#send_ecf34_and_poll(ecf, options = nil) ⇒ Object
121 122 123 |
# File 'lib/ecf_dgii/client.rb', line 121 def send_ecf34_and_poll(ecf, = nil) _send_and_poll(send_ecf34(ecf), ) end |
#send_ecf41(ecf) ⇒ Object
81 82 83 |
# File 'lib/ecf_dgii/client.rb', line 81 def send_ecf41(ecf) ecf_api.recepcion_ecf_41(ecf) end |
#send_ecf41_and_poll(ecf, options = nil) ⇒ Object
125 126 127 |
# File 'lib/ecf_dgii/client.rb', line 125 def send_ecf41_and_poll(ecf, = nil) _send_and_poll(send_ecf41(ecf), ) end |
#send_ecf43(ecf) ⇒ Object
85 86 87 |
# File 'lib/ecf_dgii/client.rb', line 85 def send_ecf43(ecf) ecf_api.recepcion_ecf_43(ecf) end |
#send_ecf43_and_poll(ecf, options = nil) ⇒ Object
129 130 131 |
# File 'lib/ecf_dgii/client.rb', line 129 def send_ecf43_and_poll(ecf, = nil) _send_and_poll(send_ecf43(ecf), ) end |
#send_ecf44(ecf) ⇒ Object
89 90 91 |
# File 'lib/ecf_dgii/client.rb', line 89 def send_ecf44(ecf) ecf_api.recepcion_ecf_44(ecf) end |
#send_ecf44_and_poll(ecf, options = nil) ⇒ Object
133 134 135 |
# File 'lib/ecf_dgii/client.rb', line 133 def send_ecf44_and_poll(ecf, = nil) _send_and_poll(send_ecf44(ecf), ) end |
#send_ecf45(ecf) ⇒ Object
93 94 95 |
# File 'lib/ecf_dgii/client.rb', line 93 def send_ecf45(ecf) ecf_api.recepcion_ecf_45(ecf) end |
#send_ecf45_and_poll(ecf, options = nil) ⇒ Object
137 138 139 |
# File 'lib/ecf_dgii/client.rb', line 137 def send_ecf45_and_poll(ecf, = nil) _send_and_poll(send_ecf45(ecf), ) end |
#send_ecf46(ecf) ⇒ Object
97 98 99 |
# File 'lib/ecf_dgii/client.rb', line 97 def send_ecf46(ecf) ecf_api.recepcion_ecf_46(ecf) end |
#send_ecf46_and_poll(ecf, options = nil) ⇒ Object
141 142 143 |
# File 'lib/ecf_dgii/client.rb', line 141 def send_ecf46_and_poll(ecf, = nil) _send_and_poll(send_ecf46(ecf), ) end |
#send_ecf47(ecf) ⇒ Object
101 102 103 |
# File 'lib/ecf_dgii/client.rb', line 101 def send_ecf47(ecf) ecf_api.recepcion_ecf_47(ecf) end |
#send_ecf47_and_poll(ecf, options = nil) ⇒ Object
145 146 147 |
# File 'lib/ecf_dgii/client.rb', line 145 def send_ecf47_and_poll(ecf, = nil) _send_and_poll(send_ecf47(ecf), ) end |
#send_ecf_and_poll(ecf, options = nil) ⇒ Object
182 183 184 |
# File 'lib/ecf_dgii/client.rb', line 182 def send_ecf_and_poll(ecf, = nil) _send_and_poll(send_ecf(ecf), ) end |
#update_certificate_company(rnc, opts = {}) ⇒ Object
246 247 248 |
# File 'lib/ecf_dgii/client.rb', line 246 def update_certificate_company(rnc, opts = {}) company_api.update_certificate_company(rnc, opts) end |
#upsert_company(body) ⇒ Object
234 235 236 |
# File 'lib/ecf_dgii/client.rb', line 234 def upsert_company(body) company_api.upsert_company(body) end |
#ventanas_mantenimiento(rnc) ⇒ Object
298 299 300 |
# File 'lib/ecf_dgii/client.rb', line 298 def ventanas_mantenimiento(rnc) dgii_api.estatus_servicios_obtener_ventanas_mantenimiento(rnc) end |