monobank 0.3.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/monobank/methods/base.rb +4 -3
- data/lib/monobank/resources/base.rb +12 -15
- data/lib/monobank/resources/personal/accounts.rb +1 -1
- data/lib/monobank/version.rb +1 -1
- data/spec/monobank_spec.rb +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa6a4b4a03f093b373724d73bbbda12ffd6c1d1728f40b5284090d9f7d1cc4fa
|
4
|
+
data.tar.gz: 6ee7b8871210e0651a7d12c93444a369b2b8601b8e1e156039d52eedf97b3626
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba86f1e0bc80f16805392f7aa1fe8612b4e50d3ea41b5f348111f1d585444e747e9bb90d2bb934bff874aa8ddcda10c98596757f34d1ae7a911d00b427f0bded
|
7
|
+
data.tar.gz: 66a504cfe64367f7f2c85b22da02e6f64927f6f4d324397608b6329e72ebd80ed2de1eb0bb9e8c60962e6a05a5dc17814382f8973dd0afb88832db29932b3207
|
@@ -8,10 +8,11 @@ module Monobank
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
|
-
|
12
|
-
|
11
|
+
http_response = response
|
12
|
+
attributes = http_response.parsed_response
|
13
|
+
return define_resources(attributes) if http_response.code == 200
|
13
14
|
|
14
|
-
Monobank::Resources::Error.new(attributes.merge('code' =>
|
15
|
+
Monobank::Resources::Error.new(attributes.merge('code' => http_response.code))
|
15
16
|
end
|
16
17
|
|
17
18
|
private
|
@@ -8,27 +8,24 @@ module Monobank
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(attributes)
|
11
|
-
@attributes =
|
12
|
-
snake_case_attributes = deep_snake_case(attributes)
|
13
|
-
snake_case_attributes.each { |key, value| @attributes[method_name(key)] = value }
|
11
|
+
@attributes = deep_snake_case(attributes)
|
14
12
|
end
|
15
13
|
|
16
14
|
def method_name(key)
|
17
15
|
key.gsub(/(.)([A-Z])/,'\1_\2').downcase
|
18
16
|
end
|
19
17
|
|
20
|
-
def deep_snake_case(
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
18
|
+
def deep_snake_case(object)
|
19
|
+
if object.is_a?(Hash)
|
20
|
+
object.map do |key, value|
|
21
|
+
[method_name(key), deep_snake_case(value)]
|
22
|
+
end.to_h
|
23
|
+
elsif object.is_a?(Array)
|
24
|
+
object.map do |value|
|
25
|
+
deep_snake_case(value)
|
26
|
+
end
|
27
|
+
else
|
28
|
+
object
|
32
29
|
end
|
33
30
|
end
|
34
31
|
|
data/lib/monobank/version.rb
CHANGED
data/spec/monobank_spec.rb
CHANGED
@@ -72,6 +72,15 @@ describe Monobank do
|
|
72
72
|
result = Monobank.client_info(token:)
|
73
73
|
expect(result.name).to eq 'Мазепа Іван'
|
74
74
|
expect(result.accounts.length).to eq 1
|
75
|
+
expect(result.accounts.first.type).to eq 'black'
|
76
|
+
expect(result.accounts.first.currency_code).to eq 980
|
77
|
+
expect(result.attributes).to match hash_including(
|
78
|
+
'accounts' => array_including([
|
79
|
+
hash_including(
|
80
|
+
"currency_code" => 980
|
81
|
+
)
|
82
|
+
])
|
83
|
+
)
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monobank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vergilet
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-
|
13
|
+
date: 2024-05-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
- !ruby/object:Gem::Version
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
156
|
+
rubygems_version: 3.5.6
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Unofficial Ruby Gem for Monobank API.
|