credova 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/credova/api.rb +6 -0
- data/lib/credova/application.rb +21 -8
- data/lib/credova/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54e99473b851da1ca94dd2ec7da47d051eeca024fe4d989b0d3efd47810a3936
|
4
|
+
data.tar.gz: 9606e87c575cc80e2c4de46692e1d1a2d8a6c4c8591b8b25ecf5335b1cc49174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c23febf54f90aa40af894de74e0fa796ff5797132e4abb576c01b06d0a3d7b9d326acf242db1ba7e2fab720426efe3427cfe78e57158f1b29592234c8d32af0
|
7
|
+
data.tar.gz: f80da5dd8473f948abbe2b3d333c211ef771650128522e0ad6cb6508b10551a73511ca044469aaf29d1847b2fdee5c7155c8ea7d427355cbddbab45ff77afc3b
|
data/lib/credova/api.rb
CHANGED
@@ -66,5 +66,11 @@ module Credova
|
|
66
66
|
file_name[(file_name.rindex('.') + 1)..-1]
|
67
67
|
end
|
68
68
|
|
69
|
+
def standardize_body_data!(submitted_data, permitted_data_attrs)
|
70
|
+
submitted_data.
|
71
|
+
select! { |k, v| permitted_data_attrs.include?(k) }.
|
72
|
+
transform_keys! { |k| k.to_s.camelize(:lower) }
|
73
|
+
end
|
74
|
+
|
69
75
|
end
|
70
76
|
end
|
data/lib/credova/application.rb
CHANGED
@@ -6,8 +6,17 @@ module Credova
|
|
6
6
|
include Credova::API
|
7
7
|
|
8
8
|
MINIMUM_FINANCING_AMOUNT = 300_00.freeze
|
9
|
-
|
10
|
-
|
9
|
+
|
10
|
+
CREATE_ATTRS = {
|
11
|
+
permitted: %i( public_id store_code first_name middle_initial last_name date_of_birth mobile_phone email needed_amount address products redirect_url reference_number ).freeze,
|
12
|
+
required: %i( store_code first_name last_name mobile_phone email ).freeze
|
13
|
+
}
|
14
|
+
|
15
|
+
SET_DELIVERY_INFORMATION_ATTRS = {
|
16
|
+
permitted: %i( federal_license_number method address address_2 city state zip carrier tracking_number ).freeze,
|
17
|
+
required: %i( method address city state zip carrier tracking_number ).freeze
|
18
|
+
}
|
19
|
+
|
11
20
|
ENDPOINTS = {
|
12
21
|
check_status_by_public_id: "applications/%s/status".freeze,
|
13
22
|
check_status_by_phone_number: "applications/phone/%s/status".freeze,
|
@@ -21,8 +30,8 @@ module Credova
|
|
21
30
|
@client = client
|
22
31
|
end
|
23
32
|
|
24
|
-
def create(callback_url = nil
|
25
|
-
requires!(
|
33
|
+
def create(application_data, callback_url = nil)
|
34
|
+
requires!(application_data, CREATE_ATTRS[:required])
|
26
35
|
|
27
36
|
endpoint = ENDPOINTS[:create]
|
28
37
|
headers = [
|
@@ -32,7 +41,9 @@ module Credova
|
|
32
41
|
|
33
42
|
headers['Callback-Url'] = callback_url if callback_url.present?
|
34
43
|
|
35
|
-
|
44
|
+
standardize_body_data!(application_data, CREATE_ATTRS[:permitted])
|
45
|
+
|
46
|
+
post_request(endpoint, application_data, headers)
|
36
47
|
end
|
37
48
|
|
38
49
|
def check_status_by_public_id(public_id)
|
@@ -47,8 +58,8 @@ module Credova
|
|
47
58
|
get_request(endpoint, auth_header(@client.access_token))
|
48
59
|
end
|
49
60
|
|
50
|
-
def set_delivery_information(public_id,
|
51
|
-
requires!(
|
61
|
+
def set_delivery_information(public_id, delivery_data)
|
62
|
+
requires!(delivery_data, SET_DELIVERY_INFORMATION_ATTRS[:required])
|
52
63
|
|
53
64
|
endpoint = ENDPOINTS[:set_delivery_information] % public_id
|
54
65
|
headers = [
|
@@ -56,7 +67,9 @@ module Credova
|
|
56
67
|
*content_type_header('application/json'),
|
57
68
|
].to_h
|
58
69
|
|
59
|
-
|
70
|
+
standardize_body_data!(delivery_data, SET_DELIVERY_INFORMATION_ATTRS[:permitted])
|
71
|
+
|
72
|
+
post_request(endpoint, delivery_data, headers)
|
60
73
|
end
|
61
74
|
|
62
75
|
def request_return(public_id)
|
data/lib/credova/version.rb
CHANGED