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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 802f8624e72cf6bfe98fefeb2e1e7aea81b4f8e3d4df53b435ab5f23c7d18f84
4
- data.tar.gz: a28e668a1c724f952c36e815320827b6bb29729a91ce2868bfedf6d7efb3d83d
3
+ metadata.gz: 54e99473b851da1ca94dd2ec7da47d051eeca024fe4d989b0d3efd47810a3936
4
+ data.tar.gz: 9606e87c575cc80e2c4de46692e1d1a2d8a6c4c8591b8b25ecf5335b1cc49174
5
5
  SHA512:
6
- metadata.gz: 3865a8d6b91f494d17f34509cfcb4e1485b23a7787fd00fc0a6a64e71b41abd722e48f73c1de1f3227eb7e39cec3bfe0b42b982876058d527971f9c91326151e
7
- data.tar.gz: e83264ab2769fa18ff4a55471e72fdd361a954da23cf26fb95bdadd28eac6e4c44cd33e3537e04fe726cb2f029ca9afba7bfabba2138c08eb5dfc8b664ec1129
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
@@ -6,8 +6,17 @@ module Credova
6
6
  include Credova::API
7
7
 
8
8
  MINIMUM_FINANCING_AMOUNT = 300_00.freeze
9
- REQUIRED_CREATE_ATTRS = %i( first_name last_name date_of_birth mobile_phone email )
10
- REQUIRED_DELIVERY_ATTRS = %i( method address city state zip carrier tracking_number )
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, options = {})
25
- requires!(options, REQUIRED_CREATE_ATTRS)
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
- post_request(endpoint, options, headers)
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, options = {})
51
- requires!(options, REQUIRED_DELIVERY_ATTRS)
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
- post_request(endpoint, options, headers)
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)
@@ -1,3 +1,3 @@
1
1
  module Credova
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credova
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Dill