Class: Credova::Application
- Inherits:
-
Base
- Object
- Base
- Credova::Application
show all
- Includes:
- API
- Defined in:
- lib/credova/application.rb
Constant Summary
collapse
- MINIMUM_FINANCING_AMOUNT =
300_00.freeze
- MAXIMUM_FINANCING_AMOUNT =
10_000_00.freeze
- CREATE_ATTRS =
{
permitted: %i( public_id store_code first_name middle_initial last_name date_of_birth mobile_phone email address products redirect_url reference_number ).freeze,
required: %i( store_code first_name last_name mobile_phone email ).freeze
}
- SET_DELIVERY_INFORMATION_ATTRS =
{
permitted: %i( federal_license_number method address address_2 city state zip carrier tracking_number ).freeze,
required: %i( method address city state zip carrier tracking_number ).freeze
}
- ENDPOINTS =
{
check_status_by_public_id: "applications/%s/status".freeze,
check_status_by_phone_number: "applications/phone/%s/status".freeze,
create: "applications".freeze,
set_delivery_information: "applications/%s/deliveryinformation".freeze,
request_return: "applications/%s/requestreturn".freeze,
upload_invoice: "applications/%s/uploadinvoice".freeze,
}
Constants included
from API
Credova::API::API_VERSION, Credova::API::DEVELOPMENT_URL, Credova::API::FILE_UPLOAD_ATTRS, Credova::API::PRODUCTION_URL, Credova::API::USER_AGENT
Instance Method Summary
collapse
Methods included from API
#get_request, #post_file_request, #post_request
Constructor Details
Returns a new instance of Application.
30
31
32
|
# File 'lib/credova/application.rb', line 30
def initialize(client)
@client = client
end
|
Instance Method Details
#check_status_by_phone_number(phone) ⇒ Object
56
57
58
59
60
|
# File 'lib/credova/application.rb', line 56
def check_status_by_phone_number(phone)
endpoint = ENDPOINTS[:check_status_by_phone_number] % phone
get_request(endpoint, (@client.access_token))
end
|
#check_status_by_public_id(public_id) ⇒ Object
50
51
52
53
54
|
# File 'lib/credova/application.rb', line 50
def check_status_by_public_id(public_id)
endpoint = ENDPOINTS[:check_status_by_public_id] % public_id
get_request(endpoint, (@client.access_token))
end
|
#create(application_data, callback_url = nil) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/credova/application.rb', line 34
def create(application_data, callback_url = nil)
requires!(application_data, *CREATE_ATTRS[:required])
endpoint = ENDPOINTS[:create]
= [
*(@client.access_token),
*('application/json'),
].to_h
['Callback-Url'] = callback_url if callback_url.present?
application_data = standardize_body_data(application_data, CREATE_ATTRS[:permitted])
post_request(endpoint, application_data, )
end
|
#request_return(public_id) ⇒ Object
76
77
78
79
80
|
# File 'lib/credova/application.rb', line 76
def request_return(public_id)
endpoint = ENDPOINTS[:request_return] % public_id
post_request(endpoint, {}, (@client.access_token))
end
|
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/credova/application.rb', line 62
def set_delivery_information(public_id, delivery_data)
requires!(delivery_data, *SET_DELIVERY_INFORMATION_ATTRS[:required])
endpoint = ENDPOINTS[:set_delivery_information] % public_id
= [
*(@client.access_token),
*('application/json'),
].to_h
delivery_data = standardize_body_data(delivery_data, SET_DELIVERY_INFORMATION_ATTRS[:permitted])
post_request(endpoint, delivery_data, )
end
|
#upload_invoice(public_id, invoice_file_data) ⇒ Object
82
83
84
85
86
87
88
|
# File 'lib/credova/application.rb', line 82
def upload_invoice(public_id, invoice_file_data)
requires!(invoice_file_data, *FILE_UPLOAD_ATTRS[:required])
endpoint = ENDPOINTS[:upload_invoice] % public_id
post_file_request(endpoint, invoice_file_data, (@client.access_token))
end
|