pfs 0.0.8 → 0.0.11

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: 8a085d9259e3eb98f2fe1b761e4c3017d5e078847ebaf196978c36df5b575284
4
- data.tar.gz: b5ad378234d9522e3f07a44095876d0f505058c6a122f6a41d78d3976f69f303
3
+ metadata.gz: b4e9653b341d206ac918d550f50e7dd980b84bd5e5b868f5c65898fa40c929c6
4
+ data.tar.gz: 59f4248c246f7cdf243126ef1baf356368ce017a23457682f6563e7dc2c338c4
5
5
  SHA512:
6
- metadata.gz: 63e7bce0ba36f33b5afc7885ba39ebe1e40222fceec9a78235f6f19d69f0a3541ed48d171a874e5dc4de5887130b3a01dfe27d83f051ed3e58f68bbe1d4aca8d
7
- data.tar.gz: 8403be7bfe84d11f8ebe5038c3a197587a500fcbc1d0b4305251f1d5cb01d20dd807da4cb076b4c530c01456cddc5cbd4cd634e348a5b44fc932da4d0a08ae23
6
+ metadata.gz: 9c80eb44c85b46d9fe0951bb4dc45ff648baa5fc72cda344bec474e6332b81c6af633cd461c655e75d6f029a4c3f9bfee5a483ecaed629462ca071c48622c685
7
+ data.tar.gz: d4d22dc29c4a333062b8b6b1455a6f6a3a4ad3442e4bfaf5c86f44a462207d5833ed8eeb908fa0cf4bfac5495c446682def69f7d8ca89d14078daa9676e1dd3a
@@ -14,7 +14,7 @@ jobs:
14
14
  - uses: actions/checkout@v2
15
15
 
16
16
  - name: Release Gem
17
- uses: cadwallion/publish-rubygems-action@8f9e0538302643309e4e43bf48cd34173ca48cfc # yamllint disable-line
17
+ uses: cadwallion/publish-rubygems-action@master # yamllint disable-line
18
18
  env:
19
19
  RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
20
20
  RELEASE_COMMAND: rake release
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PFS
2
4
  module API
3
5
  class StatementsService < Service
@@ -7,6 +9,13 @@ module PFS
7
9
  )
8
10
  Resources::Statements::Statement.new(response, response.body.dig(:data, :transaction))
9
11
  end
12
+
13
+ def history(account_id:, start_date:, end_date:, inward_outward:, processor:)
14
+ response = client.get(
15
+ "/BankPayment/#{account_id}/Statement?StartDate=#{start_date}&EndDate=#{end_date}&InwardOutward=#{inward_outward}&Processor=#{processor}"
16
+ )
17
+ Resources::Statements::Statements.new(response, response.body.dig(:data, :transactions))
18
+ end
10
19
  end
11
20
  end
12
- end
21
+ end
@@ -5,7 +5,6 @@ module PFS
5
5
  class TransactionsService < Service
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
- transactions_raw = response.body.dig(:data, :transactions)
9
8
  Resources::Transactions::Transactions.new(response, response.body.dig(:data, :transactions))
10
9
  end
11
10
  end
data/lib/pfs/client.rb CHANGED
@@ -87,25 +87,14 @@ module PFS
87
87
  def handle_request_error(error)
88
88
  case error
89
89
  when Faraday::ClientError
90
- if error.response
91
- handle_error_response(error)
92
- else
93
- handle_network_error(error)
94
- end
90
+ raise ClientError, error
91
+ when Faraday::ServerError
92
+ raise ServerError, error
95
93
  else
96
- raise error
94
+ raise Error, error
97
95
  end
98
96
  end
99
97
 
100
- def handle_error_response(error)
101
- puts "ERROR #{error.response}"
102
- raise error
103
- end
104
-
105
- def handle_network_error(error)
106
- raise error
107
- end
108
-
109
98
  def login_path?(path)
110
99
  path == "/Auth/Jwt"
111
100
  end
data/lib/pfs/error.rb ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PFS
4
+ class Error < StandardError
5
+ attr_reader :wrapped_error, :status, :response
6
+
7
+ def initialize(error)
8
+ @wrapped_error = error
9
+ @response = @wrapped_error.response if @wrapped_error.respond_to?(:response)
10
+ @status = structured_response[:status]
11
+ super(error_message)
12
+ end
13
+
14
+ private def error_message
15
+ return @wrapped_error unless @response
16
+
17
+ wrapped_error_description = "#{@wrapped_error.class}: #{@wrapped_error}"
18
+ response_description = "Status: #{structured_response[:status]} - Response: '#{structured_response[:body]}'"
19
+ "#{response_description} (#{wrapped_error_description})"
20
+ end
21
+
22
+ private def structured_response
23
+ return {} unless @response
24
+ return @response if @response.is_a?(Hash)
25
+
26
+ {
27
+ status: @response.status,
28
+ body: @response.body,
29
+ }
30
+ end
31
+ end
32
+
33
+ class ClientError < Error
34
+ end
35
+
36
+ class ServerError < Error
37
+ end
38
+ end
@@ -40,3 +40,4 @@ require_relative "transfers/internal_transfer_to"
40
40
  require_relative "transactions/transaction"
41
41
  require_relative "transactions/transactions"
42
42
  require_relative "statements/statement"
43
+ require_relative "statements/statements"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PFS
4
+ module Resources
5
+ module Statements
6
+ class Statements < Collection
7
+ def initialize(response, attributes_collection)
8
+ super(response, Statement, attributes_collection)
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -49,7 +49,7 @@ module PFS
49
49
  :walletId
50
50
 
51
51
  alias available availableBalance
52
- alias ledger availableBalance
52
+ alias ledger ledgerBalance
53
53
  alias transaction_origin transactionOrigin
54
54
  alias transaction_type transactionType
55
55
  alias transaction_description transactionDescription
data/lib/pfs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PFS
4
- VERSION = "0.0.8"
4
+ VERSION = "0.0.11"
5
5
  end
data/lib/pfs.rb CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  require "pfs/version"
3
+ require "pfs/error"
3
4
  require "pfs/client"
4
5
  module PFS
5
6
  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.8
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aitor García Rey
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-08 00:00:00.000000000 Z
11
+ date: 2023-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -111,7 +111,6 @@ files:
111
111
  - CODE_OF_CONDUCT.md
112
112
  - Gemfile
113
113
  - Guardfile
114
- - LICENSE
115
114
  - LICENSE.txt
116
115
  - README.md
117
116
  - Rakefile
@@ -126,6 +125,7 @@ files:
126
125
  - lib/pfs/api/transactions_service.rb
127
126
  - lib/pfs/api/transfers_service.rb
128
127
  - lib/pfs/client.rb
128
+ - lib/pfs/error.rb
129
129
  - lib/pfs/resources/accounts/account.rb
130
130
  - lib/pfs/resources/accounts/account_holder.rb
131
131
  - lib/pfs/resources/accounts/account_info.rb
@@ -137,6 +137,7 @@ files:
137
137
  - lib/pfs/resources/base.rb
138
138
  - lib/pfs/resources/collection.rb
139
139
  - lib/pfs/resources/statements/statement.rb
140
+ - lib/pfs/resources/statements/statements.rb
140
141
  - lib/pfs/resources/transactions/transaction.rb
141
142
  - lib/pfs/resources/transactions/transactions.rb
142
143
  - lib/pfs/resources/transfers/internal_transfer.rb
@@ -152,7 +153,7 @@ metadata:
152
153
  homepage_uri: https://github.com/devengo/pfs-ruby
153
154
  source_code_uri: https://github.com/devengo/pfs-ruby
154
155
  changelog_uri: https://github.com/devengo/pfs-ruby/CHANGELOG.md
155
- post_install_message:
156
+ post_install_message:
156
157
  rdoc_options: []
157
158
  require_paths:
158
159
  - lib
@@ -167,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
168
  - !ruby/object:Gem::Version
168
169
  version: '0'
169
170
  requirements: []
170
- rubygems_version: 3.3.7
171
- signing_key:
171
+ rubygems_version: 3.4.10
172
+ signing_key:
172
173
  specification_version: 4
173
174
  summary: PFS Finac API ruby client
174
175
  test_files: []
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Aitor García Rey
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.