creditario-client 0.0.1.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.gitignore +14 -0
- data/.gitlab-ci.yml +23 -0
- data/.rubocop.yml +155 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Dockerfile +3 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +241 -0
- data/Rakefile +21 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/creditario-client.gemspec +35 -0
- data/lib/creditario/api/create.rb +29 -0
- data/lib/creditario/api/delete.rb +25 -0
- data/lib/creditario/api/list.rb +27 -0
- data/lib/creditario/api/multipart.rb +29 -0
- data/lib/creditario/api/request.rb +101 -0
- data/lib/creditario/api/retrieve.rb +32 -0
- data/lib/creditario/api/update.rb +32 -0
- data/lib/creditario/client.rb +183 -0
- data/lib/creditario/client/railtie.rb +14 -0
- data/lib/creditario/client/version.rb +9 -0
- data/lib/creditario/exceptions.rb +121 -0
- data/lib/creditario/repositories/applications.rb +50 -0
- data/lib/creditario/repositories/attachments.rb +50 -0
- data/lib/creditario/repositories/catalogs.rb +59 -0
- data/lib/creditario/repositories/contracts.rb +29 -0
- data/lib/creditario/repositories/credit_estimates.rb +29 -0
- data/lib/creditario/repositories/credits.rb +35 -0
- data/lib/creditario/repositories/customers.rb +50 -0
- data/lib/creditario/repositories/expenses.rb +41 -0
- data/lib/creditario/repositories/incomes.rb +41 -0
- data/lib/creditario/repositories/payments.rb +34 -0
- data/lib/creditario/repositories/products.rb +38 -0
- data/lib/creditario/repositories/references.rb +41 -0
- data/lib/creditario/resources/application.rb +27 -0
- data/lib/creditario/resources/attachment.rb +19 -0
- data/lib/creditario/resources/catalog.rb +35 -0
- data/lib/creditario/resources/contract.rb +21 -0
- data/lib/creditario/resources/credit.rb +19 -0
- data/lib/creditario/resources/credit_estimate.rb +19 -0
- data/lib/creditario/resources/customer.rb +25 -0
- data/lib/creditario/resources/expense.rb +19 -0
- data/lib/creditario/resources/income.rb +19 -0
- data/lib/creditario/resources/payment.rb +21 -0
- data/lib/creditario/resources/product.rb +21 -0
- data/lib/creditario/resources/reference.rb +19 -0
- data/lib/creditario/resources/resource.rb +96 -0
- data/lib/creditario/utils/paginated_collection.rb +45 -0
- data/lib/creditario/utils/resources_collection.rb +35 -0
- data/lib/generators/creditario/USAGE +13 -0
- data/lib/generators/creditario/install_generator.rb +17 -0
- data/lib/generators/creditario/templates/creditario.yml +12 -0
- data/lib/generators/creditario/templates/initializer.rb +4 -0
- data/rakelib/fixture_api_response.rake +10 -0
- data/rakelib/fixture_api_response.rb +114 -0
- metadata +214 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Expenses
|
6
|
+
#
|
7
|
+
# Repositorio de Egresos, permite realizar las siguientes operaciones
|
8
|
+
# sobre Egresos para Solicitudes de Crédito de creditar.io
|
9
|
+
#
|
10
|
+
# - Obtener un Egreso en especifico:
|
11
|
+
#
|
12
|
+
# Creditario::Expenses.retrieve("eeedba2e-fc96-4f96-bd2e-bd046b256f96")
|
13
|
+
# => Creditario::Expense
|
14
|
+
#
|
15
|
+
# - Crear un Egreso:
|
16
|
+
#
|
17
|
+
# result = Creditario::Expenses.create(classification: "Renta", amount_cents: 25000, credit_application_id: "636264b1-77a2-45ef-b643-e44cfbc84d40")
|
18
|
+
# => Creditario::Expense
|
19
|
+
#
|
20
|
+
# - Eliminar un Egreso:
|
21
|
+
#
|
22
|
+
# result = Creditario::Expenses.delete("eeedba2e-fc96-4f96-bd2e-bd046b256f96")
|
23
|
+
# => true
|
24
|
+
module Expenses
|
25
|
+
extend Creditario::API::Retrieve
|
26
|
+
extend Creditario::API::Create
|
27
|
+
extend Creditario::API::Delete
|
28
|
+
|
29
|
+
###
|
30
|
+
# Path de la API donde se ejecutan las peticiones para Egresos.
|
31
|
+
def self.resource_path
|
32
|
+
"/expenses"
|
33
|
+
end
|
34
|
+
|
35
|
+
###
|
36
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
37
|
+
def self.resource_class
|
38
|
+
Creditario::Expense
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Incomes
|
6
|
+
#
|
7
|
+
# Repositorio de Ingresos, permite realizar las siguientes operaciones
|
8
|
+
# sobre Ingresos para Solicitudes de Crédito de creditar.io
|
9
|
+
#
|
10
|
+
# - Obtener un Ingreso en especifico:
|
11
|
+
#
|
12
|
+
# Creditario::Incomes.retrieve("0b19e3b6-9fae-40e1-a7c2-f2db1cae8a5a")
|
13
|
+
# => Creditario::Income
|
14
|
+
#
|
15
|
+
# - Crear un Ingreso:
|
16
|
+
#
|
17
|
+
# result = Creditario::Incomes.create(classification: "Trabajo", amount_cents: 45000, credit_application_id: "636264b1-77a2-45ef-b643-e44cfbc84d40")
|
18
|
+
# => Creditario::Income
|
19
|
+
#
|
20
|
+
# - Eliminar un Ingreso:
|
21
|
+
#
|
22
|
+
# result = Creditario::Incomes.delete("0b19e3b6-9fae-40e1-a7c2-f2db1cae8a5a")
|
23
|
+
# => true
|
24
|
+
module Incomes
|
25
|
+
extend Creditario::API::Retrieve
|
26
|
+
extend Creditario::API::Create
|
27
|
+
extend Creditario::API::Delete
|
28
|
+
|
29
|
+
###
|
30
|
+
# Path de la API donde se ejecutan las peticiones para Ingresos.
|
31
|
+
def self.resource_path
|
32
|
+
"/incomes"
|
33
|
+
end
|
34
|
+
|
35
|
+
###
|
36
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
37
|
+
def self.resource_class
|
38
|
+
Creditario::Income
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Payments
|
6
|
+
#
|
7
|
+
# Repositorio de Pagos, permite obtener la lista de Pagos a partir de un Crédito.
|
8
|
+
#
|
9
|
+
# - Listar Pagos por Crédito:
|
10
|
+
#
|
11
|
+
# Creditario::Payments.list(credit_id: "2e9d05b8-2180-4779-bab6-bdfd41d1569f")
|
12
|
+
# => Creditario::ResourcesCollection
|
13
|
+
#
|
14
|
+
# - Crear un Pago:
|
15
|
+
#
|
16
|
+
# Creditario::Payments.create(installment_id: "9270cc36-5f90-448a-8fd8-cff7c7bd1f75", amount_cents: 100000, payment_type: "annuity", prepaid_type: "not_reduce", payment_method: "SPEI", forgive_penalty_interest: "false")
|
17
|
+
# => Creditario::Payment
|
18
|
+
module Payments
|
19
|
+
extend Creditario::API::List
|
20
|
+
extend Creditario::API::Create
|
21
|
+
|
22
|
+
###
|
23
|
+
# Path de la API donde se ejecutan las peticiones para Pagos.
|
24
|
+
def self.resource_path
|
25
|
+
"/payments"
|
26
|
+
end
|
27
|
+
|
28
|
+
###
|
29
|
+
# Clase a utilizar para transformar las respuestas de la API
|
30
|
+
def self.resource_class
|
31
|
+
Creditario::Payment
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Products
|
6
|
+
#
|
7
|
+
# Repositorio de Productos, permite realizar las siguientes operaciones
|
8
|
+
# sobre Productos de creditar.io:
|
9
|
+
#
|
10
|
+
# - Obtener todos los Productos Activos:
|
11
|
+
#
|
12
|
+
# result = Creditario::Products.list
|
13
|
+
# => Creditario::PaginatedCollection
|
14
|
+
#
|
15
|
+
# result.items
|
16
|
+
# => [Creditario::Product, Creditario::Product, ...]
|
17
|
+
#
|
18
|
+
# - Obtener un Producto en especifico:
|
19
|
+
#
|
20
|
+
# Creditario::Products.retrieve("c005b7f7-a44a-4ec0-bf7f-73d15d806fd9")
|
21
|
+
# => Creditario::Product
|
22
|
+
module Products
|
23
|
+
extend Creditario::API::List
|
24
|
+
extend Creditario::API::Retrieve
|
25
|
+
|
26
|
+
###
|
27
|
+
# Path de la API donde se ejecutan las peticiones para Productos.
|
28
|
+
def self.resource_path
|
29
|
+
"/products"
|
30
|
+
end
|
31
|
+
|
32
|
+
###
|
33
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
34
|
+
def self.resource_class
|
35
|
+
Creditario::Product
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::References
|
6
|
+
#
|
7
|
+
# Repositorio de Referencias, permite realizar las siguientes operaciones
|
8
|
+
# sobre Referencias para Solicitudes de Crédito de creditar.io
|
9
|
+
#
|
10
|
+
# - Obtener una Referencia en especifico:
|
11
|
+
#
|
12
|
+
# Creditario::References.retrieve("0b19e3b6-9fae-40e1-a7c2-f2db1cae8a5a")
|
13
|
+
# => Creditario::Referencia
|
14
|
+
#
|
15
|
+
# - Crear una Referencia:
|
16
|
+
#
|
17
|
+
# result = Creditario::References.create(classification: "Amistad", name: "Diane Nguyen", phone: "3129743789", credit_application_id: "636264b1-77a2-45ef-b643-e44cfbc84d40")
|
18
|
+
# => Creditario::Referencia
|
19
|
+
#
|
20
|
+
# - Eliminar una Referencia:
|
21
|
+
#
|
22
|
+
# result = Creditario::References.delete("0b19e3b6-9fae-40e1-a7c2-f2db1cae8a5a")
|
23
|
+
# => true
|
24
|
+
module References
|
25
|
+
extend Creditario::API::Retrieve
|
26
|
+
extend Creditario::API::Create
|
27
|
+
extend Creditario::API::Delete
|
28
|
+
|
29
|
+
###
|
30
|
+
# Path de la API donde se ejecutan las peticiones para Referencias.
|
31
|
+
def self.resource_path
|
32
|
+
"/references"
|
33
|
+
end
|
34
|
+
|
35
|
+
###
|
36
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
37
|
+
def self.resource_class
|
38
|
+
Creditario::Reference
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Application
|
6
|
+
#
|
7
|
+
# Representa una Aplicación de Credito del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => credit_application = Creditario::Application.new({"id": "636264b1-77a2-45ef-b643-e44cfbc84d40", "application_number": "UENDSND-1", "flow": "inicio"})
|
12
|
+
# => credit_application.id
|
13
|
+
# => "636264b1-77a2-45ef-b643-e44cfbc84d40"
|
14
|
+
# => credit_application.flow = "referencias"
|
15
|
+
# => "referencias"
|
16
|
+
# => credit_application[:application_number]
|
17
|
+
# => "UENDSND-1"
|
18
|
+
class Application
|
19
|
+
include Resource
|
20
|
+
|
21
|
+
has_one :product, class: Creditario::Product
|
22
|
+
has_one :contract, class: Creditario::Contract
|
23
|
+
has_many :incomes, class: Creditario::Income
|
24
|
+
has_many :expenses, class: Creditario::Expense
|
25
|
+
has_many :references, class: Creditario::Reference
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc
|
4
|
+
###
|
5
|
+
# == Creditario::Attachment
|
6
|
+
#
|
7
|
+
# Representa un Archivo del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => attachment = Creditario::Attachment.new({"id": "aabfd43d-6f63-44dd-b7d9-9352a101d11e", "attachment_type": "INE", "url": "http://creditar.io/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBGUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--4f40e5eabc39d2215d0ce08a1ad735df3bcf74b4/image.jpg"})
|
12
|
+
# => attachment.id
|
13
|
+
# => "aabfd43d-6f63-44dd-b7d9-9352a101d11e"
|
14
|
+
# => attachment[:url]
|
15
|
+
# => "http://creditario.io/rails/active_storage/blobs/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBGUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--4f40e5eabc39d2215d0ce08a1ad735df3bcf74b4/image.jpg"
|
16
|
+
class Attachment
|
17
|
+
include Resource
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Catalog
|
6
|
+
#
|
7
|
+
# Representa un Catálogo del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => catalog = Creditario::Catalog.new({resource: "customer", field: "source"})
|
12
|
+
# => catalog.resource
|
13
|
+
# => "customer"
|
14
|
+
# => catalog[:field]
|
15
|
+
# => "source"
|
16
|
+
class Catalog
|
17
|
+
include Resource
|
18
|
+
end
|
19
|
+
|
20
|
+
###
|
21
|
+
# == Creditario::CatalogValue
|
22
|
+
#
|
23
|
+
# Representa un Valor de Catálogo del sistema creditar.io
|
24
|
+
#
|
25
|
+
# === Ejemplo
|
26
|
+
#
|
27
|
+
# => catalog = Creditario::CatalogValue.new({name: "Revista", value: "revista"})
|
28
|
+
# => catalog.name
|
29
|
+
# => "Revista"
|
30
|
+
# => catalog[:value]
|
31
|
+
# => "revista"
|
32
|
+
class CatalogValue
|
33
|
+
include Resource
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Contract
|
6
|
+
#
|
7
|
+
# Representa un Contrato del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => contract = Creditario::Contract.new({"id": "c005b7f7-a44a-4ec0-bf7f-73d15d806fd9", body: "Contrato del Crédito..."})
|
12
|
+
# => contract.id
|
13
|
+
# => "c005b7f7-a44a-4ec0-bf7f-73d15d806fd9"
|
14
|
+
# => contract.body
|
15
|
+
# => "Contrato del Crédito..."
|
16
|
+
# => contract[:body]
|
17
|
+
# => "Contrato del Crédito..."
|
18
|
+
class Contract
|
19
|
+
include Resource
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Credit
|
6
|
+
#
|
7
|
+
# Representa un Crédito del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => credit = Creditario::Credit.new({"id": "636264b1-dc0d-453e-8804-4ac451e1dbd5", "credit_application_id": "636264b1-77a2-45ef-b643-e44cfbc84d40", "customer_id": "6313ac69-dc0d-45a8-8804-4ac451e1db5c", "contract_id": "0b19e3b6-9fae-40e1-a7c2-f2db1cae8a5a", "installment_plan": [] })
|
12
|
+
# => credit.id
|
13
|
+
# => "636264b1-dc0d-453e-8804-4ac451e1dbd5"
|
14
|
+
# => credit[:customer_id]
|
15
|
+
# => "6313ac69-dc0d-45a8-8804-4ac451e1db5c"
|
16
|
+
class Credit
|
17
|
+
include Resource
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::CreditEstimate
|
6
|
+
#
|
7
|
+
# Representa una Estimación de Crédito del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => credit_estimate = Creditario::CreditEstimate.new({ "total_interest_amount_cents": 100000, "total_credit_amount_cents": 1100000 })
|
12
|
+
# => credit_estimate.total_interest_amount_cents
|
13
|
+
# => 100000
|
14
|
+
# => credit_estimate[:total_credit_amount_cents]
|
15
|
+
# => 1100000
|
16
|
+
class CreditEstimate
|
17
|
+
include Resource
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Customer
|
6
|
+
#
|
7
|
+
# Representa un Cliente del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => customer = Creditario::Customer.new({first_name: "Juan", last_name: "Carlos", credit_applications: [{"id": "636264b1-77a2-45ef-b643-e44cfbc84d40"}]})
|
12
|
+
# => customer.first_name
|
13
|
+
# => "Juan"
|
14
|
+
# => customer.first_name = "Pepé"
|
15
|
+
# => "Pepé"
|
16
|
+
# => customer[:first_name]
|
17
|
+
# => "Pepé"
|
18
|
+
# => customer[:first_name] = "Juan"
|
19
|
+
# => "Juan"
|
20
|
+
class Customer
|
21
|
+
include Resource
|
22
|
+
|
23
|
+
has_many :credit_applications, class: Creditario::Application
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario
|
4
|
+
###
|
5
|
+
# == Creditario::Expense
|
6
|
+
#
|
7
|
+
# Representa un Egreso del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => expense = Creditario::Expense.new({"id": "aff581fc-ba6e-49f2-9be7-73ef20043d1c", "classification": "Renta", "amount_cents": 30000})
|
12
|
+
# => expense.id
|
13
|
+
# => aff581fc-ba6e-49f2-9be7-73ef20043d1c
|
14
|
+
# => expense[:amount_cents]
|
15
|
+
# => 30000
|
16
|
+
class Expense
|
17
|
+
include Resource
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Income
|
6
|
+
#
|
7
|
+
# Representa un Ingreso del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => income = Creditario::Income.new({"id": "2ff8779b-ba6e-49f2-9be7-73ef20043d1c", "classification": "Trabajo", "amount_cents": 500000})
|
12
|
+
# => income.id
|
13
|
+
# => 2ff8779b-ba6e-49f2-9be7-73ef20043d1c
|
14
|
+
# => income[:amount_cents]
|
15
|
+
# => 500000
|
16
|
+
class Income
|
17
|
+
include Resource
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Creditario # :nodoc:
|
4
|
+
###
|
5
|
+
# == Creditario::Payment
|
6
|
+
#
|
7
|
+
# Representa un Pago del sistema creditar.io
|
8
|
+
#
|
9
|
+
# === Ejemplo
|
10
|
+
#
|
11
|
+
# => payment = Creditario::Payment.new({"id": "6313ac69-dc0d-45a8-8804-4ac451e1db5c", "payment_type": "annuity", "amount_cents": 100000})
|
12
|
+
# => payment.id
|
13
|
+
# => "6313ac69-dc0d-45a8-8804-4ac451e1db5c"
|
14
|
+
# => payment.payment_type = "annuity"
|
15
|
+
# => "annuity"
|
16
|
+
# => payment[:amount_cents]
|
17
|
+
# => 100000
|
18
|
+
class Payment
|
19
|
+
include Resource
|
20
|
+
end
|
21
|
+
end
|