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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ee93206500bbc4d766b102842c5abd719fc96824d78d959e851610516459266
4
- data.tar.gz: faa9a13f0c6640d4806991c4a5ff9a5dca7d9a151f591c25e9f6fa568c787b8a
3
+ metadata.gz: 8a069d25bab5d251a3d7464bde27e32480755a658f5aa100fd844c8657ea1b3e
4
+ data.tar.gz: a3d216478cbbdbd0f0560e5a77accb74a813c6da26d87cb9298c9c74d088a32d
5
5
  SHA512:
6
- metadata.gz: 0a18e9adb4ddf3844601138acfbde65d6fa0d73f1853504742b40c7787fdc599b0236895ed5c1a7e7a02c1be76f2e1ef1f07690c12cd6c72f89d7df1490f9fd8
7
- data.tar.gz: 34b80be737a174048ea8d2473bdf5d29080702c558a58c245eec10627171dc705eea76cf6dd55d01c8fa52b8bdfb34a40fa8178aef2470d51f17e2290a1c7a4d
6
+ metadata.gz: b424f8aa0ed8a5a58fda6d011c7b95ba519486ee3dbc2b0f9f28331268d67d8c862ff1826147e6bc78c6f297a79039b050168928bcec78e6dc20d90d296cadeb
7
+ data.tar.gz: c1cb89a7c2f1b86bd8a70063df33dce86939b4f7fe9864e68d11afa3dccaa4e123cc403ba5f1d30765b9d29a29b71caf9f73ae15c87f325f940f6cff30e0c6d5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capital_on_tap (0.1.0)
4
+ capital_on_tap (0.1.2)
5
5
  addressable
6
6
  faraday
7
7
  faraday_middleware
data/bin/console CHANGED
@@ -15,8 +15,7 @@ CapitalOnTap.configure do |config|
15
15
  config.debug = true
16
16
  end
17
17
 
18
- token_params = CapitalOnTap::Auth.get_token
19
- CapitalOnTap.setup_connection(token_params)
18
+ CapitalOnTap.setup_connection!
20
19
 
21
20
  require 'pry'
22
21
  Pry.start
@@ -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(params = {})
24
- raise "ERROR: #{params[:error_description]}" if params[:error]
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: params[:access_token],
28
- expires_in: params[:expires_in],
29
- refresh_token: params[: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
- # "salutation": "Mr",
21
- # "firstName": "Joe",
22
- # "middleName": "Fred",
23
- # "lastName": "Bloggs",
24
- # "dateOfBirth": "1970-02-15",
25
- # "mobilePhone": "07700900408",
26
- # "homePhone": "02079460794",
27
- # "emailAddress": "joe.bloggs@mail.com",
28
- # "customerUsesPersonalBankAccountforBusiness": true,
29
- # "monthlyIncome": "3000",
30
- # "monthlyExpenditure": "2000",
31
- #
32
- # "personalAddress": {
33
- # "company" : ""
34
- # "buildingName": "Home Building",
35
- # "buildingNumber": "123",
36
- # "unitNumber": "A",
37
- # "street": "Home Street",
38
- # "city": "London",
39
- # "postCode": "W123456",
40
- # "countryCode": "UK",
41
- # "line1":"PostApplication",
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
- # "tradingName": "Joe Bloggs Ltd",
46
- # "businessLegalName": "Joe Bloggs Ltd",
47
- # "businessLandline": "02079460182",
48
- # "yearsTrading": "5",
49
- # "monthlyTurnOver": "10000",
50
- # "businessType": "SoleTrader",
51
- # "registrationNumber": "12345678",
52
- #
53
- # "businessAddress": {
54
- # "company" : null,
55
- # "buildingName": "Business Building",
56
- # "buildingNumber": "123",
57
- # "unitNumber": "A",
58
- # "street": "Business Street",
59
- # "city": "London",
60
- # "postCode": "W123456",
61
- # "countryCode": "UK",
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
- # "promoCode": "ExampleCode",
66
- # "onPasteEventFields": "firstName",
67
- # "monthlyBusinessExpenditure": "5000",
68
- # "externalReference": "ExampleAccountNumber",
69
- # "partnerCode":null,
70
- # "restrictedCountries":false,
71
- # "requestedCredit":10000,
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
- response = CapitalOnTap.connection.post('/Applications', params)
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
- CapitalOnTap.connection.get("/Applications/#{locator_id}")
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
@@ -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.base_url) do |conn|
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
- DEFAULT_DOMAIN = 'https://prelive-api-auth.capitalontap.com'
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
- http_reponse = adapter.get(path, params)
29
+ http_response = adapter.get(path, params)
30
30
 
31
- response = Response.new(http_response)
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
- http_reponse = adapter.post(path, params)
37
+ http_response = adapter.post(path, params.to_json)
39
38
 
40
- response = Response.new(http_response)
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 = authorization_header if !@access_token.to_s.empty?
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?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CapitalOnTap
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2'
5
5
  end
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.0
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-02 00:00:00.000000000 Z
11
+ date: 2018-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable