creditario-client 1.0.1 → 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: edff92238e7b48b02ae3e3ef0a504762f153cbc16177f886c9c60ede5bca86a5
4
- data.tar.gz: 5aeb1276ded13cbdcf1c0c09de1cdbef72014406930cbaf09e8f7b63423acfde
3
+ metadata.gz: 46b308c258087cfbc03b9981c99bf430be8a508a8d3e5ba00e7f0de961e6cad5
4
+ data.tar.gz: '09d7a1455008f4180c81e8d39e263e97b9299d224c97211cbc55b3b953a1b7d7'
5
5
  SHA512:
6
- metadata.gz: 7756a2b8335aef92fa8cacd8a2cb62fbdc96c859d2c28193f4d76d95437e1b054e27e4b93a0337ca938c06f80785e3232c383794cee6b51917739944c002e7ac
7
- data.tar.gz: a06f1f6feb3cbc174ae535e257581edc971932537be094a38be7abfdf03f989f2fe4febad3a43e89d56aa4ac1a41d158441c22ecadfe8326aa14292c119845d9
6
+ metadata.gz: 502a00118b2ac43a3f3697ba301725d13dfce2be76f7f894af8dee696e11cc35a796723f464b70fd4dca0a54bcf814c975e5fd85f3b27138323b2c77e0fdc166
7
+ data.tar.gz: 76df6ff28807820bc92fb26b0ec48f800a0ce01ca1c7a04522200b76edf42a0d4676d7330b386d7dd02776b4ac63d8bdcf189a0f5785ab378527efe91f313795
@@ -35,4 +35,4 @@ jobs:
35
35
  - name: Push gem
36
36
  env:
37
37
  GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
38
- run: gem push creditario-client-${{steps.tag_version.outputs.VERSION}}.gem
38
+ run: gem push creditario-client-${{ steps.tag_version.outputs.VERSION}}.gem
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ VERSION 1.1.0
2
+
3
+ Release notes:
4
+
5
+ - Add repositories crowfunding investors, crowdfunds, funds, movements and contracts.
6
+
1
7
  VERSION 1.0.1
2
8
 
3
9
  Release notes:
@@ -5,7 +11,6 @@ Release notes:
5
11
  - Upgrade for some gems
6
12
  - HOTFIX: Creditario::API::Customers#create and Creditario::API::Multipart#create
7
13
 
8
-
9
14
  Version 0.0.7.alpha
10
15
 
11
16
  Release notes:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- creditario-client (1.0.1)
4
+ creditario-client (1.1.0)
5
5
  multipart-post (= 2.0.0)
6
6
  oj (~> 3.0.0)
7
7
 
@@ -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"
@@ -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
+ #
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
+ #
17
23
  def create(params = {})
18
- response = API.request(:post, self.resource_path, 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")
@@ -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 = "1.0.1"
7
+ VERSION = "1.1.0"
8
8
  end
9
9
  end
@@ -2,11 +2,10 @@
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"
@@ -36,6 +35,12 @@ require "creditario/resources/movement"
36
35
  require "creditario/resources/qualify_score_flow"
37
36
  require "creditario/resources/investor"
38
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"
43
+
39
44
  require "creditario/repositories/applications"
40
45
  require "creditario/repositories/customers"
41
46
  require "creditario/repositories/products"
@@ -53,6 +58,12 @@ require "creditario/repositories/qualify_score_flows"
53
58
  require "creditario/repositories/convert_application_to_credits"
54
59
  require "creditario/repositories/investors"
55
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"
66
+
56
67
  module Creditario # :nodoc:
57
68
  ###
58
69
  # == Creditario::Client
@@ -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
@@ -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
@@ -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: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - michelada.io
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-17 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
@@ -122,7 +122,7 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 3.4.2
125
- description:
125
+ description:
126
126
  email:
127
127
  - info@michelada.io
128
128
  executables: []
@@ -165,6 +165,11 @@ files:
165
165
  - lib/creditario/repositories/convert_application_to_credits.rb
166
166
  - lib/creditario/repositories/credit_estimates.rb
167
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
168
173
  - lib/creditario/repositories/customers.rb
169
174
  - lib/creditario/repositories/expenses.rb
170
175
  - lib/creditario/repositories/incomes.rb
@@ -180,6 +185,11 @@ files:
180
185
  - lib/creditario/resources/contract.rb
181
186
  - lib/creditario/resources/credit.rb
182
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
183
193
  - lib/creditario/resources/customer.rb
184
194
  - lib/creditario/resources/expense.rb
185
195
  - lib/creditario/resources/income.rb
@@ -202,7 +212,7 @@ homepage: https://www.creditar.io
202
212
  licenses:
203
213
  - MIT
204
214
  metadata: {}
205
- post_install_message:
215
+ post_install_message:
206
216
  rdoc_options: []
207
217
  require_paths:
208
218
  - lib
@@ -217,8 +227,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
227
  - !ruby/object:Gem::Version
218
228
  version: '0'
219
229
  requirements: []
220
- rubygems_version: 3.1.6
221
- signing_key:
230
+ rubygems_version: 3.1.4
231
+ signing_key:
222
232
  specification_version: 4
223
233
  summary: Ruby Client for the creditar.io API
224
234
  test_files: []