creditario-client 0.0.7.alpha → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 217be7d392fba8ad1ebe71041c71bd828e0756905a3d2acd01ac9fabdd0a67e0
4
- data.tar.gz: 024f36b22af15a41780602d9984b422a9ac863f5e0c97d9e47361b207819048b
3
+ metadata.gz: 46b308c258087cfbc03b9981c99bf430be8a508a8d3e5ba00e7f0de961e6cad5
4
+ data.tar.gz: '09d7a1455008f4180c81e8d39e263e97b9299d224c97211cbc55b3b953a1b7d7'
5
5
  SHA512:
6
- metadata.gz: 9381ab32b370ce549642676fb8d2bb53d257543b735109d1ed2f40e1fe83e6379c871af787e3dbdd2cf92c0a3ce6e668b1fd3d3bcc982f4268b58bf6e8595266
7
- data.tar.gz: 432e445cdf43cad23a4bc8d08207fa89d62f6d50698d451825be55e2189eb255cbfc3a72d6ea41cbd10e6da33f4c7b6c01ea541336ea8f00ebaf202d3e154a3d
6
+ metadata.gz: 502a00118b2ac43a3f3697ba301725d13dfce2be76f7f894af8dee696e11cc35a796723f464b70fd4dca0a54bcf814c975e5fd85f3b27138323b2c77e0fdc166
7
+ data.tar.gz: 76df6ff28807820bc92fb26b0ec48f800a0ce01ca1c7a04522200b76edf42a0d4676d7330b386d7dd02776b4ac63d8bdcf189a0f5785ab378527efe91f313795
@@ -0,0 +1,38 @@
1
+ name: "Release"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*.*.*'
7
+
8
+ jobs:
9
+ build:
10
+ name: Release
11
+ runs-on: ubuntu-18.04
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ with:
15
+ fetch-depth: 3
16
+
17
+ - name: Set up Ruby
18
+ uses: ruby/setup-ruby@v1
19
+ with:
20
+ ruby-version: 2.7.2
21
+ bundler-cache: true
22
+ cache-version: 1
23
+
24
+ - name: Get tag version
25
+ id: tag_version
26
+ run: |
27
+ echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
28
+
29
+ - name: Print tag version
30
+ run: echo ${{ steps.tag_version.outputs.VERSION }}
31
+
32
+ - name: Build gem
33
+ run: gem build creditario-client.gemspec
34
+
35
+ - name: Push gem
36
+ env:
37
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
38
+ run: gem push creditario-client-${{ steps.tag_version.outputs.VERSION}}.gem
data/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
@@ -14,3 +13,4 @@
14
13
  *.gem
15
14
 
16
15
  .tool-versions
16
+ .idea/
data/CHANGELOG CHANGED
@@ -1,3 +1,16 @@
1
+ VERSION 1.1.0
2
+
3
+ Release notes:
4
+
5
+ - Add repositories crowfunding investors, crowdfunds, funds, movements and contracts.
6
+
7
+ VERSION 1.0.1
8
+
9
+ Release notes:
10
+
11
+ - Upgrade for some gems
12
+ - HOTFIX: Creditario::API::Customers#create and Creditario::API::Multipart#create
13
+
1
14
  Version 0.0.7.alpha
2
15
 
3
16
  Release notes:
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ creditario-client (1.1.0)
5
+ multipart-post (= 2.0.0)
6
+ oj (~> 3.0.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
+ ast (2.4.2)
14
+ crack (0.4.5)
15
+ rexml
16
+ hashdiff (1.0.1)
17
+ jaro_winkler (1.5.4)
18
+ minitest (5.16.3)
19
+ multipart-post (2.0.0)
20
+ oj (3.0.11)
21
+ parallel (1.22.1)
22
+ parser (3.1.2.1)
23
+ ast (~> 2.4.1)
24
+ powerpack (0.1.3)
25
+ psych (4.0.4)
26
+ stringio
27
+ public_suffix (4.0.7)
28
+ rainbow (3.1.1)
29
+ rake (10.5.0)
30
+ rdoc (6.4.0)
31
+ psych (>= 4.0.0)
32
+ rexml (3.2.5)
33
+ rubocop (0.57.2)
34
+ jaro_winkler (~> 1.5.1)
35
+ parallel (~> 1.10)
36
+ parser (>= 2.5)
37
+ powerpack (~> 0.1)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ ruby-progressbar (~> 1.7)
40
+ unicode-display_width (~> 1.0, >= 1.0.1)
41
+ ruby-progressbar (1.11.0)
42
+ sdoc (1.1.0)
43
+ rdoc (>= 5.0)
44
+ stringio (3.0.2)
45
+ unicode-display_width (1.8.0)
46
+ webmock (3.4.2)
47
+ addressable (>= 2.3.6)
48
+ crack (>= 0.3.2)
49
+ hashdiff
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ bundler
56
+ creditario-client!
57
+ minitest (~> 5.0)
58
+ rake (~> 10.0)
59
+ rubocop (~> 0.57.2)
60
+ sdoc (~> 1.0)
61
+ webmock (~> 3.4.2)
62
+
63
+ BUNDLED WITH
64
+ 2.2.16
data/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  Solo añade a tu Gemfile:
6
6
 
7
- gem "creditario-client", git: "git@git.michelada.io:financial/creditario-client.git"
7
+ gem "creditario-client", git: "git@github.com:creditario/creditario-client.git"
8
8
 
9
9
  ## Uso
10
10
 
@@ -88,7 +88,7 @@ Las operaciones que puedes realizar sobre Productos son: listar y obtener.
88
88
 
89
89
  ### Clientes
90
90
 
91
- Las operaciones que puedes realizar sobre Clientes son: listar, obtener, crear y actualizar.
91
+ Las operaciones que puedes realizar sobre Clientes son: listar, obtener, verificar, crear y actualizar.
92
92
 
93
93
  #### Listar todos los Clientes
94
94
 
@@ -103,6 +103,11 @@ Las operaciones que puedes realizar sobre Clientes son: listar, obtener, crear y
103
103
  Creditario::Customers.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
104
104
  => Creditario::Customer
105
105
 
106
+ #### Verificar un Cliente
107
+
108
+ Creditario::Customers.exists(email: "usuario@needsmoney.com")
109
+ => Hash
110
+
106
111
  #### Crear un Cliente
107
112
 
108
113
  result = Creditario::Customers.create(email: "karla@quieredinero.com", product_id: "c005b7f7-a44a-4ec0-bf7f-73d15d806fd9")
@@ -1,7 +1,6 @@
1
1
  # coding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
-
5
4
  lib = File.expand_path("../lib", __FILE__)
6
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
6
  require "creditario/client/version"
@@ -23,10 +22,12 @@ Gem::Specification.new do |spec|
23
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
23
  spec.require_paths = ["lib"]
25
24
 
25
+ spec.required_ruby_version = ">= 2.7.0"
26
+
26
27
  spec.add_dependency "oj", "~> 3.0.0"
27
28
  spec.add_dependency "multipart-post", "2.0.0"
28
29
 
29
- spec.add_development_dependency "bundler", "~> 2.1.4"
30
+ spec.add_development_dependency "bundler"
30
31
  spec.add_development_dependency "rake", "~> 10.0"
31
32
  spec.add_development_dependency "minitest", "~> 5.0"
32
33
  spec.add_development_dependency "sdoc", "~> 1.0"
@@ -14,8 +14,16 @@ module Creditario # :nodoc:
14
14
  # Si todo sale bien devuelve una instancia del Recurso específico que el
15
15
  # Repositorio maneja.
16
16
  # De lo contrario, regresa un Hash con los errores arrojados por el servidor de creditar.io
17
- def create(**params)
18
- response = API.request(:post, self.resource_path, params)
17
+ #
18
+ # Nota: Si desea hacer uso de *multipart/form-data* es necesario pasar un parametro enctype con valor true
19
+ # para habilitarlo, por ejemplo:
20
+ #
21
+ # result = Creditario::Crowdfunding::Investors.create(email: "karla@quiereinvertir.com", encypte: true)
22
+ #
23
+ def create(params = {})
24
+ enctype = params.delete(:enctype) || false
25
+ request_method = enctype ? :multipart : :post
26
+ response = API.request(request_method, self.resource_path, params)
19
27
 
20
28
  attributes = response.dig("data").first
21
29
  links = response.dig("links")
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ require "base64"
3
+
4
+ module Creditario # :nodoc:
5
+ module API
6
+ ###
7
+ # == Creditario::API::Exists
8
+ #
9
+ # Modulo encargado de obtener si un recurso existe en la API de creditar.io
10
+ module Exists
11
+ ###
12
+ # Realiza una llamada GET al path del Repositorio que este haciendo uso
13
+ # de este modulo.
14
+ #
15
+ # Si todo sale bien devuelve una instancia del Recurso específico que el Repositorio maneja.
16
+ # De lo contrario, regresa un Hash con los errores arrojados por el servidor de creditar.io
17
+ def exists(query_params = {})
18
+ parts = [self.exists_resource_path]
19
+ path = parts.compact.join("/")
20
+ query_params[:cache] = true
21
+ query_params[:email] = Base64.encode64(query_params[:email])[0..-2]
22
+ response = API.request(:get, path, query_params)
23
+
24
+ rescue Creditario::Exceptions::ResourceNotFoundError => exception
25
+ exception.server_response
26
+ rescue Creditario::Exceptions::UnprocessableEntityError => exception
27
+ exception.server_response
28
+ end
29
+ end
30
+ end
31
+ end
@@ -14,7 +14,7 @@ module Creditario # :nodoc:
14
14
  # Si todo sale bien devuelve una instancia del Recurso específico que el
15
15
  # Repositorio maneja.
16
16
  # De lo contrario, regresa un Hash con los errores arrojados por el servidor de creditar.io
17
- def create(**params)
17
+ def create(params = {})
18
18
  response = API.request(:multipart, self.resource_path, params)
19
19
 
20
20
  attributes = response.dig("data").first
@@ -13,10 +13,18 @@ module Creditario # :nodoc:
13
13
  #
14
14
  # Si todo sale bien devuelve una instancia del Recurso específico que el Repositorio maneja.
15
15
  # De lo contrario, regresa un Hash con los errores arrojados por el servidor de creditar.io
16
+ #
17
+ # Nota: Si desea hacer uso de *multipart/form-data* es necesario pasar un parametro enctype con valor true
18
+ # para habilitarlo, por ejemplo:
19
+ #
20
+ # result = Creditario::Crowdfunding::Investors.update("97d58a6c-e943-46bf-b8ec-2db7b397bc17", full_name: "Steve Rogers", encypte: true)
21
+ #
16
22
  def update(id, params = {}, include_param = nil)
23
+ enctype = params.delete(:enctype) || false
17
24
  path = "#{self.resource_path}/#{id}"
18
25
  path = include_param.nil? ? path : path + "?include=#{include_param}"
19
- response = API.request(:patch, path, params)
26
+ request_method = enctype ? :multipart : :patch
27
+ response = API.request(request_method, path, params)
20
28
 
21
29
  attributes = response.dig("data").first
22
30
  links = response.dig("links")
@@ -4,6 +4,6 @@ module Creditario
4
4
  module Client
5
5
  ###
6
6
  # Versión actual de la gema *creditario-client*
7
- VERSION = "0.0.7.alpha"
7
+ VERSION = "1.1.0"
8
8
  end
9
9
  end
@@ -2,17 +2,17 @@
2
2
 
3
3
  require "oj"
4
4
 
5
+ require "creditario/exceptions"
5
6
  require "creditario/client/version"
6
7
  require "creditario/client/railtie" if defined?(Rails)
7
8
 
8
- require "creditario/exceptions"
9
-
10
9
  require "creditario/api/request"
11
10
  require "creditario/api/create"
12
11
  require "creditario/api/multipart"
13
12
  require "creditario/api/delete"
14
13
  require "creditario/api/list"
15
14
  require "creditario/api/retrieve"
15
+ require "creditario/api/exists"
16
16
  require "creditario/api/update"
17
17
 
18
18
  require "creditario/utils/paginated_collection"
@@ -33,6 +33,13 @@ require "creditario/resources/credit"
33
33
  require "creditario/resources/payment"
34
34
  require "creditario/resources/movement"
35
35
  require "creditario/resources/qualify_score_flow"
36
+ require "creditario/resources/investor"
37
+
38
+ require "creditario/resources/crowdfunding/fund"
39
+ require "creditario/resources/crowdfunding/investor"
40
+ require "creditario/resources/crowdfunding/movement"
41
+ require "creditario/resources/crowdfunding/contract"
42
+ require "creditario/resources/crowdfunding/crowdfund"
36
43
 
37
44
  require "creditario/repositories/applications"
38
45
  require "creditario/repositories/customers"
@@ -49,6 +56,13 @@ require "creditario/repositories/payments"
49
56
  require "creditario/repositories/movements"
50
57
  require "creditario/repositories/qualify_score_flows"
51
58
  require "creditario/repositories/convert_application_to_credits"
59
+ require "creditario/repositories/investors"
60
+
61
+ require "creditario/repositories/crowdfunding/investors"
62
+ require "creditario/repositories/crowdfunding/crowdfunds"
63
+ require "creditario/repositories/crowdfunding/funds"
64
+ require "creditario/repositories/crowdfunding/movements"
65
+ require "creditario/repositories/crowdfunding/contracts"
52
66
 
53
67
  module Creditario # :nodoc:
54
68
  ###
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ ###
6
+ # == Creditario::Crowdfunding::Contracts
7
+ #
8
+ # Repositorio de Contracto del Inversionistas, permite realizar las siguientes operaciones
9
+ # sobre Contracto del Inversionistas de creditar.io
10
+ #
11
+ # - Obtener un Contracto del Inversionista en especifico:
12
+ #
13
+ # Creditario::Crowdfunding::Contracts.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
14
+ # => Creditario::Crowdfunding::Contract
15
+ #
16
+ module Contracts
17
+ extend Creditario::API::Retrieve
18
+
19
+ ###
20
+ # Path de la API donde se ejecutan las peticiones para Contracto del Inversionistas.
21
+ def self.resource_path
22
+ "/crowdfunding/investor_contracts"
23
+ end
24
+
25
+ ###
26
+ # Clase a utilizar para transformar las respuestas de la API
27
+ def self.resource_class
28
+ Creditario::Crowdfunding::Contract
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ ###
6
+ # == Creditario::Crowdfunding::Crowdfunds
7
+ #
8
+ # Repositorio de Campañas de fondos, permite realizar las siguientes operaciones
9
+ # sobre Campañas de fondos de creditar.io
10
+ #
11
+ # - Obtener todas las Campañas de fondos:
12
+ #
13
+ # result = Creditario::Crowdfunding::Crowdfunds.list
14
+ # => Creditario::PaginatedCollection
15
+ #
16
+ # result.items
17
+ # => [Creditario::Crowdfunding::Crowdfund, Creditario::Crowdfunding::Crowdfund, ...]
18
+ #
19
+ # - Obtener una Campaña de fondos en especifico:
20
+ #
21
+ # Creditario::Crowdfunding::Crowdfunds.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
22
+ # => Creditario::Crowdfunding::Crowdfund
23
+ #
24
+ # - Crear una Campaña de fondos:
25
+ #
26
+ # result = Creditario::Crowdfunding::Crowdfunds.create(amount_cents: 100000000, ... ,campaing_days: 30)
27
+ # => Creditario::Crowdfunding::Crowdfund
28
+ #
29
+ module Crowdfunds
30
+ extend Creditario::API::List
31
+ extend Creditario::API::Retrieve
32
+ extend Creditario::API::Create
33
+
34
+ ###
35
+ # Path de la API donde se ejecutan las peticiones para campañas de fondos.
36
+ def self.resource_path
37
+ "/crowdfunding/crowdfunds"
38
+ end
39
+
40
+ ###
41
+ # Clase a utilizar para transformar las respuestas de la API
42
+ def self.resource_class
43
+ Creditario::Crowdfunding::Crowdfund
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ ###
6
+ # == Creditario::Crowdfunding::Funds
7
+ #
8
+ # Repositorio de Fondos, permite realizar las siguientes operaciones
9
+ # sobre Fondos de creditar.io
10
+ #
11
+ # - Obtener todos los Fondos:
12
+ #
13
+ # result = Creditario::Crowdfunding::Funds.list
14
+ # => Creditario::PaginatedCollection
15
+ #
16
+ # result.items
17
+ # => [Creditario::Crowdfunding::Fund, Creditario::Crowdfunding::Fund, ...]
18
+ #
19
+ # - Obtener un Fondo en especifico:
20
+ #
21
+ # Creditario::Crowdfunding::Funds.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
22
+ # => Creditario::Crowdfunding::Fund
23
+ #
24
+ # - Crear un Fondo:
25
+ #
26
+ # result = Creditario::Crowdfunding::Funds.create(amount_cents: 1000000, ..., crowdfund_id: "fef6ced1-a462-4d78-af50-70528eb2986b")
27
+ # => Creditario::Crowdfunding::Fund
28
+ #
29
+ module Funds
30
+ extend Creditario::API::List
31
+ extend Creditario::API::Retrieve
32
+ extend Creditario::API::Create
33
+
34
+ ###
35
+ # Path de la API donde se ejecutan las peticiones para Fondos.
36
+ def self.resource_path
37
+ "/crowdfunding/funds"
38
+ end
39
+
40
+ ###
41
+ # Clase a utilizar para transformar las respuestas de la API
42
+ def self.resource_class
43
+ Creditario::Crowdfunding::Fund
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ ###
6
+ # == Creditario::Crowdfunding::Investors
7
+ #
8
+ # Repositorio de Inversionistas, permite realizar las siguientes operaciones
9
+ # sobre Inversionistas de creditar.io
10
+ #
11
+ # - Obtener todos los Inversionistas:
12
+ #
13
+ # result = Creditario::Crowdfunding::Investors.list
14
+ # => Creditario::PaginatedCollection
15
+ #
16
+ # result.items
17
+ # => [Creditario::Crowdfunding::Investor, Creditario::Crowdfunding::Investor, ...]
18
+ #
19
+ # - Obtener un Inversionista en especifico:
20
+ #
21
+ # Creditario::Crowdfunding::Investors.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
22
+ # => Creditario::Crowdfunding::Investor
23
+ #
24
+ # - Crear un Inversionista:
25
+ #
26
+ # result = Creditario::Crowdfunding::Investors.create(email: "karla@quiereinvertir.com")
27
+ # => Creditario::Crowdfunding::Investor
28
+ #
29
+ module Investors
30
+ extend Creditario::API::List
31
+ extend Creditario::API::Retrieve
32
+ extend Creditario::API::Create
33
+ extend Creditario::API::Update
34
+
35
+ ###
36
+ # Path de la API donde se ejecutan las peticiones para Inversionistas.
37
+ def self.resource_path
38
+ "/crowdfunding/investors"
39
+ end
40
+
41
+ ###
42
+ # Clase a utilizar para transformar las respuestas de la API
43
+ def self.resource_class
44
+ Creditario::Crowdfunding::Investor
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ ###
6
+ # == Creditario::Crowdfunding::Movements
7
+ #
8
+ # Repositorio de Movimientos del Inversionistas, permite realizar las siguientes operaciones
9
+ # sobre Movimientos del Inversionistas de creditar.io
10
+ #
11
+ # - Obtener todos los Movimientos del Inversionistas:
12
+ #
13
+ # result = Creditario::Crowdfunding::Movements.list
14
+ # => Creditario::PaginatedCollection
15
+ #
16
+ # result.items
17
+ # => [Creditario::Crowdfunding::Movement, Creditario::Crowdfunding::Movement, ...]
18
+ #
19
+ # - Obtener un Movimientos del Inversionista en especifico:
20
+ #
21
+ # Creditario::Crowdfunding::Movements.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
22
+ # => Creditario::Crowdfunding::Movement
23
+ #
24
+ # - Crear un Movimientos del Inversionista:
25
+ #
26
+ # result = Creditario::Crowdfunding::Movements.create(amount_cents: 100000, ..., investor_id: "a7454cdb-c695-4db0-9df7-edf87944404d")
27
+ # => Creditario::Crowdfunding::Movement
28
+ #
29
+ module Movements
30
+ extend Creditario::API::List
31
+ extend Creditario::API::Retrieve
32
+ extend Creditario::API::Create
33
+
34
+ ###
35
+ # Path de la API donde se ejecutan las peticiones para Movimientos del Inversionistas.
36
+ def self.resource_path
37
+ "/crowdfunding/movements"
38
+ end
39
+
40
+ ###
41
+ # Clase a utilizar para transformar las respuestas de la API
42
+ def self.resource_class
43
+ Creditario::Crowdfunding::Movement
44
+ end
45
+ end
46
+ end
47
+ end
@@ -32,6 +32,7 @@ module Creditario # :nodoc:
32
32
  module Customers
33
33
  extend Creditario::API::List
34
34
  extend Creditario::API::Retrieve
35
+ extend Creditario::API::Exists
35
36
  extend Creditario::API::Create
36
37
  extend Creditario::API::Update
37
38
 
@@ -41,6 +42,11 @@ module Creditario # :nodoc:
41
42
  "/customers"
42
43
  end
43
44
 
45
+ # Path de la API donde se ejecutan las peticiones para Clientes, especificamente para existss.
46
+ def self.exists_resource_path
47
+ "/exists/customer"
48
+ end
49
+
44
50
  ###
45
51
  # Clase a utilizar para transformar las respuestas de la API
46
52
  def self.resource_class
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ ###
5
+ # == Creditario::Investors
6
+ #
7
+ # Repositorio de Inversionistas, permite realizar las siguientes operaciones
8
+ # sobre Inversionistas de creditar.io
9
+ #
10
+ # - Obtener todos los Inversionistas:
11
+ #
12
+ # result = Creditario::Investors.list
13
+ # => Creditario::PaginatedCollection
14
+ #
15
+ # result.items
16
+ # => [Creditario::Investor, Creditario::Investor, ...]
17
+ #
18
+ # - Obtener un Inversionista en especifico:
19
+ #
20
+ # Creditario::Investors.retrieve("2e9d05b8-2180-4779-bab6-bdfd41d1569f")
21
+ # => Creditario::Investor
22
+ #
23
+ # - Crear un Inversionista:
24
+ #
25
+ # result = Creditario::Investors.create(email: "karla@quiereinvertir.com")
26
+ # => Creditario::Investor
27
+ #
28
+ module Investors
29
+ extend Creditario::API::List
30
+ extend Creditario::API::Retrieve
31
+ extend Creditario::API::Create
32
+
33
+ ###
34
+ # Path de la API donde se ejecutan las peticiones para Inversionistas.
35
+ def self.resource_path
36
+ "/crowdfunding/investors"
37
+ end
38
+
39
+ ###
40
+ # Clase a utilizar para transformar las respuestas de la API
41
+ def self.resource_class
42
+ Creditario::Investor
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ class Contract # :nodoc:
6
+ include Resource
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ class Crowdfund # :nodoc:
6
+ include Creditario::Resource
7
+
8
+ has_one :credit_application, class: "Creditario::Application"
9
+ has_one :credit, class: "Creditario::Credit"
10
+ has_many :funds, class: "Creditario::Crowdfunding::Fund"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ class Fund # :nodoc:
6
+ include Resource
7
+
8
+ has_one :investor, class: "Creditario::Crowdfunding::Investor"
9
+ has_one :crowdfund, class: "Creditario::Crowdfunding::Crowdfund"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ module Crowdfunding # :nodoc:
5
+ class Investor # :nodoc:
6
+ include Resource
7
+
8
+ has_one :customer, class: "Creditario::Customer"
9
+ has_many :funds, class: "Creditario::Crowdfunding::Fund"
10
+ has_many :movements, class: "Creditario::Crowdfunding::Movement"
11
+ has_one :contract, class: "Creditario::Crowdfunding::Contract"
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "investor"
4
+ require_relative "fund"
5
+
6
+ module Creditario # :nodoc:
7
+ module Crowdfunding # :nodoc:
8
+ class Movement # :nodoc:
9
+ include Resource
10
+
11
+ has_one :investor, class: "Creditario::Crowdfunding::Investor"
12
+ has_one :fund, class: "Creditario::Crowdfunding::Fund"
13
+ has_one :payment, class: "Creditario::Payment"
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Creditario # :nodoc:
4
+ class Investor # :nodoc:
5
+ include Resource
6
+ end
7
+ end
@@ -62,7 +62,7 @@ module Creditario # :nodoc:
62
62
  if self.class.class_variable_defined?(:@@associations)
63
63
  association = self.class.class_variable_get(:@@associations).find { |association| association[:name] == attribute.to_sym }
64
64
  unless association.nil?
65
- attributes[attribute] = build_associations(association[:class], value)
65
+ attributes[attribute] = build_associations(constantize(association[:class].to_s), value)
66
66
  end
67
67
  end
68
68
 
@@ -70,6 +70,10 @@ module Creditario # :nodoc:
70
70
  end
71
71
  end
72
72
 
73
+ def constantize(camel_cased_word)
74
+ Object.const_get(camel_cased_word)
75
+ end
76
+
73
77
  def define_attribute_setter_and_getter(attribute, value)
74
78
  self.class.define_method(attribute) do
75
79
  attributes[attribute]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: creditario-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7.alpha
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - michelada.io
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-05-22 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.4
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.4
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -130,6 +130,7 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".DS_Store"
133
+ - ".github/workflows/release.yml"
133
134
  - ".gitignore"
134
135
  - ".gitlab-ci.yml"
135
136
  - ".rubocop.yml"
@@ -138,6 +139,7 @@ files:
138
139
  - CODE_OF_CONDUCT.md
139
140
  - Dockerfile
140
141
  - Gemfile
142
+ - Gemfile.lock
141
143
  - LICENSE.txt
142
144
  - README.md
143
145
  - Rakefile
@@ -146,6 +148,7 @@ files:
146
148
  - creditario-client.gemspec
147
149
  - lib/creditario/api/create.rb
148
150
  - lib/creditario/api/delete.rb
151
+ - lib/creditario/api/exists.rb
149
152
  - lib/creditario/api/list.rb
150
153
  - lib/creditario/api/multipart.rb
151
154
  - lib/creditario/api/request.rb
@@ -162,9 +165,15 @@ files:
162
165
  - lib/creditario/repositories/convert_application_to_credits.rb
163
166
  - lib/creditario/repositories/credit_estimates.rb
164
167
  - lib/creditario/repositories/credits.rb
168
+ - lib/creditario/repositories/crowdfunding/contracts.rb
169
+ - lib/creditario/repositories/crowdfunding/crowdfunds.rb
170
+ - lib/creditario/repositories/crowdfunding/funds.rb
171
+ - lib/creditario/repositories/crowdfunding/investors.rb
172
+ - lib/creditario/repositories/crowdfunding/movements.rb
165
173
  - lib/creditario/repositories/customers.rb
166
174
  - lib/creditario/repositories/expenses.rb
167
175
  - lib/creditario/repositories/incomes.rb
176
+ - lib/creditario/repositories/investors.rb
168
177
  - lib/creditario/repositories/movements.rb
169
178
  - lib/creditario/repositories/payments.rb
170
179
  - lib/creditario/repositories/products.rb
@@ -176,9 +185,15 @@ files:
176
185
  - lib/creditario/resources/contract.rb
177
186
  - lib/creditario/resources/credit.rb
178
187
  - lib/creditario/resources/credit_estimate.rb
188
+ - lib/creditario/resources/crowdfunding/contract.rb
189
+ - lib/creditario/resources/crowdfunding/crowdfund.rb
190
+ - lib/creditario/resources/crowdfunding/fund.rb
191
+ - lib/creditario/resources/crowdfunding/investor.rb
192
+ - lib/creditario/resources/crowdfunding/movement.rb
179
193
  - lib/creditario/resources/customer.rb
180
194
  - lib/creditario/resources/expense.rb
181
195
  - lib/creditario/resources/income.rb
196
+ - lib/creditario/resources/investor.rb
182
197
  - lib/creditario/resources/movement.rb
183
198
  - lib/creditario/resources/payment.rb
184
199
  - lib/creditario/resources/product.rb
@@ -205,14 +220,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
220
  requirements:
206
221
  - - ">="
207
222
  - !ruby/object:Gem::Version
208
- version: '0'
223
+ version: 2.7.0
209
224
  required_rubygems_version: !ruby/object:Gem::Requirement
210
225
  requirements:
211
- - - ">"
226
+ - - ">="
212
227
  - !ruby/object:Gem::Version
213
- version: 1.3.1
228
+ version: '0'
214
229
  requirements: []
215
- rubygems_version: 3.0.8
230
+ rubygems_version: 3.1.4
216
231
  signing_key:
217
232
  specification_version: 4
218
233
  summary: Ruby Client for the creditar.io API