paymentrails 0.2.2 → 0.2.7

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: c675152b7b6253f43974fe54ef75f61040576e37b8eb8d18a31e0bdcd3648b31
4
- data.tar.gz: ffed38b9237d86b3d902950fd27f520d1ebdb7854fc605844e5167933082618c
3
+ metadata.gz: fe4996752fd67c0f9f51a6928671053a2f1b4b3e292c2a49f23efccead6a93d7
4
+ data.tar.gz: 73f861274286b70a7680c26aabadac19c7330fa4108f01a4e0841519a19d76cb
5
5
  SHA512:
6
- metadata.gz: 7946d78778cd54ff5952d939adf9ab8b37b0d1449801a34c45ee09c7f121ff72b0ca1db3cf2b0429aca93ad57dfc34391289f768b4dc3b8732aedb6ed7283a4e
7
- data.tar.gz: 85347efba19d8342f71d71fe3dce890c64505b965c640aed7b4207ae112d578324291c52674bfea845475d150d7a448283e22bba8bd666b3472654be6976f2ef
6
+ metadata.gz: 616d3babeb1241de33c83d9bb0812721f47f48a88dfa516b576a978b91ca9d42a11e910cbe0ba6b77573b9fd7a8556c214b52142b2e16b736e57c8265794bb1d
7
+ data.tar.gz: 046c39226137e9a41de1f851e0fc3566b5381b187462352040df8facbf1b5bb2bd4a5a3688aabcaa7c65b8bf28f956390e58d055ad2d41654607fa33f9042344
data/lib/paymentrails.rb CHANGED
@@ -18,8 +18,7 @@ require 'paymentrails/RecipientAccount'
18
18
  require 'paymentrails/OfflinePayment'
19
19
 
20
20
  module PaymentRails
21
- def self.client(key, secret, environment = 'production')
22
- client = Gateway.new(Configuration.new(key, secret, environment))
23
- return client
21
+ def self.client(key, secret, environment = 'production', **optionals)
22
+ Gateway.new(Configuration.new(key, secret, environment, optionals))
24
23
  end
25
- end
24
+ end
@@ -1,6 +1,20 @@
1
1
  module PaymentRails
2
2
  class Batch
3
- attr_accessor :id, :amount, :completedAt, :createdAt, :currency, :description, :sentAt, :status, :totalPayments, :updatedAt, :quoteExpiredAt, :payments, :tags, :coverFees
4
- attr_writer :id, :amount, :completedAt, :createdAt, :currency, :description, :sentAt, :status, :totalPayments, :updatedAt, :quoteExpiredAt, :payments, :tags, :coverFees
3
+ attr_accessor(
4
+ :id,
5
+ :amount,
6
+ :completedAt,
7
+ :createdAt,
8
+ :currency,
9
+ :description,
10
+ :sentAt,
11
+ :status,
12
+ :totalPayments,
13
+ :updatedAt,
14
+ :quoteExpiredAt,
15
+ :payments,
16
+ :tags,
17
+ :coverFees
18
+ )
5
19
  end
6
20
  end
@@ -1,6 +1,21 @@
1
1
  module PaymentRails
2
2
  class BatchSummary
3
- attr_accessor :id, :amount, :completedAt, :createdAt, :currency, :description, :sentAt, :status, :totalPayments, :updatedAt, :methods, :detail, :total
4
- attr_writer :id, :amount, :completedAt, :createdAt, :currency, :description, :sentAt, :status, :totalPayments, :updatedAt, :methods, :detail, :total
3
+ attr_accessor(
4
+ :id,
5
+ :amount,
6
+ :completedAt,
7
+ :createdAt,
8
+ :currency,
9
+ :description,
10
+ :sentAt,
11
+ :status,
12
+ :totalPayments,
13
+ :updatedAt,
14
+ :methods,
15
+ :detail,
16
+ :total,
17
+ :balances,
18
+ :accounts
19
+ )
5
20
  end
6
- end
21
+ end
@@ -2,7 +2,6 @@
2
2
  require 'digest'
3
3
  require 'net/http'
4
4
  require 'openssl'
5
- require 'rest-client'
6
5
  require 'uri'
7
6
  require 'json'
8
7
 
@@ -34,7 +33,10 @@ module PaymentRails
34
33
 
35
34
  def send_request(endPoint, method, body = '')
36
35
  uri = URI.parse(@config.apiBase + endPoint)
37
- http = Net::HTTP.new(uri.host, uri.port)
36
+ http = Net::HTTP.new(
37
+ uri.host, uri.port,
38
+ @config.proxy&.host, @config.proxy&.port, @config.proxy&.user, @config.proxy&.password
39
+ )
38
40
  http.use_ssl = @config.useSsl?
39
41
 
40
42
  time = Time.now.to_i
@@ -77,11 +79,11 @@ module PaymentRails
77
79
  when '401'
78
80
  raise AuthenticationError, message
79
81
  when '403'
80
- raise AuthorizationErrormessage
82
+ raise AuthorizationError, message
81
83
  when '404'
82
84
  raise NotFoundError, message
83
85
  when '429'
84
- raise TooManyRequestsError message
86
+ raise TooManyRequestsError, message
85
87
  when '500'
86
88
  raise ServerError, message
87
89
  when '503'
@@ -1,16 +1,19 @@
1
1
  module PaymentRails
2
2
  class Configuration
3
+ class InvalidProxyAddress < StandardError; end
3
4
 
4
- def initialize(publicKey, privateKey, environment = 'production')
5
- # if publicKey&.empty? || privateKey&.empty?
6
- # raise ArgumentError, 'Both key/secret must be a nonempty string'
7
- # end
8
-
9
- raise ArgumentError, 'Both key/secret must be a nonempty string' if publicKey&.empty? || privateKey&.empty?
5
+ def initialize(publicKey, privateKey, environment = 'production', proxy_uri: nil)
6
+ raise ArgumentError, 'Both key/secret must be a nonempty string' if publicKey.to_s&.empty? || privateKey.to_s&.empty?
10
7
 
11
8
  @publicKey = publicKey
12
9
  @privateKey = privateKey
13
10
  @environment = environment
11
+ # failfast on a bad proxy
12
+ begin
13
+ @proxy = proxy_uri.nil? ? nil : URI.parse(proxy_uri)
14
+ rescue URI::InvalidURIError
15
+ raise InvalidProxyAddress, "Invalid proxy provided to configuration: #{proxy_uri}"
16
+ end
14
17
  end
15
18
 
16
19
  def apiBase
@@ -30,6 +33,8 @@ module PaymentRails
30
33
  apiBase.start_with? 'https'
31
34
  end
32
35
 
36
+ attr_reader :proxy
37
+
33
38
  attr_reader :publicKey
34
39
 
35
40
  attr_writer :publicKey
@@ -40,4 +45,4 @@ module PaymentRails
40
45
 
41
46
  attr_reader :environment
42
47
  end
43
- end
48
+ end
@@ -16,4 +16,4 @@ module PaymentRails
16
16
  class UnexpectedError < PaymentRailsError; end
17
17
 
18
18
  class MalformedException < PaymentRailsError; end
19
- end
19
+ end
@@ -1,6 +1,23 @@
1
1
  module PaymentRails
2
2
  class OfflinePayment
3
- attr_accessor :id, :recipientId, :externalId, :memo, :tags, :taxReportable, :category, :amount, :currency, :withholdingAmount, :withholdingCurrency, :processedAt, :equivalentWithholdingAmount, :equivalentWithholdingCurrency, :updatedAt, :createdAt, :deletedAt
4
- attr_writer :id, :externalId, :memo, :tags, :taxReportable, :category, :amount, :currency, :withholdingAmount, :withholdingCurrency, :processedAt
3
+ attr_accessor(
4
+ :id,
5
+ :recipientId,
6
+ :externalId,
7
+ :memo,
8
+ :tags,
9
+ :taxReportable,
10
+ :category,
11
+ :amount,
12
+ :currency,
13
+ :withholdingAmount,
14
+ :withholdingCurrency,
15
+ :processedAt,
16
+ :equivalentWithholdingAmount,
17
+ :equivalentWithholdingCurrency,
18
+ :updatedAt,
19
+ :createdAt,
20
+ :deletedAt
21
+ )
5
22
  end
6
23
  end
@@ -21,6 +21,7 @@ module PaymentRails
21
21
  :merchantFees,
22
22
  :compliance,
23
23
  :payoutMethod,
24
+ :estimatedDeliveryAt,
24
25
  :recipient,
25
26
  :withholdingAmount,
26
27
  :withholdingCurrency,
@@ -43,7 +44,9 @@ module PaymentRails
43
44
  :returnedNote,
44
45
  :returnedReason,
45
46
  :failureMessage,
46
- :merchantId
47
+ :merchantId,
48
+ :checkNumber,
49
+ :forceUsTaxActivity
47
50
  )
48
51
  end
49
52
  end
@@ -1,6 +1,42 @@
1
1
  module PaymentRails
2
2
  class Recipient
3
- attr_accessor :id, :routeType, :estimatedFees, :referenceId, :email, :name, :lastName, :firstName, :type, :taxType, :status, :language, :complianceStatus, :dob, :passport, :updatedAt, :createdAt, :gravatarUrl, :governmentId, :ssn, :primaryCurrency, :merchantId, :payout, :compliance, :accounts, :address, :taxWithholdingPercentage, :taxForm, :taxFormStatus, :inactiveReasons, :payoutMethod, :placeOfBirth, :tags, :taxDeliveryType
4
- attr_writer :id, :routeType, :estimatedFees, :referenceId, :email, :name, :lastName, :firstName, :type, :taxType, :status, :language, :complianceStatus, :dob, :passport, :updatedAt, :createdAt, :gravatarUrl, :governmentId, :ssn, :primaryCurrency, :merchantId, :payout, :compliance, :accounts, :address, :taxWithholdingPercentage, :taxForm, :taxFormStatus, :inactiveReasons, :payoutMethod, :placeOfBirth, :tags, :taxDeliveryType
3
+ attr_accessor(
4
+ :id,
5
+ :routeType,
6
+ :estimatedFees,
7
+ :referenceId,
8
+ :email,
9
+ :name,
10
+ :lastName,
11
+ :firstName,
12
+ :type,
13
+ :taxType,
14
+ :status,
15
+ :language,
16
+ :complianceStatus,
17
+ :dob,
18
+ :passport,
19
+ :updatedAt,
20
+ :createdAt,
21
+ :gravatarUrl,
22
+ :governmentId,
23
+ :ssn,
24
+ :primaryCurrency,
25
+ :merchantId,
26
+ :payout,
27
+ :compliance,
28
+ :accounts,
29
+ :address,
30
+ :taxWithholdingPercentage,
31
+ :taxForm,
32
+ :taxFormStatus,
33
+ :inactiveReasons,
34
+ :payoutMethod,
35
+ :placeOfBirth,
36
+ :tags,
37
+ :taxDeliveryType,
38
+ :riskScore,
39
+ :isPortalUser
40
+ )
5
41
  end
6
42
  end
@@ -1,6 +1,30 @@
1
1
  module PaymentRails
2
2
  class RecipientAccount
3
- attr_accessor :id, :primary, :currency, :recipientAccountId, :recipientId, :recipientReferenceId, :routeType, :recipientFees, :emailAddress, :country, :type, :iban, :accountNum, :accountHolderName, :swiftBic, :branchId, :bankId, :bankName, :bankAddress, :bankCity, :bankRegionCode, :bankPostalCode, :status, :disabledAt
4
- attr_writer :id, :primary, :currency, :recipientAccountId, :recipientId, :recipientReferenceId, :routeType, :recipientFees, :emailAddress, :country, :type, :iban, :accountNum, :accountHolderName, :swiftBic, :branchId, :bankId, :bankName, :bankAddress, :bankCity, :bankRegionCode, :bankPostalCode, :status, :disabledAt
3
+ attr_accessor(
4
+ :id,
5
+ :primary,
6
+ :currency,
7
+ :recipientAccountId,
8
+ :recipientId,
9
+ :recipientReferenceId,
10
+ :routeType,
11
+ :recipientFees,
12
+ :emailAddress,
13
+ :country,
14
+ :type,
15
+ :iban,
16
+ :accountNum,
17
+ :accountHolderName,
18
+ :swiftBic,
19
+ :branchId,
20
+ :bankId,
21
+ :bankName,
22
+ :bankAddress,
23
+ :bankCity,
24
+ :bankRegionCode,
25
+ :bankPostalCode,
26
+ :status,
27
+ :disabledAt
28
+ )
5
29
  end
6
- end
30
+ end
@@ -12,4 +12,4 @@ module PaymentRails
12
12
  end
13
13
 
14
14
  end
15
- end
15
+ end
@@ -1,7 +1,10 @@
1
1
  require_relative '../Client.rb'
2
+ require_relative 'GatewayHelper'
2
3
 
3
4
  module PaymentRails
4
5
  class BatchGateway
6
+ include GatewayHelper
7
+
5
8
  def initialize(client)
6
9
  @client = client
7
10
  end
@@ -51,9 +54,7 @@ module PaymentRails
51
54
  data = JSON.parse(response)
52
55
  data.each do |key, value|
53
56
  next unless key === 'batch'
54
- value.each do |newKey, newValue|
55
- batch.send("#{newKey}=", newValue)
56
- end
57
+ loosely_hydrate_model(batch, value)
57
58
  end
58
59
  batch
59
60
  end
@@ -64,9 +65,7 @@ module PaymentRails
64
65
  data = JSON.parse(response)
65
66
  data.each do |key, value|
66
67
  next unless key === 'batchSummary'
67
- value.each do |newKey, newValue|
68
- summary.send("#{newKey}=", newValue)
69
- end
68
+ loosely_hydrate_model(summary, value)
70
69
  end
71
70
  summary
72
71
  end
@@ -78,14 +77,12 @@ module PaymentRails
78
77
  data.each do |key, value|
79
78
  next unless key === 'batches'
80
79
  value.each do |newKey, _newValue|
81
- batch = Batch.new
82
- newKey.each do |key1, value1|
83
- batch.send("#{key1}=", value1)
84
- end
85
- batches.push(batch)
80
+ batches.push(
81
+ loosely_hydrate_model(Batch.new, newKey)
82
+ )
86
83
  end
87
84
  end
88
85
  batches
89
86
  end
90
87
  end
91
- end
88
+ end
@@ -0,0 +1,15 @@
1
+ module PaymentRails
2
+ module GatewayHelper
3
+ def loosely_hydrate_model(klass_instance, attributes)
4
+ attributes.each do |k, v|
5
+ begin
6
+ klass_instance.send("#{k}=", v)
7
+ rescue NoMethodError
8
+ warn "[PaymentRails] Unknown attribute #{k} for class #{klass_instance.class.name}"
9
+ end
10
+ end
11
+
12
+ klass_instance
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,10 @@
1
1
  require_relative '../Client.rb'
2
+ require_relative 'GatewayHelper'
2
3
 
3
4
  module PaymentRails
4
5
  class OfflinePaymentGateway
6
+ include GatewayHelper
7
+
5
8
  def initialize(client)
6
9
  @client = client
7
10
  end
@@ -36,9 +39,7 @@ module PaymentRails
36
39
  data = JSON.parse(response)
37
40
  data.each do |key, value|
38
41
  next unless key === 'offlinePayment'
39
- value.each do |opKey, opValue|
40
- offline_payment.send("#{opKey}=", opValue)
41
- end
42
+ loosely_hydrate_model(offline_payment, value)
42
43
  end
43
44
  offline_payment
44
45
  end
@@ -50,14 +51,11 @@ module PaymentRails
50
51
  data.each do |key, value|
51
52
  next unless key === 'offlinePayments'
52
53
  value.each do |newKey, _newValue|
53
- offline_payment = OfflinePayment.new
54
- newKey.each do |key1, value1|
55
- offline_payment.send("#{key1}=", value1)
56
- end
54
+ offline_payment = loosely_hydrate_model(OfflinePayment.new, newKey)
57
55
  offline_payments.push(offline_payment)
58
56
  end
59
57
  end
60
58
  offline_payments
61
59
  end
62
60
  end
63
- end
61
+ end
@@ -1,7 +1,10 @@
1
1
  require_relative '../Client.rb'
2
+ require_relative 'GatewayHelper'
2
3
 
3
4
  module PaymentRails
4
5
  class PaymentGateway
6
+ include GatewayHelper
7
+
5
8
  def initialize(client)
6
9
  @client = client
7
10
  end
@@ -36,9 +39,7 @@ module PaymentRails
36
39
  data = JSON.parse(response)
37
40
  data.each do |key, value|
38
41
  next unless key === 'payment'
39
- value.each do |recipKey, recipValue|
40
- payment.send("#{recipKey}=", recipValue)
41
- end
42
+ loosely_hydrate_model(payment, value)
42
43
  end
43
44
  payment
44
45
  end
@@ -50,14 +51,11 @@ module PaymentRails
50
51
  data.each do |key, value|
51
52
  next unless key === 'payments'
52
53
  value.each do |newKey, _newValue|
53
- payment = Payment.new
54
- newKey.each do |key1, value1|
55
- payment.send("#{key1}=", value1)
56
- end
54
+ payment = loosely_hydrate_model(Payment.new, newKey)
57
55
  payments.push(payment)
58
56
  end
59
57
  end
60
58
  payments
61
59
  end
62
60
  end
63
- end
61
+ end
@@ -1,7 +1,10 @@
1
1
  require_relative '../Client.rb'
2
+ require_relative 'GatewayHelper'
2
3
 
3
4
  module PaymentRails
4
5
  class RecipientAccountGateway
6
+ include GatewayHelper
7
+
5
8
  def initialize(client)
6
9
  @client = client
7
10
  end
@@ -36,9 +39,7 @@ module PaymentRails
36
39
  data = JSON.parse(response)
37
40
  data.each do |key, value|
38
41
  next unless key === 'account'
39
- value.each do |recipKey, recipValue|
40
- recipient_account.send("#{recipKey}=", recipValue)
41
- end
42
+ loosely_hydrate_model(recipient_account, value)
42
43
  end
43
44
  recipient_account
44
45
  end
@@ -50,14 +51,11 @@ module PaymentRails
50
51
  data.each do |key, value|
51
52
  next unless key === 'accounts'
52
53
  value.each do |newKey, _newValue|
53
- recipient_account = RecipientAccount.new
54
- newKey.each do |key1, value1|
55
- recipient_account.send("#{key1}=", value1)
56
- end
54
+ recipient_account = loosely_hydrate_model(RecipientAccount.new, newKey)
57
55
  recipient_accounts.push(recipient_account)
58
56
  end
59
57
  end
60
58
  recipient_accounts
61
59
  end
62
60
  end
63
- end
61
+ end
@@ -1,7 +1,10 @@
1
1
  require_relative '../Client.rb'
2
+ require_relative 'GatewayHelper'
2
3
 
3
4
  module PaymentRails
4
5
  class RecipientGateway
6
+ include GatewayHelper
7
+
5
8
  def initialize(client)
6
9
  @client = client
7
10
  end
@@ -26,8 +29,15 @@ module PaymentRails
26
29
  true
27
30
  end
28
31
 
29
- def search(page = 1, page_size = 10, term = '')
30
- response = @client.get('/v1/recipients?page=' + page.to_s + '&pageSize=' + page_size.to_s + '&search=' + term)
32
+ # TODO: if we can afford a breaking change ideally these should be kwargs
33
+ def search(page = 1, page_size = 10, prefix_search = '', filters = {})
34
+ query_string = URI.encode_www_form(
35
+ page: page.to_s,
36
+ pageSize: page_size.to_s,
37
+ search: prefix_search,
38
+ **filters
39
+ )
40
+ response = @client.get("/v1/recipients?#{query_string}")
31
41
  recipient_list_builder(response)
32
42
  end
33
43
 
@@ -36,9 +46,7 @@ module PaymentRails
36
46
  data = JSON.parse(response)
37
47
  data.each do |key, value|
38
48
  next unless key === 'recipient'
39
- value.each do |recipKey, recipValue|
40
- recipient.send("#{recipKey}=", recipValue)
41
- end
49
+ loosely_hydrate_model(recipient, value)
42
50
  end
43
51
  recipient
44
52
  end
@@ -50,14 +58,11 @@ module PaymentRails
50
58
  data.each do |key, value|
51
59
  next unless key === 'recipients'
52
60
  value.each do |newKey, _newValue|
53
- recipient = Recipient.new
54
- newKey.each do |key1, value1|
55
- recipient.send("#{key1}=", value1)
56
- end
61
+ recipient = loosely_hydrate_model(Recipient.new, newKey)
57
62
  recipients.push(recipient)
58
63
  end
59
64
  end
60
65
  recipients
61
66
  end
62
67
  end
63
- end
68
+ end
data/paymentrails.gemspec CHANGED
@@ -4,13 +4,15 @@ Gem::Specification.new do |s|
4
4
  s.name = "paymentrails"
5
5
  s.summary = "PaymentRails Ruby SDK"
6
6
  s.description = "Ruby SDK for interacting with the PaymentRails API"
7
- s.version = '0.2.2'
7
+ s.version = '0.2.7'
8
8
  s.homepage = 'https://www.paymentrails.com/'
9
9
  s.email = ['joshua@paymentrails.com']
10
10
  s.license = "MIT"
11
11
  s.author = "PaymentRails"
12
12
  s.files = Dir.glob ["README.rdoc", "LICENSE", "lib/**/*.{rb,crt}", "spec/**/*", "*.gemspec"]
13
13
  s.required_ruby_version = '>= 2.4'
14
- s.add_dependency "rest-client", ">= 2.0.0"
15
- s.add_development_dependency "rubocop", '~> 0.77'
14
+ s.add_development_dependency 'dotenv', '~> 2'
15
+ s.add_development_dependency 'rake', '~> 12'
16
+ s.add_development_dependency "rubocop", '~> 0.77.0'
17
+ s.add_development_dependency 'test-unit', '~> 3'
16
18
  end
@@ -1,10 +1,13 @@
1
- require_relative '../../lib/paymentrails'
2
- require 'test/unit'
3
- require 'securerandom'
1
+ require_relative 'helper'
4
2
 
5
3
  class BatchTest < Test::Unit::TestCase
6
4
  def setup
7
- @client = PaymentRails::Gateway.new(PaymentRails::Configuration.new('YOUR-API-KEY', 'YOUR-SECRET-KEY'))
5
+ @client = PaymentRails.client(
6
+ ENV.fetch('SANDBOX_API_KEY'),
7
+ ENV.fetch('SANDBOX_SECRET_KEY'),
8
+ 'production',
9
+ proxy_uri: ENV['PROXY_URI']
10
+ )
8
11
  end
9
12
 
10
13
  def create_recipient
@@ -1,10 +1,13 @@
1
- require_relative '../../lib/paymentrails'
2
- require 'test/unit'
3
- require 'securerandom'
1
+ require_relative 'helper'
4
2
 
5
3
  class RecipientTest < Test::Unit::TestCase
6
4
  def setup
7
- @client = PaymentRails::Gateway.new(PaymentRails::Configuration.new('YOUR-API-KEY', 'YOUR-SECRET-KEY'))
5
+ @client = PaymentRails.client(
6
+ ENV.fetch('SANDBOX_API_KEY'),
7
+ ENV.fetch('SANDBOX_SECRET_KEY'),
8
+ 'production',
9
+ proxy_uri: ENV['PROXY_URI']
10
+ )
8
11
  end
9
12
 
10
13
  def test_create
@@ -0,0 +1,4 @@
1
+ require 'dotenv/load'
2
+ require_relative '../../lib/paymentrails'
3
+ require 'test/unit'
4
+ require 'securerandom'
@@ -0,0 +1,51 @@
1
+ require_relative '../../lib/paymentrails'
2
+ require 'test/unit'
3
+
4
+ class ConfigurationTest < Test::Unit::TestCase
5
+ def test_new_nil
6
+ assert_raise ArgumentError.new('Both key/secret must be a nonempty string') do
7
+ PaymentRails::Configuration.new(nil, nil)
8
+ end
9
+ end
10
+
11
+ def test_new_empty_string
12
+ assert_raise ArgumentError.new('Both key/secret must be a nonempty string') do
13
+ PaymentRails::Configuration.new('', '')
14
+ end
15
+ end
16
+
17
+ def test_new_nonempty_string
18
+ assert_nothing_raised do
19
+ PaymentRails::Configuration.new('key', 'secret')
20
+ end
21
+ end
22
+
23
+ def test_api_base
24
+ assert_equal 'http://api.local.dev:3000', PaymentRails::Configuration.new('key', 'secret', 'integration').apiBase
25
+ assert_equal 'https://api.paymentrails.com', PaymentRails::Configuration.new('key', 'secret', 'production').apiBase
26
+ assert_equal 'https://api.railz.io', PaymentRails::Configuration.new('key', 'secret', 'development').apiBase
27
+ assert_equal 'https://api.paymentrails.com', PaymentRails::Configuration.new('key', 'secret', 'non_standard_environment').apiBase
28
+ end
29
+
30
+ def test_use_ssl?
31
+ assert_equal false, PaymentRails::Configuration.new('key', 'secret', 'integration').useSsl?
32
+ assert_equal true, PaymentRails::Configuration.new('key', 'secret', 'production').useSsl?
33
+ assert_equal true, PaymentRails::Configuration.new('key', 'secret', 'development').useSsl?
34
+ assert_equal true, PaymentRails::Configuration.new('key', 'secret', 'non_standard_environment').useSsl?
35
+ end
36
+
37
+ def test_invalid_proxy_uri
38
+ proxy_uri = 'not_://*a_valid_proxy'
39
+ assert_raise PaymentRails::Configuration::InvalidProxyAddress.new("Invalid proxy provided to configuration: #{proxy_uri}") do
40
+ PaymentRails::Configuration.new('k', 's', 'production', proxy_uri: proxy_uri).proxy
41
+ end
42
+ end
43
+
44
+ def test_vaid_proxy_uri
45
+ config = PaymentRails::Configuration.new('k', 's', 'production', proxy_uri: 'http://user:pass@gimmeproxy.com:80')
46
+ assert_equal 'gimmeproxy.com', config.proxy.host
47
+ assert_equal 80, config.proxy.port
48
+ assert_equal 'user', config.proxy.user
49
+ assert_equal 'pass', config.proxy.password
50
+ end
51
+ end
@@ -0,0 +1,15 @@
1
+ require_relative '../../lib/paymentrails'
2
+ require 'test/unit'
3
+
4
+ class PaymentRailsTest < Test::Unit::TestCase
5
+ def test_client
6
+ PaymentRails.client('key', 'secret', 'environment', proxy_uri: 'http://user:pass@gimmeproxy.com:80')
7
+ end
8
+
9
+ def test_client_invalid_proxy_uri
10
+ proxy_uri = 'not_://*a_valid_proxy'
11
+ assert_raise PaymentRails::Configuration::InvalidProxyAddress.new("Invalid proxy provided to configuration: #{proxy_uri}") do
12
+ PaymentRails.client('k', 's', 'production', proxy_uri: proxy_uri)
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,43 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymentrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - PaymentRails
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2021-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rest-client
14
+ name: dotenv
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 2.0.0
20
- type: :runtime
19
+ version: '2'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 2.0.0
26
+ version: '2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rubocop
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '0.77'
47
+ version: 0.77.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.77.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: '0.77'
68
+ version: '3'
41
69
  description: Ruby SDK for interacting with the PaymentRails API
42
70
  email:
43
71
  - joshua@paymentrails.com
@@ -60,6 +88,7 @@ files:
60
88
  - lib/paymentrails/RecipientAccount.rb
61
89
  - lib/paymentrails/gateways/BalanceGateway.rb
62
90
  - lib/paymentrails/gateways/BatchGateway.rb
91
+ - lib/paymentrails/gateways/GatewayHelper.rb
63
92
  - lib/paymentrails/gateways/OfflinePaymentGateway.rb
64
93
  - lib/paymentrails/gateways/PaymentGateway.rb
65
94
  - lib/paymentrails/gateways/RecipientAccountGateway.rb
@@ -67,6 +96,9 @@ files:
67
96
  - paymentrails.gemspec
68
97
  - spec/integration/BatchTest.rb
69
98
  - spec/integration/RecipientTest.rb
99
+ - spec/integration/helper.rb
100
+ - spec/unit/ConfigurationTest.rb
101
+ - spec/unit/PaymentRailsTest.rb
70
102
  homepage: https://www.paymentrails.com/
71
103
  licenses:
72
104
  - MIT
@@ -86,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
118
  - !ruby/object:Gem::Version
87
119
  version: '0'
88
120
  requirements: []
89
- rubygems_version: 3.0.3
121
+ rubygems_version: 3.1.2
90
122
  signing_key:
91
123
  specification_version: 4
92
124
  summary: PaymentRails Ruby SDK