capital_on_tap 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/console +1 -2
- data/lib/capital_on_tap.rb +10 -5
- data/lib/capital_on_tap/application.rb +87 -52
- data/lib/capital_on_tap/auth.rb +3 -1
- data/lib/capital_on_tap/configuration.rb +6 -1
- data/lib/capital_on_tap/connection.rb +6 -7
- data/lib/capital_on_tap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a069d25bab5d251a3d7464bde27e32480755a658f5aa100fd844c8657ea1b3e
|
4
|
+
data.tar.gz: a3d216478cbbdbd0f0560e5a77accb74a813c6da26d87cb9298c9c74d088a32d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b424f8aa0ed8a5a58fda6d011c7b95ba519486ee3dbc2b0f9f28331268d67d8c862ff1826147e6bc78c6f297a79039b050168928bcec78e6dc20d90d296cadeb
|
7
|
+
data.tar.gz: c1cb89a7c2f1b86bd8a70063df33dce86939b4f7fe9864e68d11afa3dccaa4e123cc403ba5f1d30765b9d29a29b71caf9f73ae15c87f325f940f6cff30e0c6d5
|
data/Gemfile.lock
CHANGED
data/bin/console
CHANGED
data/lib/capital_on_tap.rb
CHANGED
@@ -4,6 +4,7 @@ require 'capital_on_tap/version'
|
|
4
4
|
require 'capital_on_tap/configuration'
|
5
5
|
require 'capital_on_tap/connection'
|
6
6
|
require 'capital_on_tap/auth'
|
7
|
+
require 'capital_on_tap/application'
|
7
8
|
|
8
9
|
module CapitalOnTap
|
9
10
|
module_function
|
@@ -20,13 +21,17 @@ module CapitalOnTap
|
|
20
21
|
yield(configuration)
|
21
22
|
end
|
22
23
|
|
23
|
-
def setup_connection
|
24
|
-
|
24
|
+
def setup_connection!
|
25
|
+
token_params = CapitalOnTap::Auth.get_token
|
26
|
+
|
27
|
+
puts token_params.inspect
|
28
|
+
|
29
|
+
raise "ERROR: #{token_params[:error_description]}" if token_params[:error]
|
25
30
|
|
26
31
|
@connection = Connection.new(
|
27
|
-
access_token:
|
28
|
-
expires_in:
|
29
|
-
refresh_token:
|
32
|
+
access_token: token_params[:access_token],
|
33
|
+
expires_in: token_params[:expires_in],
|
34
|
+
refresh_token: token_params[:refresh_token]
|
30
35
|
)
|
31
36
|
end
|
32
37
|
end
|
@@ -14,69 +14,104 @@ module CapitalOnTap
|
|
14
14
|
attr_accessor :promo_code, :on_paste_event_fields, :montly_business_expenditure
|
15
15
|
attr_accessor :external_reference, :partner_code, :restricted_countries, :requested_credit
|
16
16
|
|
17
|
+
DEFAULT_PARAMS = {
|
18
|
+
CustomerId: nil,
|
19
|
+
Salutation: 'Mr',
|
20
|
+
FirstName: 'Amjed',
|
21
|
+
MiddleName: '',
|
22
|
+
LastName: 'Ali',
|
23
|
+
DateOfBirth: '1967-07-14T00:00:00+01:00',
|
24
|
+
MobilePhone: '07841580124',
|
25
|
+
HomePhone: nil,
|
26
|
+
EmailAddress: nil,
|
27
|
+
MonthlyIncome: nil,
|
28
|
+
MonthlyExpenditure: nil,
|
29
|
+
PersonalAddress: {},
|
30
|
+
TradingName: 'Glamour Bikinis And Clothing Boutique Limited',
|
31
|
+
BusinessLegalName: 'Glamour Bikinis And Clothing Boutique Limited',
|
32
|
+
BusinessLandline: '07874186570',
|
33
|
+
YearsTrading: 8,
|
34
|
+
MonthlyTurnOver: 10000,
|
35
|
+
BusinessType: 'LimitedCompany',
|
36
|
+
RegistrationNumber: 10322035,
|
37
|
+
BusinessAddress: {},
|
38
|
+
PromoCode: nil,
|
39
|
+
OnPasteEventFields: nil,
|
40
|
+
MonthlyBusinessExpenditure: nil,
|
41
|
+
GoogleSessionId: nil,
|
42
|
+
PartnerCode: nil,
|
43
|
+
ExternalReference: nil,
|
44
|
+
RestrictedCountries:false,
|
45
|
+
RequestedCredit: 10000,
|
46
|
+
ApplicationGuid: nil
|
47
|
+
}
|
48
|
+
|
17
49
|
# Create a new application with the given parameters
|
18
50
|
# Example JSON:
|
19
51
|
# {
|
20
|
-
# "
|
21
|
-
# "
|
22
|
-
# "
|
23
|
-
# "
|
24
|
-
# "
|
25
|
-
# "
|
26
|
-
# "
|
27
|
-
# "
|
28
|
-
# "
|
29
|
-
# "
|
30
|
-
# "
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# "line2":null
|
52
|
+
# "CustomerId": null,
|
53
|
+
# "Salutation": "Mr",
|
54
|
+
# "FirstName": "Amjed",
|
55
|
+
# "MiddleName": "",
|
56
|
+
# "LastName": "Ali",
|
57
|
+
# "DateOfBirth": "1967-07-14T00:00:00+01:00",
|
58
|
+
# "MobilePhone": "07841580124",
|
59
|
+
# "HomePhone": null,
|
60
|
+
# "EmailAddress": "something@anything.com",
|
61
|
+
# "MonthlyIncome": 5000,
|
62
|
+
# "MonthlyExpenditure": 4000,
|
63
|
+
# "PersonalAddress": {
|
64
|
+
# "Company": null,
|
65
|
+
# "BuildingName": "",
|
66
|
+
# "UnitNumber": "",
|
67
|
+
# "BuildingNumber": "244",
|
68
|
+
# "Street": "Grahams Road",
|
69
|
+
# "PostCode": "CH61 7XF",
|
70
|
+
# "City": "Wirral",
|
71
|
+
# "CountryCode": "UK",
|
72
|
+
# "Line1": "PostApplication",
|
73
|
+
# "Line2": null
|
43
74
|
# },
|
44
|
-
#
|
45
|
-
# "
|
46
|
-
# "
|
47
|
-
# "
|
48
|
-
# "
|
49
|
-
# "
|
50
|
-
# "
|
51
|
-
# "
|
52
|
-
#
|
53
|
-
#
|
54
|
-
# "
|
55
|
-
# "
|
56
|
-
# "
|
57
|
-
# "
|
58
|
-
# "
|
59
|
-
# "
|
60
|
-
# "
|
61
|
-
# "
|
62
|
-
# "line1":"PostApplication",
|
63
|
-
# "line2":null
|
75
|
+
# "TradingName": "Glamour Bikinis And Clothing Boutique Limited",
|
76
|
+
# "BusinessLegalName": "Glamour Bikinis And Clothing Boutique Limited",
|
77
|
+
# "BusinessLandline": "07874186570",
|
78
|
+
# "YearsTrading":8,
|
79
|
+
# "MonthlyTurnOver":10000,
|
80
|
+
# "BusinessType": "LimitedCompany",
|
81
|
+
# "RegistrationNumber":10322035,
|
82
|
+
# "BusinessAddress": {
|
83
|
+
# "Company": null,
|
84
|
+
# "BuildingName": "",
|
85
|
+
# "UnitNumber": "",
|
86
|
+
# "BuildingNumber": "102",
|
87
|
+
# "Street": "Ford Road",
|
88
|
+
# "PostCode": "CH49 0TQ",
|
89
|
+
# "City": "Wirral",
|
90
|
+
# "CountryCode": "UK",
|
91
|
+
# "Line1": "PostApplication",
|
92
|
+
# "Line2": null
|
64
93
|
# },
|
65
|
-
# "
|
66
|
-
# "
|
67
|
-
# "
|
68
|
-
# "
|
69
|
-
# "
|
70
|
-
# "
|
71
|
-
# "
|
94
|
+
# "PromoCode": null,
|
95
|
+
# "OnPasteEventFields": null,
|
96
|
+
# "MonthlyBusinessExpenditure": null,
|
97
|
+
# "GoogleSessionId": null,
|
98
|
+
# "PartnerCode": null,
|
99
|
+
# "ExternalReference": null,
|
100
|
+
# "RestrictedCountries":false,
|
101
|
+
# "RequestedCredit":10000,
|
102
|
+
# "ApplicationGuid": null
|
72
103
|
# }
|
73
104
|
def self.create(params)
|
74
|
-
|
105
|
+
url = File.join(Connection::BASE_PATH, '/Applications')
|
106
|
+
|
107
|
+
response = CapitalOnTap.connection.post(url, params)
|
75
108
|
response
|
76
109
|
end
|
77
110
|
|
78
111
|
def self.status(locator_id)
|
79
|
-
|
112
|
+
url = File.join(Connection::BASE_PATH, "/Applications/#{locator_id}")
|
113
|
+
|
114
|
+
CapitalOnTap.connection.get(url)
|
80
115
|
end
|
81
116
|
end
|
82
117
|
end
|
data/lib/capital_on_tap/auth.rb
CHANGED
@@ -32,12 +32,14 @@ module CapitalOnTap
|
|
32
32
|
# refresh_token: '<refresh_token>'
|
33
33
|
# }
|
34
34
|
def get_token
|
35
|
-
client = Faraday.new(url: config.
|
35
|
+
client = Faraday.new(url: config.base_auth_url) do |conn|
|
36
36
|
conn.headers['Content-Type'] = 'application/x-www-form-urlencoded'
|
37
37
|
conn.response :logger if config.debug?
|
38
38
|
conn.adapter Faraday.default_adapter
|
39
39
|
end
|
40
40
|
|
41
|
+
puts "[DEBUG] Sending #{token_params.inspect}" if config.debug?
|
42
|
+
|
41
43
|
result = client.post do |req|
|
42
44
|
req.url TOKEN_PATH
|
43
45
|
req.body = URI.encode_www_form(token_params)
|
@@ -5,7 +5,8 @@ module CapitalOnTap
|
|
5
5
|
attr_accessor :client_id, :client_secret, :username, :password, :env
|
6
6
|
attr_writer :debug
|
7
7
|
|
8
|
-
|
8
|
+
DEFAULT_AUTH_DOMAIN = 'https://prelive-api-auth.capitalontap.com'
|
9
|
+
DEFAULT_DOMAIN = 'https://prelive-api-partner.capitalontap.com'
|
9
10
|
|
10
11
|
def initialize
|
11
12
|
@client_id = ''
|
@@ -20,6 +21,10 @@ module CapitalOnTap
|
|
20
21
|
@debug
|
21
22
|
end
|
22
23
|
|
24
|
+
def base_auth_url
|
25
|
+
DEFAULT_AUTH_DOMAIN
|
26
|
+
end
|
27
|
+
|
23
28
|
def base_url
|
24
29
|
DEFAULT_DOMAIN
|
25
30
|
end
|
@@ -26,19 +26,17 @@ module CapitalOnTap
|
|
26
26
|
def get(path, params = {})
|
27
27
|
log "GET #{path} with #{params}"
|
28
28
|
|
29
|
-
|
29
|
+
http_response = adapter.get(path, params)
|
30
30
|
|
31
|
-
|
32
|
-
response.body
|
31
|
+
Response.new(http_response)
|
33
32
|
end
|
34
33
|
|
35
34
|
def post(path, params = {})
|
36
35
|
log "POST #{path} with #{params}"
|
37
36
|
|
38
|
-
|
37
|
+
http_response = adapter.post(path, params.to_json)
|
39
38
|
|
40
|
-
|
41
|
-
response.body
|
39
|
+
Response.new(http_response)
|
42
40
|
end
|
43
41
|
|
44
42
|
def log(text)
|
@@ -60,7 +58,8 @@ module CapitalOnTap
|
|
60
58
|
|
61
59
|
def adapter
|
62
60
|
Faraday.new(url: base_url) do |conn|
|
63
|
-
conn.headers =
|
61
|
+
conn.headers['Authorization'] = "Bearer #{@access_token}" if !@access_token.to_s.empty?
|
62
|
+
conn.headers['Content-Type'] = 'application/json'
|
64
63
|
conn.use FaradayMiddleware::ParseJson
|
65
64
|
conn.response :json, parser_options: { symbolize_names: true }
|
66
65
|
conn.response :logger if CapitalOnTap.configuration.debug?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capital_on_tap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rikas
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|