credova 0.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 +7 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +20 -0
- data/bin/console +10 -0
- data/bin/setup +3 -0
- data/credova.gemspec +28 -0
- data/lib/credova.rb +23 -0
- data/lib/credova/api.rb +80 -0
- data/lib/credova/application.rb +78 -0
- data/lib/credova/base.rb +24 -0
- data/lib/credova/client.rb +45 -0
- data/lib/credova/error.rb +11 -0
- data/lib/credova/ffl.rb +57 -0
- data/lib/credova/payments.rb +33 -0
- data/lib/credova/response.rb +48 -0
- data/lib/credova/retailer.rb +30 -0
- data/lib/credova/version.rb +3 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7084ae696e6c5359945ab0f2e256dd30c0684132cda5fe184eebb2746563f3f1
|
4
|
+
data.tar.gz: 2c748b2ab2ce6e593d9ee011261e09c43e0599ff427afcf30e3c03c69e686662
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bcf552f21d1e0ca8b1e9d5d2896b39dd2302894d568bccf0cc4afe3104872286208d1f89ce6ef7b0aa04194e73417aa88b205efa98590a03d6cc57f5d3c17ab1
|
7
|
+
data.tar.gz: 0c12e3b8e95c5ac2a9bb80bfacf01e0735c06a08feacdd1f9f2bc32db8451916fbe63a01513d1de5f5252164e9a470d51db3770fe43b455ec2e0bd2810e905dd
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2018 Jeffrey Dill
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Credova
|
2
|
+
|
3
|
+
Credova API Ruby library.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'credova'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install credova
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Documentation
|
24
|
+
|
25
|
+
The full documentation is located here: http://www.rubydoc.info/gems/credova
|
26
|
+
|
27
|
+
### Sandbox Mode
|
28
|
+
|
29
|
+
If you want to use the Credova 'sandbox' API, set the `Credova.sandbox` flag to `true`.
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Credova.sandbox = true
|
33
|
+
# Any API calls will now use the sandbox API.
|
34
|
+
```
|
35
|
+
|
36
|
+
**NOTE**: Credova currently issues different API keys for production and sandbox environments,
|
37
|
+
which means your production key **will not** work in the sandbox and vice versa.
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( https://github.com/ammoready/credova/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
require 'yard'
|
4
|
+
|
5
|
+
task :default => :spec
|
6
|
+
|
7
|
+
desc 'Run the specs'
|
8
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
|
10
|
+
desc 'Generate API docs'
|
11
|
+
YARD::Rake::YardocTask.new(:docs) do |t|
|
12
|
+
t.files = ['lib/**/*.rb']
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :docs do
|
16
|
+
desc 'Run the docs server'
|
17
|
+
task :server do
|
18
|
+
$stdout.puts `yard server --reload --bind 0.0.0.0`
|
19
|
+
end
|
20
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/credova.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'credova/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "credova"
|
8
|
+
spec.version = Credova::VERSION
|
9
|
+
spec.authors = ["Jeffrey Dill"]
|
10
|
+
spec.email = ["jeffdill2@gmail.com"]
|
11
|
+
spec.summary = %q{Credova API Ruby library.}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = "https://github.com/ammoready/credova"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "pry", "~> 0.10.4"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.1"
|
25
|
+
spec.add_development_dependency "simplecov", "~> 0.9"
|
26
|
+
spec.add_development_dependency "webmock", "~> 1.20"
|
27
|
+
spec.add_development_dependency "yard", "~> 0.9.12"
|
28
|
+
end
|
data/lib/credova.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'credova/base'
|
2
|
+
require 'credova/version'
|
3
|
+
|
4
|
+
require 'credova/api'
|
5
|
+
require 'credova/application'
|
6
|
+
require 'credova/client'
|
7
|
+
require 'credova/error'
|
8
|
+
require 'credova/ffl'
|
9
|
+
require 'credova/payments'
|
10
|
+
require 'credova/response'
|
11
|
+
require 'credova/retailer'
|
12
|
+
|
13
|
+
module Credova
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :sandbox
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.sandbox?
|
20
|
+
!!@sandbox
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
data/lib/credova/api.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module Credova
|
4
|
+
module API
|
5
|
+
|
6
|
+
DEVELOPMENT_URL = 'https://staging-lending-api.credova.com'.freeze
|
7
|
+
PRODUCTION_URL = 'https://lending-api.credova.com'.freeze
|
8
|
+
API_VERSION = 'v2'.freeze
|
9
|
+
|
10
|
+
USER_AGENT = "CredovaRubyGem/#{Credova::VERSION}".freeze
|
11
|
+
|
12
|
+
# def self.get_request(*args)
|
13
|
+
# get_request(*args)
|
14
|
+
# end
|
15
|
+
#
|
16
|
+
# def self.post_request(*args)
|
17
|
+
# post_request(*args)
|
18
|
+
# end
|
19
|
+
|
20
|
+
# private
|
21
|
+
|
22
|
+
def get_request(endpoint, headers = {})
|
23
|
+
request = Net::HTTP::Get.new(request_url(endpoint))
|
24
|
+
|
25
|
+
process_request(request, {}, headers)
|
26
|
+
end
|
27
|
+
|
28
|
+
def post_request(endpoint, data = {}, headers = {})
|
29
|
+
request = Net::HTTP::Post.new(request_url(endpoint))
|
30
|
+
|
31
|
+
process_request(request, data, headers)
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def process_request(request, data, headers)
|
37
|
+
set_request_headers(request, headers)
|
38
|
+
|
39
|
+
uri = URI(request.path)
|
40
|
+
request.body = data.is_a?(Hash) ? data.to_json : data
|
41
|
+
|
42
|
+
response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
43
|
+
http.request(request)
|
44
|
+
end
|
45
|
+
|
46
|
+
Credova::Response.new(response)
|
47
|
+
end
|
48
|
+
|
49
|
+
def set_request_headers(request, headers)
|
50
|
+
request['User-Agent'] = USER_AGENT
|
51
|
+
|
52
|
+
headers.each { |header, value| request[header] = value }
|
53
|
+
end
|
54
|
+
|
55
|
+
def auth_header(token)
|
56
|
+
{ 'Authorization' => ['Bearer', token].join(' ') }
|
57
|
+
end
|
58
|
+
|
59
|
+
def content_type_header(type)
|
60
|
+
{ 'Content-Type' => type }
|
61
|
+
end
|
62
|
+
|
63
|
+
def request_url(endpoint)
|
64
|
+
[
|
65
|
+
(Credova.sandbox? ? DEVELOPMENT_URL : PRODUCTION_URL),
|
66
|
+
API_VERSION,
|
67
|
+
endpoint,
|
68
|
+
].join('/')
|
69
|
+
end
|
70
|
+
|
71
|
+
def extract_file_extension(ffl_document_url)
|
72
|
+
metadata_raw = Net::HTTP.get(URI.parse("#{ffl_document_url}/metadata"))
|
73
|
+
metadata_json = JSON.parse(metadata_raw)
|
74
|
+
file_name = metadata_json['filename']
|
75
|
+
|
76
|
+
file_name[(file_name.rindex('.') + 1)..-1]
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'credova/api'
|
2
|
+
|
3
|
+
module Credova
|
4
|
+
class Application < Base
|
5
|
+
|
6
|
+
include Credova::API
|
7
|
+
|
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 )
|
11
|
+
ENDPOINTS = {
|
12
|
+
check_status_by_public_id: "applications/%s/status".freeze,
|
13
|
+
check_status_by_phone_number: "applications/phone/%s/status".freeze,
|
14
|
+
create: "applications".freeze,
|
15
|
+
set_delivery_information: "applications/%s/deliveryinformation".freeze,
|
16
|
+
request_return: "applications/%s/requestreturn".freeze,
|
17
|
+
upload_invoice: "applications/%s/uploadinvoice".freeze,
|
18
|
+
}
|
19
|
+
|
20
|
+
def initialize(client)
|
21
|
+
@client = client
|
22
|
+
end
|
23
|
+
|
24
|
+
def create(callback_url, options = {})
|
25
|
+
requires!(options, REQUIRED_CREATE_ATTRS)
|
26
|
+
|
27
|
+
endpoint = ENDPOINTS[:create]
|
28
|
+
headers = [
|
29
|
+
*auth_header(@client.access_token),
|
30
|
+
*content_type_header('application/json'),
|
31
|
+
].to_h
|
32
|
+
|
33
|
+
post_request(endpoint, options, headers)
|
34
|
+
end
|
35
|
+
|
36
|
+
def check_status_by_public_id(public_id)
|
37
|
+
endpoint = ENDPOINTS[:check_status_by_public_id] % public_id
|
38
|
+
|
39
|
+
get_request(endpoint, auth_header(@client.access_token))
|
40
|
+
end
|
41
|
+
|
42
|
+
def check_status_by_phone_number(phone)
|
43
|
+
endpoint = ENDPOINTS[:check_status_by_phone_number] % phone
|
44
|
+
|
45
|
+
get_request(endpoint, auth_header(@client.access_token))
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_delivery_information(public_id, options = {})
|
49
|
+
requires!(options, REQUIRED_DELIVERY_ATTRS)
|
50
|
+
|
51
|
+
endpoint = ENDPOINTS[:set_delivery_information] % public_id
|
52
|
+
headers = [
|
53
|
+
*auth_header(@client.access_token),
|
54
|
+
*content_type_header('application/json'),
|
55
|
+
].to_h
|
56
|
+
|
57
|
+
post_request(endpoint, options, headers)
|
58
|
+
end
|
59
|
+
|
60
|
+
def request_return(public_id)
|
61
|
+
endpoint = ENDPOINTS[:request_return] % public_id
|
62
|
+
|
63
|
+
post_request(endpoint, {}, auth_header(@client.access_token))
|
64
|
+
end
|
65
|
+
|
66
|
+
def upload_invoice(public_id, invoice_url)
|
67
|
+
endpoint = ENDPOINTS[:upload_invoice] % public_id
|
68
|
+
data = { form_data: ['file=@', invoice_url, '; type=application/', extract_file_extension(invoice_url)].join }
|
69
|
+
headers = [
|
70
|
+
*auth_header(@client.access_token),
|
71
|
+
*content_type_header('multipart/form-data'),
|
72
|
+
].to_h
|
73
|
+
|
74
|
+
post_request(endpoint, data, headers)
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
data/lib/credova/base.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
module Credova
|
2
|
+
class Base
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def requires!(*args)
|
7
|
+
self.class.requires!(*args)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.requires!(hash, *params)
|
11
|
+
params.each do |param|
|
12
|
+
if param.is_a?(Array)
|
13
|
+
raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
|
14
|
+
|
15
|
+
valid_options = param[1..-1]
|
16
|
+
raise ArgumentError.new("Parameter: #{param.first} must be one of: #{valid_options.join(', ')}") unless valid_options.include?(hash[param.first])
|
17
|
+
else
|
18
|
+
raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'credova/api'
|
2
|
+
require 'credova/application'
|
3
|
+
require 'credova/ffl'
|
4
|
+
require 'credova/retailer'
|
5
|
+
|
6
|
+
module Credova
|
7
|
+
class Client < Base
|
8
|
+
|
9
|
+
include Credova::API
|
10
|
+
|
11
|
+
attr_accessor :access_token
|
12
|
+
|
13
|
+
def initialize(options = {})
|
14
|
+
requires!(options, :username, :password)
|
15
|
+
@options = options
|
16
|
+
|
17
|
+
authenticate!
|
18
|
+
end
|
19
|
+
|
20
|
+
def application
|
21
|
+
@application ||= Credova::Application.new(self)
|
22
|
+
end
|
23
|
+
|
24
|
+
def ffl
|
25
|
+
@ffl ||= Credova::FFL.new(self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def retailer
|
29
|
+
@retailer ||= Credova::Retailer.new(self)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def authenticate!
|
35
|
+
response = post_request(
|
36
|
+
'token',
|
37
|
+
['username=', @options[:username], '&password=', @options[:password]].join,
|
38
|
+
content_type_header('application/x-www-form-urlencoded')
|
39
|
+
)
|
40
|
+
|
41
|
+
self.access_token = response.fetch(:jwt)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Credova
|
2
|
+
class Error < StandardError
|
3
|
+
|
4
|
+
class NoContent < Credova::Error; end
|
5
|
+
class NotAuthorized < Credova::Error; end
|
6
|
+
class NotFound < Credova::Error; end
|
7
|
+
class RequestError < Credova::Error; end
|
8
|
+
class TimeoutError < Credova::Error; end
|
9
|
+
|
10
|
+
end
|
11
|
+
end
|
data/lib/credova/ffl.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'credova/api'
|
2
|
+
|
3
|
+
module Credova
|
4
|
+
class FFL < Base
|
5
|
+
|
6
|
+
include Credova::API
|
7
|
+
|
8
|
+
REQUIRED_CREATE_ATTRS = %i( license_number expiration address_one city state zip )
|
9
|
+
ENDPOINTS = {
|
10
|
+
create: "federallicense".freeze,
|
11
|
+
upload_document: "federallicense/%s/uploadfile".freeze,
|
12
|
+
}
|
13
|
+
|
14
|
+
def initialize(client)
|
15
|
+
@client = client
|
16
|
+
end
|
17
|
+
|
18
|
+
def create(options = {})
|
19
|
+
requires!(options, REQUIRED_CREATE_ATTRS)
|
20
|
+
|
21
|
+
endpoint = ENDPOINTS[:create]
|
22
|
+
data = format_data_for_create(options)
|
23
|
+
headers = [
|
24
|
+
*auth_header(@client.access_token),
|
25
|
+
*content_type_header('application/json'),
|
26
|
+
].to_h
|
27
|
+
|
28
|
+
post_request(endpoint, data, headers)
|
29
|
+
end
|
30
|
+
|
31
|
+
def upload_document(ffl_public_id, ffl_document_url)
|
32
|
+
endpoint = ENDPOINTS[:upload_document] % ffl_public_id
|
33
|
+
data = { form_data: ['file=@', ffl_document_url, '; type=application/', extract_file_extension(ffl_document_url)].join }
|
34
|
+
headers = [
|
35
|
+
*auth_header(@client.access_token),
|
36
|
+
*content_type_header('multipart/form-data'),
|
37
|
+
].to_h
|
38
|
+
|
39
|
+
post_request(endpoint, data, headers)
|
40
|
+
end
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def format_data_for_create(data)
|
45
|
+
{
|
46
|
+
licenseNumber: data[:license_number],
|
47
|
+
expiration: data[:expiration].strftime('%Y/%m/%d'),
|
48
|
+
address: data[:address_one],
|
49
|
+
address2: data[:address_two],
|
50
|
+
city: data[:city],
|
51
|
+
state: data[:state],
|
52
|
+
zip: data[:zip],
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'credova/api'
|
2
|
+
|
3
|
+
module Credova
|
4
|
+
module Payments
|
5
|
+
|
6
|
+
extend Credova::API
|
7
|
+
|
8
|
+
ENDPOINTS = {
|
9
|
+
lowest_payment_option: "calculator/store/%s/amount/%s/lowestpaymentoption".freeze,
|
10
|
+
lender_payment_options: "calculator/lender/%s/amount/%s".freeze,
|
11
|
+
store_payment_options: "calculator/store/%s/amount/%s".freeze,
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.lowest_payment_option(store_code, amount_to_finance)
|
15
|
+
endpoint = ENDPOINTS[:lowest_payment_option] % [store_code, amount_to_finance]
|
16
|
+
|
17
|
+
post_request(endpoint)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.lender_payment_options(lender_code, amount_to_finance)
|
21
|
+
endpoint = ENDPOINTS[:lender_payment_options] % [lender_code, amount_to_finance]
|
22
|
+
|
23
|
+
post_request(endpoint)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.store_payment_options(store_code, amount_to_finance)
|
27
|
+
endpoint = ENDPOINTS[:store_payment_options] % [store_code, amount_to_finance]
|
28
|
+
|
29
|
+
post_request(endpoint)
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Credova
|
2
|
+
class Response
|
3
|
+
|
4
|
+
attr_accessor :success
|
5
|
+
|
6
|
+
def initialize(response)
|
7
|
+
@response = response
|
8
|
+
|
9
|
+
case @response
|
10
|
+
when Net::HTTPUnauthorized
|
11
|
+
Credova::Error::NotAuthorized.new(@response.body)
|
12
|
+
when Net::HTTPNotFound
|
13
|
+
Credova::Error::NotFound.new(@response.body)
|
14
|
+
when Net::HTTPNoContent
|
15
|
+
Credova::Error::NoContent.new(@response.body)
|
16
|
+
when Net::HTTPOK, Net::HTTPSuccess
|
17
|
+
self.success = true
|
18
|
+
_data = JSON.parse(@response.body)
|
19
|
+
|
20
|
+
@data = case
|
21
|
+
when _data.is_a?(Hash)
|
22
|
+
_data.deep_symbolize_keys
|
23
|
+
when _data.is_a?(Array)
|
24
|
+
_data.map(&:deep_symbolize_keys)
|
25
|
+
end
|
26
|
+
else
|
27
|
+
raise Credova::Error::RequestError.new(@response.body)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](key)
|
32
|
+
@data[key]
|
33
|
+
end
|
34
|
+
|
35
|
+
def body
|
36
|
+
@data
|
37
|
+
end
|
38
|
+
|
39
|
+
def fetch(key)
|
40
|
+
@data.fetch(key)
|
41
|
+
end
|
42
|
+
|
43
|
+
def success?
|
44
|
+
!!success
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'credova/api'
|
2
|
+
|
3
|
+
module Credova
|
4
|
+
class Retailer
|
5
|
+
|
6
|
+
include Credova::API
|
7
|
+
|
8
|
+
ENDPOINTS = {
|
9
|
+
lenders: "lenders".freeze,
|
10
|
+
stores: "stores".freeze,
|
11
|
+
}
|
12
|
+
|
13
|
+
def initialize(client)
|
14
|
+
@client = client
|
15
|
+
end
|
16
|
+
|
17
|
+
def lenders
|
18
|
+
endpoint = ENDPOINTS[:lenders]
|
19
|
+
|
20
|
+
get_request(endpoint, auth_header(@client.access_token))
|
21
|
+
end
|
22
|
+
|
23
|
+
def stores
|
24
|
+
endpoint = ENDPOINTS[:stores]
|
25
|
+
|
26
|
+
get_request(endpoint, auth_header(@client.access_token))
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: credova
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jeffrey Dill
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.10.4
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.10.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.1'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.9'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.9'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: webmock
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.20'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.20'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.9.12
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.9.12
|
111
|
+
description: ''
|
112
|
+
email:
|
113
|
+
- jeffdill2@gmail.com
|
114
|
+
executables:
|
115
|
+
- console
|
116
|
+
- setup
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".travis.yml"
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
- bin/console
|
128
|
+
- bin/setup
|
129
|
+
- credova.gemspec
|
130
|
+
- lib/credova.rb
|
131
|
+
- lib/credova/api.rb
|
132
|
+
- lib/credova/application.rb
|
133
|
+
- lib/credova/base.rb
|
134
|
+
- lib/credova/client.rb
|
135
|
+
- lib/credova/error.rb
|
136
|
+
- lib/credova/ffl.rb
|
137
|
+
- lib/credova/payments.rb
|
138
|
+
- lib/credova/response.rb
|
139
|
+
- lib/credova/retailer.rb
|
140
|
+
- lib/credova/version.rb
|
141
|
+
homepage: https://github.com/ammoready/credova
|
142
|
+
licenses:
|
143
|
+
- MIT
|
144
|
+
metadata: {}
|
145
|
+
post_install_message:
|
146
|
+
rdoc_options: []
|
147
|
+
require_paths:
|
148
|
+
- lib
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
requirements: []
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 2.7.7
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: Credova API Ruby library.
|
165
|
+
test_files: []
|