monobank 0.3.0 → 1.0.0
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/version.rb +1 -1
- data/spec/monobank_spec.rb +8 -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: 1330fb91b27e94addd547a3e917a377569f7f94da100c549608c482fad521a31
|
4
|
+
data.tar.gz: 4fa1fcb966b87ad1ae081ac1d0dbc011c3bec0b3ffc40a969040c27b41ab1afd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7aba78c72f755a0cc634914f9be012c7e12c1a739e3ed54c1d186328476c263c9dfdcfa058134819fb066ce1088e636805fd85555ade32ee05c6067eeb23273
|
7
|
+
data.tar.gz: 0ef715b877691c7669efc5dc64b7b428fd761b365f060426fc68e3ed31daa852c4a03b37fb8f59147162672a945f40081e2c0a2183cf5d4767cffd075cab226d
|
@@ -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,14 @@ 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.currency_code).to eq 980
|
76
|
+
expect(result.attributes).to match hash_including(
|
77
|
+
'accounts' => array_including([
|
78
|
+
hash_including(
|
79
|
+
"currency_code" => 980
|
80
|
+
)
|
81
|
+
])
|
82
|
+
)
|
75
83
|
end
|
76
84
|
end
|
77
85
|
|
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.0
|
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-02
|
13
|
+
date: 2024-05-02 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.
|