fidor_api 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +5 -3
- data/CHANGELOG.md +114 -0
- data/Gemfile +3 -2
- data/README.md +12 -10
- data/lib/fidor_api/account.rb +7 -10
- data/lib/fidor_api/amount_attributes.rb +23 -20
- data/lib/fidor_api/approval_required.rb +9 -0
- data/lib/fidor_api/auth.rb +1 -1
- data/lib/fidor_api/beneficiary/ach.rb +39 -0
- data/lib/fidor_api/beneficiary/base.rb +118 -0
- data/lib/fidor_api/beneficiary/generic.rb +24 -0
- data/lib/fidor_api/beneficiary/p2p_account_number.rb +14 -0
- data/lib/fidor_api/beneficiary/p2p_phone.rb +14 -0
- data/lib/fidor_api/beneficiary/p2p_username.rb +14 -0
- data/lib/fidor_api/beneficiary/swift.rb +35 -0
- data/lib/fidor_api/beneficiary/unknown.rb +16 -0
- data/lib/fidor_api/beneficiary/utility.rb +35 -0
- data/lib/fidor_api/beneficiary.rb +27 -0
- data/lib/fidor_api/card.rb +31 -48
- data/lib/fidor_api/card_limit_attribute.rb +52 -0
- data/lib/fidor_api/card_limits.rb +6 -34
- data/lib/fidor_api/client.rb +8 -2
- data/lib/fidor_api/collection.rb +15 -6
- data/lib/fidor_api/confirmable_action.rb +45 -0
- data/lib/fidor_api/connectivity/connection.rb +113 -0
- data/lib/fidor_api/connectivity/endpoint.rb +82 -0
- data/lib/fidor_api/connectivity/resource.rb +76 -0
- data/lib/fidor_api/connectivity.rb +17 -0
- data/lib/fidor_api/constants.rb +3 -0
- data/lib/fidor_api/customer.rb +41 -23
- data/lib/fidor_api/customers/confirmations.rb +19 -0
- data/lib/fidor_api/errors.rb +14 -3
- data/lib/fidor_api/message.rb +17 -18
- data/lib/fidor_api/msisdn.rb +1 -1
- data/lib/fidor_api/password.rb +30 -0
- data/lib/fidor_api/preauth.rb +5 -12
- data/lib/fidor_api/session_token.rb +20 -0
- data/lib/fidor_api/transaction.rb +5 -12
- data/lib/fidor_api/transfer/ach.rb +46 -0
- data/lib/fidor_api/transfer/bank_internal.rb +37 -0
- data/lib/fidor_api/transfer/base.rb +36 -0
- data/lib/fidor_api/transfer/fps.rb +56 -0
- data/lib/fidor_api/transfer/generic.rb +134 -0
- data/lib/fidor_api/transfer/internal.rb +53 -0
- data/lib/fidor_api/transfer/p2p_account_number.rb +45 -0
- data/lib/fidor_api/transfer/p2p_phone.rb +45 -0
- data/lib/fidor_api/transfer/p2p_username.rb +45 -0
- data/lib/fidor_api/transfer/sepa.rb +56 -0
- data/lib/fidor_api/transfer/swift.rb +49 -0
- data/lib/fidor_api/transfer/utility.rb +50 -0
- data/lib/fidor_api/transfer.rb +13 -186
- data/lib/fidor_api/user.rb +12 -11
- data/lib/fidor_api/version.rb +1 -1
- data/lib/fidor_api.rb +39 -22
- metadata +37 -4
- data/lib/fidor_api/resource.rb +0 -84
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fidor_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Klaus Meyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- ".ruby-gemset"
|
91
91
|
- ".ruby-version"
|
92
92
|
- ".travis.yml"
|
93
|
+
- CHANGELOG.md
|
93
94
|
- Gemfile
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|
@@ -100,22 +101,54 @@ files:
|
|
100
101
|
- lib/fidor_api.rb
|
101
102
|
- lib/fidor_api/account.rb
|
102
103
|
- lib/fidor_api/amount_attributes.rb
|
104
|
+
- lib/fidor_api/approval_required.rb
|
103
105
|
- lib/fidor_api/auth.rb
|
106
|
+
- lib/fidor_api/beneficiary.rb
|
107
|
+
- lib/fidor_api/beneficiary/ach.rb
|
108
|
+
- lib/fidor_api/beneficiary/base.rb
|
109
|
+
- lib/fidor_api/beneficiary/generic.rb
|
110
|
+
- lib/fidor_api/beneficiary/p2p_account_number.rb
|
111
|
+
- lib/fidor_api/beneficiary/p2p_phone.rb
|
112
|
+
- lib/fidor_api/beneficiary/p2p_username.rb
|
113
|
+
- lib/fidor_api/beneficiary/swift.rb
|
114
|
+
- lib/fidor_api/beneficiary/unknown.rb
|
115
|
+
- lib/fidor_api/beneficiary/utility.rb
|
104
116
|
- lib/fidor_api/card.rb
|
117
|
+
- lib/fidor_api/card_limit_attribute.rb
|
105
118
|
- lib/fidor_api/card_limits.rb
|
106
119
|
- lib/fidor_api/client.rb
|
107
120
|
- lib/fidor_api/collection.rb
|
121
|
+
- lib/fidor_api/confirmable_action.rb
|
122
|
+
- lib/fidor_api/connectivity.rb
|
123
|
+
- lib/fidor_api/connectivity/connection.rb
|
124
|
+
- lib/fidor_api/connectivity/endpoint.rb
|
125
|
+
- lib/fidor_api/connectivity/resource.rb
|
126
|
+
- lib/fidor_api/constants.rb
|
108
127
|
- lib/fidor_api/customer.rb
|
128
|
+
- lib/fidor_api/customers/confirmations.rb
|
109
129
|
- lib/fidor_api/errors.rb
|
110
130
|
- lib/fidor_api/message.rb
|
111
131
|
- lib/fidor_api/msisdn.rb
|
132
|
+
- lib/fidor_api/password.rb
|
112
133
|
- lib/fidor_api/preauth.rb
|
113
134
|
- lib/fidor_api/preauth_details.rb
|
114
|
-
- lib/fidor_api/
|
135
|
+
- lib/fidor_api/session_token.rb
|
115
136
|
- lib/fidor_api/token.rb
|
116
137
|
- lib/fidor_api/transaction.rb
|
117
138
|
- lib/fidor_api/transaction_details.rb
|
118
139
|
- lib/fidor_api/transfer.rb
|
140
|
+
- lib/fidor_api/transfer/ach.rb
|
141
|
+
- lib/fidor_api/transfer/bank_internal.rb
|
142
|
+
- lib/fidor_api/transfer/base.rb
|
143
|
+
- lib/fidor_api/transfer/fps.rb
|
144
|
+
- lib/fidor_api/transfer/generic.rb
|
145
|
+
- lib/fidor_api/transfer/internal.rb
|
146
|
+
- lib/fidor_api/transfer/p2p_account_number.rb
|
147
|
+
- lib/fidor_api/transfer/p2p_phone.rb
|
148
|
+
- lib/fidor_api/transfer/p2p_username.rb
|
149
|
+
- lib/fidor_api/transfer/sepa.rb
|
150
|
+
- lib/fidor_api/transfer/swift.rb
|
151
|
+
- lib/fidor_api/transfer/utility.rb
|
119
152
|
- lib/fidor_api/user.rb
|
120
153
|
- lib/fidor_api/version.rb
|
121
154
|
homepage: https://github.com/klausmeyer/fidor_api
|
@@ -138,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
171
|
version: '0'
|
139
172
|
requirements: []
|
140
173
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.
|
174
|
+
rubygems_version: 2.6.8
|
142
175
|
signing_key:
|
143
176
|
specification_version: 4
|
144
177
|
summary: Simple ruby client for the Fidor Bank API
|
data/lib/fidor_api/resource.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
module FidorApi
|
2
|
-
|
3
|
-
class Resource
|
4
|
-
include ActiveModel::Model
|
5
|
-
|
6
|
-
attr_accessor :client
|
7
|
-
|
8
|
-
class Response
|
9
|
-
include ActiveModel::Model
|
10
|
-
|
11
|
-
attr_accessor :headers, :body
|
12
|
-
|
13
|
-
def body
|
14
|
-
if headers["content-type"] =~ /json/
|
15
|
-
JSON.parse(@body)
|
16
|
-
else
|
17
|
-
@body
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def initialize(attributes = {})
|
23
|
-
set_attributes(attributes)
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.request(method: :get, access_token: nil, endpoint: nil, query_params: {}, body: {}, htauth: false)
|
27
|
-
response = connection(htauth: htauth).public_send(method, endpoint) do |request|
|
28
|
-
request.params = query_params
|
29
|
-
request.headers = {}
|
30
|
-
request.headers["Authorization"] = "Bearer #{access_token}" if access_token
|
31
|
-
request.headers["Accept"] = "application/vnd.fidor.de; version=1,text/json"
|
32
|
-
request.headers["Content-Type"] = "application/json"
|
33
|
-
request.body = body.to_json unless body.empty?
|
34
|
-
end
|
35
|
-
Response.new(headers: response.headers, body: response.body)
|
36
|
-
rescue Faraday::Error::ClientError => e
|
37
|
-
case e.response[:status]
|
38
|
-
when 401
|
39
|
-
raise UnauthorizedTokenError
|
40
|
-
when 422
|
41
|
-
body = JSON.parse(e.response[:body])
|
42
|
-
raise ValidationError.new(body["message"], body["errors"])
|
43
|
-
else
|
44
|
-
raise ClientError
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def self.model_name
|
49
|
-
ActiveModel::Name.new(self, nil, self.name.sub("FidorApi::", ""))
|
50
|
-
end
|
51
|
-
|
52
|
-
def persisted?
|
53
|
-
id.present?
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def self.connection(htauth: false)
|
59
|
-
Faraday.new(url: FidorApi.configuration.api_url) do |config|
|
60
|
-
config.use Faraday::Request::BasicAuthentication, FidorApi.configuration.htauth_user, FidorApi.configuration.htauth_password if htauth
|
61
|
-
config.request :url_encoded
|
62
|
-
config.response :logger if FidorApi.configuration.logging
|
63
|
-
config.response :raise_error
|
64
|
-
config.adapter Faraday.default_adapter
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
def create(options = {})
|
69
|
-
raise InvalidRecordError unless valid?
|
70
|
-
set_attributes self.class.request({ method: :post, access_token: client.try { |c| c.token.access_token }, endpoint: self.class.resource, body: as_json }.merge(options)).body
|
71
|
-
true
|
72
|
-
rescue ValidationError => e
|
73
|
-
map_errors(e.fields)
|
74
|
-
false
|
75
|
-
end
|
76
|
-
|
77
|
-
def map_errors(fields)
|
78
|
-
fields.each do |hash|
|
79
|
-
errors.add(hash["field"].to_sym, hash["message"]) if respond_to? hash["field"].to_sym
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
end
|