youlend 1.0.2 → 1.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 126e7fc7a5c9de8aeb4edb0f0cf1d8eb8d26f278aacae932cdcb9a37f9ad8b29
4
- data.tar.gz: f191162bbe623e51e42b04a5ca8eb362d2cb9ea1013e7a5c7edeaca6102312ca
3
+ metadata.gz: 753df522751bc4e37f063c0465712af287e0fbaeed9c0acff47f5aa32c4d0afe
4
+ data.tar.gz: 2887079f70a94f202c181420f91fa488f052e09d91dba221f7eaa2154772e577
5
5
  SHA512:
6
- metadata.gz: c112d229b26ea67974658bb9269b04bab1a63c1f0a12d2335901ea43155b539fff2e55292d85c707827176006929dd9977df71320ee3109979c9a3a34a522f1e
7
- data.tar.gz: 41cbed12eb598138645524229e0411fc4abff5d570f66f310c301b1ba542c1474c51e5d7ece9241e267de2ca0f97ad6cfe7e80a20be246ab624b2048a004b8b0
6
+ metadata.gz: 4cb5cd6c2ed7586afd475ca38394d4a4c7d0e74f2ccc4d29dcce5891a57cd88e9474824718de02a4620ee32e6019b5550678b6723b3c7936d14ba2c2287b6f48
7
+ data.tar.gz: f20ec73ba109a0c15ea17d2004a760b60635ae7f4e8e63161a50ca074cfbeb5a1753e65dcdd39be251c32d0ee719553a1cbb2d6f61f5ef9489dff8b7fb21ed94
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- youlend (1.0.2)
4
+ youlend (1.1.1)
5
5
  addressable
6
6
  faraday
7
7
  faraday_middleware
data/bin/console CHANGED
@@ -3,8 +3,8 @@
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'youlend'
6
- require 'youlend/merchant_generator'
7
- require 'youlend/lead_generator'
6
+ require 'youlend/params_generators/prequalification'
7
+ require 'youlend/params_generators/lead'
8
8
 
9
9
  require 'dotenv'
10
10
  Dotenv.load
@@ -15,12 +15,12 @@ Youlend.configure do |config|
15
15
  config.debug = true
16
16
  end
17
17
 
18
- def generate_merchant
19
- Youlend::MerchantGenerator.generate
18
+ def generate_prequalification
19
+ Youlend::ParamsGenerators::Prequalification.generate
20
20
  end
21
21
 
22
22
  def generate_lead
23
- Youlend::LeadGenerator.generate
23
+ Youlend::ParamsGenerators::Lead.generate
24
24
  end
25
25
 
26
26
  require 'pry'
data/lib/youlend.rb CHANGED
@@ -4,7 +4,7 @@ require 'youlend/version'
4
4
  require 'youlend/auth'
5
5
  require 'youlend/configuration'
6
6
  require 'youlend/connection'
7
- require 'youlend/quote'
7
+ require 'youlend/prequalification'
8
8
  require 'youlend/lead'
9
9
 
10
10
  module Youlend
data/lib/youlend/lead.rb CHANGED
@@ -3,6 +3,10 @@
3
3
  # Following the API description here: https://staging.youlend.com/developer/main/onboardingdoc
4
4
  module Youlend
5
5
  class Lead
6
+ def self.create(params)
7
+ new(params).create
8
+ end
9
+
6
10
  def initialize(params)
7
11
  @id = nil
8
12
  @params = params
@@ -12,10 +16,6 @@ module Youlend
12
16
  Youlend.connection.post('/onboarding/Leads', :onboarding, @params)
13
17
  end
14
18
 
15
- def self.create(params)
16
- new(params).create
17
- end
18
-
19
19
  def self.details(lead_id)
20
20
  Youlend.connection.get("/onboarding/Leads/#{lead_id}/details", :onboarding)
21
21
  end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faker'
4
+
5
+ module Youlend
6
+ module ParamsGenerators
7
+ class Lead
8
+ def self.generate
9
+ new.generate
10
+ end
11
+
12
+ def initialize
13
+ Faker::Config.locale = 'en-GB'
14
+
15
+ generate
16
+ end
17
+
18
+ # Mandatory fields:
19
+ # * CompanyName
20
+ # * CompanyType (ltd, plc, llp, dac, soleTrader, aps, as, ks, ivs and is)
21
+ # * MonthsTrading
22
+ # * CountryISOCode (GBR, DNK and IRE)
23
+ # * KeyContactName
24
+ # * ThirdPartyLeadId
25
+ # * RegisteredAddress
26
+ # * ContactPhoneNumber
27
+ # * MonthlyCardRevenue (must be greater than or equal to '1000')
28
+ # * ContactEmailAddress
29
+ # * LoanCurrencyISOCode (ISO 4217 currency code. Valid codes are GBP, EUR and DKK)
30
+ # * ThirdPartyCustomerId
31
+ def generate
32
+ {
33
+ companyName: 'HOKO LTD',
34
+ companyType: 'ltd',
35
+ monthsTrading: rand(3..10),
36
+ countryISOCode: 'GBR',
37
+ keyContactName: Faker::Name.name,
38
+ thirdPartyLeadId: SecureRandom.uuid,
39
+ registeredAddress: address,
40
+ contactPhoneNumber: Faker::PhoneNumber.phone_number,
41
+ monthlyCardRevenue: 10_000,
42
+ contactEmailAddress: Faker::Internet.email,
43
+ loanCurrencyISOCode: 'GBP',
44
+ thirdPartyCustomerId: SecureRandom.uuid,
45
+ companyNumber: '09525857', # optional
46
+ notificationURL: Faker::Internet.url, # optional
47
+ thirdPartyMerchantId: SecureRandom.uuid # optional
48
+ }
49
+ end
50
+
51
+ private
52
+
53
+ def address
54
+ {
55
+ line1: Faker::Address.street_address,
56
+ line2: Faker::Address.secondary_address,
57
+ city: 'London',
58
+ region: 'London',
59
+ areaCode: Faker::Address.zip_code,
60
+ country: 'UK'
61
+ }
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faker'
4
+
5
+ module Youlend
6
+ module ParamsGenerators
7
+ class Prequalification
8
+ def self.generate
9
+ new.generate
10
+ end
11
+
12
+ def initialize
13
+ Faker::Config.locale = 'en-GB'
14
+
15
+ generate
16
+ end
17
+
18
+ # Mandatory fields:
19
+ # * CompanyType (ltd, plc, llp, dac, partnership, soleTrader, aps, as, ks, ivs and is)
20
+ # * FinancialData
21
+ # * CountryISOCode (GBR, DNK and IRE)
22
+ # * LoanCurrencyISOCode (ISO 4217 currency code. Valid codes are GBP, EUR and DKK)
23
+ # * ThirdPartyMerchantId
24
+ #
25
+ # The only mandatory field should be the financial data. You SHOULD NOT provide company
26
+ # number, otherwise Youlend needs to ask for permission on credit checks.
27
+ def generate
28
+ {
29
+ companyType: 'ltd',
30
+ financialData: financial_data,
31
+ countryISOCode: 'GBR',
32
+ loanCurrencyISOCode: 'GBP',
33
+ thirdPartyMerchantId: SecureRandom.uuid,
34
+ companyName: 'HOKO LTD', # optional
35
+ companyNumber: '09525857', # optional
36
+ significantPersons: [significant_person], # optional
37
+ contactEmailAddress: 'oterosantos@gmail.com' # optional
38
+ }
39
+ end
40
+
41
+ private
42
+
43
+ def financial_data
44
+ {
45
+ monthlyCardRevenue: 0,
46
+ monthlyValueOfPurchaseTransactions: 0,
47
+ monthlyRevenueFromInvoices: 0,
48
+ paymentData: payment_data
49
+ }
50
+ end
51
+
52
+ def payment_data
53
+ (1..12).to_a.map do |month|
54
+ formatted_month = format('%02<month>d', month: month)
55
+
56
+ {
57
+ paymentDate: "#{Date.today.year - 1}-#{formatted_month}-01",
58
+ amount: 5000,
59
+ currencyISOCode: 'GBP'
60
+ }
61
+ end
62
+ end
63
+
64
+ def significant_person
65
+ {
66
+ firstName: Faker::Name.first_name,
67
+ surname: Faker::Name.last_name,
68
+ address: address,
69
+ dateOfBirth: Date.parse('1980-01-01').to_s
70
+ }
71
+ end
72
+
73
+ def address
74
+ {
75
+ line1: Faker::Address.street_address,
76
+ line2: Faker::Address.secondary_address,
77
+ city: 'London',
78
+ region: 'London',
79
+ areaCode: Faker::Address.zip_code,
80
+ country: 'UK'
81
+ }
82
+ end
83
+ end
84
+ end
85
+ end
@@ -2,9 +2,17 @@
2
2
 
3
3
  # Following the API description here: https://staging.youlendapi.com/prequalification/index.html
4
4
  module Youlend
5
- class Quote
6
- def self.pre_qualification(params)
7
- response = Youlend.connection.post('/prequalification/Requests', :prequalification, params)
5
+ class Prequalification
6
+ def self.verify(params)
7
+ new(params).verify
8
+ end
9
+
10
+ def initialize(params)
11
+ @params = params
12
+ end
13
+
14
+ def verify
15
+ response = Youlend.connection.post('/prequalification/Requests', :prequalification, @params)
8
16
 
9
17
  # If there are errors in the data just return the response right away
10
18
  return response if response.status == 422
@@ -12,17 +20,22 @@ module Youlend
12
20
  # If we got back a response but all the funded amounts are 0.0 it means that the load was
13
21
  # actually rejected! We'll replace the response body with an error message instead and change
14
22
  # the success code.
15
- if loan_accepted?(response.body)
16
- response
17
- else
23
+ unless loan_accepted?(response.body)
18
24
  response.http_response.env.status = 422
19
- response.http_response.env.body = { error: 'Rejected', error_description: 'Loan was rejected' }
20
- response
25
+ response.http_response.env.body = {
26
+ error: 'Rejected',
27
+ error_description: 'Loan was rejected'
28
+ }
21
29
  end
30
+
31
+ response
22
32
  end
23
33
 
24
- def self.loan_accepted?(data)
34
+ private
35
+
36
+ def loan_accepted?(data)
25
37
  return false unless data[:loanOptions]
38
+
26
39
  options = data[:loanOptions]
27
40
 
28
41
  funded_amounts = options.map { |option| option[:fundedAmount] }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Youlend
4
- VERSION = '1.0.2'
4
+ VERSION = '1.1.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youlend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rikas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-03 00:00:00.000000000 Z
11
+ date: 2021-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -256,11 +256,10 @@ files:
256
256
  - lib/youlend/configuration.rb
257
257
  - lib/youlend/connection.rb
258
258
  - lib/youlend/lead.rb
259
- - lib/youlend/lead_generator.rb
260
- - lib/youlend/merchant.rb
261
- - lib/youlend/merchant_generator.rb
259
+ - lib/youlend/params_generators/lead.rb
260
+ - lib/youlend/params_generators/prequalification.rb
262
261
  - lib/youlend/path_sanitizer.rb
263
- - lib/youlend/quote.rb
262
+ - lib/youlend/prequalification.rb
264
263
  - lib/youlend/response.rb
265
264
  - lib/youlend/version.rb
266
265
  - vcr_cassettes/auth_incorrect.yml
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'faker'
4
-
5
- module Youlend
6
- class LeadGenerator
7
- def self.generate
8
- new.generate
9
- end
10
-
11
- def initialize
12
- Faker::Config.locale = 'en-GB'
13
-
14
- generate
15
- end
16
-
17
- # Mandatory fields:
18
- # * CompanyName
19
- # * CompanyType (ltd, plc, llp, dac, soleTrader, aps, as, ks, ivs and is)
20
- # * MonthsTrading
21
- # * CountryISOCode (GBR, DNK and IRE)
22
- # * KeyContactName
23
- # * ThirdPartyLeadId
24
- # * RegisteredAddress
25
- # * ContactPhoneNumber
26
- # * MonthlyCardRevenue (must be greater than or equal to '1000')
27
- # * ContactEmailAddress
28
- # * LoanCurrencyISOCode (ISO 4217 currency code. Valid codes are GBP, EUR and DKK)
29
- # * ThirdPartyCustomerId
30
- def generate
31
- {
32
- companyName: 'HOKO LTD',
33
- companyType: 'ltd',
34
- monthsTrading: rand(3..10),
35
- countryISOCode: 'GBR',
36
- keyContactName: Faker::Name.name,
37
- thirdPartyLeadId: SecureRandom.uuid,
38
- registeredAddress: address,
39
- contactPhoneNumber: Faker::PhoneNumber.phone_number,
40
- monthlyCardRevenue: 10_000,
41
- contactEmailAddress: Faker::Internet.email,
42
- loanCurrencyISOCode: 'GBP',
43
- thirdPartyCustomerId: SecureRandom.uuid,
44
- companyNumber: '09525857', # optional
45
- notificationURL: Faker::Internet.url, # optional
46
- thirdPartyMerchantId: SecureRandom.uuid # optional
47
- }
48
- end
49
-
50
- private
51
-
52
- def address
53
- {
54
- line1: Faker::Address.street_address,
55
- line2: Faker::Address.secondary_address,
56
- city: 'London',
57
- region: 'London',
58
- areaCode: Faker::Address.zip_code,
59
- country: 'UK'
60
- }
61
- end
62
- end
63
- end
File without changes
@@ -1,82 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'faker'
4
-
5
- module Youlend
6
- class MerchantGenerator
7
- def self.generate
8
- new.generate
9
- end
10
-
11
- def initialize
12
- Faker::Config.locale = 'en-GB'
13
-
14
- generate
15
- end
16
-
17
- # Mandatory fields:
18
- # * CompanyName
19
- # * CompanyType (ltd, plc, llp, dac, partnership, soleTrader, aps, as, ks, ivs and is)
20
- # * CompanyNumber
21
- # * FinancialData
22
- # * CountryISOCode (GBR, DNK and IRE)
23
- # * LoanCurrencyISOCode (ISO 4217 currency code. Valid codes are GBP, EUR and DKK)
24
- # * ThirdPartyMerchantId
25
- def generate
26
- {
27
- companyName: 'HOKO LTD',
28
- companyType: 'ltd',
29
- companyNumber: '09525857',
30
- financialData: financial_data,
31
- countryISOCode: 'GBR',
32
- loanCurrencyISOCode: 'GBP',
33
- thirdPartyMerchantId: SecureRandom.uuid,
34
- significantPersons: [significant_person], # optional
35
- contactEmailAddress: 'oterosantos@gmail.com' # optional
36
- }
37
- end
38
-
39
- private
40
-
41
- def financial_data
42
- {
43
- monthlyCardRevenue: 0,
44
- monthlyValueOfPurchaseTransactions: 0,
45
- monthlyRevenueFromInvoices: 0,
46
- paymentData: payment_data
47
- }
48
- end
49
-
50
- def payment_data
51
- (1..12).to_a.map do |month|
52
- formatted_month = format('%02<month>d', month: month)
53
-
54
- {
55
- paymentDate: "#{Date.today.year - 1}-#{formatted_month}-01",
56
- amount: 5000,
57
- currencyISOCode: 'GBP'
58
- }
59
- end
60
- end
61
-
62
- def significant_person
63
- {
64
- firstName: Faker::Name.first_name,
65
- surname: Faker::Name.last_name,
66
- address: address,
67
- dateOfBirth: Date.parse('1980-01-01').to_s
68
- }
69
- end
70
-
71
- def address
72
- {
73
- line1: Faker::Address.street_address,
74
- line2: Faker::Address.secondary_address,
75
- city: 'London',
76
- region: 'London',
77
- areaCode: Faker::Address.zip_code,
78
- country: 'UK'
79
- }
80
- end
81
- end
82
- end