pfs 0.0.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f9bc4bcadfedb5b3e865bde23698a09905d831d9e17c925c6068b10cee704342
4
- data.tar.gz: 3c57813ca02b7242b80424b4db5175aa6cb414997a88bc1ab922d4bd1a991c9e
3
+ metadata.gz: 1f06e43fb3cf05a637ffddb40603839f31b4f7cb61dd66b08f01b3d76484c2ae
4
+ data.tar.gz: 5df9f6b3946a646848a8a109bc9c646a3ac6d4b22400782f8e807e36566297b4
5
5
  SHA512:
6
- metadata.gz: 715b55f016153d1b4617b15676f2291f754b7ac5f1ad8e2d4a702dfa0466fb4e077c48daeafbdd3955b8008ffff927008636b1b99c000a21c74b2b0b279dd18f
7
- data.tar.gz: 786b31c85653245a3db6ce3e4048840a2f65e9b2affae8164f94d730f72ceb57d0249091725d203ab9a308ad1d10766e54616b2e627c7f1fd3dd6a5b339d22db
6
+ metadata.gz: 82cb826b1fb37bd4dd5626f17b863385737ba5bddce16ce05d264d5fb54c9134cc4aee6b45d408ded9f1fa3aad530975adcd109c14fe0d60fc73c3ca0b9ada01
7
+ data.tar.gz: 01bb4d39ac2b493c1fa3443e286e93d5b2aa35511cca687cf31f3e5a752564b9b5e09210deffde84acd00ba3bc0d4a4ad505ae92a4cfd349fb1be8b6f04bee73
@@ -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.body[:data])
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.body[:data])
19
+ Resources::Accounts::BalanceCredit.new(response, 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.body[:data])
12
+ Resources::Authentication::Token.new(response, response.body[:data])
13
13
  end
14
14
  end
15
15
  end
@@ -5,7 +5,7 @@ module PFS
5
5
  response = client.get(
6
6
  "/BankPayment/#{account_id}/StatementById?statementitemid=#{statement_id}&InwardOutward=#{inward_outward}&Processor=#{processor}"
7
7
  )
8
- Resources::Statements::Statement.new(response.body.dig(:data, :transaction))
8
+ Resources::Statements::Statement.new(response, response.body.dig(:data, :transaction))
9
9
  end
10
10
  end
11
11
  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.new(response.body.dig(:data, :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.body[:data])
19
+ Resources::Transfers::Transfer.new(response, response.body[:data])
20
20
  end
21
21
  end
22
22
  end
@@ -10,8 +10,8 @@ module PFS
10
10
  alias access_token accessToken
11
11
  alias expires_in expiresIn
12
12
 
13
- def initialize(response)
14
- super(response)
13
+ def initialize(response, attributes = {})
14
+ super(response, attributes)
15
15
  @expires_on = Time.now + expires_in
16
16
  end
17
17
 
@@ -3,7 +3,10 @@
3
3
  module PFS
4
4
  module Resources
5
5
  class Base
6
- def initialize(attributes = {})
6
+ attr_reader :response
7
+
8
+ def initialize(response, attributes = {})
9
+ @response = response
7
10
  attributes.each do |key, value|
8
11
  m = "#{key}=".to_sym
9
12
  send(m, value) if respond_to?(m)
@@ -4,10 +4,12 @@ module PFS
4
4
  module Resources
5
5
  class Collection
6
6
  include Enumerable
7
+ attr_reader :response
7
8
 
8
- def initialize(item_klass, attributes_collection = [])
9
+ def initialize(response, item_klass, attributes_collection = [])
10
+ @response = response
9
11
  @attributes_collection = attributes_collection
10
- @items = attributes_collection.map { |attributes_item| item_klass.new(attributes_item) }
12
+ @items = attributes_collection.map { |attributes_item| item_klass.new(nil, attributes_item) }
11
13
  end
12
14
 
13
15
  def each(&block)
@@ -4,8 +4,8 @@ module PFS
4
4
  module Resources
5
5
  module Transactions
6
6
  class Transactions < Collection
7
- def initialize(attributes_collection)
8
- super(Transaction, attributes_collection)
7
+ def initialize(response, attributes_collection)
8
+ super(response, Transaction, attributes_collection)
9
9
  end
10
10
  end
11
11
  end
data/lib/pfs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module PFS
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
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.3
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-13 00:00:00.000000000 Z
11
+ date: 2022-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday