pfs 0.0.1 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/lib/pfs/api/accounts_service.rb +2 -2
- data/lib/pfs/api/authentication_service.rb +1 -1
- data/lib/pfs/api/services.rb +5 -0
- data/lib/pfs/api/statements_service.rb +12 -0
- data/lib/pfs/api/transactions_service.rb +1 -1
- data/lib/pfs/api/transfers_service.rb +1 -1
- data/lib/pfs/client.rb +2 -0
- data/lib/pfs/resources/accounts/balance.rb +1 -1
- data/lib/pfs/resources/authentication/token.rb +2 -2
- data/lib/pfs/resources/base.rb +3 -4
- data/lib/pfs/resources/collection.rb +3 -3
- data/lib/pfs/resources/statements/statement.rb +49 -0
- data/lib/pfs/resources/transactions/transaction.rb +78 -41
- data/lib/pfs/resources/transactions/transactions.rb +3 -16
- data/lib/pfs/version.rb +1 -1
- metadata +4 -3
- data/lib/pfs/resources/accounts/transaction.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f06e43fb3cf05a637ffddb40603839f31b4f7cb61dd66b08f01b3d76484c2ae
|
4
|
+
data.tar.gz: 5df9f6b3946a646848a8a109bc9c646a3ac6d4b22400782f8e807e36566297b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82cb826b1fb37bd4dd5626f17b863385737ba5bddce16ce05d264d5fb54c9134cc4aee6b45d408ded9f1fa3aad530975adcd109c14fe0d60fc73c3ca0b9ada01
|
7
|
+
data.tar.gz: 01bb4d39ac2b493c1fa3443e286e93d5b2aa35511cca687cf31f3e5a752564b9b5e09210deffde84acd00ba3bc0d4a4ad505ae92a4cfd349fb1be8b6f04bee73
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# PFS FINAC API Ruby client
|
2
2
|
|
3
3
|
Ruby client for PFS (cf. <https://staging-api.prepaidfinancialservices.com/apidocumentation>)
|
4
4
|
|
@@ -28,13 +28,20 @@ gem install pfs
|
|
28
28
|
|
29
29
|
## Development
|
30
30
|
|
31
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
32
|
|
33
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then
|
33
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then tag and push the new version:
|
34
|
+
|
35
|
+
```git
|
36
|
+
git tag vx.x.x main
|
37
|
+
git push origin vx.x.x
|
38
|
+
```
|
39
|
+
|
40
|
+
The tagging will trigger the GitHub action defined in `release.yml`, pushing the gem to [rubygems.org](https://rubygems.org).
|
34
41
|
|
35
42
|
## Contributing
|
36
43
|
|
37
|
-
Bug reports and pull requests are welcome on GitHub at <https://github.com/
|
44
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/devengoapp/pfs-ruby>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/devengoapp/pfs-ruby/pfs/blob/master/CODE_OF_CONDUCT.md).
|
38
45
|
|
39
46
|
## License
|
40
47
|
|
@@ -42,4 +49,4 @@ The gem is available as open-source under the terms of the [MIT License](https:/
|
|
42
49
|
|
43
50
|
## Code of Conduct
|
44
51
|
|
45
|
-
Everyone interacting in the PFS project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/
|
52
|
+
Everyone interacting in the PFS project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/devengoapp/pfs-ruby/blob/master/CODE_OF_CONDUCT.md).
|
@@ -5,7 +5,7 @@ module PFS
|
|
5
5
|
class AccountsService < Service
|
6
6
|
def balance(account_id)
|
7
7
|
response = client.get("/Account/#{account_id}/Balance")
|
8
|
-
Resources::Accounts::Balance.new(response)
|
8
|
+
Resources::Accounts::Balance.new(response, response.body[:data])
|
9
9
|
end
|
10
10
|
|
11
11
|
def credit(account_id, currency, amount, fee_code = "**API", description = "Deposit To Card API")
|
@@ -16,7 +16,7 @@ module PFS
|
|
16
16
|
transactionDescription: description,
|
17
17
|
}
|
18
18
|
response = client.post("/Account/#{account_id}/Balance/Credit", attributes)
|
19
|
-
Resources::Accounts::BalanceCredit.new(response)
|
19
|
+
Resources::Accounts::BalanceCredit.new(response, response.body[:data])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/pfs/api/services.rb
CHANGED
@@ -5,6 +5,7 @@ require_relative "accounts_service"
|
|
5
5
|
require_relative "authentication_service"
|
6
6
|
require_relative "transactions_service"
|
7
7
|
require_relative "transfers_service"
|
8
|
+
require_relative "statements_service"
|
8
9
|
|
9
10
|
module PFS
|
10
11
|
module API
|
@@ -24,6 +25,10 @@ module PFS
|
|
24
25
|
def transactions
|
25
26
|
@services[:transactions] ||= API::TransactionsService.new(self)
|
26
27
|
end
|
28
|
+
|
29
|
+
def statements
|
30
|
+
@services[:statements] ||= API::StatementsService.new(self)
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module PFS
|
2
|
+
module API
|
3
|
+
class StatementsService < Service
|
4
|
+
def by_id(account_id:, statement_id:, inward_outward:, processor:)
|
5
|
+
response = client.get(
|
6
|
+
"/BankPayment/#{account_id}/StatementById?statementitemid=#{statement_id}&InwardOutward=#{inward_outward}&Processor=#{processor}"
|
7
|
+
)
|
8
|
+
Resources::Statements::Statement.new(response, response.body.dig(:data, :transaction))
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -6,7 +6,7 @@ module PFS
|
|
6
6
|
def history(account_id:, start_date:, end_date:)
|
7
7
|
response = client.get("/Account/#{account_id}/Transactions?StartDate=#{start_date}&EndDate=#{end_date}")
|
8
8
|
transactions_raw = response.body.dig(:data, :transactions)
|
9
|
-
Resources::Transactions::Transactions.
|
9
|
+
Resources::Transactions::Transactions.new(response, response.body.dig(:data, :transactions))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -16,7 +16,7 @@ module PFS
|
|
16
16
|
data[:isinstant] = true if options[:instant]
|
17
17
|
data[:reference] = options[:reference] if options[:reference]
|
18
18
|
response = client.post("/BankPayment/#{account_id}/OneOffPayment", data, options)
|
19
|
-
Resources::Transfers::Transfer.new(response)
|
19
|
+
Resources::Transfers::Transfer.new(response, response.body[:data])
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/pfs/client.rb
CHANGED
data/lib/pfs/resources/base.rb
CHANGED
@@ -5,9 +5,8 @@ module PFS
|
|
5
5
|
class Base
|
6
6
|
attr_reader :response
|
7
7
|
|
8
|
-
def initialize(response,
|
8
|
+
def initialize(response, attributes = {})
|
9
9
|
@response = response
|
10
|
-
attributes = response.body[root]
|
11
10
|
attributes.each do |key, value|
|
12
11
|
m = "#{key}=".to_sym
|
13
12
|
send(m, value) if respond_to?(m)
|
@@ -17,11 +16,11 @@ module PFS
|
|
17
16
|
end
|
18
17
|
end
|
19
18
|
|
19
|
+
require_relative "collection"
|
20
20
|
require_relative "accounts/balance"
|
21
21
|
require_relative "accounts/balance_credit"
|
22
|
-
require_relative "accounts/transaction"
|
23
|
-
require_relative "accounts/transaction"
|
24
22
|
require_relative "authentication/token"
|
25
23
|
require_relative "transfers/transfer"
|
26
24
|
require_relative "transactions/transaction"
|
27
25
|
require_relative "transactions/transactions"
|
26
|
+
require_relative "statements/statement"
|
@@ -4,12 +4,12 @@ module PFS
|
|
4
4
|
module Resources
|
5
5
|
class Collection
|
6
6
|
include Enumerable
|
7
|
-
|
8
7
|
attr_reader :response
|
9
8
|
|
10
|
-
def initialize(response, item_klass,
|
9
|
+
def initialize(response, item_klass, attributes_collection = [])
|
11
10
|
@response = response
|
12
|
-
@
|
11
|
+
@attributes_collection = attributes_collection
|
12
|
+
@items = attributes_collection.map { |attributes_item| item_klass.new(nil, attributes_item) }
|
13
13
|
end
|
14
14
|
|
15
15
|
def each(&block)
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PFS
|
4
|
+
module Resources
|
5
|
+
module Statements
|
6
|
+
class Statement < Base
|
7
|
+
attr_accessor :id,
|
8
|
+
:transactionId,
|
9
|
+
:amount,
|
10
|
+
:cardholderID,
|
11
|
+
:debtorBankIndentifier,
|
12
|
+
:debtorAccountIdentifier,
|
13
|
+
:debtorFullName,
|
14
|
+
:debtorFullAddress,
|
15
|
+
:debtorCountryCode,
|
16
|
+
:creditorBankIdentifier,
|
17
|
+
:creditorAccountIdentifier,
|
18
|
+
:creditorFullName,
|
19
|
+
:creditorFullAddress,
|
20
|
+
:creditorCountryCode,
|
21
|
+
:reference,
|
22
|
+
:dateTimeEntered,
|
23
|
+
:inwardOutward,
|
24
|
+
:processorType,
|
25
|
+
:paymentStatus,
|
26
|
+
:userDefinedFields
|
27
|
+
|
28
|
+
alias transaction_id transactionId
|
29
|
+
alias cardholder_id cardholderID
|
30
|
+
alias debtor_bank_identifier debtorBankIndentifier
|
31
|
+
alias debtor_account_identifier debtorAccountIdentifier
|
32
|
+
alias debtor_full_name debtorFullName
|
33
|
+
alias debtor_full_address debtorFullAddress
|
34
|
+
alias debtor_country_code debtorCountryCode
|
35
|
+
alias creditor_bank_identifier creditorBankIdentifier
|
36
|
+
alias creditor_account_identifier creditorAccountIdentifier
|
37
|
+
alias creditor_full_name creditorFullName
|
38
|
+
alias creditor_full_address creditorFullAddress
|
39
|
+
alias creditor_country_code creditorCountryCode
|
40
|
+
alias entered_at dateTimeEntered
|
41
|
+
alias inward_outward inwardOutward
|
42
|
+
alias processor_type processorType
|
43
|
+
alias status paymentStatus
|
44
|
+
alias user_defined_fields userDefinedFields
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -3,48 +3,85 @@
|
|
3
3
|
module PFS
|
4
4
|
module Resources
|
5
5
|
module Transactions
|
6
|
-
class Transaction
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
class Transaction < Base
|
7
|
+
attr_accessor :date,
|
8
|
+
:amount,
|
9
|
+
:currency,
|
10
|
+
:availableBalance,
|
11
|
+
:ledgerBalance,
|
12
|
+
:transactionOrigin,
|
13
|
+
:transactionType,
|
14
|
+
:transactionDescription,
|
15
|
+
:transactionCodeDescription,
|
16
|
+
:transactionResult,
|
17
|
+
:terminalID,
|
18
|
+
:terminalLocation,
|
19
|
+
:terminalOwner,
|
20
|
+
:terminalCity,
|
21
|
+
:terminalState,
|
22
|
+
:terminalCountry,
|
23
|
+
:terminalCurrency,
|
24
|
+
:uniqueReference,
|
25
|
+
:cardType,
|
26
|
+
:mti,
|
27
|
+
:arn,
|
28
|
+
:stn,
|
29
|
+
:authenticationNumber,
|
30
|
+
:recordType,
|
31
|
+
:fee,
|
32
|
+
:atmFee,
|
33
|
+
:issuerFee,
|
34
|
+
:foreignExchangeFee,
|
35
|
+
:clientId,
|
36
|
+
:mcc,
|
37
|
+
:surcharge,
|
38
|
+
:responseCode,
|
39
|
+
:originalTransactionAmount,
|
40
|
+
:originalHoldAmount,
|
41
|
+
:conversionRate,
|
42
|
+
:cardAcceptorIdCode,
|
43
|
+
:actionCodeDescription,
|
44
|
+
:acquiringInstitution,
|
45
|
+
:processor,
|
46
|
+
:posEntryMode,
|
47
|
+
:walletProvider,
|
48
|
+
:cardId,
|
49
|
+
:walletId
|
15
50
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
51
|
+
alias available availableBalance
|
52
|
+
alias ledger availableBalance
|
53
|
+
alias transaction_origin transactionOrigin
|
54
|
+
alias transaction_type transactionType
|
55
|
+
alias transaction_description transactionDescription
|
56
|
+
alias transaction_code_description transactionCodeDescription
|
57
|
+
alias transaction_result transactionResult
|
58
|
+
alias terminal_id terminalID
|
59
|
+
alias transfer_response_reference terminalID
|
60
|
+
alias terminal_location terminalLocation
|
61
|
+
alias terminal_owner terminalOwner
|
62
|
+
alias terminal_city terminalCity
|
63
|
+
alias terminal_state terminalState
|
64
|
+
alias terminal_country terminalCountry
|
65
|
+
alias terminal_currency terminalCurrency
|
66
|
+
alias unique_reference uniqueReference
|
67
|
+
alias card_type cardType
|
68
|
+
alias authentication_number authenticationNumber
|
69
|
+
alias record_type recordType
|
70
|
+
alias atm_fee atmFee
|
71
|
+
alias foreign_exchange_fee foreignExchangeFee
|
72
|
+
alias issuer_fee issuerFee
|
73
|
+
alias client_id clientId
|
74
|
+
alias response_code responseCode
|
75
|
+
alias original_transaction_amount originalTransactionAmount
|
76
|
+
alias original_hold_amount originalHoldAmount
|
77
|
+
alias conversion_rate conversionRate
|
78
|
+
alias card_acceptor_id_code cardAcceptorIdCode
|
79
|
+
alias action_code_description actionCodeDescription
|
80
|
+
alias acquiring_institution acquiringInstitution
|
81
|
+
alias pos_entry_mode posEntryMode
|
82
|
+
alias wallet_provider walletProvider
|
83
|
+
alias card_id cardId
|
84
|
+
alias wallet_id walletId
|
48
85
|
end
|
49
86
|
end
|
50
87
|
end
|
@@ -3,22 +3,9 @@
|
|
3
3
|
module PFS
|
4
4
|
module Resources
|
5
5
|
module Transactions
|
6
|
-
class Transactions
|
7
|
-
|
8
|
-
|
9
|
-
def self.from_raw(raw_transactions)
|
10
|
-
transactions = raw_transactions.map do |transaction|
|
11
|
-
Transaction.from_raw(transaction)
|
12
|
-
end
|
13
|
-
new(transactions)
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize(transactions)
|
17
|
-
@transactions = transactions
|
18
|
-
end
|
19
|
-
|
20
|
-
def each(&block)
|
21
|
-
@transactions.each(&block)
|
6
|
+
class Transactions < Collection
|
7
|
+
def initialize(response, attributes_collection)
|
8
|
+
super(response, Transaction, attributes_collection)
|
22
9
|
end
|
23
10
|
end
|
24
11
|
end
|
data/lib/pfs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pfs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aitor García Rey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -51,15 +51,16 @@ files:
|
|
51
51
|
- lib/pfs/api/authentication_service.rb
|
52
52
|
- lib/pfs/api/service.rb
|
53
53
|
- lib/pfs/api/services.rb
|
54
|
+
- lib/pfs/api/statements_service.rb
|
54
55
|
- lib/pfs/api/transactions_service.rb
|
55
56
|
- lib/pfs/api/transfers_service.rb
|
56
57
|
- lib/pfs/client.rb
|
57
58
|
- lib/pfs/resources/accounts/balance.rb
|
58
59
|
- lib/pfs/resources/accounts/balance_credit.rb
|
59
|
-
- lib/pfs/resources/accounts/transaction.rb
|
60
60
|
- lib/pfs/resources/authentication/token.rb
|
61
61
|
- lib/pfs/resources/base.rb
|
62
62
|
- lib/pfs/resources/collection.rb
|
63
|
+
- lib/pfs/resources/statements/statement.rb
|
63
64
|
- lib/pfs/resources/transactions/transaction.rb
|
64
65
|
- lib/pfs/resources/transactions/transactions.rb
|
65
66
|
- lib/pfs/resources/transfers/transfer.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PFS
|
4
|
-
module Resources
|
5
|
-
module Accounts
|
6
|
-
class Transaction < Base
|
7
|
-
attr_accessor :date,
|
8
|
-
:transactionType,
|
9
|
-
:authenticationNumber,
|
10
|
-
:transactionOrigin,
|
11
|
-
:transactionDescription,
|
12
|
-
:amount,
|
13
|
-
:fee,
|
14
|
-
:availableBalance,
|
15
|
-
:ledgerBalance,
|
16
|
-
:terminalID,
|
17
|
-
:terminalLocation,
|
18
|
-
:terminalOwner,
|
19
|
-
:transactionCodeDescription,
|
20
|
-
:transactionResult,
|
21
|
-
:authenticationNumber,
|
22
|
-
:authenticationNumber
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|