paymentrails 0.2.4 → 0.2.5

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: 44ac83f800a214ab670b0f896817785b08c17a7991c1a9bd709eecefbea624f9
4
- data.tar.gz: 8645750959fe8071d3d07e155473a4eb29ded347f44d25ea7bf12b92a71ec46b
3
+ metadata.gz: d8e68d127632642e2a6f5e589f9917f2097973f38d2359d4f4a30dadff376adb
4
+ data.tar.gz: 0ad8869d5c77c0934a8e6a13a2d65a100aeaef98d6a50fb1dee8331b0a6e34e8
5
5
  SHA512:
6
- metadata.gz: 17135435e18bda035813a88c3ad821add0a85cdf519e853e49c93ada53f24cd15a0432f5dbba439b7b25ae41bbcc621c7f032ae69ad7f9c4caaba63451d3086b
7
- data.tar.gz: 86b59823d94e9d096d13580658b076d5548ac33ec4af4e8f6b6ca7de659c9038a5535f65b72ee0b20721a4e5ba17170af24c4dd21d7b2119a92952ceaf7e4943
6
+ metadata.gz: f7084cb8f263e09821cd799238f05a0d8c21a6032b865cf437dbe52fc31b9672474713c484718023f698e9f456040e0d7b0598ff9d58c74eb9dacb7aff394029
7
+ data.tar.gz: 68ea9490dd727eebf0b70d19af963d2c21ed736f957741a620b83de22de3607f16bb00a16f189ccb50c4210070830ee057e7112fb07956ca45eeb3bc085f6c89
data/lib/paymentrails.rb CHANGED
@@ -21,4 +21,4 @@ module PaymentRails
21
21
  def self.client(key, secret, environment = 'production', **optionals)
22
22
  Gateway.new(Configuration.new(key, secret, environment, optionals))
23
23
  end
24
- 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,20 @@
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
+ )
5
19
  end
6
- end
20
+ end
@@ -45,4 +45,4 @@ module PaymentRails
45
45
 
46
46
  attr_reader :environment
47
47
  end
48
- 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
@@ -44,7 +44,8 @@ module PaymentRails
44
44
  :returnedNote,
45
45
  :returnedReason,
46
46
  :failureMessage,
47
- :merchantId
47
+ :merchantId,
48
+ :checkNumber
48
49
  )
49
50
  end
50
51
  end
@@ -1,6 +1,41 @@
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
+ )
5
40
  end
6
41
  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
@@ -36,9 +39,7 @@ module PaymentRails
36
39
  data = JSON.parse(response)
37
40
  data.each do |key, value|
38
41
  next unless key === 'recipient'
39
- value.each do |recipKey, recipValue|
40
- recipient.send("#{recipKey}=", recipValue)
41
- end
42
+ loosely_hydrate_model(recipient, value)
42
43
  end
43
44
  recipient
44
45
  end
@@ -50,14 +51,11 @@ module PaymentRails
50
51
  data.each do |key, value|
51
52
  next unless key === 'recipients'
52
53
  value.each do |newKey, _newValue|
53
- recipient = Recipient.new
54
- newKey.each do |key1, value1|
55
- recipient.send("#{key1}=", value1)
56
- end
54
+ recipient = loosely_hydrate_model(Recipient.new, newKey)
57
55
  recipients.push(recipient)
58
56
  end
59
57
  end
60
58
  recipients
61
59
  end
62
60
  end
63
- end
61
+ end
data/paymentrails.gemspec CHANGED
@@ -4,7 +4,7 @@ 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.4'
7
+ s.version = '0.2.5'
8
8
  s.homepage = 'https://www.paymentrails.com/'
9
9
  s.email = ['joshua@paymentrails.com']
10
10
  s.license = "MIT"
@@ -13,6 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.required_ruby_version = '>= 2.4'
14
14
  s.add_development_dependency 'dotenv', '~> 2'
15
15
  s.add_development_dependency 'rake', '~> 12'
16
- s.add_development_dependency "rubocop", '~> 0.77'
16
+ s.add_development_dependency "rubocop", '~> 0.77.0'
17
17
  s.add_development_dependency 'test-unit', '~> 3'
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymentrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - PaymentRails
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-27 00:00:00.000000000 Z
11
+ date: 2020-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.77'
47
+ version: 0.77.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0.77'
54
+ version: 0.77.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: test-unit
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -88,6 +88,7 @@ files:
88
88
  - lib/paymentrails/RecipientAccount.rb
89
89
  - lib/paymentrails/gateways/BalanceGateway.rb
90
90
  - lib/paymentrails/gateways/BatchGateway.rb
91
+ - lib/paymentrails/gateways/GatewayHelper.rb
91
92
  - lib/paymentrails/gateways/OfflinePaymentGateway.rb
92
93
  - lib/paymentrails/gateways/PaymentGateway.rb
93
94
  - lib/paymentrails/gateways/RecipientAccountGateway.rb