pfs 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d53fb6ce5c9683637596438a427cccce4ce657c1832f5dfa39d746175a474344
4
- data.tar.gz: 4afa2887ffb5663b916c9f78fb9d2b6f79336793ed8b1866f6fff98902ce8c39
3
+ metadata.gz: a4ffbfed283d9a1eb89089f8bd15e98ec2dc89ddcbc1f972ceed0a7dbcef5c2c
4
+ data.tar.gz: 65aaff12422e7369d9cd525c3976ac711d9153e93bc4f5ea829c884af17783f8
5
5
  SHA512:
6
- metadata.gz: 68d23a3e05f5d0d8f921e4647765b386ac1db9114711656479e80f0d6903c4f592e77e989d0bafbc8a9a0406e6b4f1b73121a7708291f3a45158264dc1936e16
7
- data.tar.gz: 1810aee630ba56917b9d399ba57e15558ef519d7b7c79efd868620fff6c39e3c04ffb4ab52728e1c7a248114b3ba0ea842173835db4b9cc1fea22f29d8134c2f
6
+ metadata.gz: 4849cdbab3506e2e0625eece427ea671fba0c7180987454109d5ec94a692e6e6108a54acd467f72b6b4c07bd1cd03382fefc3ff14b508686e457529d4647e54a
7
+ data.tar.gz: 01b6e3c69925c6b8b060225b57dec87e7b8bc3e7c52685ca18ec62fe4edaad4ddd4a4c22b64762fe1e54228e4365307a867e165b3d01fd751a845d2f0908d6c7
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Pfs
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 spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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 run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/aitor/pfs>. 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/aitor/pfs/blob/master/CODE_OF_CONDUCT.md).
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/aitor/pfs/blob/master/CODE_OF_CONDUCT.md).
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.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.body[:data])
20
20
  end
21
21
  end
22
22
  end
@@ -9,7 +9,7 @@ module PFS
9
9
  password: password,
10
10
  }
11
11
  response = client.post("/Auth/Jwt", attributes, options)
12
- Resources::Authentication::Token.new(response)
12
+ Resources::Authentication::Token.new(response.body[:data])
13
13
  end
14
14
  end
15
15
  end
@@ -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.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.from_raw(transactions_raw)
9
+ Resources::Transactions::Transactions.new(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.body[:data])
20
20
  end
21
21
  end
22
22
  end
data/lib/pfs/client.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "faraday"
4
+ require "securerandom"
5
+
4
6
  # require "faraday_middleware"
5
7
  require_relative "api/services"
6
8
  require_relative "resources/base"
@@ -3,7 +3,7 @@
3
3
  module PFS
4
4
  module Resources
5
5
  module Accounts
6
- class Balance < Resources::Base
6
+ class Balance < Base
7
7
  attr_accessor :currency,
8
8
  :availableBalance,
9
9
  :ledgerBalance
@@ -3,11 +3,7 @@
3
3
  module PFS
4
4
  module Resources
5
5
  class Base
6
- attr_reader :response
7
-
8
- def initialize(response, root = :data)
9
- @response = response
10
- attributes = response.body[root]
6
+ def initialize(attributes = {})
11
7
  attributes.each do |key, value|
12
8
  m = "#{key}=".to_sym
13
9
  send(m, value) if respond_to?(m)
@@ -17,11 +13,11 @@ module PFS
17
13
  end
18
14
  end
19
15
 
16
+ require_relative "collection"
20
17
  require_relative "accounts/balance"
21
18
  require_relative "accounts/balance_credit"
22
- require_relative "accounts/transaction"
23
- require_relative "accounts/transaction"
24
19
  require_relative "authentication/token"
25
20
  require_relative "transfers/transfer"
26
21
  require_relative "transactions/transaction"
27
22
  require_relative "transactions/transactions"
23
+ require_relative "statements/statement"
@@ -5,11 +5,9 @@ module PFS
5
5
  class Collection
6
6
  include Enumerable
7
7
 
8
- attr_reader :response
9
-
10
- def initialize(response, item_klass, data)
11
- @response = response
12
- @items = (data || []).map { |item| item_klass.new(response, item) }
8
+ def initialize(item_klass, attributes_collection = [])
9
+ @attributes_collection = attributes_collection
10
+ @items = attributes_collection.map { |attributes_item| item_klass.new(attributes_item) }
13
11
  end
14
12
 
15
13
  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
- attr_reader :amount,
8
- :currency,
9
- :transaction_description,
10
- :transaction_origin,
11
- :transaction_type,
12
- :date,
13
- :unique_reference,
14
- :transfer_response_reference
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
- def self.from_raw(raw_transaction)
17
- new(
18
- amount: raw_transaction[:amount],
19
- currency: raw_transaction[:currency],
20
- transaction_description: raw_transaction[:transactionDescription],
21
- transaction_origin: raw_transaction[:transactionOrigin],
22
- transaction_type: raw_transaction[:transactionType],
23
- date: raw_transaction[:date],
24
- unique_reference: raw_transaction[:uniqueReference],
25
- transfer_response_reference: raw_transaction[:terminalID]
26
- )
27
- end
28
-
29
- def initialize(
30
- amount:,
31
- currency:,
32
- transaction_description:,
33
- transaction_origin:,
34
- transaction_type:,
35
- date:,
36
- unique_reference:,
37
- transfer_response_reference:
38
- )
39
- @amount = amount
40
- @currency = currency
41
- @transaction_description = transaction_description
42
- @transaction_origin = transaction_origin
43
- @transaction_type = transaction_type
44
- @date = date
45
- @unique_reference = unique_reference
46
- @transfer_response_reference = transfer_response_reference
47
- end
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
- include Enumerable
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(attributes_collection)
8
+ super(Transaction, attributes_collection)
22
9
  end
23
10
  end
24
11
  end
data/lib/pfs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PFS
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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.1
4
+ version: 0.0.2
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-07 00:00:00.000000000 Z
11
+ date: 2022-06-13 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