capital_on_tap 0.1.3 → 0.1.4

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: bff5891dcbecd3178438709a8cb21596381130a8cd1a88dbd02129042a993625
4
- data.tar.gz: 6ef2b505c7fa934fca6ca5b5cd8e2fb008e4ad749c5ca773011bb2a700b2a50a
3
+ metadata.gz: ff304abb175e93a841c01589d25435e3f8b6528930ea343220f2d212037c1512
4
+ data.tar.gz: 191e56331d8a27a8598e79571316713e48390a8bce5a9b86221a4e8654f37ea7
5
5
  SHA512:
6
- metadata.gz: 675f9a641f3264869f8095791c376248fd2677267e3c255e0e6bb819b36cd8a9a7e2444baf14f616ee457bd7328faf1e93a43569d0647a49c54e714cad98c0aa
7
- data.tar.gz: 9e5355e7313b3f13446abfe91b9e5ffbc5f8cfdccc20d993c37dc1caf00d6a11a9a64aae1370cd57c472d66648350a833bddf67458909652bea24267110da85c
6
+ metadata.gz: b9ff711519ecfa374a4570fe8b7766faee184bdf156ede7d5f2376d157ca51de33c61c0426ab7879b2afbfbd21908263ea24b9ab0f2ef6d21a02847bc2093016
7
+ data.tar.gz: 75e6517a653a7cf19c401c3a0e6958b629f7c954eadd9f31bb5c0890235606f1fd3ee5c93a0e7098c86dd58d3aae89a791f962b9e43d09c278c53d7d15a150f2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- capital_on_tap (0.1.3)
4
+ capital_on_tap (0.1.4)
5
5
  addressable
6
6
  faraday
7
7
  faraday_middleware
data/bin/console CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'bundler/setup'
5
5
  require 'capital_on_tap'
6
+ require 'date'
6
7
 
7
8
  require 'dotenv'
8
9
  Dotenv.load
@@ -17,5 +18,39 @@ end
17
18
 
18
19
  CapitalOnTap.setup_connection!
19
20
 
21
+ def generate_params
22
+ {
23
+ Salutation: 'Mr',
24
+ FirstName: 'Roberto',
25
+ LastName: 'Caras',
26
+ DateOfBirth: Date.parse("1980-#{rand(1..12)}-#{rand(1..28)}"),
27
+ MobilePhone: "077123456#{rand(11..99)}",
28
+ EmailAddress: "oterosantos_#{rand(1..100)}@gmail.com",
29
+ PersonalAddress: {
30
+ CountryCode: 'UK',
31
+ Street: "Unit #{rand(1..99)} Falcon Way Adelaide Industrial Estate, Boucher Road",
32
+ PostCode: 'BT12 6SQ',
33
+ City: 'Belfast'
34
+ },
35
+ TradingName: 'DUNDER MCMIFFLIN LTD',
36
+ BusinessLegalName: 'DUNDER MCMIFFLIN LTD',
37
+ BusinessLandline: '07874186570',
38
+ YearsTrading: rand(1..10),
39
+ MonthlyTurnOver: rand(300...9000),
40
+ BusinessType: 'LimitedCompany',
41
+ BusinessAddress: {
42
+ CountryCode: 'UK',
43
+ Street: "Unit #{rand(1..99)} Falcon Way Adelaide Industrial Estate, Boucher Road",
44
+ PostCode: 'BT12 6SQ',
45
+ City: 'Belfast'
46
+ },
47
+ RegistrationNumber: 'NI644403'
48
+ }
49
+ end
50
+
51
+ def generate_code
52
+ CapitalOnTap::Application.create(generate_params)
53
+ end
54
+
20
55
  require 'pry'
21
56
  Pry.start
@@ -5,15 +5,22 @@ module CapitalOnTap
5
5
  attr_accessor :client_id, :client_secret, :username, :password, :env
6
6
  attr_writer :debug
7
7
 
8
- DEFAULT_AUTH_DOMAIN = 'https://prelive-api-auth.capitalontap.com'
9
- DEFAULT_DOMAIN = 'https://prelive-api-partner.capitalontap.com'
8
+ AUTH_DOMAINS = {
9
+ production: 'https://api-auth.capitalontap.com',
10
+ development: 'https://prelive-api-auth.capitalontap.com'
11
+ }
12
+
13
+ API_DOMAINS = {
14
+ production: 'https://api-partner.capitalontap.com',
15
+ development: 'https://prelive-api-partner.capitalontap.com'
16
+ }
10
17
 
11
18
  def initialize
12
19
  @client_id = ''
13
20
  @client_secret = ''
14
21
  @username = ''
15
22
  @password = ''
16
- @env = :development
23
+ @env = defined?(Rails) ? Rails.env : :development
17
24
  @debug = false
18
25
  end
19
26
 
@@ -22,11 +29,11 @@ module CapitalOnTap
22
29
  end
23
30
 
24
31
  def base_auth_url
25
- DEFAULT_AUTH_DOMAIN
32
+ AUTH_DOMAINS[@env.to_sym]
26
33
  end
27
34
 
28
35
  def base_url
29
- DEFAULT_DOMAIN
36
+ API_DOMAINS[@env.to_sym]
30
37
  end
31
38
  end
32
39
  end
@@ -28,6 +28,8 @@ module CapitalOnTap
28
28
 
29
29
  http_response = adapter.get(path, params)
30
30
 
31
+ log "Response: #{http_response.body}"
32
+
31
33
  Response.new(http_response)
32
34
  end
33
35
 
@@ -36,6 +38,8 @@ module CapitalOnTap
36
38
 
37
39
  http_response = adapter.post(path, params.to_json)
38
40
 
41
+ log "Response: #{http_response.body}"
42
+
39
43
  Response.new(http_response)
40
44
  end
41
45
 
@@ -62,7 +66,7 @@ module CapitalOnTap
62
66
  conn.headers['Content-Type'] = 'application/json'
63
67
  conn.use FaradayMiddleware::ParseJson
64
68
  conn.response :json, parser_options: { symbolize_names: true }
65
- conn.response :logger if CapitalOnTap.configuration.debug?
69
+ # conn.response :logger if CapitalOnTap.configuration.debug?
66
70
  conn.adapter Faraday.default_adapter
67
71
  end
68
72
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CapitalOnTap
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -24,8 +24,6 @@ module CapitalOnTap
24
24
  def setup_connection!
25
25
  token_params = CapitalOnTap::Auth.get_token
26
26
 
27
- puts token_params.inspect
28
-
29
27
  raise "ERROR: #{token_params[:error_description]}" if token_params[:error]
30
28
 
31
29
  @connection = Connection.new(
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - rikas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-07 00:00:00.000000000 Z
11
+ date: 2019-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable