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
- CREATE_ATTRS =
{
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,
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::PRODUCTION_URL, Credova::API::USER_AGENT
Instance Method Summary
collapse
Methods included from API
#get_request, #post_request
Constructor Details
Returns a new instance of Application.
29
30
31
|
# File 'lib/credova/application.rb', line 29
def initialize(client)
@client = client
end
|
Instance Method Details
#check_status_by_phone_number(phone) ⇒ Object
55
56
57
58
59
|
# File 'lib/credova/application.rb', line 55
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
49
50
51
52
53
|
# File 'lib/credova/application.rb', line 49
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/credova/application.rb', line 33
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
75
76
77
78
79
|
# File 'lib/credova/application.rb', line 75
def request_return(public_id)
endpoint = ENDPOINTS[:request_return] % public_id
post_request(endpoint, {}, (@client.access_token))
end
|
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/credova/application.rb', line 61
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_url) ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/credova/application.rb', line 81
def upload_invoice(public_id, invoice_url)
endpoint = ENDPOINTS[:upload_invoice] % public_id
data = { form_data: ['file=@', invoice_url, '; type=application/', (invoice_url)].join }
= [
*(@client.access_token),
*('multipart/form-data'),
].to_h
post_request(endpoint, data, )
end
|