creditario-client 0.0.1.alpha
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 +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,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "creditario/client"
|
|
4
|
+
require "rails"
|
|
5
|
+
|
|
6
|
+
module Creditario # :nodoc:
|
|
7
|
+
class Railtie < Rails::Railtie # :nodoc:
|
|
8
|
+
railtie_name :creditario
|
|
9
|
+
|
|
10
|
+
generators do
|
|
11
|
+
require_relative "../../generators/creditario/install_generator"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario
|
|
4
|
+
###
|
|
5
|
+
# === Creditario::Exceptions
|
|
6
|
+
#
|
|
7
|
+
# Modulo para definir todas las excepciones reconocidas para esta gema.
|
|
8
|
+
module Exceptions
|
|
9
|
+
###
|
|
10
|
+
# Excepción arrojada cuando se intenta hacer un request sin haber
|
|
11
|
+
# especificado un api_key.
|
|
12
|
+
#
|
|
13
|
+
# Para arreglar este error es necesario definir el api_key de la siguiente manera:
|
|
14
|
+
#
|
|
15
|
+
# Creditario::Client.api_key = "tu-api-key"
|
|
16
|
+
class MissingAPIKeyError < StandardError
|
|
17
|
+
def initialize(msg = "No API Key Provided") # :nodoc:
|
|
18
|
+
super
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
###
|
|
23
|
+
# Excepción arrojada cuando se intenta acceder a algún recurso
|
|
24
|
+
# que no existe en creditar.io
|
|
25
|
+
#
|
|
26
|
+
# Si se rescata esta excepción, se puede acceder a su atributo *server_response*
|
|
27
|
+
# para obtener la respuesta de creditar.io
|
|
28
|
+
class ResourceNotFoundError < StandardError
|
|
29
|
+
###
|
|
30
|
+
# Contiene los detalles de la respuesta de creditar.io
|
|
31
|
+
attr_reader :server_response
|
|
32
|
+
|
|
33
|
+
def initialize(response) # :nodoc:
|
|
34
|
+
@server_response = Oj.load(response.body)
|
|
35
|
+
super(msg = "The resource does not exist")
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
###
|
|
40
|
+
# Excepción arrojada cuando durante la creación o actualización
|
|
41
|
+
# de algún recurso, se envían datos inválidos a creditar.io
|
|
42
|
+
#
|
|
43
|
+
# Si se rescata esta excepción, se puede acceder a su atributo *server_response*
|
|
44
|
+
# para obtener la respuesta de creditar.io
|
|
45
|
+
class UnprocessableEntityError < StandardError
|
|
46
|
+
###
|
|
47
|
+
# Contiene los detalles de la respuesta de creditar.io
|
|
48
|
+
attr_reader :server_response
|
|
49
|
+
|
|
50
|
+
def initialize(response) # :nodoc:
|
|
51
|
+
@server_response = Oj.load(response.body)
|
|
52
|
+
super(msg = "There are some validation issues")
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
###
|
|
57
|
+
# Excepción arrojada cuando existen restricciones para crear o modificar un
|
|
58
|
+
# recurso en creditar.io
|
|
59
|
+
#
|
|
60
|
+
# Si se rescata esta excepción, se puede acceder a su atributo *server_response*
|
|
61
|
+
# para obtener la respuesta de creditar.io
|
|
62
|
+
class ForbiddenError < StandardError
|
|
63
|
+
###
|
|
64
|
+
# Contiene los detalles de la respuesta de creditar.io
|
|
65
|
+
attr_reader :server_response
|
|
66
|
+
|
|
67
|
+
def initialize(response) # :nodoc:
|
|
68
|
+
@server_response = Oj.load(response.body)
|
|
69
|
+
super(msg = "There are restrictions on the resource")
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
###
|
|
74
|
+
# Excepción arrojada cuando se intenta hacer un request con una API Key inválida.
|
|
75
|
+
# Para arreglar este error es necesario definir la API Key correcta.
|
|
76
|
+
#
|
|
77
|
+
# Creditario::Client.api_key = "tu-api-key"
|
|
78
|
+
class InvalidAPIKeyError < StandardError
|
|
79
|
+
def initialize(msg = "The API Key provided is invalid or it has expired.") # :nodoc:
|
|
80
|
+
super
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
###
|
|
85
|
+
# Excepción arrojada cuando no se puede establecer comunicación con el servidor
|
|
86
|
+
# de la API de creditar.io
|
|
87
|
+
class APINotReachableError < StandardError
|
|
88
|
+
TECHNICAL_MESSAGE = "Technical message -> " # :nodoc:
|
|
89
|
+
HUMAN_MESSAGE = "Looks like the API for creditar.io is down.\n" # :nodoc:
|
|
90
|
+
|
|
91
|
+
def initialize(message) # :nodoc:
|
|
92
|
+
super(msg = "#{HUMAN_MESSAGE}#{TECHNICAL_MESSAGE}#{message}")
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
###
|
|
97
|
+
# Excepción arrojada cuando el servidor de creditar.io regresa una respuesta que no es JSON
|
|
98
|
+
# Probablemente estás mandando un header incorrecto.
|
|
99
|
+
class InvalidResponseBodyError < StandardError
|
|
100
|
+
TECHNICAL_MESSAGE = "Technical message -> " # :nodoc:
|
|
101
|
+
HUMAN_MESSAGE = "The API responded with something that is not JSON, is your request ok?\n" # :nodoc:
|
|
102
|
+
|
|
103
|
+
def initialize(message) # :nodoc:
|
|
104
|
+
super(msg = "#{HUMAN_MESSAGE}#{TECHNICAL_MESSAGE}#{message}")
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
###
|
|
109
|
+
# Excepción arrojada cuando el servidor de creditar.io se tarda mucho en responder.
|
|
110
|
+
# O cuando se pierde la conexión de internet a medio request.
|
|
111
|
+
# Probablemente reintentando la petición se solucione el problema.
|
|
112
|
+
class APIBusyError < StandardError
|
|
113
|
+
TECHNICAL_MESSAGE = "Technical message -> " # :nodoc:
|
|
114
|
+
HUMAN_MESSAGE = "The communication with the API has timed out.\n" # :nodoc:
|
|
115
|
+
|
|
116
|
+
def initialize(message) # :nodoc:
|
|
117
|
+
super(msg = "#{HUMAN_MESSAGE}#{TECHNICAL_MESSAGE}#{message}")
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::Applications
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Solicitudes de Crédito, permite realizar las siguientes operaciones
|
|
8
|
+
# sobre Solicitudes de Crédito de creditar.io
|
|
9
|
+
#
|
|
10
|
+
# - Obtener todas las Solicitudes:
|
|
11
|
+
#
|
|
12
|
+
# result = Creditario::Applications.list
|
|
13
|
+
# => Creditario::PaginatedCollection
|
|
14
|
+
#
|
|
15
|
+
# result.items
|
|
16
|
+
# => [Creditario::Application, Creditario::Application, ...]
|
|
17
|
+
#
|
|
18
|
+
# - Obtener una Solicitud en especifico:
|
|
19
|
+
#
|
|
20
|
+
# Creditario::Applications.retrieve("0b19e3b6-9fae-40e1-a7c2-f2db1cae8a5a")
|
|
21
|
+
# => Creditario::Application
|
|
22
|
+
#
|
|
23
|
+
# - Crear una Solicitud:
|
|
24
|
+
#
|
|
25
|
+
# result = Creditario::Applications.create(customer_id: "2e9d05b8-2180-4779-bab6-bdfd41d1569f", product_id: "c005b7f7-a44a-4ec0-bf7f-73d15d806fd9")
|
|
26
|
+
# => Creditario::Application
|
|
27
|
+
#
|
|
28
|
+
# - Actualizar una Solicitud:
|
|
29
|
+
#
|
|
30
|
+
# result = Creditario::Applications.update("c0324939-0802-41b2-b81e-04e8982270ec", { street: "Avenida Siempre Viva", exterior_number: "742" })
|
|
31
|
+
# => Creditario::Application
|
|
32
|
+
module Applications
|
|
33
|
+
extend Creditario::API::List
|
|
34
|
+
extend Creditario::API::Retrieve
|
|
35
|
+
extend Creditario::API::Create
|
|
36
|
+
extend Creditario::API::Update
|
|
37
|
+
|
|
38
|
+
###
|
|
39
|
+
# Path de la API donde se ejecutan las peticiones para Solicitudes.
|
|
40
|
+
def self.resource_path
|
|
41
|
+
"/applications"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
###
|
|
45
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
|
46
|
+
def self.resource_class
|
|
47
|
+
Creditario::Application
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::Attachments
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Archivos, permite realizar las siguientes operaciones
|
|
8
|
+
# sobre Archivos para Solicitudes de Crédito y Clientes de creditario.io
|
|
9
|
+
#
|
|
10
|
+
# - Obtener un Archivo en especifico:
|
|
11
|
+
#
|
|
12
|
+
# Creditario::Attachments.retrieve("aabfd43d-6f63-44dd-b7d9-9352a101d11e")
|
|
13
|
+
# => Creditario::Attachment
|
|
14
|
+
#
|
|
15
|
+
# - Crear un Archivo:
|
|
16
|
+
#
|
|
17
|
+
# Nota: Para el envío del archivo es necesario utilizar la clase +UploadIO.new+.
|
|
18
|
+
#
|
|
19
|
+
# file_upload_io = UploadIO.new(File.new("@/path/to/a/file.jpg"), "image/jpg", "file.jpg")
|
|
20
|
+
#
|
|
21
|
+
# result = Creditario::Attachments.create(
|
|
22
|
+
# attachmentable_type: "credit_application",
|
|
23
|
+
# attachmentable_id: "4e9ece5f-d4e6-4fcd-bc9b-b437bef23ceb",
|
|
24
|
+
# attachment_type: "INE",
|
|
25
|
+
# file: file_upload_io
|
|
26
|
+
# )
|
|
27
|
+
# => Creditario::Attachment
|
|
28
|
+
#
|
|
29
|
+
# - Eliminar un Archivo:
|
|
30
|
+
#
|
|
31
|
+
# result = Creditario::Attachments.delete("aabfd43d-6f63-44dd-b7d9-9352a101d11e")
|
|
32
|
+
# => true
|
|
33
|
+
class Attachments
|
|
34
|
+
extend Creditario::API::Multipart
|
|
35
|
+
extend Creditario::API::Retrieve
|
|
36
|
+
extend Creditario::API::Delete
|
|
37
|
+
|
|
38
|
+
###
|
|
39
|
+
# Path de la API donde se ejecutan las peticiones para Egresos.
|
|
40
|
+
def self.resource_path
|
|
41
|
+
"/attachments"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
###
|
|
45
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
|
46
|
+
def self.resource_class
|
|
47
|
+
Creditario::Attachment
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::Catalogs
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Catálogos, permite realizar las siguientes operaciones
|
|
8
|
+
# sobre Catálogos de creditar.io:
|
|
9
|
+
#
|
|
10
|
+
# - Obtener todos los Catálogos disponibles:
|
|
11
|
+
#
|
|
12
|
+
# result = Creditario::Catalogs.list
|
|
13
|
+
# => Creditario::ResourcesCollection
|
|
14
|
+
#
|
|
15
|
+
# result.items
|
|
16
|
+
# => [Creditario::Catalog, Creditario::Catalog, ...]
|
|
17
|
+
#
|
|
18
|
+
# - Obtener los valores de un Catálogo en especifico:
|
|
19
|
+
#
|
|
20
|
+
# Creditario::Catalog.retrieve(resource: "customer", field: "source")
|
|
21
|
+
# => Creditario::ResourcesCollection
|
|
22
|
+
module Catalogs
|
|
23
|
+
extend Creditario::API::List
|
|
24
|
+
|
|
25
|
+
###
|
|
26
|
+
# Path de la API donde se ejecutan las peticiones para Catálogos
|
|
27
|
+
def self.resource_path
|
|
28
|
+
if caller_locations[0].label == "retrieve"
|
|
29
|
+
"/catalog"
|
|
30
|
+
else
|
|
31
|
+
"/catalogs"
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
###
|
|
36
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
|
37
|
+
def self.resource_class
|
|
38
|
+
if caller_locations[0].label == "retrieve"
|
|
39
|
+
Creditario::CatalogValue
|
|
40
|
+
else
|
|
41
|
+
Creditario::Catalog
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
###
|
|
46
|
+
# Método para obtener los valores de un Catálogo, que generalmente son varios.
|
|
47
|
+
# Es por ello que no se extendió el modulo Creditario::API::Retrieve ya que ese está pensado
|
|
48
|
+
# para procesar un solo Recurso a la vez.
|
|
49
|
+
#
|
|
50
|
+
# Los *search_params* necesitan ser **resource** y **field** tal y como se especifica
|
|
51
|
+
# en la descripción del Repositorio Creditario::Catalogs.
|
|
52
|
+
def self.retrieve(**search_params)
|
|
53
|
+
response = API.request(:get, resource_path, search_params)
|
|
54
|
+
ResourcesCollection.new(response, self.resource_class)
|
|
55
|
+
rescue Creditario::Exceptions::ResourceNotFoundError => exception
|
|
56
|
+
exception.server_response
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::Contracts
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Contratos, permite realizar las siguientes operaciones
|
|
8
|
+
# sobre Contratos de creditar.io:
|
|
9
|
+
#
|
|
10
|
+
# - Obtener un Contrato en especifico:
|
|
11
|
+
#
|
|
12
|
+
# Creditario::Contracts.retrieve("c005b7f7-a44a-4ec0-bf7f-73d15d806fd9")
|
|
13
|
+
# => Creditario::Contract
|
|
14
|
+
module Contracts
|
|
15
|
+
extend Creditario::API::Retrieve
|
|
16
|
+
|
|
17
|
+
###
|
|
18
|
+
# Path de la API donde se ejecutan las peticiones para Contratos.
|
|
19
|
+
def self.resource_path
|
|
20
|
+
"/contracts"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
###
|
|
24
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
|
25
|
+
def self.resource_class
|
|
26
|
+
Creditario::Contract
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::CreditEstimates
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Estimaciones de Crédito, permite obtener una Estimación de Crédito
|
|
8
|
+
# en base a un Producto de creditar.io:
|
|
9
|
+
#
|
|
10
|
+
# - Obtener una Estimación:
|
|
11
|
+
#
|
|
12
|
+
# Creditario::CreditEstimates.retrieve(nil, product_id: "c005b7f7-a44a-4ec0-bf7f-73d15d806fd9", amount_cents: 1000000, installments_number: 12)
|
|
13
|
+
# => Creditario::CreditEstimate
|
|
14
|
+
module CreditEstimates
|
|
15
|
+
extend Creditario::API::Retrieve
|
|
16
|
+
|
|
17
|
+
###
|
|
18
|
+
# Path de la API donde se ejecutan las peticiones para Estimaciones.
|
|
19
|
+
def self.resource_path
|
|
20
|
+
"/credit_estimates"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
###
|
|
24
|
+
# Clase a utilizar para transformar las respuestas de la API.
|
|
25
|
+
def self.resource_class
|
|
26
|
+
Creditario::CreditEstimate
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::Credits
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Créditos, permite obtener la lista de Créditos a partir de un Cliente
|
|
8
|
+
# así como obtener un Crédito a partir de su ID.
|
|
9
|
+
#
|
|
10
|
+
# - Listar Créditos por Cliente:
|
|
11
|
+
#
|
|
12
|
+
# Creditario::Credits.list(customer_id: "2e9d05b8-2180-4779-bab6-bdfd41d1569f")
|
|
13
|
+
# => Creditario::ResourcesCollection
|
|
14
|
+
#
|
|
15
|
+
# - Obtener un Crédito:
|
|
16
|
+
#
|
|
17
|
+
# Creditario::Credits.retrieve("636264b1-dc0d-453e-8804-4ac451e1dbd5")
|
|
18
|
+
# => Creditario::Credit
|
|
19
|
+
module Credits
|
|
20
|
+
extend Creditario::API::List
|
|
21
|
+
extend Creditario::API::Retrieve
|
|
22
|
+
|
|
23
|
+
###
|
|
24
|
+
# Path de la API donde se ejecutan las peticiones para Créditos.
|
|
25
|
+
def self.resource_path
|
|
26
|
+
"/credits"
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
###
|
|
30
|
+
# Clase a utilizar para transformar las respuestas de la API
|
|
31
|
+
def self.resource_class
|
|
32
|
+
Creditario::Credit
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Creditario # :nodoc:
|
|
4
|
+
###
|
|
5
|
+
# == Creditario::Customers
|
|
6
|
+
#
|
|
7
|
+
# Repositorio de Clientes, permite realizar las siguientes operaciones
|
|
8
|
+
# sobre Clientes de creditar.io
|
|
9
|
+
#
|
|
10
|
+
# - Obtener todos los Clientes:
|
|
11
|
+
#
|
|
12
|
+
# result = Creditario::Customers.list
|
|
13
|
+
# => Creditario::PaginatedCollection
|
|
14
|
+
#
|
|
15
|
+
# result.items
|
|
16
|
+
# => [Creditario::Customer, Creditario::Customer, ...]
|
|
17
|
+
#
|
|
18
|
+
# - Obtener un Cliente en especifico:
|
|
19
|
+
#
|
|
20
|
+
# Creditario::Customers.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
|
|
21
|
+
# => Creditario::Customer
|
|
22
|
+
#
|
|
23
|
+
# - Crear un Cliente:
|
|
24
|
+
#
|
|
25
|
+
# result = Creditario::Customers.create(email: "karla@quieredinero.com")
|
|
26
|
+
# => Creditario::Customer
|
|
27
|
+
#
|
|
28
|
+
# - Actualizar un cliente:
|
|
29
|
+
#
|
|
30
|
+
# result = Creditario::Customers.update("2e9d05b8-2180-4779-bab6-bdfd41d1569f", { email: "karina@necesitadinero.com" })
|
|
31
|
+
# => Creditario::Customer
|
|
32
|
+
module Customers
|
|
33
|
+
extend Creditario::API::List
|
|
34
|
+
extend Creditario::API::Retrieve
|
|
35
|
+
extend Creditario::API::Create
|
|
36
|
+
extend Creditario::API::Update
|
|
37
|
+
|
|
38
|
+
###
|
|
39
|
+
# Path de la API donde se ejecutan las peticiones para Clientes.
|
|
40
|
+
def self.resource_path
|
|
41
|
+
"/customers"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
###
|
|
45
|
+
# Clase a utilizar para transformar las respuestas de la API
|
|
46
|
+
def self.resource_class
|
|
47
|
+
Creditario::Customer
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|